genit
Generator based utility belt
$ npm install genit
Key
- Usage
- Utilities
- Synchronous
- Asynchronous
- Coming Soon
- Miscellaneous
Usage
Direct
'use strict' let genit = ; let { return genit; }
Module Extension
'use strict' let _ = ; let genit = ; genit; _; //existing _ // injected { return _genit; // injected to .genit property (name collision) }
Utilities
Synchronous
Mixed Synchronous
each
- Parameters
- [Required] [Mixed] - Collection to operate on,
- [Required] [Generator Function] - Operation to perform
- Functionality
- Iterates over every item in the collection (objec tor array)
- Executes the operation on each item
- Returns
- Undefined
genit;// console:// 1 = one ~ one// 2 = two ~ two// 3 = three ~ three genit;// console:// one = foo ~ foo// two = bar ~ bar// three = biz ~ biz
map
- Parameters
- [Required] [Mixed] - Collection to operate on,
- [Required] [Generator Function] - Operation to perform
- Functionality
- Iterates over every item in the collection (objec tor array)
- Executes the operation on each item
- Returned value is added to the resulting array
- Returns
- Array of values returned
let result = genit;// console:// 1 = one ~ one// 2 = two ~ two// 3 = three ~ threeconsole;// console:// [0, 1, 2] let result = genit;// console:// one = foo ~ foo// two = bar ~ bar// three = biz ~ bizconsole;// console:// ['foo', 'bar', 'biz']
filter
- Parameters
- [Required] [Mixed] - Collection to operate on,
- [Required] [Generator Function] - Operation to perform
- Functionality
- Iterates over every item in the collection (object or array)
- Reserve only the item that passed the checking condition
- Returned value is added to the resulting array or object
- Returns
- Array or object values returned
let result = genit;console;// console:// [4,5] let result = genit;console;// console:// {two : 'bar', three: 'biz'}
Asynchronous
Coming Soon
Miscellaneous
isGenerator
- Parameters
- [Required] [Mixed] - object to type check
- Functionality
- Test whether or not a function is a generator
- Returns
- Boolean of generator status
let result = genit;console; // => false let result = genit;console; // => true
inject
- Parameters
- [Required] [Object] - object to inject properties to
- Functionality
- Inject properties into target Object
- Collision in property name move genit property to the
.genit
property
- Returns
- target object with injected properties
'use strict' let test = { return 'Original Each'; } ; let genit = ; genit; console; // => "Original Each" console // => "false" console // => "true"
Authors
- John Hofrichter
- Contributor Lan Nguyen