@pabloadoue/zero-fill
v1.0.2
Published
Zero-fill a number to the given size.
Downloads
9
Maintainers
Readme
pabloadoue/zero-fill
This library is a fork of zero-fill originaly created by feross. I just updated the library to TypeScript so that in can be used without the need to define types, and added testing to the source code.
Zero-fill a number to the given size.
Installation
# Using npm
npm install --save @pabloadoue/zero-fill
# Using yarn
yarn add @pabloadoue/zero-fill
Example
import zeroFill from "@pabloadoue/zero-fill";
zeroFill(4, 1);
// => "0001"
zeroFill(10, 55);
// => "0000000055"
zeroFill(1, 5);
// => "1"
Documentation
zeroFill(input, fillCount, paddingCharacter?)
Zero-fill a number to the given size.
Params
- Integer
input
: The input object. - Integer
fillCount
: The path to the value you want to find. - String
paddingCharacter?
: [Optional] Character to use as padding character. Defaults to '0';
Return
- String The original number as string with
fillCount
leadingpaddingCharacter