@stackone/expressions 0.2.0 → 0.3.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/dist/index.es.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/validate.d.ts +1 -0
- package/package.json +6 -4
package/dist/index.es.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as r}from"@stackone/utils";import*as
|
|
1
|
+
import{isObject as t,notMissing as r}from"@stackone/utils";import e from"lodash.get";import*as n from"jexl";const o=/\${([^}]+)}/g,c=(t=()=>new n.Jexl)=>t(),l=t=>t.replace(/\$\./g,"").trim(),a=(t,r)=>{try{return t.compile(r)}catch(t){return null}},s=(r,e)=>{const n=t(e)?e:{},o=c(),s=l(r),p=u(s,n);if(p)return p;const i=a(o,s);if(!i)return null;try{return i.evalSync(n)}catch(t){return null}},u=(t,n)=>{const c=t.match(o)?.map((t=>({toReplace:t,path:t.slice(2,-1)})));if(!c)return;let l=String(t);for(const t of c){const o=e(n,t.path);r(o)&&(l=l.replace(t.toReplace,`${String(o)}`))}return l},p=t=>{const r=c(),e=l(t),n=a(r,e);return!!i(e)||!(!n||"."===e)},i=t=>new RegExp(o).test(t);export{s as evaluate,i as isInterpolatedExpression,p as isValidExpression};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@stackone/utils");function r(e){var
|
|
1
|
+
"use strict";var e=require("@stackone/utils"),t=require("lodash.get");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(require("jexl"));const c=/\${([^}]+)}/g,o=(e=()=>new n.Jexl)=>e(),s=e=>e.replace(/\$\./g,"").trim(),i=(e,t)=>{try{return e.compile(t)}catch(e){return null}},u=(r,n)=>{const o=r.match(c)?.map((e=>({toReplace:e,path:e.slice(2,-1)})));if(!o)return;let s=String(r);for(const r of o){const c=t(n,r.path);e.notMissing(c)&&(s=s.replace(r.toReplace,`${String(c)}`))}return s},a=e=>new RegExp(c).test(e);exports.evaluate=(t,r)=>{const n=e.isObject(r)?r:{},c=o(),a=s(t),l=u(a,n);if(l)return l;const p=i(c,a);if(!p)return null;try{return p.evalSync(n)}catch(e){return null}},exports.isInterpolatedExpression=a,exports.isValidExpression=e=>{const t=o(),r=s(e),n=i(t,r);return!!a(r)||!(!n||"."===r)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const INTERPOLATED_EXPRESSION_REGEX: RegExp;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { evaluateExpression as evaluate } from './evaluate';
|
|
2
|
-
export { isValidExpression } from './validate';
|
|
2
|
+
export { isValidExpression, isInterpolatedExpression } from './validate';
|
package/dist/types/validate.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/expressions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.es.
|
|
6
|
+
"module": "dist/index.es.mjs",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
"author": "StackOne",
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@stackone/utils": "*",
|
|
35
36
|
"jexl": "^2.3.0",
|
|
36
|
-
"
|
|
37
|
+
"lodash.get": "^4.4.2"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@types/jexl": "^2.3.4"
|
|
40
|
+
"@types/jexl": "^2.3.4",
|
|
41
|
+
"@types/lodash.get": "^4.4.9"
|
|
40
42
|
}
|
|
41
43
|
}
|