# zeropad

> Zeropad your integers with optional n-length padding.

Latest version **1.1.0** (published 2016-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install zeropad
pnpm add zeropad
yarn add zeropad
bun add zeropad
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2016-07-04 |
| First published | 2015-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Michael Wuergler |
| Maintainers | radiovisual |
| Keywords | zeropad, string, padding, values, number, integer, negative, positive, fill, pad, zero |

## Links

- npm: https://www.npmjs.com/package/zeropad
- Repository: https://github.com/radiovisual/zeropad
- Homepage: https://github.com/radiovisual/zeropad#readme
- Issues: https://github.com/radiovisual/zeropad/issues
- npm.io page: https://npm.io/package/zeropad

## Dependencies (1)

- [negative-zero](https://npm.io/package/negative-zero.md) ^1.0.0

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2016-07-04
- 1.0.4 — 2015-09-08
- 1.0.1 — 2015-09-08
- 1.0.0 — 2015-09-08

## README

# zeropad

> Zeropad your integers with optional n-length padding.

[![Build Status](https://travis-ci.org/radiovisual/zeropad.svg)](https://travis-ci.org/radiovisual/zeropad)

The default is to give you classic padding behavior where numbers less than 10 are padded with a single zero:  
  `'9' → '09'`, but you can optionally pad to any length, for example: `'9' → '0009'`.
  
**Note:** Since version `1.1.0` you can also pad negative numbers.
 
## Install

```
$ npm install --save zeropad
```

## Usage

```js
var zeropad = require('zeropad');

zeropad(5);
// => '05'

zeropad(10, 4);
// => '0010'

zeropad('11', 4);
// => '0011'

zeropad(4, 10);
// => '0000000004');

zeropad(9, 4);
// => '0009');

zeropad(-9, 4);
// => '-0009');
```

## API

### zeropad(number, [length])

### number 

*Required*  
Type: `Number` `String`

The number you want to pad.

### length

Type: `Number`  
Default: `2`

The length you want to pad to. The default is `2`, which emulates classic padding behavior.


## Related

- [simple-zeropad](https://github.com/radiovisual/simple-zeropad) Classic number padding (no length options)


## License

MIT @ [Michael Wuergler](http://numetriclabs.com)

---
_Source: https://npm.io/package/zeropad · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
