MCPcopy
hub / github.com/tensorflow/tensorboard / set

Function set

tensorboard/components/tf_storage/storage.ts:125–146  ·  view source on GitHub ↗
(key: string, value: T, options: SetterOptions<T> = {})

Source from the content-addressed store, hash-verified

123 return value == undefined ? _.cloneDeep(defaultValue)! : fromString(value)!;
124 }
125 function set(key: string, value: T, options: SetterOptions<T> = {}): void {
126 const {
127 defaultValue,
128 useLocalStorage = false,
129 useLocationReplace = false,
130 } = options;
131 const stringValue = toString(value);
132 if (useLocalStorage) {
133 window.localStorage.setItem(key, stringValue);
134 // Because of listeners.ts:[1], we need to manually notify all UI elements
135 // listening to storage within the tab of a change.
136 fireStorageChanged();
137 } else if (!_.isEqual(value, get(key, {useLocalStorage}))) {
138 if (_.isEqual(value, defaultValue)) {
139 unsetFromURI(key, useLocationReplace);
140 } else {
141 const items = componentToDict(readComponent());
142 items[key] = stringValue;
143 writeComponent(dictToComponent(items), useLocationReplace);
144 }
145 }
146 }
147 /**
148 * Returns a function that can be used on a `value` declaration to a Polymer
149 * property. It updates the `polymerProperty` when storage changes -- i.e.,

Callers 15

configureMethod · 0.85
combineFunction · 0.85
getObserverFunction · 0.85
__init__Method · 0.85
http_util.pyFile · 0.85
ReloadMethod · 0.85

Calls 7

fireStorageChangedFunction · 0.90
unsetFromURIFunction · 0.90
componentToDictFunction · 0.90
readComponentFunction · 0.90
writeComponentFunction · 0.90
dictToComponentFunction · 0.90
getFunction · 0.85