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

Method get

third_party/subscriptions-project/swg.js:18737–18756  ·  view source on GitHub ↗

* @param {string} key * @param {boolean=} useLocalStorage * @return {!Promise<?string>}

(key, useLocalStorage = false)

Source from the content-addressed store, hash-verified

18735 * @return {!Promise<?string>}
18736 */
18737 get(key, useLocalStorage = false) {
18738 if (!this.values_[key]) {
18739 this.values_[key] = new Promise((resolve) => {
18740 const storage = useLocalStorage
18741 ? this.win_.localStorage
18742 : this.win_.sessionStorage;
18743 if (storage) {
18744 try {
18745 resolve(storage.getItem(storageKey(key)));
18746 } catch (e) {
18747 // Ignore error.
18748 resolve(null);
18749 }
18750 } else {
18751 resolve(null);
18752 }
18753 });
18754 }
18755 return this.values_[key];
18756 }
18757
18758 /**
18759 * @param {string} key

Callers 15

test-gesture.jsFile · 0.45
test-runtime.jsFile · 0.45
test-scheduler.jsFile · 0.45
test-cid.jsFile · 0.45
compareFunction · 0.45
expectStorageFunction · 0.45
test-storage.jsFile · 0.45

Calls 3

storageKeyFunction · 0.85
getItemMethod · 0.80
resolveFunction · 0.50

Tested by

no test coverage detected