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-transform-private-methods
Advanced tools
This plugin transforms private class methods
The @babel/plugin-transform-private-methods package is a Babel plugin that allows developers to use private methods and accessors in classes, according to the ECMAScript specifications. This plugin transforms private methods and accessors so that they can be used in environments that do not support them natively.
Private Method Transformation
This feature allows developers to define private methods in a class, which are not accessible from outside of the class. The plugin will transform these methods so that they are functionally private in environments that do not have native support for private methods.
class MyClass {
#privateMethod() {
return 'Hello from private method';
}
publicMethod() {
return this.#privateMethod();
}
}
const instance = new MyClass();
console.log(instance.publicMethod()); // 'Hello from private method'
Private Accessor Transformation
This feature enables the use of private getters and setters within a class. Similar to private methods, these accessors are transformed by the plugin to maintain their privacy outside of the class.
class MyClass {
#privateField = 'private value';
get #privateAccessor() {
return this.#privateField;
}
publicMethod() {
return this.#privateAccessor;
}
}
const instance = new MyClass();
console.log(instance.publicMethod()); // 'private value'
This package allows developers to use class properties, which includes static and instance properties. It can be used in conjunction with @babel/plugin-transform-private-methods to support private class properties, but it does not handle private methods or accessors on its own.
This plugin provides support for checking if a private field is in an object. It is complementary to @babel/plugin-transform-private-methods, which handles the transformation of private methods and accessors, but does not include the functionality to check for private field existence.
This plugin transforms private class methods
See our website @babel/plugin-transform-private-methods for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-private-methods
or using yarn:
yarn add @babel/plugin-transform-private-methods --dev
v7.25.9 (2024-10-22)
babel-parser
, babel-template
, babel-types
syntacticPlaceholders
mode (@liuxingbaoyu)babel-helper-compilation-targets
, babel-preset-env
ClassAccessorProperty
to prevent the no-undef
rule (@victorenator)babel-parser
, babel-types
VISITOR_KEYS
etc. faster to access (@liuxingbaoyu)FAQs
This plugin transforms private class methods
The npm package @babel/plugin-transform-private-methods receives a total of 13,879,065 weekly downloads. As such, @babel/plugin-transform-private-methods popularity was classified as popular.
We found that @babel/plugin-transform-private-methods 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.
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.