MCPcopy
hub / github.com/tensorflow/playground / serialize

Method serialize

src/state.ts:244–266  ·  view source on GitHub ↗

* Serializes the state into the url hash.

()

Source from the content-addressed store, hash-verified

242 * Serializes the state into the url hash.
243 */
244 serialize() {
245 // Serialize regular properties.
246 let props: string[] = [];
247 State.PROPS.forEach(({name, type, keyMap}) => {
248 let value = this[name];
249 // Don't serialize missing values.
250 if (value == null) {
251 return;
252 }
253 if (type === Type.OBJECT) {
254 value = getKeyFromValue(keyMap, value);
255 } else if (type === Type.ARRAY_NUMBER ||
256 type === Type.ARRAY_STRING) {
257 value = value.join(",");
258 }
259 props.push(`${name}=${value}`);
260 });
261 // Serialize properties that correspond to hiding UI controls.
262 getHideProps(this).forEach(prop => {
263 props.push(`${prop}=${this[prop]}`);
264 });
265 window.location.hash = props.join("&");
266 }
267
268 /** Returns all the hidden properties. */
269 getHiddenProps(): string[] {

Callers 4

makeGUIFunction · 0.80
resetFunction · 0.80
hideControlsFunction · 0.80
generateDataFunction · 0.80

Calls 2

getKeyFromValueFunction · 0.85
getHidePropsFunction · 0.85

Tested by

no test coverage detected