
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Format the number to two digits
First, install the library in your project by npm:
$ npm install two-digit
Or Yarn:
$ yarn add two-digit
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 */);
| Type | Description |
|---|---|
| string or number (if a value of a different type is passed, the function returns the value passed) | value to be formatted |
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
This project is licensed under the MIT License © 2020-present Jakub Biesiada
FAQs
Format the number to two digits
We found that two-digit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.