lambdajson-js 1.1.6 → 1.1.7
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/package.json +1 -1
- package/src/primitives.js +8 -1
package/package.json
CHANGED
package/src/primitives.js
CHANGED
|
@@ -62,5 +62,12 @@ export const primitives = {
|
|
|
62
62
|
return _init
|
|
63
63
|
? x => reduce(_collection(x), (a, v) => aggregator(x, [a, v]), _init(x))
|
|
64
64
|
: x => reduce(_collection(x), (a, v) => aggregator(x, [a, v]));
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
|
+
$replace: ({ _regex, _substitute, _string = input, _global }) => x => {
|
|
67
|
+
const pattern = _global?.(x) ? new RegExp(_regex(x), 'g') : _regex(x);
|
|
68
|
+
return _string(x).replace(pattern, _substitute(x));
|
|
69
|
+
},
|
|
70
|
+
$isMatch: ({ _pattern, _string = input }) => x => new RegExp(_pattern(x)).test(_string(x)),
|
|
71
|
+
$parseInt: f => x => { const n = parseInt(f(x), 10); return isNaN(n) ? undefined : n; },
|
|
72
|
+
$parseFloat: f => x => { const n = parseFloat(f(x)); return isNaN(n) ? undefined : n; },
|
|
66
73
|
}
|