repeat-string
repeat-string copied to clipboard
Infinity and early conditions
This pull request has a few things going on:
- Mocha was a bit out of date. Upgraded it but that meant having to stop testing on Node.js 6 and below. These versions of Node.js aren't supported anymore so probably not a big deal anyway.
- Added a few missing tests: numbers aren't rounded and negative numbers produce empty strings
- There were
varandconst. No need to have both so replaced withconst. - Early exit condition when the string to repeat is empty
- Breaking change: can't repeat a string when number is
Infinity
Infinity
The native String#repeat method does throw an error when Infinity is given as a parameter. So this changes aligns with the native behaviour. Also there's an issue with how Infinity works right now: with the same string to repeat, it will produce a different string:
const repeat = require('repeat-string');
repeat('🌯', Infinity)
//=> '🌯🌯'
repeat('🌯', Infinity)
//=> '🌯🌯🌯🌯'
repeat('🌯', Infinity)
//=> '🌯🌯🌯🌯🌯🌯'
This didn't seem right to me so took the liberty to throw an error instead.
@jonschlinkert 👋
@customcommander nice work! I only had the one comment, everything else is great. thank you!