-
Notifications
You must be signed in to change notification settings - Fork 291
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
fix #192 - remove String.repeat usage to remove IE11 polyfill requirement #193
Conversation
@@ -79,8 +79,8 @@ describe('sprintfjs', function() { | |||
assert.equal('3.14159', sprintf('%.6g', pi)) | |||
assert.equal('3.14', sprintf('%.3g', pi)) | |||
assert.equal('3', sprintf('%.1g', pi)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only those 2 tests below seem to care about this so far.
@@ -131,7 +131,7 @@ | |||
} | |||
pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ' | |||
pad_length = ph.width - (sign + arg).length | |||
pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' | |||
pad = ph.width ? (pad_length > 0 ? new Array(pad_length + 1).join(pad_character) : '') : '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be concern of optimization - native String.repeat I assume is not only faster but also simpler.
It could also do a feature check:
pad = ph.width ? (pad_length > 0 ? String.prototype.hasOwnProperty('repeat') ? pad_character.repeat(pad_length) : new Array(pad_length + 1).join(pad_character) : '') : ''
@@ -131,7 +131,7 @@ | |||
} | |||
pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ' | |||
pad_length = ph.width - (sign + arg).length | |||
pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' | |||
pad = ph.width ? (pad_length > 0 ? new Array(pad_length + 1).join(pad_character) : '') : '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny thiats similar solution to one removed 4ed9a44#diff-13ed28d46a5f76f4d44561850bda81bbL222
I've seen this before and I've made it clear this is not going to happen. Sorry! |
Fix #192