Skip to content

Commit

Permalink
fixes #2430 - scientific notation support
Browse files Browse the repository at this point in the history
  • Loading branch information
OlaOluwalekan committed Oct 27, 2024
1 parent 12b27a2 commit e6fbe15
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib/isNumeric.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assertString from './util/assertString';
import { decimal } from './alpha';
import assertString from "./util/assertString";

Check failure on line 1 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 1 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 1 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 1 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 1 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote

Check failure on line 1 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 1 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote
import { decimal } from "./alpha";

Check failure on line 2 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 2 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 2 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 2 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 2 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote

Check failure on line 2 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 2 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote

const numericNoSymbols = /^[0-9]+$/;

Expand All @@ -8,5 +8,10 @@ export default function isNumeric(str, options) {
if (options && options.no_symbols) {
return numericNoSymbols.test(str);
}
return (new RegExp(`^[+-]?([0-9]*[${(options || {}).locale ? decimal[options.locale] : '.'}])?[0-9]+$`)).test(str);

const decimalSymbol = (options || {}).locale ? decimal[options.locale] : ".";

Check failure on line 12 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Strings must use singlequote

Check failure on line 12 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Strings must use singlequote

Check failure on line 12 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Strings must use singlequote

Check failure on line 12 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Strings must use singlequote

Check failure on line 12 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Strings must use singlequote

Check failure on line 12 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Strings must use singlequote

Check failure on line 12 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Strings must use singlequote

return new RegExp(

Check failure on line 14 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Unexpected newline after '('

Check failure on line 14 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Unexpected newline after '('

Check failure on line 14 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Unexpected newline after '('

Check failure on line 14 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Unexpected newline after '('

Check failure on line 14 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Unexpected newline after '('

Check failure on line 14 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Unexpected newline after '('

Check failure on line 14 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Unexpected newline after '('
`^[+-]?(?:\\d+|\\d*${decimalSymbol}\\d+)(?:[eE][+-]?\\d+)?$`
).test(str);

Check failure on line 16 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 16

Unexpected newline before ')'

Check failure on line 16 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 12

Unexpected newline before ')'

Check failure on line 16 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 14

Unexpected newline before ')'

Check failure on line 16 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 10

Unexpected newline before ')'

Check failure on line 16 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 8

Unexpected newline before ')'

Check failure on line 16 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 18

Unexpected newline before ')'

Check failure on line 16 in src/lib/isNumeric.js

View workflow job for this annotation

GitHub Actions / Run tests on Node.js 20

Unexpected newline before ')'
}

0 comments on commit e6fbe15

Please sign in to comment.