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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nwglobal

v0.0.2

Published

Node.js globals for node-webkit's HTML5

Readme

This Node.js module (nwglobal) provides a workaround for node-webkit's issues #702, #716, #832.

These issues happen in node-webkit because, as the modules run in Node context, the constructors of their global objects (such as Date or ArrayBuffer or even Array) differ from WebKit's.

(An example below demonstrates that you may pass an array from some <script>…</script> to the async module that you have previously required, but that module cannot recognize such an array.)

To prevent the trouble, nwglobal exports Node's constructors. You may use them instead of the constructors available in WebKit's context, and then you may pass the resulting object instances to any Node code.

Installation

(npm package version)

  • Latest packaged version: npm install nwglobal

  • Latest githubbed version: npm install https://github.com/Mithgol/nwglobal/tarball/master

You may visit https://github.com/Mithgol/nwglobal#readme occasionally to read the latest README because the package's version is not planned to grow after changes when they happen in README only. (And npm publish --force is forbidden nowadays.)

Example

Classic async waterfall example:

require('async').waterfall([
    function(callback){
        callback(null, 'one', 'two');
    },
    function(arg1, arg2, callback){
        callback(null, 'three');
    },
    function(arg1, callback){
        // arg1 now equals 'three'
        callback(null, 'done');
    }
], function (err, result) {
   // result now equals 'done'
   console.log(result);
});

does not report 'done' in node-webkit (issue #832), but can be fixed with the following changes:

require('async').waterfall( require('nwglobal').Array(
    function(callback){
        callback(null, 'one', 'two');
    },
    function(arg1, arg2, callback){
        callback(null, 'three');
    },
    function(arg1, callback){
        // arg1 now equals 'three'
        callback(null, 'done');
    }
), function (err, result) {
   // result now equals 'done'
   console.log(result);
});

The aforementioned problem was also fixed in async module version 0.3.0 (and newer versions) after its own source code was changed to take a possible difference of JavaScript contexts into account.

You may find another example in “Differences of JavaScript contexts”.

Implementation details

The following Node.js globals are available as the exported fields of require('nwglobal'):

  • Standard object types: Array, Boolean, Date, Function, Number, Object, RegExp, String.

  • Typed array types: ArrayBuffer, DataView, Float32Array, Float64Array, Int16Array, Int32Array, Int8Array, Uint16Array, Uint32Array, Uint8Array.

  • Error types: Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError.

  • Special value types: Infinity, NaN, undefined, null.

However, the latter four (Infinity, NaN, undefined, null) are actually superglobal (i.e. they are the same in Node's and WebKit's contexts). You may use nwglobal to check it with the following four statements in node-webkit's “Developer Tools” console:

  • null === require('nwglobal').null

  • typeof require('nwglobal').undefined === 'undefined'

  • Infinity === require('nwglobal').Infinity

  • isNaN( require('nwglobal').NaN )

These statements are true. (Meaning that you won't need these four exported values IRL.)

Limits

It is not possible to replace the default constructors of arrays and objects created by [] and {} initialisers.

(Standard ECMA-262 5.1 Edition very specifically defines array initialiser and object initialiser so that the corresponding standard built-in constructor is used for each.)

Therefore you have to use Array() and Object() constructors exported by require('nwglobal') in order to create arrays and objects in Node's context.

NB: you can cast browser's [] array to node.js array with require('nwglobal').Array.prototype.slice.call(browserContextArray).

NB2: With this you can transform jquery set.

License

MIT License, see the LICENSE file.