`Array.prototype.map` for object keys
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

object-keys-map

Build Status

Array.prototype.map for object keys.

Usage

var assert = require('assert');
var objmap = require('object-keys-map');

var o1 = {
  foo: 'bar',
  bar: 'foo'
};

objmap(o1, function (key) {
  return 'foo/' + key;
}); // => `{ 'foo/foo': 'bar', 'foo/bar': 'foo' }`

API

objectKeysMap(obj, iterator, this)

  • obj (object) - object to map on
  • iterator (function, required) - iterator function
  • this (optional) - this for iterator

Iterates over keys of obj and creates a new object with keys based on return value of iterator and values from obj.