@alpaca-travel/fexp-js
Advanced tools
Comparing version 1.0.0-alpha.0 to 1.0.1-alpha.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("assert"))&&"object"==typeof t&&"default"in t?t.default:t;const n=(t,e={},n={})=>{if(g(t))try{const s=v(t),u=b(t),c=y(t),i=d(s,e);h(i);const p=a(i,r(e,n))(u);return m(p)?o(p,[],c):o(i,p,c)}catch(t){throw t}return t},r=(t,e)=>{const r=r=>n(r,t,e);return r.lang=t,r.options=e,r},o=(t,e=[],n=!1)=>{w(t);const r=function(r){const o=s(e,r),a=t(o);return n?l(a):a};return r.returns=t.returns,r.invocable=!0,r},s=(t,e)=>{const n=(e,s)=>{const a={};a.get=r(a);const u=o(a);return a[Symbol.iterator]=u,a.contextParent=s,a.context=e,a.arguments=(t=0)=>[...u(t)],a.length=t.length,a.createSubRuntime=t=>n(t,e),a},r=e=>function(n){const r=t[n];return"function"==typeof r&&!0===r.invocable?r(e.context):r},o=e=>function*(n=0){let r=n;for(;r<t.length;)yield e.get(r++)};return n(e)},a=(t,e)=>{const n=t=>e(t);return n.validateTypes=t=>{},n.lang=e.lang,n.options=e.options,m(t.parse)?e=>t.parse(e,n):t=>{const r=t.map(e);return n.validateTypes(r),r}},u=([t])=>t;u.parse=t=>t;const c=([t])=>t,i=([t])=>l(t),p=t=>f(t)(...t.arguments(1)),f=t=>(...e)=>t.createSubRuntime({vars:{arguments:[...e]}}).get(0),l=t=>{if("function"==typeof t)return(...t)=>l(...t);if("boolean"==typeof t)return!t;throw new Error("Can not negate a non-boolean result")},g=t=>Array.isArray(t)&&t.length>0&&"string"==typeof t[0],m=t=>"function"==typeof t,y=([t])=>"!"==t.substr(0,1),v=t=>{const[e]=t;return"!"===e.substr(0,1)?e.substr(1):e},b=([,...t])=>t,d=(t,e)=>{if(x(e),e[t])return e[t];switch(t){case"!":case"negate":return i;case"literal":return u;case"fn":return f;case"evaluate":return p;case"":return c}},x=t=>e("object"==typeof t,"Language mapping is not present"),h=t=>e("function"==typeof t,"Language function is not valid"),w=t=>{if(e(t,"Runtime not found"),"function"!=typeof t&&"function"!=typeof t.run)throw new Error("Invalid run function")};var R={getFunctionName:v,isExpression:g,getFunction:d,getArgumentsParser:a,getParser:r,composeRuntimeArgumentsContext:s,createRuntimeFunction:o,parse:n};const j=function(t,e,n){const r=R.parse(t,e,n);return function(...t){const e={vars:{arguments:[...t]}};return"function"==typeof r?r(e):r}};var A={langs:(...t)=>Object.assign({},...t),evaluate:(t,e,...n)=>j(t,e)(...n),compile:(t,e)=>({compiled:j(t,e)}),parse:j,parser:R},P=A.langs,E=A.evaluate,F=A.compile,S=A.parse,C=A.parser;exports.compile=F,exports.default=A,exports.evaluate=E,exports.langs=P,exports.parse=S,exports.parser=C; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var assert=_interopDefault(require("assert"));const parse=(e,t={},n={})=>{if(isExpression(e))try{const r=getFunctionName(e),s=getFunctionArguments(e),a=isFunctionNegated(e),o=getFunction(r,t);assertValidExpressionFunction(o);const u=getArgumentsParser(o,getParser(t,n))(s);return isFunction(u)?createRuntimeFunction(u,[],a):createRuntimeFunction(o,u,a)}catch(e){throw e}return e},getParser=(e,t)=>{const n=n=>parse(n,e,t);return n.lang=e,n.options=t,n},createRuntimeFunction=(e,t=[],n=!1)=>{assertValidRuntimeFunction(e);const r=function(r){const s=composeRuntimeArgumentsContext(t,r),a=e(s);return n?negateValue(a):a};return r.returns=e.returns,r.invocable=!0,r},composeRuntimeArgumentsContext=(e,t)=>{const n=(t,a)=>{const o={};o.get=r(o);const u=s(o);return o[Symbol.iterator]=u,o.contextParent=a,o.context=t,o.arguments=(e=0)=>[...u(e)],o.length=e.length,o.createSubRuntime=e=>n(e,t),o},r=t=>(function(n){const r=e[n];return"function"==typeof r&&!0===r.invocable?r(t.context):r}),s=t=>(function*(n=0){let r=n;for(;r<e.length;)yield t.get(r++)});return n(t)},getArgumentsParser=(e,t)=>{const n=e=>t(e);return n.validateTypes=e=>{},n.lang=t.lang,n.options=t.options,(()=>isFunction(e.parse)?t=>e.parse(t,n):e=>{const r=e.map(t);return n.validateTypes(r),r})()},literalFn=([e])=>e;literalFn.parse=e=>e;const continueFn=([e])=>e,negateFn=([e])=>negateValue(e),evaluateFn=e=>{return functionFn(e)(...e.arguments(1))},functionFn=e=>(...t)=>{return e.createSubRuntime({vars:{arguments:[...t]}}).get(0)},negateValue=e=>{if("function"==typeof e)return(...e)=>negateValue(...e);if("boolean"==typeof e)return!e;throw new Error("Can not negate a non-boolean result")},isExpression=e=>Array.isArray(e)&&e.length>0&&"string"==typeof e[0],isFunction=e=>"function"==typeof e,isFunctionNegated=([e])=>"!"==e.substr(0,1),getFunctionName=e=>{const[t]=e;return"!"===t.substr(0,1)?t.substr(1):t},getFunctionArguments=([,...e])=>e,getFunction=(e,t)=>{if(assertValidLanguage(t),t[e])return t[e];switch(e){case"!":case"negate":return negateFn;case"literal":return literalFn;case"fn":return functionFn;case"evaluate":return evaluateFn;case"":return continueFn}},assertValidLanguage=e=>assert("object"==typeof e,"Language mapping is not present"),assertValidExpressionFunction=e=>assert("function"==typeof e,"Language function is not valid"),assertValidRuntimeFunction=e=>{if(assert(e,"Runtime not found"),"function"!=typeof e&&"function"!=typeof e.run)throw new Error("Invalid run function")};var parse_1={getFunctionName:getFunctionName,isExpression:isExpression,getFunction:getFunction,getArgumentsParser:getArgumentsParser,getParser:getParser,composeRuntimeArgumentsContext:composeRuntimeArgumentsContext,createRuntimeFunction:createRuntimeFunction,parse:parse};const langs=(...e)=>Object.assign({},...e),compile=(e,t)=>({compiled:parse$1(e,t)}),evaluate=(e,t,...n)=>parse$1(e,t)(...n),parse$1=function(e,t,n){const r=parse_1.parse(e,t,n);return function(...e){const t={vars:{arguments:[...e]}};return"function"==typeof r?r(t):r}};var src={langs:langs,evaluate:evaluate,compile:compile,parse:parse$1,parser:parse_1},src_1=src.langs,src_2=src.evaluate,src_3=src.compile,src_4=src.parse,src_5=src.parser;exports.compile=src_3,exports.default=src,exports.evaluate=src_2,exports.langs=src_1,exports.parse=src_4,exports.parser=src_5; |
{ | ||
"name": "@alpaca-travel/fexp-js", | ||
"version": "1.0.0-alpha.0", | ||
"version": "1.0.1-alpha.0", | ||
"description": "Functional expressions", | ||
@@ -35,3 +35,6 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "7190656edfa4ef54a93fb6e49c986b3fa40b206d" | ||
"dependencies": { | ||
"assert": "^2.0.0" | ||
}, | ||
"gitHead": "c8139aff5bf56730cc1f36c5e2c06d0b0e5112a6" | ||
} |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
6776
14
0
1
+ Addedassert@^2.0.0
+ Addedassert@2.1.0(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-nan@1.3.2(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedobject-is@1.1.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.7(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedutil@0.12.5(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)