Skip to content

Solution: Allowed operators whitelist #283

Open
@mytonwalletorg

Description

@mytonwalletorg

In case anyone needs to whitelist only selected operators without explicitly setting false for every other:

const ALLOWED_OPERATORS = ['add', 'subtract', 'multiply', 'divide', 'power'];

const parser = new Parser({
  operators: new Proxy({}, {
    has() {
      return true;
    },

    get(target, prop) {
      return typeof prop === 'string' && ALLOWED_OPERATORS.includes(prop);
    },
  }),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions