Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
/ map Public archive

Map over an object, array or string in JavaScript

License

Notifications You must be signed in to change notification settings

blakeembrey/map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Map

NPM version Build status Test coverage Greenkeeper badge

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

About

Map over an object, array or string in JavaScript

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published