New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

two-digit

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

two-digit

Format the number to two digits

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

two-digit

NPM version NPM downloads NPM license Codecov Travis Bundle size

About

Format the number to two digits

Alternatives

How to Install

First, install the library in your project by npm:

$ npm install two-digit

Or Yarn:

$ yarn add two-digit

Getting Started

Connect libary to project using ES6 import:

import twoDigit from 'two-digit';

Or CommonJS:

const twoDigit = require('two-digit');

Next use library:

const formattedValue = twoDigit(/* value */);

Params

TypeDescription
string or number (if a value of a different type is passed, the function returns the value passed)value to be formatted

Example

Example results for different data:

twoDigit(5); // '05'
twoDigit(15); // 15
twoDigit(120); // 120
twoDigit(2.51); // '02.51'
twoDigit(Math.PI); // '03.141592653589793'
twoDigit(-1); // -1
twoDigit('2'); // '02'
twoDigit('04'); // '04'
twoDigit('10'); // '10'
twoDigit('204'); // '204'
twoDigit('2.1.3'); // '2.1.3'
twoDigit(0b111); // '07'
twoDigit(0b1100); // 0b1100 (12 decimal)
twoDigit(0o5); // '05'
twoDigit(0o12); // 0o12 (10 decimal)
twoDigit(0x8); // '08'
twoDigit(0xf2); // 0xf2 (242 decimal)
twoDigit('J'); // 'J'
twoDigit('Hello World!'); // 'Hello World!'
twoDigit({ name: 'John' }); // { name: 'John' }
twoDigit(Infinity); // Infinity
twoDigit(null); // null

License

This project is licensed under the MIT License © 2020-present Jakub Biesiada

Keywords

string

FAQs

Package last updated on 19 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts