Extended Modules for Node.js
em extends few core NodeJS modules with
simpler object oriented interface and immutable objects.
It can be installed directly from NPM:
npm install em
Open source, MIT-style license.
You can create instances of
URL by calling
URL.create() only creates new objects when it must. For
example when called with an another instance of
URL it can simply
return it since it's immutable and cannot be changed.
Each method of
URL returns an another URL object so you can chain its
var url = URLcreate''resolve'/2012/12/24/setting-up-http-server-on-windows-with-node-js/';console.logurlhref;
One of the coolest features of
URL is that parsing can be done just
in time on demand. In the previous example the URL wasn't parsed until
url.href! However if you need you can call
url.parse() and get a real object with no magic members and JIT.
Path works the same way.
You can create objects by calling
new Path('/foo/bar'). Paths are immutable, too.
var path = Pathcreate'/foo'join'bar/docroot/'join'index.html';console.log'dirname: '+pathdirname; // Returns '/foo/bar/docroot'console.log'pathname: '+pathbasename'.html'; // Returns 'index'
At the moment for further details please take a look at tests.