@lowentry/utils 1.6.3 → 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.
Files changed (2) hide show
  1. package/LeTypes.js +5 -2
  2. 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowentry/utils",
3
- "version": "1.6.3",
3
+ "version": "1.7.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Provides utilities for general JavaScript development.",