Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@mattisg/object.map
Advanced tools
Array.map for Object. Map both an object’s keys and values. Defaults to cleanly augment prototype.
Array.map
for Object
in JavaScript. Map both an object’s keys and values.
By default, will allow calling Object.map
(obviously, as a non-enumerable property).
If you're terrified about augmenting prototypes of natives zomg ruin on us all, just set the shouldAugmentObjectPrototype
param to false
on the last line. The enclosing IEFE will then return the mapObject
function with the source object as its first parameter, so you can call it however you want.
/**
*@param {Function|String} [valueMapper = pass-through] The function to map the value from the source's value. Will be passed the current value, the original key, and the mapped key. If a string, will be set to an accessor for that attribute.
*@param {Function|String} [keyMapper = pass-through] The function to map the key from the source's key. Will be passed the original key and the original value. If a string, will be set to an accessor for that attribute.
*@throws TypeError If one of the mapper is an illegal type.
*@returns {Object<String,String>}
*/
Object.map(valueMapper, keyMapper);
var source = { a: 1, b: 2 };
function sum(x) { return x + x }
source.map(sum); // returns { a: 2, b: 4 }
source.map(undefined, sum); // returns { aa: 1, bb: 2 }
source.map(sum, sum); // returns { aa: 2, bb: 4 }
MIT: Do whatever you want as long as you don't sue me nor prevent others to reuse this piece of software. Also, credit is always appreciated ;)
FAQs
Array.map for Object. Map both an object’s keys and values. Defaults to cleanly augment prototype.
We found that @mattisg/object.map 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
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.