Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
babel-plugin-transform-currency-operators
Advanced tools
https://github.com/scurker/babel-plugin-transform-currency-operators
An experimental babel plugin for transforming currency.js operators.
In
import currency from 'currency.js';
var currency1 = currency(1.23);
var currency2 = currency1 + 4.56;
var currency3 = currency2 - 4.56;
var currency4 = currency3 * 2;
var currency5 = currency4 / 4;
var currency6 = currency1 + currency2;
var MultiDecimal = value => currency(value, { decimals: 3 });
var currency7 = MultiDecimal(1.234) + 5.678;
if(currency1 < currency2) { ... }
if(currency1 > currency2) { ... }
if(currency1 === 1.23) { ... }
Out
import currency from 'currency.js';
var currency1 = currency(1.23);
var currency2 = currency1.add(4.56);
var currency3 = currency2.subtract(4.56);
var currency4 = currency3.multiply(2);
var currency5 = currency4.divide(4);
var currency6 = currency1.add(currency2);
var MultiDecimal = value => currency(value, { decimals: 3 });
var currency7 = MultiDecimal(1.234).add(5.678);
if(currency1.value < currency2.value) { ... }
if(currency1.value > currency2.value) { ... }
if(currency1.value === 1.23) { ... }
With npm:
npm install --save-dev babel-plugin-transform-currency-operators
With yarn:
yarn install babel-plugin-transform-currency-operators --dev
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-currency-operators"]
}
babel --plugins transform-currency-operators
require("babel-core").transform("code", {
plugins: ["transform-currency-operators"]
});
If you have a need to customize and export currency settings as a module, you can include the path to your currency (relative from the root of your project) in your .babelrc
plugin configuration to transform those imported module's operator along with any currency.js
imports:
File in your project:
path/to/custom/currency.js
import currency from 'currency.js';
export default function myCustomCurrencyDefaults(value) {
return currency(value, { symbol: '€', ...otherOptions });
}
.babelrc
{
"plugins": ["transform-currency-operators", ['./path/to/custom/currency']]
}
v1.0.1
Added not equals (!=
) and strict not equals (!==
) transforms. (#15 thanks @jesobreira)
FAQs
https://github.com/scurker/babel-plugin-transform-currency-operators
The npm package babel-plugin-transform-currency-operators receives a total of 22 weekly downloads. As such, babel-plugin-transform-currency-operators popularity was classified as not popular.
We found that babel-plugin-transform-currency-operators 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.