Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alpaca-travel/fexp-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alpaca-travel/fexp-js - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0-alpha.0

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const negate=e=>{if("boolean"!=typeof e)throw new Error("Can not negate a non boolean value");return!e},nOpArg0=([e])=>e,evaluate=(e,n,...t)=>{const r=(e,t)=>{if(Array.isArray(e)&&"string"==typeof e[0]){let[s,...a]=e,o="!"===s.substr(0,1);if(o&&(s=s.substr(1)),"literal"===s)return o?negate(a[0]):a[0];if("fn"===s)return function(){const e=r(a[0],{vars:{arguments:arguments},prior:t});return o?negate(e):e};if("evaluate"===s){const[e,...n]=a,s=r(e,{vars:{arguments:n.map(e=>r(e,t))},prior:t});return o?negate(s):s}const c=0===s.length?nOpArg0:n&&n[s];if("function"==typeof c){const e=c(a.map(e=>r(e,t)),t);return o?negate(e):e}throw new Error(`Unmatched function: ${s}`)}return e};return r(e,{vars:{arguments:t},calling:null})};var evaluate_1=evaluate;const compile=(e,n,t=0,r=0)=>{const s=(()=>{if(Array.isArray(e)&&"string"==typeof e[0]){let[s,...a]=e,o="!"===s.substr(0,1);if(o&&(s=s.substr(1)),"literal"===s)return o?`negate(${JSON.stringify(a[0])})`:JSON.stringify(a[0]);if("fn"===s){const e=`{ vars: { arguments: s${t} }, prior: ctx${r} }`,s=compile(a[0],n,t+1,r+1);return`function(...s${t}) { const ctx${r+1} = ${e}; const result = ${s}; return ${o?"negate(result)":"result"}; }`}if("evaluate"===s){const e=`{ vars: { arguments: [${compile(a[1],n,t+1,r)}], prior: ctx${r} } }`,s=compile(a[0],n,t+1,r+1),c=`(() => { const ctx${r+1} = ${e}; return ${s}; })()`;return o?`negate(${c})`:c}if("function"==typeof n[s]||0===s.length){const e=a.map(e=>compile(e,n,t+1,r));if(0===s.length)return`negate(${e[0]})`;const c=`fns['${s}']([${e.join(", ")}], ctx${r})`;return o?`negate(${c})`:c}throw new Error(`Unmatched function: ${s}`)}return JSON.stringify(e)})();if(0===t){const e=`\n// Function arguments\nconst [fns, ...callArgs] = arguments;\n\n// Negate Check\nconst negate = (val) => { if (typeof val !== 'boolean') { throw new Error('Can not negate a non-boolean result'); } return !val; };\n\nconst ctx0 = { vars: { arguments: callArgs } };\n\n// Compiled Expression\nreturn ${s};`;return{source:e,compiled:new Function(e)}}return s};var compile_1=compile;const langs=(...e)=>Object.assign({},...e);var src={evaluate:evaluate_1,compile:compile_1,langs:langs},src_1=src.evaluate,src_2=src.compile,src_3=src.langs;exports.compile=src_2,exports.default=src,exports.evaluate=src_1,exports.langs=src_3;
"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;
{
"name": "@alpaca-travel/fexp-js",
"version": "0.3.0",
"version": "1.0.0-alpha.0",
"description": "Functional expressions",

@@ -35,3 +35,3 @@ "main": "dist/index.js",

},
"gitHead": "a0c2e02f59a31c82238a86d35ddc3714bec84b7b"
"gitHead": "7190656edfa4ef54a93fb6e49c986b3fa40b206d"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc