MCPcopy Create free account
hub / github.com/FThompson/FormPersistence.js / save

Function save

form-persistence.js:175–184  ·  view source on GitHub ↗

* Saves the given form to local or session storage. * * @param {HTMLFormElement} form The form to serialize to local storage. * @param {Object} options Options object containing any of the following: * * uuid - A unique identifier for this form's storage key. *

(form, options)

Source from the content-addressed store, hash-verified

173 * is excluded if the function returns true.
174 */
175 function save(form, options) {
176 let defaults = {
177 uuid: null,
178 useSessionStorage: false
179 }
180 let config = Object.assign({}, defaults, options)
181 let data = serialize(form, config)
182 let storage = config.useSessionStorage ? sessionStorage : localStorage
183 storage.setItem(getStorageKey(form, config.uuid), JSON.stringify(data))
184 }
185
186 /**
187 * Loads a given form by deserializing given data, optionally with given special value handling functions.

Callers 1

saveFormFunction · 0.85

Calls 2

serializeFunction · 0.85
getStorageKeyFunction · 0.85

Tested by

no test coverage detected