0.1.0 • Published 7 years ago

okei v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

okei

Object Iteration tool

Usage

const okeiMap = require('okei')('map');

const obj = {
  foo: 'poo',
  bar: 'par',
};

okeiMap(obj, val => val); // returns ['foo', 'bar']
okeiMap(obj, val => obj[val]); // returns ['poo', 'par']
okeiMap('foo', val => val); // returns ['f', 'o', 'o']

const okeiReduce = require('okei')('reduce');

okeiReduce([0, 1, 2, 3], (a, b) => a + b); // returns 6
okeiReduce([[0, 1], [2, 3], [4, 5]], (a, b) => a.concat(b), []); // returns [ 0, 1, 2, 3, 4, 5 ]
okeiReduce(obj, (newObj, key) => {
  newObj[obj[key]] = key;
  return newObj;
}, {}); // returns { poo: 'foo', par: 'bar' }