1.0.71 • Published 8 years ago

co-dash v1.0.71

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

co-dash

Lodash-inspired library for generators

Install

Install the package with npm:

$ npm install co-dash

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();
	// result is cached, getData is only called once
})

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);
	//returns [ '...', '...' ]; array of files data
})

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

1.0.71

8 years ago

1.0.70

8 years ago

1.0.69

8 years ago

1.0.68

8 years ago

1.0.67

8 years ago

1.0.66

8 years ago

1.0.65

8 years ago

1.0.64

8 years ago

1.0.63

8 years ago

1.0.62

8 years ago

1.0.61

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago