Răsfoiți Sursa

feature: add new clear() method

Ryan Chandler 4 ani în urmă
părinte
comite
e5cfceb0b9
7 a modificat fișierele cu 8 adăugiri și 0 ștergeri
  1. 0 0
      dist/spruce.js
  2. 0 0
      dist/spruce.js.map
  3. 0 0
      dist/spruce.module.js
  4. 0 0
      dist/spruce.module.js.map
  5. 0 0
      dist/spruce.umd.js
  6. 0 0
      dist/spruce.umd.js.map
  7. 8 0
      src/index.js

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.js.map


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.module.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.module.js.map


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.umd.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/spruce.umd.js.map


+ 8 - 0
src/index.js

@@ -180,6 +180,10 @@ const Spruce = {
         return this.set(name, ! this.get(name))
         return this.set(name, ! this.get(name))
     },
     },
 
 
+    clear(name) {
+        return this.persistenceDriver.removeItem(`__spruce:${name}`)
+    },
+
     watch(name, callback) {
     watch(name, callback) {
         if (! this.hasStarted) {
         if (! this.hasStarted) {
             this.watchers[name] || (this.watchers[name] = [])
             this.watchers[name] || (this.watchers[name] = [])
@@ -250,6 +254,10 @@ const Spruce = {
             throw new Error('[Spruce] The persistence driver must have a `setItem(key, value)` method.')
             throw new Error('[Spruce] The persistence driver must have a `setItem(key, value)` method.')
         }
         }
 
 
+        if (typeof driver.removeItem !== 'function') {
+            throw new Error('[Spruce] The persistence driver must have a `removeItem(name)` method.')
+        }
+
         this.persistenceDriver = driver
         this.persistenceDriver = driver
     }
     }
 }
 }

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff