
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
deep-map-object
Advanced tools
The utility for deep mapping object keys and values
The util help facilitating the deep transform from one object to another by given helpers function.
npm i deep-map-object
ES6
import deepMap from 'deep-map-object';
const options = function(value) {
return value + 1;
};
const data = {
x: 1,
y: {
z: [2, 3],
t: 4
}
};
const result = deepMap(options)(data);
console.log(result);
/*
{
x: 2,
y: {
z: [3, 4],
t: 5
}
}
*/
ES5
var deepMap = require('deep-map-object');
var options = function(value) {
return value + 1;
};
var data = {
x: 1,
y: {
z: [2, 3],
t: 4
}
};
var result = deepMap(options)(data);
console.log(result);
/*
{
x: 2,
y: {
z: [3, 4],
t: 5
}
}
*/
deepMap: function(options: function|object) => (resolve: function(value: any) => result:any)
import deepMap from 'deep-map-object';
const data = { x: 1 };
const result = deepMap(value => value + 1)(data);
console.log(result); // {x : 2}
mapValue: function(value: primitive, resolve: function(value: any))
import deepMap from 'deep-map-object';
const data = { x: 1 };
const result = deepMap({ mapValue: value => value + 1 })(data);
console.log(result); // {x : 2}
mapArray: function(value: array, resolve: function(value: any))
import deepMap from 'deep-map-object';
const data = { a: [1, 2, 3] };
const result = deepMap({ mapArray: values => values.map(value => value + 1) })(data);
console.log(result); // { a: [2, 3, 4] };
mapObject: function(value: object, resolve: function(value: any))
import deepMap from 'deep-map-object';
const data = { a: { num: 0 }, b: { num: 1 } };
const result = deepMap({
mapObject: (obj, resolve) => obj.num > 0
? {...obj, num: obj.num + 1 }
: deepMap.mapObject(obj, resolve)
})(data);
console.log(result); // { a: { num: 0 }, b: { num: 2 } };
mapFn: function(value:any, resolve: function(value: any))
// If mapFn is used, mapValue, mapArray, mapObject options will be disabled
import deepMap from 'deep-map-object';
const data = { a: { num: 0 }, c: { d: [1, 2] } };
const result = deepMap({
mapFn: (val, resolve) => {
if (Array.isArray(val)) return val.map(resolve);
if (val instanceof Object) return deepMap.mapObject(val, resolve);
return val + 1;
}
})(data);
console.log(result); // { a: { num: 1 }, c: { d: [2, 3] } };
deepMap.mapArray: function(value: array, resolve: function(value: any))
deepMap.mapObject: function(value: object, resolve: function(value: any))
FAQs
The utility for deep mapping object's keys and values
The npm package deep-map-object receives a total of 1,383 weekly downloads. As such, deep-map-object popularity was classified as popular.
We found that deep-map-object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.