Skip to content

Commit 7972077

Browse files
committed
added namespace.clear() feature (marcuswestin#300)
1 parent b8e22fe commit 7972077

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/store-engine.js

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ var storeAPI = {
5252
this.storage.clearAll()
5353
},
5454

55+
56+
57+
// clear will remove all the stored key-value pairs in this namespace.
58+
clear: function() {
59+
let fn = (val, key) => {
60+
if (key.startsWith(this._namespacePrefix)) {
61+
this.storage.remove(key)
62+
}
63+
}
64+
this.storage.each(fn)
65+
},
66+
5567
// additional functionality that can't live in plugins
5668
// ---------------------------------------------------
5769

0 commit comments

Comments
 (0)