@lowentry/utils 1.6.2 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LeTypes.js +5 -2
- package/README.md +1 -1
- package/package.json +1 -1
package/LeTypes.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
const REGEX_ALL_NON_FLOAT_CHARACTERS = /[^0-9.\-]/g;
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Returns true if the value is set (not undefined and not null).
|
|
3
6
|
*
|
|
@@ -152,7 +155,7 @@ export const INT_LAX_ANY = (...values) => Math.round(FLOAT_LAX_ANY(...values));
|
|
|
152
155
|
*/
|
|
153
156
|
export const FLOAT_LAX = (value) =>
|
|
154
157
|
{
|
|
155
|
-
const v = parseFloat(value);
|
|
158
|
+
const v = (typeof value === 'number') ? value : parseFloat((value + '').replace(REGEX_ALL_NON_FLOAT_CHARACTERS, ''));
|
|
156
159
|
if(!isNaN(v))
|
|
157
160
|
{
|
|
158
161
|
return v;
|
|
@@ -173,7 +176,7 @@ export const FLOAT_LAX_ANY = (...values) =>
|
|
|
173
176
|
{
|
|
174
177
|
if(value !== null)
|
|
175
178
|
{
|
|
176
|
-
const v = parseFloat(value);
|
|
179
|
+
const v = (typeof value === 'number') ? value : parseFloat((value + '').replace(REGEX_ALL_NON_FLOAT_CHARACTERS, ''));
|
|
177
180
|
if(!isNaN(v))
|
|
178
181
|
{
|
|
179
182
|
return v;
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Provides utilities for general JavaScript development.
|
|
|
5
5
|
|
|
6
6
|
## Description
|
|
7
7
|
|
|
8
|
-
This plugin
|
|
8
|
+
This plugin adds utility functions and classes to make it easier to program general JavaScript.
|
|
9
9
|
|
|
10
10
|
Think about things such as:
|
|
11
11
|
|