Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
reduce-array-object
Advanced tools
Readme
reduce-array-object is a small module to reduce arrays to objects supporting customized parameters. You can pass a numeric array or an array of objects and define what parater to use as key or value (default key: index, default value: item)
You can install with [npm]:
$ npm install --save reduce-array-object
Please check the index.test.js
to get a full list of examples but a typical use case in the following:
// Array of objects with country data.
const countries = [
{ name: 'Colombia', code: 'co', area: 1197411 },
{ name: 'Argentina', code: 'ar', area: 2766890 },
{ name: 'Canada', code: 'ca', area: 9984670 },
{ name: 'Brasil', code: 'br', area: 8511965 }
]
// Importing this module
const arrObjReducer = require('reduce-array-object')
// Reduce using the country code as key and the name as value.
const reduced = arrObjReducer((countries, {key: 'code', value: 'name'}))
// output: { co: 'Colombia', ar: 'Argentina', ca: 'Canada', br: 'Brasil' }
In conclusion the first parameter is the array
to reduce and the second parameter is a configuration object
where you can optionally define the key
and value
parameters to be used in the resulting object.
You can run the tests and check the functionality of this module using:
$ npm test
Copyright © 2020, Juan Convers. Released under the MIT License.
FAQs
Small module to reduce arrays to objects supporting customized parameters.
The npm package reduce-array-object receives a total of 0 weekly downloads. As such, reduce-array-object popularity was classified as not popular.
We found that reduce-array-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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.