# zero-pad

> Should prepend a 0 to whole numbers less than equal 9 and larger than equal 0. Perfect use case for dates.

Latest version **1.1.0** (published 2018-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install zero-pad
pnpm add zero-pad
yarn add zero-pad
bun add zero-pad
```

## 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 | 2018-02-20 |
| First published | 2016-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Bjarne Oeverli |
| Maintainers | bjarneo |
| Keywords | zero, pad, zeroPad, date, format |

## Links

- npm: https://www.npmjs.com/package/zero-pad
- Repository: https://github.com/bjarneo/zero-pad
- Issues: https://github.com/bjarneo/zero-pad/issues
- npm.io page: https://npm.io/package/zero-pad

## Dependencies (1)

- [is-whole-number](https://npm.io/package/is-whole-number.md) 1.0.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-02-20
- 1.0.2 — 2016-04-14
- 1.0.1 — 2016-04-14
- 1.0.0 — 2016-04-14

## README

zero-pad
======
![Travis](https://travis-ci.org/bjarneo/zero-pad.svg?branch=master)

Should prepend a 0 to whole numbers less than equal 9 and larger than equal 0. Perfect use case for dates.

Installation
------
```bash
$ npm i --save zero-pad
```

Usage
------
```js
const zeroPad = require('zero-pad');

console.log(zeroPad(7)); // 07
console.log(zeroPad(9)); // 09
console.log(zeroPad(-1)); // -1
console.log(zeroPad(0.1)); // 0.1

// With an array as argument
const arr = zeroPad([1, 10, 7]);
console.log(arr); // [01, 10, 07]

// Example with dates
const date = new Date(2016, 10, 5);
const pad = zeroPad([
  date.getFullYear(),
  date.getMonth(),
  date.getDate()
]);

console.log(pad.join('-')); // 2016-10-05
```

Tests
------
```bash
$ npm test
```

Contribution
------
Contributions are appreciated.

License
------
MIT-licensed. See LICENSE.

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