Comment by mirekrusin
11 years ago
Edge case for left padding - when you provide empty string as padding filler. It can go into infinite loop if not written correctly.
11 years ago
Edge case for left padding - when you provide empty string as padding filler. It can go into infinite loop if not written correctly.
Write a damn unit test for your padding function. We should share unit tests, not one-line libs. Libs with unit tests can be one-liners and be as fine-grained as we like, since it's something your users don't have to download
> We should share unit tests, not one-line libs.
Most of the small libs I've shared are mainly sharing unit tests.
Here's a function I've shared on npm:
The tests:
If you've called it with an empty string there's probably a bug in your calling code which you'll want to test for anyway.