tiny-storage-kogo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -0
- package/package.json +16 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var g=(i,e)=>{for(var r in e)s(i,r,{get:e[r],enumerable:!0})},f=(i,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!l.call(i,t)&&t!==r&&s(i,t,{get:()=>e[t],enumerable:!(n=a(e,t))||n.enumerable});return i};var x=i=>f(s({},"__esModule",{value:!0}),i);var c={};g(c,{TinyStorage:()=>o});module.exports=x(c);var o=class{prefix;constructor(e={}){this.prefix=e.prefix||"tiny_"}set(e,r,n){let t={value:r,expire:n?Date.now()+n*1e3:null};localStorage.setItem(this.prefix+e,JSON.stringify(t))}get(e){let r=localStorage.getItem(this.prefix+e);if(!r)return null;let{value:n,expire:t}=JSON.parse(r);return t&&Date.now()>t?(this.remove(e),null):n}remove(e){localStorage.removeItem(this.prefix+e)}};0&&(module.exports={TinyStorage});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface StorageOptions {
|
|
2
|
+
prefix?: string;
|
|
3
|
+
expire?: number;
|
|
4
|
+
}
|
|
5
|
+
declare class TinyStorage {
|
|
6
|
+
private prefix;
|
|
7
|
+
constructor(options?: StorageOptions);
|
|
8
|
+
set(key: string, value: any, expire?: number): void;
|
|
9
|
+
get(key: string): any;
|
|
10
|
+
remove(key: string): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { type StorageOptions, TinyStorage };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface StorageOptions {
|
|
2
|
+
prefix?: string;
|
|
3
|
+
expire?: number;
|
|
4
|
+
}
|
|
5
|
+
declare class TinyStorage {
|
|
6
|
+
private prefix;
|
|
7
|
+
constructor(options?: StorageOptions);
|
|
8
|
+
set(key: string, value: any, expire?: number): void;
|
|
9
|
+
get(key: string): any;
|
|
10
|
+
remove(key: string): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { type StorageOptions, TinyStorage };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=class{prefix;constructor(e={}){this.prefix=e.prefix||"tiny_"}set(e,t,r){let i={value:t,expire:r?Date.now()+r*1e3:null};localStorage.setItem(this.prefix+e,JSON.stringify(i))}get(e){let t=localStorage.getItem(this.prefix+e);if(!t)return null;let{value:r,expire:i}=JSON.parse(t);return i&&Date.now()>i?(this.remove(e),null):r}remove(e){localStorage.removeItem(this.prefix+e)}};export{n as TinyStorage};
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tiny-storage-kogo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A lightweight storage library with expiration.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean --minify",
|
|
14
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch --dts"
|
|
15
|
+
}
|
|
16
|
+
}
|