4 ms·
Javascript has an excellent standard library - lodash. Here is its string padding: https://lodash.com/docs#pad https://lodash.com/docs#pad. Lodash also ships h
by jasim 11y ago
Javascript has an excellent standard library - lodash. Here is its string padding: https://lodash.com/docs#pad https://lodash.com/docs#pad.
Lodash also ships hundreds of independent npm modules for those who don't need the entire package. Here is pad as an independent package: https://www.npmjs.com/package/lodash.pad https://www.npmjs.com/package/lodash.pad.
Lodash is here today, it works, it is reliable, and it doesn't pull the rug from under you.
- jasongill 11y agoLodash only got padLeft in version 3.0.0 (released last January), and then that method was renamed to padStart in 4.0.0 this January, so it's not exactly the paragon of reliability (although I understand your sentiment)
- sod 11y agodalton likes to name methods as ecmascript itself, what I very much appreciate. padStart() was proposed as standard after lodash 3.0.0 was released. So he changed it on the next major release: https://github.com/tc39/proposal-string-pad-start-end https://github.com/tc39/proposal-string-pad-start-end
- jdd 11y agoNaw, I changed it on a major bump which requires opt-in and didn't pull the rug out from underneath people. As @sod pointed out the change is based on the newish ES7 proposal.
- buster 11y agoThat's not a standard library.