_part_
This micro library encourages functional programming by making native methods available as partially applied functions.
//typical receiver-method-arguments pattern123; // [2,3,4]
The "left-part" functions prepend the method name with an underscore and expect the receiver as the first argument in the first invocation.
{ return n + 1; } ; // [2,3,4]
The "right-part" functions suffix the method name with an underscore and expect the receiver as the first argument in the function returned by the first invocation.
123 ; // [2,3,4]
See the docs.
Try the live demo.
Getting Started
See the following examples of how to include _part_.
Custom namespace;
// NodeJS examplevar _part_ = ;var util = {};_part_ Arrayprototype "reduce" ; { return +a + +b; }utilsum = util;moduleexports = util;
<!-- Browser example -->
Extending the _part_ namespace;
// NodeJS examplevar _part_ = ;_part_ Arrayprototype "reduce" ; { return +a + +b; }var sum = util;
<!-- Browser example -->
Non-namespaced utilities
// NodeJS examplevar _part_ = ;var reduce_ = _part_; { return +a + +b; }var sum = ;
<!-- Browser example -->
Updates
- 2013-12-11 - Added
papply
to the_part_
namespace.