#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 onObject.prototype
.array
-- Install methods onArray.prototype
.collection
-- Install methods that apply to all "collection-like" objects.function
-- Install methods onFunction.prototype
._
-- Install_
globally.
The default is to install everything except _
.