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

fix #192 - remove String.repeat usage to remove IE11 polyfill requirement #193

Closed
wants to merge 1 commit into from
Closed

fix #192 - remove String.repeat usage to remove IE11 polyfill requirement #193

wants to merge 1 commit into from

Conversation

ashwalk33r
Copy link

@ashwalk33r ashwalk33r commented Apr 4, 2020

Fix #192

@@ -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))
Copy link
Author

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) : '') : ''
Copy link
Author

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) : '') : ''
Copy link
Author

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

@alexei
Copy link
Owner

alexei commented May 18, 2020

I've seen this before and I've made it clear this is not going to happen. Sorry!

@alexei alexei closed this May 18, 2020
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.

Remove browser .repeat polyfill requirement
2 participants