Skip to content

Common array functions with support for generators (forEach, filter, map)

License

Notifications You must be signed in to change notification settings

vadimdemedes/array-generators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

array-generators Circle CI

Array methods (forEach, forEachSeries, map, filter) with support for generator functions.

Installation

$ npm install array-generators --save

Usage

let array = require('array-generators');

let forEach = array.forEach;
let filter = array.filter;
let map = array.map;

let arr = ['first', 'second', 'third'];


/* forEach (async) */
yield forEach(arr, function * (item, index) {
	// item is value, e.g. 'first'
	// index is, well, index, e.g. 0
});


/* forEachSeries (serially) */
yield forEachSeries(arr, function * (item, index) {
  // same as forEach()
});

/* filter */
let result = yield filter(arr, function * (item, index) {
	// return true or false
});


/* map */
let result = yield map(arr, function * (item, index) {
	// return value
});

Tests

Circle CI

$ make test

License

MIT © Vadym Demedes

About

Common array functions with support for generators (forEach, filter, map)

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published