Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option for mangling privates in code gen (all members prefixed with a single underscore) #309

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

BonsaiDen
Copy link

Potentially unsafe, but was an easy add and I know a lot of people who want this, not only does it make the code even smaller (20% in my non-trivial use case) but it's also a nice to have feature if you want to make sure that nobody calls / accesses the stuff :)

Let me know what you think about it.

Best
Ivo

…l names matching a given regexp. This is an easy way to mangle 'privates' by prefixing them with a '_' and then using a matching regexp. This is potentially unsafe but works great on the untrivial code I've tested it on thus far
@eduardocereto
Copy link

I do a lot of code with Google Analytics functions, and these functions all start with an underscore. And while I'd like to have this feature I can't use this because that would mangle these methods as well.

Maybe add an option to mangle double underscores only ?

@RGustBardon
Copy link
Contributor

Some pitfalls in dbf2df3:

var foo = {}, bar = '_baz';
foo._baz = 42;
console.log('number' === typeof foo[bar]);
console.log(foo.hasOwnProperty('_baz'));
console.log(-1 !== Object.keys(foo).indexOf('_baz'));
with (foo) {
  console.log('number' === typeof _baz);
}

@RGustBardon
Copy link
Contributor

Duplicate of issue #219.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants