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

@coders-tm/vue-number-format

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coders-tm/vue-number-format - npm Package Compare versions

Comparing version 2.1.11 to 2.1.12

94

dist/index.cjs.js

@@ -32,20 +32,24 @@ /**

this.options = Object.assign(options, config);
this.input = '';
this.number = '';
this.input = "";
this.number = "";
this.isClean = false;
this.isNull = (input = this.input) => !this.numberOnly(input, new RegExp('[^0-9]+', 'gi'));
this.isNull = (input = this.input) =>
this.numberOnly(input, new RegExp("[^0-9]+", "gi")) === null;
this.clean = (clean = false) => {
this.isClean = clean;
return this
return this;
};
this.sign = () => {
const sign = (this.input.toString().indexOf('-') >= 0 && this.realNumber() > 0) ? '-' : '';
return sign
const sign =
this.input.toString().indexOf("-") >= 0 && this.realNumber() > 0
? "-"
: "";
return sign;
};
function between(min, n, max) {
return Math.max(min, Math.min(n, max))
return Math.max(min, Math.min(n, max));
}

@@ -55,3 +59,3 @@

function fixed(precision) {
return between(0, precision, 20)
return between(0, precision, 20);
}

@@ -63,3 +67,3 @@

var float = parseFloat(numbers) / exp;
return float.toFixed(fixed(precision))
return float.toFixed(fixed(precision));
}

@@ -69,23 +73,32 @@

this.numberOnly = (string, regExp) => string.toString().replace(regExp, '');
this.numberOnly = (string, regExp) => string.toString().replace(regExp, "");
this.isNegative = this.sign() === '-';
this.isNegative = this.sign() === "-";
this.numbers = () => {
if (this.options.reverseFill) {
this.number = toFixed(this.numberOnly(this.input, /\D+/g), this.options.precision).replace('.', this.options.decimal);
} else if (typeof this.input === 'number') {
this.number = this.parts(this.input.toString().replace('-', ''), '.').join(this.options.decimal);
this.number = toFixed(
this.numberOnly(this.input, /\D+/g),
this.options.precision
).replace(".", this.options.decimal);
} else if (typeof this.input === "number") {
this.number = this.parts(
this.input.toString().replace("-", ""),
"."
).join(this.options.decimal);
} else {
this.number = this.numberOnly(this.input, new RegExp(`[^0-9\\${this.options.decimal}]+`, 'gi'));
this.number = this.numberOnly(
this.input,
new RegExp(`[^0-9\\${this.options.decimal}]+`, "gi")
);
this.number = this.parts(this.number).join(this.options.decimal);
}
return this.number
return this.number;
};
this.realNumber = () => {
return this.numbers().toString().replace(this.options.decimal, '.')
return this.numbers().toString().replace(this.options.decimal, ".");
};
this.parts = (number = '', decimal = this.options.decimal) => {
this.parts = (number = "", decimal = this.options.decimal) => {
var parts = number.toString().split(decimal);

@@ -95,3 +108,3 @@ parts[0] = this.toNumber(parts[0]) || 0;

if (parts.length > 1) {
parts[1] = parts.slice(1, parts.length).join('');
parts[1] = parts.slice(1, parts.length).join("");
parts = parts.slice(0, 2);

@@ -101,14 +114,22 @@ }

if (this.isClean) {
const newNumber = this.toNumber(parts.join('.')).toFixed(this.options.precision);
const newNumber = this.toNumber(parts.join(".")).toFixed(
this.options.precision
);
const cleanNumber = this.toNumber(newNumber);
const minimumDigits = cleanNumber.toFixed(this.options.minimumFractionDigits);
const minimumDigits = cleanNumber.toFixed(
this.options.minimumFractionDigits
);
if (this.options.minimumFractionDigits && this.options.minimumFractionDigits >= 0 && cleanNumber.toString().length < minimumDigits.length) {
parts = minimumDigits.toString().split('.');
if (
this.options.minimumFractionDigits &&
this.options.minimumFractionDigits >= 0 &&
cleanNumber.toString().length < minimumDigits.length
) {
parts = minimumDigits.toString().split(".");
} else {
parts = cleanNumber.toString().split('.');
parts = cleanNumber.toString().split(".");
}
}
return parts.slice(0, 2)
return parts.slice(0, 2);
};

@@ -118,4 +139,6 @@

var parts = this.numbers().split(this.options.decimal);
parts[0] = parts[0].toString().replace(/(\d)(?=(?:\d{3})+\b)/gm, `$1${this.options.separator}`);
return parts.join(this.options.decimal)
parts[0] = parts[0]
.toString()
.replace(/(\d)(?=(?:\d{3})+\b)/gm, `$1${this.options.separator}`);
return parts.join(this.options.decimal);
};

@@ -129,6 +152,11 @@

this.format = (input) => {
if (input === '') return this.options.nullValue
if (input === "") return this.options.nullValue;
this.input = input || this.options.nullValue;
if (this.isNull()) return this.options.nullValue
return this.sign() + this.options.prefix + this.addSeparator() + this.options.suffix
if (this.isNull()) return this.options.nullValue;
return (
this.sign() +
this.options.prefix +
this.addSeparator() +
this.options.suffix
);
};

@@ -142,6 +170,6 @@

this.unformat = (input) => {
if (input === '') return this.options.nullValue
if (input === "") return this.options.nullValue;
this.input = input || this.options.nullValue;
if (this.isNull()) return this.options.nullValue
return this.sign() + this.realNumber()
if (this.isNull()) return this.options.nullValue;
return this.sign() + this.realNumber();
};

@@ -148,0 +176,0 @@ }

@@ -28,20 +28,24 @@ /**

this.options = Object.assign(options, config);
this.input = '';
this.number = '';
this.input = "";
this.number = "";
this.isClean = false;
this.isNull = (input = this.input) => !this.numberOnly(input, new RegExp('[^0-9]+', 'gi'));
this.isNull = (input = this.input) =>
this.numberOnly(input, new RegExp("[^0-9]+", "gi")) === null;
this.clean = (clean = false) => {
this.isClean = clean;
return this
return this;
};
this.sign = () => {
const sign = (this.input.toString().indexOf('-') >= 0 && this.realNumber() > 0) ? '-' : '';
return sign
const sign =
this.input.toString().indexOf("-") >= 0 && this.realNumber() > 0
? "-"
: "";
return sign;
};
function between(min, n, max) {
return Math.max(min, Math.min(n, max))
return Math.max(min, Math.min(n, max));
}

@@ -51,3 +55,3 @@

function fixed(precision) {
return between(0, precision, 20)
return between(0, precision, 20);
}

@@ -59,3 +63,3 @@

var float = parseFloat(numbers) / exp;
return float.toFixed(fixed(precision))
return float.toFixed(fixed(precision));
}

@@ -65,23 +69,32 @@

this.numberOnly = (string, regExp) => string.toString().replace(regExp, '');
this.numberOnly = (string, regExp) => string.toString().replace(regExp, "");
this.isNegative = this.sign() === '-';
this.isNegative = this.sign() === "-";
this.numbers = () => {
if (this.options.reverseFill) {
this.number = toFixed(this.numberOnly(this.input, /\D+/g), this.options.precision).replace('.', this.options.decimal);
} else if (typeof this.input === 'number') {
this.number = this.parts(this.input.toString().replace('-', ''), '.').join(this.options.decimal);
this.number = toFixed(
this.numberOnly(this.input, /\D+/g),
this.options.precision
).replace(".", this.options.decimal);
} else if (typeof this.input === "number") {
this.number = this.parts(
this.input.toString().replace("-", ""),
"."
).join(this.options.decimal);
} else {
this.number = this.numberOnly(this.input, new RegExp(`[^0-9\\${this.options.decimal}]+`, 'gi'));
this.number = this.numberOnly(
this.input,
new RegExp(`[^0-9\\${this.options.decimal}]+`, "gi")
);
this.number = this.parts(this.number).join(this.options.decimal);
}
return this.number
return this.number;
};
this.realNumber = () => {
return this.numbers().toString().replace(this.options.decimal, '.')
return this.numbers().toString().replace(this.options.decimal, ".");
};
this.parts = (number = '', decimal = this.options.decimal) => {
this.parts = (number = "", decimal = this.options.decimal) => {
var parts = number.toString().split(decimal);

@@ -91,3 +104,3 @@ parts[0] = this.toNumber(parts[0]) || 0;

if (parts.length > 1) {
parts[1] = parts.slice(1, parts.length).join('');
parts[1] = parts.slice(1, parts.length).join("");
parts = parts.slice(0, 2);

@@ -97,14 +110,22 @@ }

if (this.isClean) {
const newNumber = this.toNumber(parts.join('.')).toFixed(this.options.precision);
const newNumber = this.toNumber(parts.join(".")).toFixed(
this.options.precision
);
const cleanNumber = this.toNumber(newNumber);
const minimumDigits = cleanNumber.toFixed(this.options.minimumFractionDigits);
const minimumDigits = cleanNumber.toFixed(
this.options.minimumFractionDigits
);
if (this.options.minimumFractionDigits && this.options.minimumFractionDigits >= 0 && cleanNumber.toString().length < minimumDigits.length) {
parts = minimumDigits.toString().split('.');
if (
this.options.minimumFractionDigits &&
this.options.minimumFractionDigits >= 0 &&
cleanNumber.toString().length < minimumDigits.length
) {
parts = minimumDigits.toString().split(".");
} else {
parts = cleanNumber.toString().split('.');
parts = cleanNumber.toString().split(".");
}
}
return parts.slice(0, 2)
return parts.slice(0, 2);
};

@@ -114,4 +135,6 @@

var parts = this.numbers().split(this.options.decimal);
parts[0] = parts[0].toString().replace(/(\d)(?=(?:\d{3})+\b)/gm, `$1${this.options.separator}`);
return parts.join(this.options.decimal)
parts[0] = parts[0]
.toString()
.replace(/(\d)(?=(?:\d{3})+\b)/gm, `$1${this.options.separator}`);
return parts.join(this.options.decimal);
};

@@ -125,6 +148,11 @@

this.format = (input) => {
if (input === '') return this.options.nullValue
if (input === "") return this.options.nullValue;
this.input = input || this.options.nullValue;
if (this.isNull()) return this.options.nullValue
return this.sign() + this.options.prefix + this.addSeparator() + this.options.suffix
if (this.isNull()) return this.options.nullValue;
return (
this.sign() +
this.options.prefix +
this.addSeparator() +
this.options.suffix
);
};

@@ -138,6 +166,6 @@

this.unformat = (input) => {
if (input === '') return this.options.nullValue
if (input === "") return this.options.nullValue;
this.input = input || this.options.nullValue;
if (this.isNull()) return this.options.nullValue
return this.sign() + this.realNumber()
if (this.isNull()) return this.options.nullValue;
return this.sign() + this.realNumber();
};

@@ -144,0 +172,0 @@ }

{
"name": "@coders-tm/vue-number-format",
"version": "2.1.11",
"version": "2.1.12",
"private": false,

@@ -38,3 +38,4 @@ "description": "Easy formatted numbers, currency and percentage with input/directive mask for Vue.js",

"currency input",
"money input"
"money input",
"v-number"
],

@@ -41,0 +42,0 @@ "license": "MIT",

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