How to use jsep - 10 common examples

To help you get started, we’ve selected a few jsep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addBinaryOp('in', 13);
    jsep.addBinaryOp('nin', 13);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}
github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addBinaryOp('in', 13);
    jsep.addBinaryOp('nin', 13);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}
github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addBinaryOp('in', 13);
    jsep.addBinaryOp('nin', 13);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}
github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}
github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}
github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}
github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addBinaryOp('in', 13);
    jsep.addBinaryOp('nin', 13);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}
github TwoRavens / TwoRavens / assets / app / manipulations / queryMongo.js View on Github external
throw 'Invalid unary operator: ' + tree.operator;
        }

        // Binary Operators
        if (tree.type === 'BinaryExpression') {
            if (tree.operator in binaryOperators) {
                usedTerms.binaryOperators.add(tree.operator);
                return {['$' + binaryOperators[tree.operator]]: [parse(tree.left), parse(tree.right)]};
            }
            throw 'Invalid binary operator: ' + tree.operator;
        }

        throw 'Unknown syntax: ' + tree.type;
    };

    return {query: parse(jsep(text)), usedTerms};
}
github mapbox / expression-jamsession / src / formula-to-expression.js View on Github external
function formulaToExpression(input) {
  if (input === '' || input === undefined) {
    return;
  }

  if (typeof input !== 'string') {
    throw new Error('input must be a string');
  }

  // Change hyphens in expression operators to underscores. This allows JS
  // parsing to work, but then needs to be reversed above.
  input = input.replace(/([a-z]+)-([a-z]+)\(/, '$1_$2(');

  let ast;
  try {
    ast = jsep(input);
  } catch (syntaxError) {
    throw handleSyntaxErrors(syntaxError, input);
  }

  const expression = astToExpression(ast);
  return expression;
}
github CartoDB / carto-vl / src / renderer / viz / parser.js View on Github external
function prepareJsep () {
    // jsep addBinaryOp pollutes its module scope, we need to remove the custom operators afterwards
    jsep.addBinaryOp(':', 0);
    jsep.addBinaryOp('^', 11);
    jsep.addBinaryOp('or', 1);
    jsep.addBinaryOp('and', 2);
    jsep.addBinaryOp('in', 13);
    jsep.addBinaryOp('nin', 13);
    jsep.addIdentifierChar('@');
    jsep.addIdentifierChar('#');
    jsep.removeLiteral('true');
    jsep.removeLiteral('false');
}

jsep

a tiny JavaScript expression parser

MIT
Latest version published 1 year ago

Package Health Score

79 / 100
Full package analysis