Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
babel-plugin-inline-functions
Advanced tools
babel-plugin-inline-functions - a Babel plugin to inline selected functions
$ npm install babel-plugin-inline-functions
$ cat test.js
function __INLINE__coalesce (value) {
return value ?? ''
}
const foo = __INLINE__coalesce(options.foo)
$ babel --plugins inline-functions test.js
const foo = options.foo ?? ''
This is a Babel plugin which inlines calls to selected functions within the scope in which the functions are declared. Only functions which contain a single return statement are inlined. Arguments passed to inlined functions are substituted for the corresponding parameters in the function body and (by default) the original function is removed.
Functions can be marked for inlining by using a custom prefix in the function
name, a comment before the function declaration, or a label for the return
statement in the function's body. By default, functions whose names begin with
"__INLINE__"
are inlined, but this can be modified or disabled via the
plugin's options.
The following plugin options are supported.
string | false
false
Select functions for inlining by the presence of a block comment before the
function
keyword in the declaration. If set, the comment body is trimmed and
compared to the option's value, and, if equal, the function is inlined. If set
to false (as it is by default), function declaration comments are not checked.
{
"plugins": [
["inline-functions", {
"comment": "inline"
}]
]
}
/* inline */ function coalesce (value) {
return value ?? ''
}
const foo = coalesce(options.foo)
const foo = options.foo ?? ''
string | false
false
Select functions for inlining by the presence of a label with this name before the return statement. If set to false (as it is by default), return statement labels are not checked.
{
"plugins": [
["inline-functions", {
"label": "inline"
}]
]
}
function coalesce (value) {
inline: return value ?? ''
}
const foo = coalesce(options.foo)
const foo = options.foo ?? ''
string | false
"__INLINE__"
Select functions for inlining whose names start with the specified prefix. If set to false, function names are not checked.
{
"plugins": [
["inline-functions", {
"prefix": "__inline__"
}]
]
}
function __inline__coalesce (value) {
return value ?? ''
}
const foo = __inline__coalesce(options.foo)
const foo = options.foo ?? ''
boolean
true
Remove the inlined function declaration. If set to false, the declaration is preserved.
{
"plugins": [
["inline-functions", {
"remove": false
}]
]
}
function __INLINE__coalesce (value) {
return value ?? ''
}
const foo = __INLINE__coalesce(options.foo)
function __INLINE__coalesce (value) {
return value ?? ''
}
const foo = options.foo ?? ''
$ cat .babelrc
{
"plugins": ["inline-functions"]
}
$ babel --plugins inline-functions script.js
require('@babel/core').transform(code, {
plugins: ['inline-functions']
})
The following NPM scripts are available:
1 Particularly on v8, which may have a better idea of what should be inlined when, and the memory/speed tradeoffs, than the developer.
1.0.1
Copyright © 2016-2020 by Emile Cantin.
This is free software; you can redistribute it and/or modify it under the terms of the ISC License.
1.0.1 - 2020-05-31
FAQs
A Babel plugin to inline selected functions
The npm package babel-plugin-inline-functions receives a total of 1 weekly downloads. As such, babel-plugin-inline-functions popularity was classified as not popular.
We found that babel-plugin-inline-functions 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.