Skip to content

Commit

Permalink
Removed default operators
Browse files Browse the repository at this point in the history
  • Loading branch information
kannangce committed Sep 16, 2023
1 parent 0546a71 commit dd9e863
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions jgen.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
export class DSLInterpreter {
constructor(customOperators = {}) {
this.operators = {
'add': this.add,
'resolve': this.resolve,
'bind': this.bind,
'delete': this.delete,
...customOperators
};
}

add(context, params) {
return params.reduce((acc, curr) => acc + curr, 0);
}

resolve(context, params) {
return params[0];
}

bind(context, params) {
return params[0];
}

delete(context, params) {
return null;
}

isOperator(json) {
return json && typeof json === 'object' && Object.keys(this.operators).includes(Object.keys(json)[0]);
}

setOperator(name, func) {
this.operators[name] = func;
}

compile(json) {
if (Array.isArray(json)) {
let compiledList = json.map(item => this.compile(item));
Expand Down

0 comments on commit dd9e863

Please sign in to comment.