utile / 0.3.0 last updated 4 months ago created on Oct 31st 2011
Install
npm install --save utile
Clone
git clone git@github.com:flatiron/utile.git
dependencies
show all 16
| main |
|
async | 0.9.0 | MIT |
|
|
i | 0.3.2 | MIT | |
|
|
mkdirp | 0.5.0 | MIT | |
|
|
ncp | 1.0.1 | MIT | |
|
|
rimraf | 2.3.2 | MIT |
maintainers
versions
19 total
| 0.3.0 | 4 months ago | indexzero |
| 0.2.1 | a year ago | jcrugzz |
| 0.2.0 | 2 years ago | mmalecki |
| 0.1.7 | 2 years ago | mmalecki |
| 0.1.6 | 2 years ago | indexzero |
| 0.1.5 | 3 years ago | indexzero |
| 0.1.3 | 3 years ago | indexzero |
| 0.1.2 | 3 years ago | indexzero |
| 0.1.1 | 3 years ago | indexzero |
| 0.1.0 | 3 years ago | indexzero |
| 0.0.10 | 3 years ago | indexzero |
| 0.0.9 | 3 years ago | indexzero |
| 0.0.8 | 3 years ago | indexzero |
| 0.0.6 | 3 years ago | dominictarr |
| 0.0.5 | 3 years ago | dominictarr |
| 0.0.4 | 3 years ago | dominictarr |
| 0.0.3 | 3 years ago | indexzero |
| 0.0.2 | 3 years ago | indexzero |
| 0.0.1 | 3 years ago | indexzero |
readme
utile 
A drop-in replacement for util with some additional advantageous functions
Motivation
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:
When one considers their own utility library, why ever bother requiring util again? That is the approach taken by this module. To compare:
As 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..args(arguments): Converts function arguments into actual array with specialcallback,cb,array, andlastproperties. Also supports optional argument contracts. See the example for more details..requireDir(directory): Requires all files and directories fromdirectory, returning an object with keys being filenames (without trailing.js) and respective values being return values ofrequire(filename)..requireDirLazy(directory): Lazily requires all files and directories fromdirectory, returning an object with keys being filenames (without trailing.js) and respective values (getters) being return values ofrequire(filename)..format([string] text, [array] formats, [array] replacements): Replaceformatsintextwithreplacements. This will fall back to the originalutil.formatcommand if it is called improperly.
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.inflect: Customizable inflections for node.js.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
Installation
Installing npm (node package manager)
Installing utile
Tests
All tests are written with vows and should be run with npm: