Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
babel-plugin-transform-js-macros
Advanced tools
A handful of useful macros as babel-plugin.
npm install --save-dev babel-plugin-transform-js-macros
.babelrc
<- { "plugins": ["babel-plugin-transform-js-macros"] }
Detect free variables in an expression and return a lambda that takes those as arguments.
symbolic, x + y;
gives
({ x, y }) => x + y;
Mimics haskell do-notation. Takes an additional function to flatten the structure.
join, (x = 1), (y = 2), 3;
gives
_joiner => _joiner(1, x => _joiner(2, y => 3));
examples:
// Promise chain
const then = (promise, callback) => Promise.resolve(promise).then(callback);
const six = (join,
(x = Promise.resolve(4)), // binding a Promise
(y = x * 2), // Promise.resolve will take care non-promise values
Promise.resolve(y - 2))(then);
six.then(console.log); // 6
// Maybe
class Nothing {
mbind(f) {
return new Nothing();
}
}
class Just {
constructor(x) {
this.x = x;
}
mbind(f) {
return f(this.x);
}
}
const bind = (monad, binder) => monad.mbind(binder);
// here the magic
const plus3 = n =>
(join,
(a = n), // n must be a monad
(b = new Just(3)),
new Just(a + b))(bind);
expect(plus3(new Nothing())).toEqual(new Nothing());
expect(plus3(new Just(5))).toEqual(new Just(8));
const toArray = (item, next) => [item].concat(next(item));
expect((join, (a = 1), (b = 2), a + b)(toArray)).toEqual([1, 2, 3]);
const assign = (item, next) => next(item);
expect((join, (a = 1), (b = 2), { a, b })(assign)).toEqual({ a: 1, b: 2 });
FAQs
A handful of useful macros as babel-plugin.
The npm package babel-plugin-transform-js-macros receives a total of 3 weekly downloads. As such, babel-plugin-transform-js-macros popularity was classified as not popular.
We found that babel-plugin-transform-js-macros 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.