From 1b081e0ef3995259d602e3f0a2f29acc94617aca Mon Sep 17 00:00:00 2001 From: bat Date: Sun, 7 May 2023 04:53:46 +0000 Subject: [PATCH] add plugin support --- storage.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/storage.js b/storage.js index 51d135d..0cf7f6c 100644 --- a/storage.js +++ b/storage.js @@ -27,9 +27,20 @@ class Session { export class Storage { constructor() { this.session = new Session() + this.plugins = [] + } + + addPlugin(plugin) { + this.plugins.push(plugin) } getItem(k) { + for (const plugin of this.plugins) { + const result = plugin(k) + if (result ?? undefined !== undefined) { + return result + } + } return localStorage.getItem(k) }