npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nightmarejs

v0.0.1

Published

NightmareJS is a means to communicate between a CasperJS runtime and a Node server to allow executing of Node functions and data modification features.

Readme

#NightmareJS

NightmareJS is a means to connect CasperJS with NodeJS. There is no need to rewrite existing CasperJS code. Instead, it passes data over a socket.io connection between the Casper object and the Node server, allowing you to query specific data or execute specific functions that node offers but are unavailable in the web browser that Casper operates through.

##Install ###Prerequisites

NightmareJS is available through NPM.

> npm install nightmarejs

##Usage You'll first need to create a javascript file to control and listen to the nightmare components. To initialize the class, use:

var nightmareJS = require('nightmareServer').nightmare();

If you plan to use this for testing, pass in the parameter 'test' to the object during creation, like:

var nightmareJS = require('nightmareServer').nightmare('test');

Once the object has been created, you'll need to implement a function called 'notifyCasperMessage'. This is the function that gets called every time the node side receives a message from the casper side. An example implementation is:

nightmareJS.notifyCasperMessage = function(msg) {
    if(msg.type == 'statement') {
        console.log(msg.msg);
        console.log("Nightmare Server says hello.");
    }
    else if(msg.type == 'dateQuestion') {
        console.log(msg.msg);
        var d = new Date();
        nightmareJS.sendCasperMessage({ time: d.toString(), timeNow: d.getTime()});
    }
}

On the Casper side, to send a message to the server, call the function:

/**
	msgForParent	= Object to be sent to the Node server.
	expectedTerm 		= Term that is expected to be included in response from the Node server.
	then			= Function with the next step for casper to execute. (Optional)
	timeout			= Millisecond timeout value. If not included, specified default is used instead. (Optional)
	onTimeout		= Function to be executed on timeout. (Optional)
*/
casper.waitForMessageResponse(msgForParent, expectedTerm, then, timeout, onTimeout);

Once it is all together, you can run it like:

> node examples/server.js --log-level=debug --direct examples/casper.js

For a more complete example set, please look in the example folder.

##Command Line Options When running a Nightmare test, you can pass in any of the command line options that CasperJS takes provided that they come after your server file. Example form:

> node server_filename.js [command line options] casper_filenames.js

##License MIT Licensed