Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

number-minify

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-minify

Converts numbers to shorter strings

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

number-minify

Usage

npm install number-minify

Syntax

With default settings the conversion is made with characters 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_.

encode(1234);
> "JI"

decode("JI");
> 1234

You can change the characters by providing a options object.

encode(1234, {
  characters: 'abcd'
});
> "badbac"

decode("badbac", {
  characters: 'abcd'
});
> 1234

Negative numbers

encode(-1234, {
  useNegativePrefix: true
});
> "-JI"

decode("-JI", {
  useNegativePrefix: true
});
> -1234

By default number-minify doesn't handle negative numbers. If you wish to have a some solution, you can give options to encode and decode to have negative shortens prefixed with a minus sign (-) and then they can be decoded back to negative numbers.

You should not use minus sign (-) as a convertable character while using "useNegativePrefix".

FAQs

Package last updated on 17 Jun 2019

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