1.0.1 • Published 10 years ago

util-map v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Map

NPM version Build status Test coverage Gittip

Map over an object, array or string and keep the result as the same type.

Installation

npm install util-map --save

Usage

var map = require('util-map');

// Map over objects.
map({
  a: 0,
  b: 1,
  c: 2
}, function (value, key, obj) {
  return value + 10;
});
//=> { a: 10, b: 11, c: 12 }

// Map over arrays.
map(['a', 'b', 'c'], function (value, key, obj) {
  return String.fromCharCode(value.charCodeAt(0) + 1);
});
// => ['b', 'c', 'd']

// Map over strings.
map('abc', function (value, key, obj) {
  return key + 1;
});
//=> '123'

License

MIT

1.0.1

10 years ago

1.0.0

10 years ago