Package Exports
- utile
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (utile) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
utile
A drop-in replacement for util with some additional advantageous functions
Installation
Installing npm (node package manager)
curl http://npmjs.org/install.sh | shInstalling utile
[sudo] npm install utileMotivation
Javascript is definitely a "batteries not included language" when compared to languages like Ruby or Python. Node.js has a simple utility library which exposes some basic (but important) functionality:
$ node
> var util = require('util');
> util.
(...)
util.debug util.error util.exec util.inherits util.inspect
util.log util.p util.print util.pump util.putsWhen one considers their own utility library, why ever bother requiring util again? That is the approach taken by this module. To compare:
$ node
> var utile = require('./lib')
> utile.
(...)
utile.async utile.capitalize utile.clone utile.cpr utile.debug
utile.each utile.error utile.exec utile.inherits utile.inspect
utile.log utile.mixin utile.mkdirp utile.p utile.print
utile.pump utile.puts utile.randomString utile.read utile.rimrafAs you can see all of the original methods from util are there, but there are several new methods specific to utile. A note about implementation: no node.js native modules are modified by utile, it simply copies those methods.
Methods
The utile modules exposes some simple utility methods:
.each(obj, iterator): Iterate over the keys of an object..mixin(target [source0, source1, ...]): Copies enumerable properties fromsource0 ... sourceNontotargetand returns the resulting object..clone(obj): Shallow clones the specified object..capitalize(str): Capitalizes the specifiedstr..randomString(length): randomString returns a pseudo-random ASCII string (subset) the return value is a string of length ⌈bits/6⌉ of characters from the base64 alphabet..filter(obj, test): return an object with the properties thattestreturns true on.
Packaged Dependencies
In addition to the methods that are built-in, utile includes a number of commonly used dependencies to reduce the number of includes in your package.json. These modules are not eagerly loaded to be respectful of startup time, but instead are lazy-loaded getters on the utile object
.async: Async utilities for node and the browser.mkdirp: Recursively mkdir, like mkdir -p, but in node.js.rimraf: A rm -rf util for nodejs.cpr: Asynchronous recursive file copying with Node.js
Tests
All tests are written with vows and should be run with npm:
$ npm test