<commit_before>phantomjs-nodify
================

Set of scripts that make [PhantomJS](http://www.phantomjs.org/) environment
more similar to [Node.js](http://nodejs.org/).
I implemented what I needed for my scripts. Feel free to fork and add more.

Implemented features:

* Module support mostly compatible with CommonJS and Node.js, i.e. `require()`
  works not only for PhantomJS built-in modules. Most of the functionality from
  [Node.js Modules](http://nodejs.org/api/modules.html) (up to
  [The `module` Object](http://nodejs.org/api/modules.html#modules_the_module_object))
  should work.
* Exceptions thrown from required files are properly reported (with file name
  and line number). Line number for `.coffee` files may not be accurate.
  _Unfortunately this is [broken in PhantomJS 1.5](http://code.google.com/p/phantomjs/issues/detail?id=510)_
* Global `process` object (some basic functionality + emits `uncaughtException`
  on exceptions that occur inside `setTimeout` blocks).
* `console` with string formatting (e.g. `console.log('hello %s', 'world')`).
* Some Node.js modules (see `modules` dir).
* Other minor tweaks.

Some code taken from [Node.js](http://nodejs.org/).
Uses [CoffeeScript](http://jashkenas.github.com/coffee-script/)
and [Mocha](http://visionmedia.github.com/mocha/)
+ [Chai](http://chaijs.com/) for testing.


How to use
----------

Clone:

    git clone git://github.com/jgonera/phantomjs-nodify.git

If you want to use CoffeeScript, clone with submodules:

    git clone git://github.com/jgonera/phantomjs-nodify.git --recursive

Inject in your PhantomJS script at the very first line:

```js
var nodify = 'phantomjs-nodify/nodify.js';
phantom.injectJs(nodify);
```

You **must** provide the path to `nodify.js` in the global `nodify` variable.

Then, wrap your script in `nodify.run()`:

```js
var nodify = 'phantomjs-nodify/nodify.js';
phantom.injectJs(nodify);

nodify.run(function() {<commit_msg>fixed readme<commit_after>phantomjs-nodify
================

Set of scripts that make [PhantomJS](http://www.phantomjs.org/) environment
more similar to [Node.js](http://nodejs.org/).
I implemented what I needed for my scripts. Feel free to fork and add more.

Implemented features:

* Module support mostly compatible with CommonJS and Node.js, i.e. `require()`
  works not only for PhantomJS built-in modules. Most of the functionality from
  [Node.js Modules](http://nodejs.org/api/modules.html) (up to
  [The `module` Object](http://nodejs.org/api/modules.html#modules_the_module_object))
  should work.
* Exceptions thrown from required files are properly reported (with file name
  and line number). Line number for `.coffee` files may not be accurate.
  _Unfortunately this is [broken in PhantomJS 1.5](http://code.google.com/p/phantomjs/issues/detail?id=510)_
* Global `process` object (some basic functionality + emits `uncaughtException`
  on exceptions that occur inside `setTimeout` blocks).
* `console` with string formatting (e.g. `console.log('hello %s', 'world')`).
* Some Node.js modules (see `modules` dir).
* Other minor tweaks.

Some code taken from [Node.js](http://nodejs.org/).
Uses [CoffeeScript](http://jashkenas.github.com/coffee-script/)
and [Mocha](http://visionmedia.github.com/mocha/) + [Chai](http://chaijs.com/)
for testing.


How to use
----------

Clone:

    git clone git://github.com/jgonera/phantomjs-nodify.git

If you want to use CoffeeScript, clone with submodules:

    git clone git://github.com/jgonera/phantomjs-nodify.git --recursive

Inject in your PhantomJS script at the very first line:

```js
var nodify = 'phantomjs-nodify/nodify.js';
phantom.injectJs(nodify);
```

You **must** provide the path to `nodify.js` in the global `nodify` variable.

Then, wrap your script in `nodify.run()`:

```js
var nodify = 'phantomjs-nodify/nodify.js';
phantom.injectJs(nodify);

nodify.run(function() {
{'fraction_non_alphanumeric': 0.14282031451405, 'fraction_numerical': 0.002577984016499098, 'mean_word_length': 4.388888888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5658641', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1220, 'n_words': 387}