src/lib/modules/expression/index.js
/**
   * evaluate a JS expression
   * @param {String} expression
   * @param {Object} [scope] - a customized scope that the expression will be evaluated in
   * @returns Promise
   */
evaluate a JS expression
@param {String} expression
@param {Object} [scope] - a customized scope that the expression will be evaluated in
@returns Promise
evaluate a JS expression @param { String } expression @param { Object } [ scope ] - a customized scope that the expression will be evaluated in @returns Promise
evaluate(expression, scope) {
    return new Promise((resolve, reject) => {
      if (!expression) return reject(new Error('Expression - eval() - expression is required'));
      let astTokens = esprima.tokenize(expression);
      let startTime = process.hrtime();
      _eval(expression, scope)
        .then(result => {
          let time = _getTime(startTime);
          let expressionResult = {
            result: result,
            time: time,
            mongoMethodName: _getMongoMethodName(astTokens),
            mongoCollectionName: _getMongoCollectionName(expression, astTokens)
          };
          if (_.isArray(expressionResult.result)) {
            expressionResult.keyValueResults = keyValueUtils.convert(expressionResult.result);
          }
          return resolve(expressionResult);
        })
        .catch(reject);
    });
  }
evaluate ( expression , scope ) { return new Promise ( ( resolve , reject ) => { if ( ! expression ) return reject ( new Error ( 'Expression - eval() - expression is required' ) ) ; let astTokens = esprima . tokenize ( expression ) ; let startTime = process . hrtime ( ) ; _eval ( expression , scope ) . then ( result => { let time = _getTime ( startTime ) ; let expressionResult = { result : result , time : time , mongoMethodName : _getMongoMethodName ( astTokens ) , mongoCollectionName : _getMongoCollectionName ( expression , astTokens ) } ; if ( _ . isArray ( expressionResult . result ) ) { expressionResult . keyValueResults = keyValueUtils . convert ( expressionResult . result ) ; } return resolve ( expressionResult ) ; } ) . catch ( reject ) ; } ) ; }
evaluate a JS expression
 @param {String} expression
 @param {Object} [scope] - a customized scope that the expression will be evaluated in
 @returns Promise
evaluate a JS expression @param { String } expression @param { Object } [ scope ] - a customized scope that the expression will be evaluated in @returns Promise