uses
There are just too many use cases, when you might find that methods exposed by built-ins is not enough. Also, different libraries try to fix in a different ways:
-
Libraries like sugarjs extend built-ins with a collection of helpful methods, that provide natural and concise API, which still may or may not fit your use case (if not, you're back to the original problem).
-
Libraries like underscore provide handful utility functions. Unfortunately those are not as chaining friendly (degrade code readability when chaining multiple actions) and have different signature from built-ins.
var sum = _
This library tryes to provide a natural, chainable API that is not limited to any collection of heldful methods, in fact it does not comes with thouse and encourages to build / reuse use case specific methods and collections.
Examples
Any funcitons with generic DSL
var uses = use = usesuse Target = usesTarget { var sources = Arrayprototypeslice var target = sources var whitelist = {} sources return Object} { var names = Arrayprototypeslice var source = names var properties = var whitelist = {} names return Object} var actual = // => { x: 12, a: 1, b: 2 }
Define custom DSL
var uses = use = usesuse DSL = usesDSL // Define methods useful for working with objects like hashes.var Hash = DSL var hash = // => { x: 12, a: 1, b: 2 }
fab inspired DSL
Go crazy with var uses = use = usesuse fab = usesfab// Same map / filter as in first examplevar hash = merge x: 12 y: 13 filter 'a' 'b' 'x' fabrun // => { x: 12, a: 1, b: 2 }
Install
npm install uses