* 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)
| 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. |
no test coverage detected