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

@n8n/tournament

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@n8n/tournament - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

dist/Evaluator.d.ts

8

dist/index.d.ts
import type { ExpressionAnalysis } from './ExpressionBuilder';
import type { ExpressionEvaluatorClass } from './Evaluator';
export type { TmplDifference } from './Analysis';
export type { ExpressionEvaluator, ExpressionEvaluatorClass } from './Evaluator';
export type ReturnValue = string | null | (() => unknown);

@@ -7,8 +9,8 @@ export declare class Tournament {

private _dataNodeName;
private _codeCache;
constructor(errorHandler?: (error: Error) => void, _dataNodeName?: string);
private evaluator;
constructor(errorHandler?: (error: Error) => void, _dataNodeName?: string, Evaluator?: ExpressionEvaluatorClass);
setEvaluator(Evaluator: ExpressionEvaluatorClass): void;
getExpressionCode(expr: string): [string, ExpressionAnalysis];
tmplDiff(expr: string): import("./Analysis").TmplDifference;
private getFunction;
execute(expr: string, data: unknown): ReturnValue;
}

@@ -6,9 +6,13 @@ "use strict";

const Analysis_1 = require("./Analysis");
const FunctionEvaluator_1 = require("./FunctionEvaluator");
const DATA_NODE_NAME = '___n8n_data';
class Tournament {
constructor(errorHandler = () => { }, _dataNodeName = DATA_NODE_NAME) {
constructor(errorHandler = () => { }, _dataNodeName = DATA_NODE_NAME, Evaluator = FunctionEvaluator_1.FunctionEvaluator) {
this.errorHandler = errorHandler;
this._dataNodeName = _dataNodeName;
this._codeCache = {};
this.setEvaluator(Evaluator);
}
setEvaluator(Evaluator) {
this.evaluator = new Evaluator(this);
}
getExpressionCode(expr) {

@@ -20,11 +24,2 @@ return (0, ExpressionBuilder_1.getExpressionCode)(expr, this._dataNodeName);

}
getFunction(expr) {
if (expr in this._codeCache) {
return this._codeCache[expr];
}
const [code, analysis] = this.getExpressionCode(expr);
const func = new Function('E', code + ';');
this._codeCache[expr] = [func, analysis];
return [func, analysis];
}
execute(expr, data) {

@@ -34,4 +29,3 @@ if (!expr) {

}
const fn = this.getFunction(expr)[0];
return fn.call(data, this.errorHandler);
return this.evaluator.evaluate(expr, data);
}

@@ -38,0 +32,0 @@ }

@@ -24,2 +24,3 @@ "use strict";

};
const polyfillExceptions = ['this', 'window', 'global'];
const polyfillVar = (path, dataNode, force = false) => {

@@ -31,2 +32,5 @@ if (!force) {

}
if (polyfillExceptions.includes(path.node.name)) {
return;
}
path.replace(buildGlobalSwitch(path.node, dataNode));

@@ -33,0 +37,0 @@ };

{
"name": "@n8n/tournament",
"version": "1.0.0",
"description": "Output compatiable rewrite of riot tmpl",
"version": "1.0.1",
"description": "Output compatible rewrite of riot tmpl",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "module": "src/index.ts",

import { getExpressionCode } from './ExpressionBuilder';
import type { ExpressionAnalysis } from './ExpressionBuilder';
import { getTmplDifference } from './Analysis';
import type { ExpressionEvaluator, ExpressionEvaluatorClass } from './Evaluator';
import { FunctionEvaluator } from './FunctionEvaluator';
export type { TmplDifference } from './Analysis';
export type { ExpressionEvaluator, ExpressionEvaluatorClass } from './Evaluator';

@@ -10,3 +13,3 @@ const DATA_NODE_NAME = '___n8n_data';

export class Tournament {
private _codeCache: Record<string, [Function, ExpressionAnalysis]> = {};
private evaluator!: ExpressionEvaluator;

@@ -16,4 +19,11 @@ constructor(

private _dataNodeName: string = DATA_NODE_NAME,
) {}
Evaluator: ExpressionEvaluatorClass = FunctionEvaluator,
) {
this.setEvaluator(Evaluator);
}
setEvaluator(Evaluator: ExpressionEvaluatorClass) {
this.evaluator = new Evaluator(this);
}
getExpressionCode(expr: string): [string, ExpressionAnalysis] {

@@ -27,12 +37,2 @@ return getExpressionCode(expr, this._dataNodeName);

private getFunction(expr: string): [Function, ExpressionAnalysis] {
if (expr in this._codeCache) {
return this._codeCache[expr];
}
const [code, analysis] = this.getExpressionCode(expr);
const func = new Function('E', code + ';');
this._codeCache[expr] = [func, analysis];
return [func, analysis];
}
execute(expr: string, data: unknown): ReturnValue {

@@ -44,5 +44,4 @@ // This is to match tmpl. This will only really happen if

}
const fn = this.getFunction(expr)[0];
return fn.call(data, this.errorHandler);
return this.evaluator.evaluate(expr, data);
}
}

@@ -42,2 +42,4 @@ import type { types } from 'recast';

const polyfillExceptions = ['this', 'window', 'global'];
const polyfillVar = (

@@ -54,2 +56,6 @@ path: NodePath<types.namedTypes.Identifier>,

}
// For tmpl compat we ignore these identifiers
if (polyfillExceptions.includes(path.node.name)) {
return;
}
path.replace(buildGlobalSwitch(path.node, dataNode));

@@ -56,0 +62,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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