Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including object-keys-map with all npm packages installed. Try it out:

var objectKeysMap = require("object-keys-map")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

object-keys-map v1.0.2

`Array.prototype.map` for object keys

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.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free