Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@babel/plugin-transform-new-target
Advanced tools
The @babel/plugin-transform-new-target npm package is designed to transform instances of the `new.target` meta-property within functions. This is particularly useful for compiling ES6 code to be compatible with environments that do not support the `new.target` syntax. The `new.target` property is used within constructors to determine if the constructor was called with the `new` operator, allowing constructors to identify how they were invoked and to behave differently if necessary.
Transforming new.target
This feature allows the transformation of `new.target` usage into a form that can be understood by environments that do not support this syntax. It checks if the constructor was called with `new` and throws an error if it wasn't, ensuring that the constructor behaves as intended even in older JavaScript environments.
function MyConstructor() {\n if (!new.target) {\n throw 'MyConstructor must be called with new';\n }\n console.log('MyConstructor was called with new');\n}\n// Transformed Code:\nfunction MyConstructor() {\n var _newtarget = this instanceof MyConstructor ? this.constructor : void 0;\n if (!_newtarget) {\n throw 'MyConstructor must be called with new';\n }\n console.log('MyConstructor was called with new');\n}
Similar to @babel/plugin-transform-new-target, this package transforms ES6 arrow functions into function expressions that older JavaScript environments can understand. While it focuses on arrow functions rather than the `new.target` property, both plugins serve the purpose of making modern JavaScript code compatible with older environments.
This package transforms ES6 class syntax into equivalent ES5 constructor functions. Like @babel/plugin-transform-new-target, it deals with issues related to constructor functions and their invocation, ensuring that class-based code can run in environments that do not support the ES6 class syntax.
Transforms new.target meta property
See our website @babel/plugin-transform-new-target for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-new-target
or using yarn:
yarn add @babel/plugin-transform-new-target --dev
v7.22.5 (2023-06-08)
babel-preset-env
, babel-standalone
syntax-unicode-sets-regex
in standalone (@nicolo-ribaudo)babel-core
-transform-
when resolving missing plugins (@nicolo-ribaudo)FAQs
Transforms new.target meta property
The npm package @babel/plugin-transform-new-target receives a total of 22,937,729 weekly downloads. As such, @babel/plugin-transform-new-target popularity was classified as popular.
We found that @babel/plugin-transform-new-target demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.