Add support for custom transfers in pl.ing
This commit is contained in:
@@ -2,8 +2,14 @@ const standardContext = {
|
||||
|
||||
};
|
||||
|
||||
export function js1<I, O>(code: string, i1: string = "$", context: Record<string, unknown> = {}): (i: I) => O {
|
||||
const ctx = { ...standardContext, ...context };
|
||||
const fn = new Function(i1, ...Object.keys(ctx), code);
|
||||
return (i: I) => fn(i, ...Object.values(ctx));
|
||||
}
|
||||
|
||||
export function js2<I1, I2, O>(code: string, i1: string, i2: string, context: Record<string, unknown> = {}): (i1: I1, i2: I2) => O {
|
||||
const ctx = { ...standardContext, ...context };
|
||||
const filter = new Function(i1, i2, ...Object.keys(ctx), code);
|
||||
return (i1: I1, i2: I2) => filter(i1, i2, ...Object.values(ctx));
|
||||
const fn = new Function(i1, i2, ...Object.keys(ctx), code);
|
||||
return (i1: I1, i2: I2) => fn(i1, i2, ...Object.values(ctx));
|
||||
}
|
||||
Reference in New Issue
Block a user