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.
@critocrito/namefn
Advanced tools
namefn
Set the name property of a function.
When programmatically generating functions in JavaScript, they often lack a
name. This reduces the usability of using those functions in a REPL. namefn
is a little helper to set the names of functions at construction time.
npm install @critocrito/namefn
import namefn from "@critocrito/namefn";
const f = namefn("identity", x => x);
console.log(f.name); // identity
f; // [Function: identity]
import namefn from "@critocrito/namefn";
const f = x => () => x;
const g = f(23);
console.log(g.name); // ""
g; // ""
const constant23 = namefn("constant23", f(23));
console.log(constant23.name); // "constant23"
constant23; // "[Function: constant23]"
The following example implements a curry
function, and includes the number
of missing arguments in the function name.
import namefn from "@critocrito/namefn";
const curry = n => {
const localCurry = (name, f, ...args) => {
const g = (...largs) => {
const rest = args.concat(largs);
if (rest.length < n) return localCurry(name, f, ...rest);
return f(...rest);
};
return namefn(`${name}-${n - args.length}`, g);
};
return namefn(`curry${n}`, localCurry);
};
const curry2 = curry(2);
const map = curry2("map", (f, xs) => xs.map(f));
map; // [Function: map-2]
const addOne = map(i => i + 1);
addOne; // [Function: map-1]
FAQs
Set the name property of a function.
The npm package @critocrito/namefn receives a total of 1 weekly downloads. As such, @critocrito/namefn popularity was classified as not popular.
We found that @critocrito/namefn 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.