function extractFromDoc(docPath, pointer) {
  const doc = docCache[docPath];
  if (doc && !lib.isPromise(doc)) {
    // If doc is already available, return __value together with the promise.
    // __value is for special handling in cycle check:
    // pointerAlreadyInPath() won't work if patch.value is a promise,
    // thus when that promise is finally resolved, cycle might happen (because
    // `spec` and `docCache[basePath]` refer to the exact same object).
    // See test "should resolve a cyclic spec when baseDoc is specified".
    try {
      const v = extract(pointer, doc);
      return Object.assign(Promise.resolve(v), { __value: v });
    } catch (e) {
      return Promise.reject(e);
    }
  }

  return getDoc(docPath).then((_doc) => extract(pointer, _doc));
}
Extracts a pointer from its document.
@param  {String} docPath the absolute document URL.
@param  {String} pointer the pointer whose value is to be extracted.
@return {Promise}        a promise of the pointer value.
@api public