You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
123456789101112131415161718192021222324252627282930313233343536
  1. ## left-pad
  2. String left pad
  3. [![Build Status][travis-image]][travis-url]
  4. ## Install
  5. ```bash
  6. $ npm install left-pad
  7. ```
  8. ## Usage
  9. ```js
  10. const leftPad = require('left-pad')
  11. leftPad('foo', 5)
  12. // => " foo"
  13. leftPad('foobar', 6)
  14. // => "foobar"
  15. leftPad(1, 2, '0')
  16. // => "01"
  17. leftPad(17, 5, 0)
  18. // => "00017"
  19. ```
  20. **NOTE:** The third argument should be a single `char`. However the module doesn't throw an error if you supply more than one `char`s. See [#28](https://github.com/stevemao/left-pad/pull/28).
  21. **NOTE:** Characters having code points outside of [BMP plan](https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane) are considered a two distinct characters. See [#58](https://github.com/stevemao/left-pad/issues/58).
  22. [travis-image]: https://travis-ci.org/stevemao/left-pad.svg?branch=master
  23. [travis-url]: https://travis-ci.org/stevemao/left-pad