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

autonumeric

Package Overview
Dependencies
Maintainers
2
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autonumeric - npm Package Compare versions

Comparing version 4.5.0 to 4.5.1

2

package.json
{
"name": "autonumeric",
"version": "4.5.0",
"version": "4.5.1",
"description": "autoNumeric is a standalone Javascript library that provides live *as-you-type* formatting for international numbers and currencies. It supports most international numeric formats and currencies including those used in Europe, Asia, and North and South America.",

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

@@ -64,5 +64,6 @@ /**

*
* @param {string} decimalCharacter The decimal character to use in the float numbers
* @returns {Token}
*/
getNextToken() {
getNextToken(decimalCharacter = '.') {
this._skipSpaces();

@@ -80,3 +81,3 @@

this.token.type = 'num';
this.token.value = this._getNumber();
this.token.value = this._getNumber(decimalCharacter);

@@ -110,6 +111,8 @@ return this.token;

*
* @param {string} decimalCharacter The decimal character to use in the float numbers
*
* @returns {string}
* @private
*/
_getNumber() {
_getNumber(decimalCharacter) {
this._skipSpaces();

@@ -122,16 +125,17 @@

if (this.text[this.index] === '.') {
if (this.text[this.index] === decimalCharacter) {
this.index++;
}
while (this.index <= this.textLength && AutoNumericHelper.isDigit(this.text[this.index])) { // Decimal part
while (this.index <= this.textLength && AutoNumericHelper.isDigit(this.text[this.index])) { // Decimal part, if any
this.index++;
}
if (this.index - startIndex === 0) {
if (this.index === startIndex) {
throw new Error(`No number has been found while it was expected`);
}
return this.text.substring(startIndex, this.index);
// Convert the localized float number to a Javascript number
return this.text.substring(startIndex, this.index).replace(decimalCharacter, '.');
}
}

@@ -55,8 +55,10 @@ /**

* @param {string} text
* @param {string} customDecimalCharacter The custom decimal character to use in floats
* @returns {ASTNode}
*/
constructor(text) {
constructor(text, customDecimalCharacter = '.') {
this.text = text;
this.decimalCharacter = customDecimalCharacter;
this.lexer = new Lexer(text);
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);

@@ -79,3 +81,3 @@ return this._exp();

case '+':
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
termNode = this._term();

@@ -86,3 +88,3 @@ exprNode = this._moreExp();

case '-':
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
termNode = this._term();

@@ -110,3 +112,3 @@ exprNode = this._moreExp();

case '*':
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
factorNode = this._factor();

@@ -117,3 +119,3 @@ termsNode = this._moreTerms();

case '/':
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
factorNode = this._factor();

@@ -135,7 +137,7 @@ termsNode = this._moreTerms();

value = this.token.value;
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
return ASTNode.createLeaf(value);
case '-':
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
factor = this._factor();

@@ -145,3 +147,3 @@

case '(':
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
expression = this._exp();

@@ -160,3 +162,3 @@ this._match(')');

if (this.text[index] === expected) {
this.token = this.lexer.getNextToken();
this.token = this.lexer.getNextToken(this.decimalCharacter);
} else {

@@ -163,0 +165,0 @@ throw new Error(`Unexpected token '${this.token.symbol}' at position '${index}' in the match function`);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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 too big to display

Sorry, the diff of this file is too big to display

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