## Resolve Paths
Find and resolve path strings

@param {Object} data
@param {String} value
@returns {String}
192852
function resolvePaths(globals, data, value) {
    var regex = /\{\{(.*?)\}\}/g;

    value = value.replace(regex, function (match, path) {
        var result;

        // Handle aliases
        path = pathAliases[path] ? pathAliases[path] : path;
        // Handle Handlebars .[] style arrays
        path = path.replace(/\.\[/g, '[');

        if (path.charAt(0) === '@') {
            result = jsonpath.query(globals, path.substr(1));
        } else {
            // Do the query, which always returns an array of matches
            result = jsonpath.query(data, path);
        }

        // Handle the case where the single data property we return is a Date
        // Data.toString() is not DB compatible, so use `toISOString()` instead
        if (_.isDate(result[0])) {
            result[0] = result[0].toISOString();
        }

        // Concatenate the results with a comma, handles common case of multiple tag slugs
        return result.join(',');
    });

    return value;
}
550521
function resolvePathname(to) {
  var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

  var toParts = to && to.split('/') || [];
  var fromParts = from && from.split('/') || [];

  var isToAbs = to && isAbsolute(to);
  var isFromAbs = from && isAbsolute(from);
  var mustEndAbs = isToAbs || isFromAbs;

  if (to && isAbsolute(to)) {
    // to is absolute
    fromParts = toParts;
  } else if (toParts.length) {
    // to is relative, drop the filename
    fromParts.pop();
    fromParts = fromParts.concat(toParts);
  }

  if (!fromParts.length) { return '/'; }

  var hasTrailingSlash = void 0;
  if (fromParts.length) {
    var last = fromParts[fromParts.length - 1];
    hasTrailingSlash = last === '.' || last === '..' || last === '';
  } else {
    hasTrailingSlash = false;
  }

  var up = 0;
  for (var i = fromParts.length; i >= 0; i--) {
    var part = fromParts[i];

    if (part === '.') {
      spliceOne(fromParts, i);
    } else if (part === '..') {
      spliceOne(fromParts, i);
      up++;
    } else if (up) {
      spliceOne(fromParts, i);
      up--;
    }
  }

  if (!mustEndAbs) { for (; up--; up) {
    fromParts.unshift('..');
  } }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) { fromParts.unshift(''); }

  var result = fromParts.join('/');

  if (hasTrailingSlash && result.substr(-1) !== '/') { result += '/'; }

  return result;
}
780568
function resolvePath(path, options, callback) {
        if (!callback) {
            callback = options;
            options = {};
        }
        
        var alreadyRooted = options.alreadyRooted;
        var checkSymlinks = options.checkSymlinks === undefined 
            ? true : options.checkSymlinks;
        var isHome        = false;
        
        if (checkSymlinks === undefined)
            checkSymlinks = true;
        if (path.substr(0, 2) == "~/") {
            isHome = true;
            path = process.env.HOME + path.substr(1);
        }
        else if (!alreadyRooted) 
            path = join(root, path);

        if (checkSymlinks && fsOptions.checkSymlinks && !alreadyRooted) 
            fs.realpath(path, check);
        else check(null, path);

        function check(err, path) {
            if (err) return callback(err);
            
            if (!options.nocheck) {
                if (!(path === base || path.substr(0, root.length) === root)
                  && !isHome) {
                    err = new Error("EACCESS: '" + path + "' not in '" + root + "'");
                    err.code = "EACCESS";
                    return callback(err);
                }
            }
            callback(null, path);
        }
    }
1112829
function resolveObject(path, obj) {
  return path.split(".").reduce(function (prev, curr) {
    return prev ? prev[curr] : undefined;
  }, obj || self);
}
958095
function resolve(root, args) {
  args = root.concat(Array.prototype.slice.call(args));
  return path.resolve.apply(path, args);
}
1242437
public function resolvePath($value)
    {
        do {
            $value = $this->getValueByPath($value);
        } while (self::isPath($value));

        return $value;
    }
1257305
function parseOptions(globals, data, options) {
    if (_.isString(options.filter)) {
        options.filter = resolvePaths(globals, data, options.filter);
    }

    return options;
}
1137783
function resolveString () {
    // resolve with original value unless value is id
    if (!this.value.match(idRegExp)) {
        return Promise.resolve(value)
    }
    // do query
    return this.model.query(this.getQueryArgs(this.value))
}
1187349
function resolve(value, conf, ring = []) {
	value.match(CONFIG_VAR_REGEX).forEach((variable) => {
		const key = variable.substring(variable.lastIndexOf('${') + 2, variable.lastIndexOf('}'));

		if (ring.includes(key)) {
			throw `Circular dependency error: cannot resolve variable(s) ${ring}.`;
		}
		ring.push(key);

		let resolved = conf[key];
		if (!resolved) {
			throw `Could not resolve ${key} - make sure this key is defined in _config.yml.`;
		}
		if (CONFIG_VAR_REGEX.test(resolved)) {
			resolved = resolve(resolved, conf, ring);
		}
		value = value.replace(variable, resolved);
		ring.pop();
	});
	return value;
}
136947
function resolveProperty (data, property, resolveValueArgs) {
    // get resolve value args
    var resolveValueArgs = this.resolveValueArgs(data, property, resolveValueArgs)
    // skip if args not defined
    if (!defined(resolveValueArgs)) {
        return
    }
    // get resolve value instance
    var resolveValue = new ImmutableCoreModelResolveValue(resolveValueArgs)
    // resolve value(s)
    return resolveValue.resolveValue()
}
569160
public static String resolve(String value, Map<String, String> properties) {
		do {
			int i = value.indexOf("${");
			if (i < 0) return value;
			int j = value.indexOf('}', i + 2);
			if (j < 0) return value;
			String name = value.substring(i + 2, j);
			String val = properties.get(name);
			if (val == null) val = "";
			value = value.substring(0, i) + val + value.substring(j + 1);
		} while (true);		
	}
