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-alkali
Advanced tools
This babel plugin will transform expressions that use a react
keyword/call to produce reactive variables. This relies on alkali for variable operations that produce reactively bound variables.
$ npm install babel-plugin-transform-alkali
The basic format of using the transform is to write reactive expressions in the form:
react(expression)
The react
variable should be imported from alkali. The expression
will be transformed to code that will reactively respond to any changes in inputs values, reflecting them in the output variable. For example:
import { react } from 'alkali'
let a = react(2)
let b = react(4)
let sum = react(a + b)
sum.valueOf() -> 6
a.put(4)
sum.valueOf() -> 8
Reactive properties and assignments are supported as well. Property access within a reactive expression will be converted to a property variable (basically obj.prop
-> obj.property('prop')
, with object mappings and safety checks). And assignments within a reactive expression will be converted to a put
call (basically v = 'hi'
-> v.put('hi')
with similar variable mapping/creation as necessary). For example:
let obj = react({
foo: 3
})
let doubleFoo = react(obj.foo * 2)
doubleFoo.valueOf() -> 6
react(obj.foo = 5)
doubleFoo.valueOf() -> 10
Function and method calls can be made written in reactive expressions as well. These calls will be performed lazily/on-demand, and reexecuted as needed. The target function will be called with the values of the variables (not the variables themselves). For example:
let smallest = react(Math.min(a, b))
The react
operator returns alkali variables, that can be bound to DOM elements or any other alkali target.
import { react, Div } from 'alkali'
// create a div with its text bound to the sum
parent.appendChild(new Div(sum))
And the reactive expressions maintain operator relationships, so alkali's reversible data flow is supported as well:
let a = react(2)
let doubleA = react(a * 2)
react(doubleA = 10) // will flow back through the expression
a.valueOf() -> 5
The react
function can take multiple arguments, the last argument output will be returned as the variable from the react
call.
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-alkali"]
}
$ babel --plugins transform-alkali
require("babel-core").transform("code", {
plugins: ["transform-alkali"]
});
FAQs
Transform reactive code to use alkali API
The npm package babel-plugin-transform-alkali receives a total of 0 weekly downloads. As such, babel-plugin-transform-alkali popularity was classified as not popular.
We found that babel-plugin-transform-alkali 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.