# digits

> Pad numbers with zeros. Automatically pad the number of digits based on the length of the array, or explicitly pass in the number of digits to use.

Latest version **0.2.0** (published 2014-12-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2014-12-05 |
| First published | 2013-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | amount, digit, digits, helper, mixin, number, pad, padded, padding |

## Links

- npm: https://www.npmjs.com/package/digits
- Repository: https://github.com/jonschlinkert/digits
- Issues: https://github.com/jonschlinkert/digits/issues
- npm.io page: https://npm.io/package/digits

## Dependencies (2)

- [longest](https://npm.io/package/longest.md) ^0.2.1
- [pad-left](https://npm.io/package/pad-left.md) ^0.2.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

- 0.2.0 (latest) — 2014-12-05
- 0.1.4 — 2014-01-22
- 0.1.3 — 2014-01-15
- 0.1.2 — 2013-12-09
- 0.1.1 — 2013-12-09
- 0.1.0 — 2013-12-08

## README

# digits [![NPM version](https://badge.fury.io/js/digits.svg)](http://badge.fury.io/js/digits)

> Pad numbers with zeros. Automatically pad the number of digits based on the length of the array, or explicitly pass in the number of digits to use.

## Install with [npm](npmjs.org)

```bash
npm i digits --save
```

## Run tests

```bash
npm test
```

## Usage

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

## API
### [digits](index.js#L37)

Left pad the given `value` with the specified `number` of zeros or alternate `character`.

* `value` **{String}**    
* `number` **{String}**    
* `returns` **{String}** `character`  

```js
digits('abc', 10);
//=> '0000000000abc'

digits('abc', 10, '~');
//=> '~~~~~~~~~~abc'
```

### [.each](index.js#L62)

Pad left pad each value in the given `array` to align with the longest item/number in the array. Zeros are used by default, but a custom `character` can be passed as the second argument.

* `arr` **{Number}**: The array of values to pad.    
* `len` **{Number}**: Amount to pad the number.    
* `returns` **{String}**: Padded number  

**Example**

```js
digits.each([1, 100, 1000])
//=> ['0001', '0100', '1000']

digits.each([a, bb, ccc], ' ')
//=> ['  a', ' bb', 'ccc']
```


## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/digits/issues)

## Author

**Jon Schlinkert**
 
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) 

## License
Copyright (c) 2014 Jon Schlinkert  
Released under the MIT license

***

_This file was generated by [verb](https://github.com/assemble/verb) on December 05, 2014. To update, run `npm i -g verb && verb`._

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