property-map
Apply a given function to each property of an object
Last updated 4 years ago by angus-c .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install property-map 
SYNC missed versions from official npm registry.

property-map

Apply a function to each property of an object

Install

npm install property-map

API

propertyMap(baseObj, callback [, thisObject]);

callback is a function that can accept up to three arguments:

value
The value for each property in baseObj
key (optional)
The key for each property in baseObj
baseObj (optional)
The baseObj

Usage

// commonJS...
var propertyMap = require('property-map');
// ...or es2015
import propertyMap from 'property-map';

propertyMap(
  {a: 4, b: 6, c: 3},
  value => value + 1
); // {a: 5, b: 7, c: 4}

propertyMap(
  {a: 4, b: 6, c: 3},
  function(_, key) {return this[key]},
  {a: 1, c: 3}
); // {a: 1, b: undefined, c: 3}

Tests

npm test

Current Tags

  • 0.0.2                                ...           latest (4 years ago)

2 Versions

  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |