New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zeropad

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

zeropad

Zeropad your integers with optional n-length padding.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-17.38%
Maintainers
1
Weekly downloads
 
Created
Source

zeropad

Zeropad your integers with optional n-length padding.

Build Status

The default is to give you classic padding behavior where numbers less than 10 are padded with a single zero:
'9' → '09', but you can optionally pad to any length, for example: '9' → '0009'.

Note: Since version 1.1.0 you can also pad negative numbers.

Install

$ npm install --save zeropad

Usage

var zeropad = require('zeropad');

zeropad(5);
// => '05'

zeropad(10, 4);
// => '0010'

zeropad('11', 4);
// => '0011'

zeropad(4, 10);
// => '0000000004');

zeropad(9, 4);
// => '0009');

zeropad(-9, 4);
// => '-0009');

API

zeropad(number, [length])

number

Required
Type: Number String

The number you want to pad.

length

Type: Number
Default: 2

The length you want to pad to. The default is 2, which emulates classic padding behavior.

  • simple-zeropad Classic number padding (no length options)

License

MIT @ Michael Wuergler

Keywords

FAQs

Package last updated on 04 Jul 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc