
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
array-to-obj
Advanced tools
Convert an array of objects into a keyed object
$ npm install array-to-obj
id
const arrayToObj = require('array-to-obj');
const districts = [
{id: 1, name: 'Richmond'},
{id: 2, name: 'Cow Hollow, Marina, Pacific Heights'}
];
arrayToObj(districts);
// {
// 1: { id: 1, name: 'Richmond' },
// 2: { id: 2, name: 'Cow Hollow, Marina, Pacific Heights' }
// }
const arrayToObj = require('array-to-obj');
const songs = [
{title: 'Bluebird', artist: 'One Self'},
{title: 'Sunshine', artist: 'Atmosphere'}
];
arrayToObj(songs, {
key: 'title'
});
// {
// Bluebird: { title: 'Bluebird', artist: 'One Self' },
// Sunshine: { title: 'Sunshine', artist: 'Atmosphere' }
// }
const arrayToObj = require('array-to-obj');
const browsers = [
{engine: 'Blink', name: 'Chrome'},
{engine: 'Gecko', name: 'Firefox'}
];
arrayToObj(browsers, {
key: browser => browser.engine.toLowerCase()
});
// {
// blink: { engine: 'Blink', name: 'Chrome' },
// gecko: { engine: 'Gecko', name: 'Firefox' }
// }
const arrayToObj = require('array-to-obj');
const shortid = require('shortid');
const books = [
{title: 'The Three-Body Problem', meta: {upc: 9781784971571}},
{title: 'The Dark Forest'}
];
const converted = arrayToObj(books, {
key: book => {
try {
return book.meta.upc;
} catch (error) {
return shortid.generate();
}
}
});
const arrayToObj = require('array-to-obj');
const shortid = require('shortid');
const movies = [
{released: '2001', title: 'Spirited Away'},
{released: '2004', title: 'Howl\'s Moving Castle'}
];
arrayToObj(sourceArray, {
key: () => shortid.generate()
});
// {
// qy5Tisvbu: { released: '2001', title: 'Spirited Away' },
// kYzoS40SOn: { released: '2004', title: 'Howl\'s Moving Castle' }
// }
Type: array
An array of objects to convert to an object.
Type: Object
Type: string
or function
Default: 'id'
The property to use as a key. The array index is used when the property is undefined.
MIT © Chris Vogt
FAQs
Convert an array of objects into a keyed object
The npm package array-to-obj receives a total of 0 weekly downloads. As such, array-to-obj popularity was classified as not popular.
We found that array-to-obj 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.