lib/pointer.js
function createPointerEvaluator(target) {
  // Use cache to store already received values.
  var cache = {};

  return function(pointer) {
      if (!isValidJSONPointer(pointer)) {
          // If it's not, an exception will be thrown.
          throw new ReferenceError(ErrorMessage.INVALID_POINTER);
      }

      // First, look up in the cache.
      if (cache.hasOwnProperty(pointer)) {
          // If cache entry exists, return it's value.
          return cache[pointer];
      }

      // Now, when all arguments are valid, we can start evaluation.
      // First of all, let's convert JSON pointer string to tokens list.
      var tokensList = parsePointer(pointer);
      var token;
      var value = target;

      // Evaluation will be continued till tokens list is not empty
      // and returned value is not an undefined.
      while (!_.isUndefined(value) && !_.isUndefined(token = tokensList.pop())) {
          // Evaluate the token in current context.
          // `getValue()` might throw an exception, but we won't handle it.
          value = getValue(value, token);
      }

      // Pointer evaluation is done, save value in the cache and return it.
      cache[pointer] = value;
      return value;
  };
}
function createPointerEvaluator(target) {
  // Use cache to store already received values.
  var cache = {};

  return function(pointer) {
      if (!isValidJSONPointer(pointer)) {
          // If it's not, an exception will be thrown.
          throw new ReferenceError(ErrorMessage.INVALID_POINTER);
      }

      // First, look up in the cache.
      if (cache.hasOwnProperty(pointer)) {
          // If cache entry exists, return it's value.
          return cache[pointer];
      }

      // Now, when all arguments are valid, we can start evaluation.
      // First of all, let's convert JSON pointer string to tokens list.
      var tokensList = parsePointer(pointer);
      var token;
      var value = target;

      // Evaluation will be continued till tokens list is not empty
      // and returned value is not an undefined.
      while (!_.isUndefined(value) && !_.isUndefined(token = tokensList.pop())) {
          // Evaluate the token in current context.
          // `getValue()` might throw an exception, but we won't handle it.
          value = getValue(value, token);
      }

      // Pointer evaluation is done, save value in the cache and return it.
      cache[pointer] = value;
      return value;
  };
}
function createPointerEvaluator ( target ) { // Use cache to store already received values. var cache = { } ; return function ( pointer ) { if ( ! isValidJSONPointer ( pointer ) ) { // If it's not, an exception will be thrown. throw new ReferenceError ( ErrorMessage . INVALID_POINTER ) ; } // First, look up in the cache. if ( cache . hasOwnProperty ( pointer ) ) { // If cache entry exists, return it's value. return cache [ pointer ] ; } // Now, when all arguments are valid, we can start evaluation. // First of all, let's convert JSON pointer string to tokens list. var tokensList = parsePointer ( pointer ) ; var token ; var value = target ; // Evaluation will be continued till tokens list is not empty // and returned value is not an undefined. while ( ! _ . isUndefined ( value ) && ! _ . isUndefined ( token = tokensList . pop ( ) ) ) { // Evaluate the token in current context. // `getValue()` might throw an exception, but we won't handle it. value = getValue ( value , token ) ; } // Pointer evaluation is done, save value in the cache and return it. cache [ pointer ] = value ; return value ; } ; }
Returns function that takes JSON Pointer as single argument
and evaluates it in given |target| context.
Returned function throws an exception if pointer is not valid
or any error occurs during evaluation.

@param {Object} target Evaluation target.
@returns {Function}
Returns function that takes JSON Pointer as single argument and evaluates it in given |target| context . Returned function throws an exception if pointer is not valid or any error occurs during evaluation .