Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pvorb/numpad

leading zeros for numbers in JavaScript
https://github.com/pvorb/numpad

Last synced: about 1 month ago
JSON representation

leading zeros for numbers in JavaScript

Awesome Lists containing this project

README

        

# numpad

pad numbers with leading zeros.

## Installation

`npm install numpad` or `ender add numpad`

## API

```js
numpad(x, digits);
```

Returns a string that is padded with leading zeros.

* `x` Number
* `digits` Number of digits (defaults to 2)

## Usage

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

numpad(5); // '05'
numpad(5, 4); // '0005'
numpad(1.23); // '01.23'
numpad(1.23, 4); // '0001.23'
numpad(892, 2); // '892'
numpad(892.453, 2); // '892.453'
```

## Bugs and Issues

If you encounter any bugs or issues, feel free to open an issue at
[github](https://github.com/pvorb/numpad/issues).

## License

Copyright © 2012 Paul Vorbach

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.