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

js-abbreviation-number

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-abbreviation-number - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

7

dist/index.d.ts

@@ -1,1 +0,6 @@

export declare function abbreviateNumber(num: number, digit?: number, symbols?: Array<string>): string;
interface Options {
padding?: boolean;
symbols?: string[];
}
export declare function abbreviateNumber(num: number, digit?: number, options?: Options | Options["symbols"]): string;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function abbreviateNumber(num, digit, symbols) {
var defaultOptions = {
padding: true,
symbols: ["", "K", "M", "G", "T", "P", "E"],
};
function abbreviateNumber(num, digit, options) {
if (digit === void 0) { digit = 1; }
if (symbols === void 0) { symbols = ["", "K", "M", "G", "T", "P", "E"]; }
// Previous options style
if (Array.isArray(options)) {
options = { symbols: options };
}
var _a = Object.assign({}, defaultOptions, options), symbols = _a.symbols, padding = _a.padding;
// handle negatives

@@ -21,5 +29,9 @@ var sign = Math.sign(num) >= 0;

var scaled = num / scale;
var rounded = scaled.toFixed(digit);
if (!padding) {
rounded = String(Number(rounded));
}
// format number and add suffix
return (!sign ? "-" : "") + scaled.toFixed(digit) + suffix;
return (!sign ? "-" : "") + rounded + suffix;
}
exports.abbreviateNumber = abbreviateNumber;

2

package.json
{
"name": "js-abbreviation-number",
"version": "1.1.0",
"version": "1.1.1",
"description": "Abbreviate numbers in javascript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -26,4 +26,3 @@ <div align="center">

```
```js
import { abbreviateNumber } from "js-abbreviation-number";

@@ -30,0 +29,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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