Artifact [343c338e61]

Not logged in

Artifact 343c338e616e4ca4abe4290b0517221ede277ff7:

Wiki page [No-Dash] by andy 2014-09-27 15:50:22.
D 2014-09-27T22:50:22.756
L No-Dash
N text/x-markdown
P bd0b029ed7dcb464ea86be51a4c7c6bca9907dc3
U andy
W 1305
#No-Dash

At this point, all the modern browsers (FF, Chrome, IE9, and Opera) support `Object.defineProperty` which can be used to *safely* add non-enumerable properties to the global prototypes. Thus, its possible to "monkey patch" utilities into *all* arrays, *all* objects, etc. No-Dash is a thin wrapper around Lo-Dash that does just this, copying the various categories of methods from Lo-Dash into the respective prototypes. A simple example:


    require('nodash').install();
    
    [1,2,3,4].max(); // Returns 4
    [1,2,3,4].map(function(i) { return i*i; }); // returns [1,4,9,16]

No-Dash can be loaded with `require` as usual, and returns a module object which exports `_` (from Lo-Dash) as well as the `install` method. No changes are made to the global prototypes unless `install` is called. 

`install` optionally takes a list of strings as arguments, specifying the categories of functions to install. The available categories are

  *  `object` -- Install methods on `Object.prototype`.
  *  `array` -- Install methods on `Array.prototype`.
  *  `collection` -- Install methods that apply to all "collection-like" objects.
  *  `function` -- Install methods on `Function.prototype`.
  *  `_` -- Install `_` globally.

The default is to install everything except `_`.
Z 0d3169d4d7220f40e7932dbf49340f8d