How to use the pouchdb-utils.scopeEval function in pouchdb-utils

To help you get started, we’ve selected a few pouchdb-utils 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 pouchdb / pouchdb / packages / node_modules / pouchdb-changes-filter / src / evalView-browser.js View on Github external
var code = [
    'return function(doc) {',
    '  "use strict";',
    '  var emitted = false;',
    '  var emit = function (a, b) {',
    '    emitted = true;',
    '  };',
    '  var view = ' + input + ';',
    '  view(doc);',
    '  if (emitted) {',
    '    return true;',
    '  }',
    '};'
  ].join('\n');

  return scopeEval(code, {});
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-mapreduce / src / evalFunctionWithEval.js View on Github external
function evalFunctionWithEval(func, emit) {
  return scopeEval(
    "return (" + func.replace(/;\s*$/, "") + ");",
    {
      emit: emit,
      sum: sum,
      log: log,
      isArray: isArray,
      toJSON: toJSON
    }
  );
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-changes-filter / src / evalFilter-browser.js View on Github external
function evalFilter(input) {
  return scopeEval('"use strict";\nreturn ' + input + ';', {});
}