Comments (3)
You should maybe specify that left-pad does not handle code points out of BMP plan as single characters.
Let's add it to the docs. PR welcome
from left-pad.
I had a look to the implementation selected by latest versions of ECMA for padStart
. They chose to consider code points outside the BMP plan as two distinct characters.
With padStart
on Chrome and Firefox I get the following:
'a\u{1f431}b'.padStart(4, 'x') => "a🐱b"
'abc'.padStart(4, '\u{1f431}') => "\ud83dabc"
from left-pad.
If the choice of left-pad is to be compliant with padStart then the only way to handle this case would be to solve the issue of the third argument not accepting multiple characters.
Otherwise if the choice is leftPad on code points (and not code units) the fix consists in measuring the size of the input string by by-passing String.length and measuring the length manually (only characters in the range \ud800
to \udfff
can be by pairs). Then the pad code will be the same.
from left-pad.
Related Issues (20)
- O(n^2) time HOT 6
- give you my support HOT 7
- left-pad is probably not properly licensed under the WTFPL HOT 5
- Under what licence is this module released? HOT 1
- Why do you publish this module on NPM? HOT 1
- benchmarks HOT 3
- Why is your code so complicated? HOT 2
- Why O(log(n))? HOT 4
- why npm doesn't work HOT 1
- Getting more done in GitHub with ZenHub HOT 1
- TypeError: Cannot read property '1' of undefined HOT 3
- It is not O(log n) HOT 1
- To fulfill both backward-compatibility and improvement for modern engines. HOT 2
- Remove misleading "Time complexity: O(log(n))" from README HOT 4
- License clarification for older versions HOT 5
- Internatiinaliz
- Issue identified with PR #66 (non-integer length corner case and cache)
- I'll take ownership HOT 7
- left-pad should correctly handle Unicode HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from left-pad.