Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
babel-plugin-private-class-fields-to-public
Advanced tools
Readme
_
is the new _
!
There's this TC39 proposal to add private properties to javascript classes, which are "hard private" - you can't access them from other scopes.
This is a babel plugin which adds getters and setters for all private properties, so now you can access them from other scopes. Given a class like:
class MyClass {
#secret = "you can't see me!";
}
This plugin will transform the class to:
class MyClass {
#secret = "you can't see me!";
get _secret() {return this.#secret;}
set _secret(secret) {this.#secret = secret;}
}
At present, the proposal is still stage 3, so this plugin is really a "proof
of concept". A package author could guard against this plugin by doing something
like redefining the _secret
property in the constructor. We could get around
this by tring to detect it and picking a different name, or by allowing a custom
prefix for the accessor functions in the plugin configuration.
There's a lot of decisions being made in the TC 39 class fields proposal based on the notion that private fields should be "hard private". There are pros and cons to "hard private" fields, but unfortunately I don't think Javascript is capable of supporting such a notion. This plugin is meant as a proof-of-concept to demonstrate an easy way to turn "hard private" into "soft private".
FAQs
`_` is the new `_`!
The npm package babel-plugin-private-class-fields-to-public receives a total of 2 weekly downloads. As such, babel-plugin-private-class-fields-to-public popularity was classified as not popular.
We found that babel-plugin-private-class-fields-to-public 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.