475468
function localizePaths(pathList) {
  // resolve paths so that './foo/bar.js' and 'foo/bar.js' resolve to the same localized path
  pathList = pathList.map(function (p) {
    var resolvedPath = path.resolve(p);
    if (resolvedPath.substr(resolvedPath.length - 3) === '.js') {
      resolvedPath = resolvedPath.substr(0, resolvedPath.length - 3);
    }
    return resolvedPath;
  });

  var localizedPathList = [];
  if (pathList.length > 0) {
    var commonPath = null;
    pathList.forEach(function (fullPath, i) {
      var parts;
      if (commonPath === null) {
        parts = fullPath.split('/');
        if (parts.length > 1) {
          commonPath = parts.slice(0, parts.length - 1).join('/') + '/';
        } else {
          commonPath = '';
        }
      } else if (commonPath.length > 0) {
        parts = commonPath.split('/');
        parts.pop();
        commonPath = '';
        for (var partIndex = 0; partIndex < parts.length; partIndex++) {
          var testPath = commonPath + parts[partIndex] + '/';
          if (fullPath.substring(0, testPath.length) === testPath) {
            commonPath = testPath;
          } else {
            break;
          }
        }
      }
    });
    pathList.forEach(function (fullPath, i) {
      localizedPathList.push(fullPath.substr(commonPath.length));
    });
  }
  return localizedPathList;
}
1249419
function resolveNodeValue(value, part) {
  if (isDirective(value)) {
    value = resolveDirectiveValue(value, part);
  }

  if (value === nothingString || value === undefined) {
    return emptyStringBuffer;
  }

  if (isPrimitive(value)) {
    const string = typeof value !== 'string' ? String(value) : value;
    // Escape if not prefixed with unsafePrefixString, otherwise strip prefix
    return Buffer.from(
      string.indexOf(unsafePrefixString) === 0 ? string.slice(33) : escapeHTML(string)
    );
  } else if (isTemplateResult(value) || Buffer.isBuffer(value)) {
    return value;
  } else if (isPromise(value)) {
    return value.then((value) => resolveNodeValue(value, part));
  } else if (isSyncIterator(value)) {
    if (!Array.isArray(value)) {
      value = Array.from(value);
    }
    return value.reduce((values, value) => {
      value = resolveNodeValue(value, part);
      // Flatten
      if (Array.isArray(value)) {
        return values.concat(value);
      }
      values.push(value);
      return values;
    }, []);
  } else if (isAsyncIterator(value)) {
    return resolveAsyncIteratorValue(value, part);
  } else {
    throw Error('unknown NodePart value', value);
  }
}
40926
function (data, path) {
    path = path || '';
    if (_.isObject(data)) {
      for (var key in data) {
        if (_.isObject(data)) {
          data[key] = _recurseFeedDefaultNamespace(data[key], path !== '' ? path + '.' + key : key);
        }
      }
      return data;
    }
    else {
      if (data == null || data === '') {
        // return default data if empty/null
        return path;
      }
      else {
        return data;
      }
    }
  }
54035
function (paths, obj, defaultValue = null) {
        if (!Array.isArray(paths)) {
            throw new Error("paths must be an array of strings");
        }

        let res = defaultValue;
        paths.some(path => {
            const result = this.getFlattened(path, obj, defaultValue);
            if (result !== defaultValue) {
                res = result;
                return true;
            }
            return false;
        });

        return res;
    }
546898
function resolve(opts, done) {
  debug('resolving paths for globs:\n', JSON.stringify(opts.globs));
  var tasks = opts.globs.map(function(pattern) {
    return function(cb) {
      debug('resolving `%s`...', pattern);
      glob(pattern, {}, function(err, files) {
        if (err) {
          return cb(err);
        }
        debug('resolved %d file(s) for `%s`', files.length, pattern);
        if (files.length > 0) {
          opts.files.push.apply(opts.files, files);
        }
        cb();
      });
    };
  });
  async.parallel(tasks, function(err) {
    if (err) {
      return done(err);
    }
    debug('checking and removing duplicate paths...');
    opts.files = unique(opts.files);
    debug('final result has `%d` files', opts.files.length);
    done(null, opts.files);
  });
}
1080594
function resolveAll () {
    // get data column to decode data
    var dataColumn = this.query.model.columnName('data')
    // skip if no data column
    if (!defined(dataColumn) || !defined(this.result[dataColumn])) {
        return
    }
    // get data
    var data = this.result[dataColumn]
    // iterate over properties resolving any models
    return Promise.map(_.keys(data), property => {
        return this.resolveProperty(data, property)
    }, {
        concurrency: this.query.model.concurrency,
    })
    // discard map result
    .then(() => undefined)
}