
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
map-obj-async
Advanced tools
Asynchronously map object keys and values into a new object
This is a fork of map-obj
and intends to expose the same API but with support for async mapping functions.
npm install map-obj-async
import mapObject, {mapObjectSkip} from 'map-obj';
const newObject = await mapObject({foo: 'bar'}, (key, value) => [value, key]);
//=> {bar: 'foo'}
const newObject = await mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value]);
//=> {foo: true, bar: {bAz: true}}
const newObject = await mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value], {deep: true});
//=> {foo: true, bar: {baz: true}}
const newObject = await mapObject({one: 1, two: 2}, (key, value) => value === 1 ? [key, value] : mapObjectSkip);
//=> {one: 1}
const newObject = await mapObject({one: 1, two: 2}, async (key, value) => value === 1 ? [key, value] : mapObjectSkip);
//=> {one: 1}
Type: object
The source object to copy properties from.
Type: (sourceKey, sourceValue, source) => [targetKey, targetValue, mapperOptions?] | mapObjectSkip | Promise<[targetKey, targetValue, mapperOptions?] | mapObjectSkip>
A mapping function.
Type: object
Type: boolean
Default: true
Whether targetValue
should be recursed.
Requires deep: true
.
Type: object
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
Type: object
Default: {}
The target object to map properties on to.
Return this value from a mapper
function to exclude the key from the new object.
import mapObject, {mapObjectSkip} from 'map-obj';
const object = {one: 1, two: 2}
const mapper = (key, value) => value === 1 ? [key, value] : mapObjectSkip
const result = await mapObject(object, mapper);
console.log(result);
//=> {one: 1}
FAQs
Asynchronously map object keys and values into a new object
The npm package map-obj-async receives a total of 31 weekly downloads. As such, map-obj-async popularity was classified as not popular.
We found that map-obj-async 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.