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.0.1 to 0.0.2

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,t=null,n)=>{if(Array.isArray(e)&&"string"==typeof e[0]){let[r,...a]=e,o="!"===r.substr(0,1);if(o&&(r=r.substr(1)),"literal"===r)return o?negate(a[0]):a[0];if("evaluate"===r){const e=evaluate(a[1],t,n),r=evaluate(a[0],e,n);return o?negate(r):r}const s=0===r.length?nOpArg0:n&&n[r];if("function"==typeof s){const e=s(a.map(e=>evaluate(e,t,n)),t);return o?negate(e):e}throw new Error(`Unmatched function: ${r}`)}return e};var evaluate_1=evaluate;const compile=(e,t,n=[],r=0,a=0)=>{const o=(()=>{if(Array.isArray(e)&&"string"==typeof e[0]){let[o,...s]=e,l="!"===o.substr(0,1);if(l&&(o=o.substr(1)),"literal"===o)return l?`negate(${JSON.stringify(s[0])})`:JSON.stringify(s[0]);if("evaluate"===o){const e=`${compile(s[1],t,n,r+1,a)}`,o=compile(s[0],t,n,r+1,a+1),u=`(() => { const ctx${a+1} = ${e}; return ${o}; })()`;return l?`negate(${u})`:u}if("function"==typeof t[o]||0===o.length){const e=s.map(e=>compile(e,t,n,r+1));if(0===o.length)return`negate(${e[0]})`;const u=`fns['${o}']([${e.join(", ")}], ctx${a>0?a:""})`;return l?`negate(${u})`:u}throw new Error(`Unmatched function: ${o}`)}return JSON.stringify(e)})();if(0===r){return{source:`\n// Function arguments\nconst [ctx, fns] = 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\n// Compiled Expression\nreturn ${o};`}}return o};var compile_1=compile,src={evaluate:evaluate_1,compile:compile_1},src_1=src.evaluate,src_2=src.compile;exports.compile=src_2,exports.default=src,exports.evaluate=src_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,t,n=null)=>{if(Array.isArray(e)&&"string"==typeof e[0]){let[r,...o]=e,a="!"===r.substr(0,1);if(a&&(r=r.substr(1)),"literal"===r)return a?negate(o[0]):o[0];if("evaluate"===r){const e=evaluate(o[1],t,n),r=evaluate(o[0],t,e);return a?negate(r):r}const s=0===r.length?nOpArg0:t&&t[r];if("function"==typeof s){const e=s(o.map(e=>evaluate(e,t,n)),n);return a?negate(e):e}throw new Error(`Unmatched function: ${r}`)}return e};var evaluate_1=evaluate;const compile=(e,t,n=[],r=0,o=0)=>{const a=(()=>{if(Array.isArray(e)&&"string"==typeof e[0]){let[a,...s]=e,c="!"===a.substr(0,1);if(c&&(a=a.substr(1)),"literal"===a)return c?`negate(${JSON.stringify(s[0])})`:JSON.stringify(s[0]);if("evaluate"===a){const e=`${compile(s[1],t,n,r+1,o)}`,a=compile(s[0],t,n,r+1,o+1),l=`(() => { const ctx${o+1} = ${e}; return ${a}; })()`;return c?`negate(${l})`:l}if("function"==typeof t[a]||0===a.length){const e=s.map(e=>compile(e,t,n,r+1));if(0===a.length)return`negate(${e[0]})`;const l=`fns['${a}']([${e.join(", ")}], ctx${o>0?o:""})`;return c?`negate(${l})`:l}throw new Error(`Unmatched function: ${a}`)}return JSON.stringify(e)})();if(0===r){const e=`\n// Function arguments\nconst [fns, ctx] = 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\n// Compiled Expression\nreturn ${a};`;return{source:e,compiled:new Function(e)}}return a};var compile_1=compile,src={evaluate:evaluate_1,compile:compile_1},src_1=src.evaluate,src_2=src.compile;exports.compile=src_2,exports.default=src,exports.evaluate=src_1;
{
"name": "@alpaca-travel/fexp-js",
"version": "0.0.1",
"version": "0.0.2",
"description": "Functional expressions",

@@ -9,2 +9,6 @@ "main": "index.js",

"private": false,
"repository": {
"type": "git",
"url": "https://github.com/AlpacaTravel/fexp-js"
},
"files": [

@@ -14,2 +18,3 @@ "dist"

"scripts": {
"prepublish": "npm run build",
"test": "jest",

@@ -32,3 +37,3 @@ "test:coverage": "jest --coverage",

},
"gitHead": "98f3b8ab01c05dccde8f0851a3564a68e137eb12"
"gitHead": "a26af52305c1d2ca735f4e7dff2f93d2153cac75"
}
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