
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.
babel-plugin-implicit-function
Advanced tools
Babel plugin to allow lazy expressions by implicit arrow functions via ~ operator
This plugin is made to make JS syntax easier to work with functional programming by creating
quoted expressions that may be lazily evaluated and work together with functional libraries,
like Ramda. I've overloaded the ~
prefix unary operator for that.
import { cond } from 'ramda';
const precomputedResult = ~(10 === 20);
const otherwise = ~true;
const matches = cond([
[precomputedResult, ~'Something is reeeeally wrong!'],
[otherwise, ~'Nice! Math still works!']
]);
Turn into
import { cond } from 'ramda';
const precomputedResult = () => 10 === 20;
const otherwise = () => true;
const matches = cond([
[precomputedResult, () => 'Something is reeeeally wrong!'],
[otherwise, () => 'Nice! Math still works!']
]);
This is a good replacement for always
function, because this is really lazy, and the value
only gets computed when you need it. Using always
can cause problems by premature evaluation:
getUsers()
.then(always(doSomethingImportantAndReturn());
Note that doSomethingImportantAndReturn
needs getUsers
to be computed before, but that's
not what happen, and this is a source of error and code smell. We could easily fix that with
~
operator. Remember: never use always
!
getUsers()
.then(~doSomethingImportantAndReturn());
If you want to use the original bitwise negation operator, you can disable this plugin in
current scope (and it children scopes) using 'no implicit function'
directive.
$ npm install --save-dev babel-plugin-implicit-function
.babelrc
(Recommended).babelrc
{
"plugins": ["implicit-function"]
}
$ babel --plugins implicit-function script.js
require('babel-core').transform('code', {
plugins: ['implicit-function']
});
MIT
FAQs
Babel plugin to allow lazy expressions by implicit arrow functions via ~ operator
The npm package babel-plugin-implicit-function receives a total of 4 weekly downloads. As such, babel-plugin-implicit-function popularity was classified as not popular.
We found that babel-plugin-implicit-function 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
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.