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

@fnmain/number

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fnmain/number - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

4

dist/index.d.ts

@@ -15,4 +15,6 @@ type Options = {

export declare function isNotNumber(value: any): boolean;
export declare function formatWithCommas(value: any): string;
export declare function formatWithCommas(value: any, { strNaN }?: {
strNaN: string;
}): string;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -114,4 +114,7 @@ "use strict";

exports.isNotNumber = isNotNumber;
function formatWithCommas(value) {
function formatWithCommas(value, { strNaN } = { strNaN: "NaN" }) {
const val = parseNumber(value);
if (isNaN(val)) {
return strNaN;
}
return val.toString().replace(/(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");

@@ -118,0 +121,0 @@ }

@@ -33,2 +33,4 @@ "use strict";

console.log((0, index_1.formatWithCommas)("12345.6789")); // 12,345.6789
console.log((0, index_1.formatWithCommas)("abc")); // "NaN"
console.log((0, index_1.formatWithCommas)("abc", { strNaN: "" })); // ""
//# sourceMappingURL=test.js.map
{
"name": "@fnmain/number",
"version": "1.5.2",
"version": "1.6.0",
"description": "number utils",

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

@@ -138,5 +138,8 @@ type Options = {

export function formatWithCommas(value: any): string {
export function formatWithCommas(value: any, { strNaN } = { strNaN: "NaN" }): string {
const val = parseNumber(value);
if (isNaN(val)) {
return strNaN;
}
return val.toString().replace(/(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
}

@@ -37,1 +37,3 @@ import { formatWithCommas, isNotNumber, isNumber, parseNumber, toAuto, toPercent } from "./index";

console.log(formatWithCommas("12345.6789")); // 12,345.6789
console.log(formatWithCommas("abc")); // "NaN"
console.log(formatWithCommas("abc", { strNaN: "" })); // ""

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