
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
map-anything
Advanced tools
npm i map-anything
Array.map but for objects. A small and simple integration.
I always want to do:
someObject.map(val => someFunction)
But this doesn't exist for objects, so you need to do this instead:
Object.entries(someObject).reduce((carry, [key, value], index, array) => {
carry[key] = someFunction(value, index, array)
return carry
}, {})
So I made a wrapper function for that. 😃
import { mapObject } from 'map-anything'
const pokemon = {
'001': { name: 'Bulbasaur', level: 10 },
'004': { name: 'Charmander', level: 8 },
'007': { name: 'Squirtle', level: 11 }
}
const levelUp = mapObject(pokemon, pkmn => {
pkmn.level++
return pkmn
})
levelUp ===
{
'001': { name: 'Bulbasaur', level: 11 },
'004': { name: 'Charmander', level: 9 },
'007': { name: 'Squirtle', level: 12 }
}
Please note, just like
Array.map
when using nested values/objects, the original object will also have its values modified because of references.
The source code is literally just this:
function mapObject (object, fn) {
return Object.entries(object)
.reduce((carry, [key, value], index, array) => {
carry[key] = fn(value, index, array)
return carry
}, {})
}
FAQs
Array.map but for objects with good TypeScript support. A small and simple integration.
The npm package map-anything receives a total of 499 weekly downloads. As such, map-anything popularity was classified as not popular.
We found that map-anything demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.