MCPcopy
hub / github.com/jeromegn/Backbone.localStorage / _clear

Method _clear

src/localstorage.js:128–143  ·  view source on GitHub ↗

Clear localStorage for a collection * @returns {undefined}

()

Source from the content-addressed store, hash-verified

126 * @returns {undefined}
127 */
128 _clear() {
129 const local = this.localStorage();
130 const itemRe = new RegExp(`^${this.name}-`);
131
132 // Remove id-tracking item (e.g., "foo").
133 local.removeItem(this.name);
134
135 // Match all data items (e.g., "foo-ID") and remove.
136 for (let k in local) {
137 if (itemRe.test(k)) {
138 local.removeItem(k);
139 }
140 }
141
142 this.records.length = 0;
143 }
144
145 /** Number of items in localStorage
146 * @returns {integer} - Number of items

Callers

nothing calls this directly

Calls 1

localStorageMethod · 0.95

Tested by

no test coverage detected