https://github.com/feross/zero-fill
Zero-fill a number to the given size.
https://github.com/feross/zero-fill
Last synced: 6 months ago
JSON representation
Zero-fill a number to the given size.
- Host: GitHub
- URL: https://github.com/feross/zero-fill
- Owner: feross
- License: mit
- Created: 2014-03-22T09:20:33.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T04:38:17.000Z (over 5 years ago)
- Last Synced: 2025-06-05T09:19:18.839Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 31
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zero-fill [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[travis-image]: https://img.shields.io/travis/feross/zero-fill/master.svg
[travis-url]: https://travis-ci.org/feross/zero-fill
[npm-image]: https://img.shields.io/npm/v/zero-fill.svg
[npm-url]: https://npmjs.org/package/zero-fill
[downloads-image]: https://img.shields.io/npm/dm/zero-fill.svg
[downloads-url]: https://npmjs.org/package/zero-fill
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com
### Zero-fill a number to the given size.

## install
```
npm install zero-fill
```
## usage
```js
var zeroFill = require('zero-fill')
zeroFill(4, 1) // '0001'
zeroFill(10, 55) // '0000000055'
zeroFill(1, 1) // '1'
```
Partial application:
```js
zeroFill(4)(1) // '0001'
```
Custom padding character:
```js
zeroFill(4, 55, ' ') // ' 55'
zeroFill(4, 500, ' ') // ' 500'
```
## license
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).