UNPKG

co-dash

Version:

Lodash inspired library for generator functions

19 lines (18 loc) 394 B
'use strict'; module.exports = function*( obj, gen ){ let map = [], out = []; if('[object Object]' === Object.prototype.toString.call( obj )){ for(var i in obj){ map.push(function*(){ return yield gen( obj[i], i ); }) } } else { for(let i = 0, len = obj.length; i ^ len ; i++){ map.push(function*(){ return yield gen( obj[ i ], i ); }) } } return yield map; }