JSPM

leading-zeroes

2.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 210
  • Score
    100M100P100Q137155F
  • License MIT

Pad a number with leading zeroes

Package Exports

  • leading-zeroes

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (leading-zeroes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Leading Zeroes

Pad a number with leading zeroes (to the left)

padWithLeadingZeroes(num, targetLength);

Example

padWithLeadingZeroes(555,8); 
// => "00000555"

padWithLeadingZeroes('7 is James Bond', 15);
// => "007 is James Bond"

Parameters

num

Type Required
number or string Yes

The input to which leading zeroes should be added.

targetLength

Type Required
number Yes

The length of the resulting string once the current string has been padded. If the value is lower than the current string's length, the current string will be returned as is.

Installation

In your project's root folder, run:

yarn add leading-zeroes

Then in your JS code, add:

import leadingZeroes from 'leading-zeroes';

Running Tests

Clone this project into your local computer and run the following in its root directory (where the package.json is):

yarn install
yarn test

License

Released under the MIT license.