Research
Security News
Malicious npm Package Typosquats react-login-page to Deploy Keylogger
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
@babel/plugin-transform-new-target
Advanced tools
Package description
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.
Readme
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
FAQs
Unknown package
The npm package @babel/plugin-transform-new-target receives a total of 13,245,233 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
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
Security News
The JavaScript community has launched the e18e initiative to improve ecosystem performance by cleaning up dependency trees, speeding up critical parts of the ecosystem, and documenting lighter alternatives to established tools.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.