Skip to content

Commit

Permalink
feat: add a patch for storejs to expose length of the store (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoumitaM committed Apr 17, 2024
1 parent f3a59a1 commit 36a13b0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LocalStorage implements IStorage {

setItem(key: string, value: any) {
store.set(key, value);
this.length = store.keys().length;
this.length = store.len();
}

// eslint-disable-next-line class-methods-use-this
Expand All @@ -49,7 +49,7 @@ class LocalStorage implements IStorage {

removeItem(key: string) {
store.remove(key);
this.length = store.keys().length;
this.length = store.len();
}

clear() {
Expand Down
55 changes: 55 additions & 0 deletions patches/storejs+2.0.7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/node_modules/storejs/dist/store.cjs.js b/node_modules/storejs/dist/store.cjs.js
index 3de4dd1..bea302a 100644
--- a/node_modules/storejs/dist/store.cjs.js
+++ b/node_modules/storejs/dist/store.cjs.js
@@ -144,6 +144,9 @@ Store.prototype = {
if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]);
}
return dt;
+ },
+ len: function len() {
+ return storage.length;
}
};
var _Store = null;
diff --git a/node_modules/storejs/dist/store.esm.js b/node_modules/storejs/dist/store.esm.js
index 9c7daf0..dcaa79f 100644
--- a/node_modules/storejs/dist/store.esm.js
+++ b/node_modules/storejs/dist/store.esm.js
@@ -142,6 +142,9 @@ Store.prototype = {
if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]);
}
return dt;
+ },
+ len: function len() {
+ return storage.length;
}
};
var _Store = null;
diff --git a/node_modules/storejs/dist/store.js b/node_modules/storejs/dist/store.js
index f5d95a5..ff20315 100644
--- a/node_modules/storejs/dist/store.js
+++ b/node_modules/storejs/dist/store.js
@@ -148,6 +148,9 @@
if (arr[i].indexOf(str) > -1) dt[arr[i]] = this.get(arr[i]);
}
return dt;
+ },
+ len: function len() {
+ return storage.length;
}
};
var _Store = null;
diff --git a/node_modules/storejs/types/index.d.ts b/node_modules/storejs/types/index.d.ts
index 9ea1ef8..4ae8abe 100644
--- a/node_modules/storejs/types/index.d.ts
+++ b/node_modules/storejs/types/index.d.ts
@@ -30,6 +30,8 @@ declare class Store {
search(keyword: string): Record<string, any>

clear(): Store
+
+ len(): number
}

declare let s: typeof store & Store

0 comments on commit 36a13b0

Please sign in to comment.