Socket
Socket
Sign inDemoInstall

number-string

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.5 to 1.1.6

28

dist/app.js

@@ -62,3 +62,3 @@ "use strict";

* @param {string} [options.decimalMark="."] Decimal mark character
* @param {string} [options.thousandSeperator=","] Thousands separator character
* @param {string} [options.thousandSeparator=","] Thousands separator character
* @param {number} [options.maxPrecision=10] Maximum number of decimal places

@@ -75,3 +75,5 @@ * @param {number} [options.minPrecision=0] Minimum number of decimal places

_ref2$thousandSeperat = _ref2.thousandSeperator,
thousandSeperator = _ref2$thousandSeperat === void 0 ? "," : _ref2$thousandSeperat,
thousandSeperator = _ref2$thousandSeperat === void 0 ? null : _ref2$thousandSeperat,
_ref2$thousandSeparat = _ref2.thousandSeparator,
thousandSeparator = _ref2$thousandSeparat === void 0 ? "," : _ref2$thousandSeparat,
_ref2$maxPrecision = _ref2.maxPrecision,

@@ -83,2 +85,7 @@ maxPrecision = _ref2$maxPrecision === void 0 ? 10 : _ref2$maxPrecision,

// 1.500000 -> 1.5; 1.0000 -> 1
if (thousandSeperator) {
thousandSeparator = thousandSeperator;
console.error("`thousandSeperator` is deprecated use `thousandSeparator` instead.");
}
if (typeof value !== "number") {

@@ -128,5 +135,5 @@ value = toNumber(value, {

var regexpDecimalMark = regexpEscape(decimalMark);
var thousandSeperatorRegexp = new RegExp("\\d(?=(\\d{3})+".concat(regexpDecimalMark, ")"), "g");
var thousandSeparatorRegexp = new RegExp("\\d(?=(\\d{3})+".concat(regexpDecimalMark, ")"), "g");
var trimRegexp = new RegExp("".concat(regexpDecimalMark, "$"));
n = n.replace(thousandSeperatorRegexp, "$&".concat(thousandSeperator)).replace(trimRegexp, "");
n = n.replace(thousandSeparatorRegexp, "$&".concat(thousandSeparator)).replace(trimRegexp, "");
return n;

@@ -140,3 +147,3 @@ }

* @param {string} [options.decimalMark="."] Decimal mark character
* @param {string} [options.thousandSeperator=","] Thousands separator character
* @param {string} [options.thousandSeparator=","] Thousands separator character
* @param {number} [options.maxPrecision=10] Maximum number of decimal places

@@ -156,3 +163,5 @@ * @param {number} [options.minPrecision=0] Minimum number of decimal places

_ref3$thousandSeperat = _ref3.thousandSeperator,
thousandSeperator = _ref3$thousandSeperat === void 0 ? "," : _ref3$thousandSeperat,
thousandSeperator = _ref3$thousandSeperat === void 0 ? null : _ref3$thousandSeperat,
_ref3$thousandSeparat = _ref3.thousandSeparator,
thousandSeparator = _ref3$thousandSeparat === void 0 ? "," : _ref3$thousandSeparat,
_ref3$maxPrecision = _ref3.maxPrecision,

@@ -170,2 +179,7 @@ maxPrecision = _ref3$maxPrecision === void 0 ? 2 : _ref3$maxPrecision,

// -1234.56 -> ($1,234.56)
if (thousandSeperator) {
thousandSeparator = thousandSeperator;
console.error("`thousandSeperator` is deprecated use `thousandSeparator` instead.");
}
if (typeof value !== "number") {

@@ -201,3 +215,3 @@ value = toNumber(value, {

decimalMark: decimalMark,
thousandSeperator: thousandSeperator,
thousandSeparator: thousandSeparator,
maxPrecision: maxPrecision,

@@ -204,0 +218,0 @@ minPrecision: minPrecision

{
"name": "number-string",
"version": "1.1.5",
"version": "1.1.6",
"description": "Functions to format number to string",

@@ -33,18 +33,18 @@ "main": "dist/app.js",

"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/register": "^7.12.10",
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/preset-env": "^7.14.2",
"@babel/register": "^7.13.16",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.2.0",
"@semantic-release/npm": "^7.0.9",
"@semantic-release/release-notes-generator": "^9.0.1",
"@semantic-release/github": "^7.2.3",
"@semantic-release/npm": "^7.1.3",
"@semantic-release/release-notes-generator": "^9.0.2",
"assert": "^2.0.0",
"eslint": "^7.18.0",
"eslint": "^7.26.0",
"istanbul": "^0.4.5",
"mocha": "^8.2.1",
"mocha": "^8.4.0",
"rimraf": "^3.0.2",
"semantic-release": "^17.3.3",
"typescript": "^4.1.3"
"semantic-release": "^17.4.3",
"typescript": "^4.2.4"
},

@@ -51,0 +51,0 @@ "release": {

@@ -43,3 +43,3 @@ [![Actions Status](https://github.com/UziTech/number-string/workflows/CI/badge.svg)](https://github.com/UziTech/number-string/actions)

decimalMark = ".",
thousandSeperator = ",",
thousandSeparator = ",",
maxPrecision = 10,

@@ -65,3 +65,3 @@ minPrecision = 0,

decimalMark = ".",
thousandSeperator = ",",
thousandSeparator = ",",
maxPrecision = 2,

@@ -68,0 +68,0 @@ minPrecision = 2,

@@ -45,3 +45,3 @@ /**

* @param {string} [options.decimalMark="."] Decimal mark character
* @param {string} [options.thousandSeperator=","] Thousands separator character
* @param {string} [options.thousandSeparator=","] Thousands separator character
* @param {number} [options.maxPrecision=10] Maximum number of decimal places

@@ -53,6 +53,14 @@ * @param {number} [options.minPrecision=0] Minimum number of decimal places

decimalMark = ".",
thousandSeperator = ",",
/**
* @deprecated use thousandSeparator instead.
*/
thousandSeperator = null,
thousandSeparator = ",",
maxPrecision = 10,
minPrecision = 0,
} = {}) { // 1.500000 -> 1.5; 1.0000 -> 1
if (thousandSeperator) {
thousandSeparator = thousandSeperator;
console.error("`thousandSeperator` is deprecated use `thousandSeparator` instead.");
}
if (typeof value !== "number") {

@@ -95,5 +103,5 @@ value = toNumber(value, {

const regexpDecimalMark = regexpEscape(decimalMark);
const thousandSeperatorRegexp = new RegExp(`\\d(?=(\\d{3})+${regexpDecimalMark})`, "g");
const thousandSeparatorRegexp = new RegExp(`\\d(?=(\\d{3})+${regexpDecimalMark})`, "g");
const trimRegexp = new RegExp(`${regexpDecimalMark}$`);
n = n.replace(thousandSeperatorRegexp, `$&${thousandSeperator}`).replace(trimRegexp, "");
n = n.replace(thousandSeparatorRegexp, `$&${thousandSeparator}`).replace(trimRegexp, "");

@@ -109,3 +117,3 @@ return n;

* @param {string} [options.decimalMark="."] Decimal mark character
* @param {string} [options.thousandSeperator=","] Thousands separator character
* @param {string} [options.thousandSeparator=","] Thousands separator character
* @param {number} [options.maxPrecision=10] Maximum number of decimal places

@@ -120,3 +128,7 @@ * @param {number} [options.minPrecision=0] Minimum number of decimal places

decimalMark = ".",
thousandSeperator = ",",
/**
* @deprecated use thousandSeparator instead.
*/
thousandSeperator = null,
thousandSeparator = ",",
maxPrecision = 2,

@@ -128,2 +140,6 @@ minPrecision = 2,

} = {}) { // -1234.56 -> ($1,234.56)
if (thousandSeperator) {
thousandSeparator = thousandSeperator;
console.error("`thousandSeperator` is deprecated use `thousandSeparator` instead.");
}
if (typeof value !== "number") {

@@ -157,3 +173,3 @@ value = toNumber(value, {

decimalMark,
thousandSeperator,
thousandSeparator,
maxPrecision,

@@ -160,0 +176,0 @@ minPrecision

@@ -79,5 +79,8 @@ const assert = require("assert");

});
it("Change Thousands Seperator", function() {
it("Change Deprecated Thousands Seperator", function() {
assert.strictEqual(ns.toClean(1234.5, { thousandSeperator: "." }), "1.234.5");
});
it("Change Thousands Separator", function() {
assert.strictEqual(ns.toClean(1234.5, { thousandSeparator: "." }), "1.234.5");
});
it("Change Max Precision", function() {

@@ -141,5 +144,8 @@ assert.strictEqual(ns.toClean(1234.5, { maxPrecision: 0 }), "1,235");

});
it("Change Thousands Seperator", function() {
it("Change Deprecated Thousands Seperator", function() {
assert.strictEqual(ns.toMoney(1234.5, { thousandSeperator: "." }), "$1.234.50");
});
it("Change Thousands Separator", function() {
assert.strictEqual(ns.toMoney(1234.5, { thousandSeparator: "." }), "$1.234.50");
});
it("Change Max Precision", function() {

@@ -146,0 +152,0 @@ assert.strictEqual(ns.toMoney(1234.5, { maxPrecision: 0 }), "$1,235");

@@ -9,3 +9,3 @@ /**

export function toNumber(value: string | number, { decimalMark, }?: {
decimalMark: string;
decimalMark?: string;
}): number;

@@ -17,3 +17,3 @@ /**

* @param {string} [options.decimalMark="."] Decimal mark character
* @param {string} [options.thousandSeperator=","] Thousands separator character
* @param {string} [options.thousandSeparator=","] Thousands separator character
* @param {number} [options.maxPrecision=10] Maximum number of decimal places

@@ -23,7 +23,7 @@ * @param {number} [options.minPrecision=0] Minimum number of decimal places

*/
export function toClean(value: string | number, { decimalMark, thousandSeperator, maxPrecision, minPrecision, }?: {
decimalMark: string;
thousandSeperator: string;
maxPrecision: number;
minPrecision: number;
export function toClean(value: string | number, { decimalMark, thousandSeperator, thousandSeparator, maxPrecision, minPrecision, }?: {
decimalMark?: string;
thousandSeparator?: string;
maxPrecision?: number;
minPrecision?: number;
}): string;

@@ -36,3 +36,3 @@ /**

* @param {string} [options.decimalMark="."] Decimal mark character
* @param {string} [options.thousandSeperator=","] Thousands separator character
* @param {string} [options.thousandSeparator=","] Thousands separator character
* @param {number} [options.maxPrecision=10] Maximum number of decimal places

@@ -45,10 +45,10 @@ * @param {number} [options.minPrecision=0] Minimum number of decimal places

*/
export function toMoney(value: string | number, { decimalMark, thousandSeperator, maxPrecision, minPrecision, symbol, symbolBehind, useParens, }?: {
decimalMark: string;
thousandSeperator: string;
maxPrecision: number;
minPrecision: number;
symbol: string;
symbolBehind: any;
useParens: any;
export function toMoney(value: string | number, { decimalMark, thousandSeperator, thousandSeparator, maxPrecision, minPrecision, symbol, symbolBehind, useParens, }?: {
decimalMark?: string;
thousandSeparator?: string;
maxPrecision?: number;
minPrecision?: number;
symbol?: string;
symbolBehind?: any;
useParens?: any;
}, ...args: any[]): string;

@@ -55,0 +55,0 @@ /**

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc