| 146 | * characters) - or all keys associated with this store if no prefix. |
| 147 | */ |
| 148 | clear(keyPrefix) { |
| 149 | const fullPrefix = storePrefix + (keyPrefix || ''); |
| 150 | const keyMatch = keyPrefixMatch(fullPrefix, keyPrefix ? '.' : ''); |
| 151 | const keysToRemove = []; |
| 152 | // 2-step process, so we don't depend on any particular behavior of |
| 153 | // key order while removing some |
| 154 | for (let i = 0; i < this._storage.length; i++) { |
| 155 | const fullKey = this._storage.key(i); |
| 156 | if (keyMatch(fullKey)) { |
| 157 | keysToRemove.push(fullKey); |
| 158 | } |
| 159 | } |
| 160 | forEach(k => this._storage.removeItem(k), keysToRemove); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | class MemStore { |