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

Need String#normalize #134

Closed
paulmillr opened this issue Aug 27, 2013 · 10 comments
Closed

Need String#normalize #134

paulmillr opened this issue Aug 27, 2013 · 10 comments

Comments

@paulmillr
Copy link
Owner

No description provided.

@Yaffle
Copy link
Contributor

Yaffle commented Aug 27, 2013

String.prototype.normalize = function(){return String(this);}

@ljharb
Copy link
Collaborator

ljharb commented Aug 27, 2013

Unfortunately it's far more complex than that. The spec says that it takes a "form" argument that defaults to "NFC", and it throws a RangeError if String(form) is not "NFC", "NFD", "NFKC", or "NFKD" - then it uses the Unicode Normalization Algorithm for the specified form.

@mathiasbynens
Copy link
Contributor

http://git.io/unorm

@cscott
Copy link
Collaborator

cscott commented Jan 27, 2014

The Unicode databases required are rather large; perhaps this should be an optional dependency? That is, something like:

String.prototype.normalize = function(form) { return require('unorm')[String(form).toLowerCase()](this); }

with the appropriate error handling and helpful messages if require('unorm') fails.

@ljharb
Copy link
Collaborator

ljharb commented Jan 27, 2014

https://github.com/walling/unorm/blob/master/lib/unorm.js doesn't seem that large… While that's a valid concern, I think having a single es6-shim.js file that shims as much as it can is very important to the purpose of the shim.

As for a require, that'd be nice, but we'd need to ensure the shim still works with all the module systems it currently has - it might be better to copy/paste it in, like I did with the Math.fround/numberConversion stuff.

@cscott
Copy link
Collaborator

cscott commented Jan 27, 2014

https://github.com/walling/unorm/blob/master/lib/unorm.js is 141kB. That's the standalone version of the library (it appears to combine unorm.js with https://github.com/walling/unorm/blob/master/src/unormdata.js, which is 122kB).

For comparison, unminimized es6-shim.js is currently 42kB. So this would be a 435% increase in the size of es6-shim -- probably a larger increase if you look at the minimized sizes. I think that's large enough that people would avoid using es6-shim for mobile projects.

@ljharb
Copy link
Collaborator

ljharb commented Jan 28, 2014

Fair point. If we want to point people at https://github.com/walling/unorm, then we need to make it very clear in the documentation.

@paulmillr
Copy link
Owner Author

yup totally agree, including ultra-big shims with the lib is not good

at least until we will have custom builds

@cscott
Copy link
Collaborator

cscott commented Feb 28, 2014

I added a pointer to unorm in the documentation (see c185084 and a04221b).

@ljharb
Copy link
Collaborator

ljharb commented Nov 18, 2014

Closing this for now - when/if #136 happens, we will include String#normalize as an includable option.

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

No branches or pull requests

5 participants