MCPcopy
hub / github.com/ampproject/amphtml / getGeo_

Method getGeo_

src/service/url-replacements-impl.js:784–794  ·  view source on GitHub ↗

* Resolves the value via geo service. * @param {function(!../../extensions/amp-geo/0.1/amp-geo.GeoDef)} getter * @param {string} expr * @return {!Promise<{[key: string]: (string|Array >} * @template T * @private

(getter, expr)

Source from the content-addressed store, hash-verified

782 * @private
783 */
784 getGeo_(getter, expr) {
785 if (this.cachedGeo_ !== null) {
786 return getter(this.cachedGeo_);
787 }
788
789 return Services.geoForDocOrNull(this.ampdoc.getHeadNode()).then((geo) => {
790 userAssert(geo, 'To use variable %s, amp-geo should be configured', expr);
791 this.cachedGeo_ = geo;
792 return getter(geo);
793 });
794 }
795
796 /**
797 * Returns cached uach signal if available, calculate it if not.

Callers 1

initializeMethod · 0.95

Calls 4

userAssertFunction · 0.90
getterFunction · 0.85
thenMethod · 0.45
getHeadNodeMethod · 0.45

Tested by

no test coverage detected