co-dash
1.0.71 • Public • Published co-dash
Lodash-inspired library for generators
Install
Install the package with npm:
Usage
codash.once(fn)
const co = require('co');
const { once } = require('co-dash');
let getData = once(getData);
co(function*(){
let data1 = yield getData();
let data2 = yield getData();
})
codash.filter(arr, fn)
const co = require('co');
const fs = require('co-fs');
const { filter } = require('co-dash');
co(function*(){
yield filter(['test1.log','test2.log'], fs.exists);
})
codash.map(arr, fn)
const co = require('co');
const fs = require('co-fs');
const { map } = require('co-dash');
co(function*(){
let files = yield map(['test1.log','test2.log'], fs.readFile);
})
codash.each(arr, fn)
const co = require('co');
const fs = require('co-fs');
const { each } = require('co-dash');
co(function*(){
yield each(['test1.log','test2.log'], *function(fileName){
console.log(yield fs.stat(fileName))
});
})
codash.reduce(arr, fn, init)
const co = require('co');
const fs = require('co-fs');
const { reduce } = require('co-dash');
co(function*(){
let sum = yield reduce(['test1.log','test2.log'], *function(a, b){
return a + b
});
})
License
MIT
Package Sidebar
Install
Weekly Downloads