
Security News
Rust RFC Proposes a Security Tab on crates.io for RustSec Advisories
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.
Map object keys and values into a new object
npm install map-obj
import mapObject, {mapObjectSkip} from 'map-obj';
// Swap keys and values
const newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);
//=> {bar: 'foo'}
// Convert keys to lowercase (shallow)
const newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value]);
//=> {foo: true, bar: {bAz: true}}
// Convert keys to lowercase (deep recursion)
const newObject = mapObject({FOO: true, bAr: {bAz: true}}, (key, value) => [key.toLowerCase(), value], {deep: true});
//=> {foo: true, bar: {baz: true}}
// Filter out specific values
const newObject = mapObject({one: 1, two: 2}, (key, value) => value === 1 ? [key, value] : mapObjectSkip);
//=> {one: 1}
// Include symbol keys
const symbol = Symbol('foo');
const newObject = mapObject({bar: 'baz', [symbol]: 'qux'}, (key, value) => [key, value], {includeSymbols: true});
//=> {bar: 'baz', [Symbol(foo)]: 'qux'}
Type: object
The source object to copy properties from.
Type: (sourceKey, sourceValue, source) => [targetKey, targetValue, mapperOptions?] | mapObjectSkip
A mapping function.
[!NOTE] When
options.deepistrue, the mapper receives keys and values from nested objects and arrays. ThesourceKeyparameter is typed asstring | symbolandsourceValueasunknownto reflect the actual runtime behavior when recursing into unknown shapes. The third argumentsourceis always the original input object, not the current nested owner.
Type: object
Type: boolean
Default: true
Whether to recurse into targetValue.
Requires deep: true.
Type: object
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
Built-in objects like RegExp, Error, Date, Map, Set, WeakMap, WeakSet, Promise, ArrayBuffer, DataView, typed arrays (Uint8Array, etc.), and Blob are not recursed into. Special objects like Jest matchers are also automatically excluded.
Type: boolean
Default: false
Include symbol keys in the iteration.
By default, symbol keys are completely ignored and not passed to the mapper function. When enabled, the mapper will also be called with symbol keys from the source object, allowing them to be transformed or included in the result. Only enumerable symbol properties are included.
Type: object
Default: {}
The target object to map properties onto.
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 = mapObject(object, mapper);
console.log(result);
//=> {one: 1}
lodash.mapkeys is a method from the Lodash library that allows you to create an object with the same values as the original object but with keys mapped using a provided function. It is similar to map-obj but is part of the larger Lodash utility library.
object-map is a package that provides a function to map the values of an object to new values based on a provided function. It is similar to map-obj but focuses only on mapping values, not keys.
deep-map-object is a package that allows deep mapping of object keys and values. It is similar to map-obj's deep mapping feature but is specifically designed for deep transformations.
FAQs
Map object keys and values into a new object
The npm package map-obj receives a total of 18,540,015 weekly downloads. As such, map-obj popularity was classified as popular.
We found that map-obj demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.

Security News
/Research
Socket found a Rust typosquat (finch-rust) that loads sha-rust to steal credentials, using impersonation and an unpinned dependency to auto-deliver updates.

Research
/Security Fundamentals
A pair of typosquatted Go packages posing as Google’s UUID library quietly turn helper functions into encrypted exfiltration channels to a paste site, putting developer and CI data at risk.