Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Function to match against stuff.
Inspired by:
Load the thing:
const match = require('pamach');
Pass some args and spec obj:
const drink = 'coke';
const myDrink = match(drink)({
coke: () => { return 'Pssshhh...'; },
wine: () => { return 'I like this harvest from summer 1901...'; },
beer: () => { return 'After a long day...' },
default: () => { return 'H20'; },
});
console.log(myDrink); // -> 'Pssshhh...'
Multiple arguments:
const firstComponent = 'coke';
const secondComponent = 'vodka';
const cocktail = match(firstComponent, secondComponent)({
'coke, vodka': () => { return 'Much better together'; },
'beer, vodka': () => { return 'Are you sure this is a good idea?'; },
default: () => { return 'H20'; }
});
console.log(cocktail); // -> 'Much better together'
Accepts anything that implements .toString
:
const person = {
firstName: 'Steve',
lastName: 'Jobs',
toString: function() { return `${this.firstName} ${this.lastName}` }
};
const collegue = match(person)({
'Steve Jobs': () => {
return { firstName: 'Jonny', lastName: 'Ive' }
},
'Fox Malder': () => {
return { firstName: 'Dana', lastName: 'Scully' }
}
});
console.log(collegue); // -> { firstName: 'Jonny', lastName: 'Ive' }
match([args])
-> FunctionTakes any number of args and returns new matcher
function
matcher(spec)
-> Anythat takes spec
object to map args
separated by ', '
(coma + space) as
key to corresponding function, so value returned by this function becomes the
return value of matcher
.
If no key found for given set of args
, matcher
tries to find default key in
the spec
object and call its value.
If no default
key found, undefined
is returned.
License - MIT
FAQs
Pattern matching utility.
We found that pamach 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.