@casfa/storage-memory 0.1.0 → 0.3.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/README.md CHANGED
@@ -28,12 +28,6 @@ await storage.put('node:abcd1234...', data);
28
28
 
29
29
  // Retrieve data
30
30
  const data = await storage.get('node:abcd1234...');
31
-
32
- // Check existence
33
- const exists = await storage.has('node:abcd1234...');
34
-
35
- // Delete
36
- const deleted = await storage.delete('node:abcd1234...');
37
31
  ```
38
32
 
39
33
  ### With Inspection (Testing)
@@ -89,8 +83,6 @@ interface MemoryStorageConfig {
89
83
  interface StorageProvider {
90
84
  get(key: string): Promise<Uint8Array | null>;
91
85
  put(key: string, data: Uint8Array): Promise<void>;
92
- has(key: string): Promise<boolean>;
93
- delete(key: string): Promise<boolean>;
94
86
  }
95
87
  ```
96
88
 
package/README.zh-CN.md CHANGED
@@ -28,12 +28,6 @@ await storage.put('node:abcd1234...', data);
28
28
 
29
29
  // 检索数据
30
30
  const data = await storage.get('node:abcd1234...');
31
-
32
- // 检查是否存在
33
- const exists = await storage.has('node:abcd1234...');
34
-
35
- // 删除
36
- const deleted = await storage.delete('node:abcd1234...');
37
31
  ```
38
32
 
39
33
  ### 带检查功能(测试用)
@@ -89,8 +83,6 @@ interface MemoryStorageConfig {
89
83
  interface StorageProvider {
90
84
  get(key: string): Promise<Uint8Array | null>;
91
85
  put(key: string, data: Uint8Array): Promise<void>;
92
- has(key: string): Promise<boolean>;
93
- delete(key: string): Promise<boolean>;
94
86
  }
95
87
  ```
96
88
 
package/dist/index.d.ts CHANGED
@@ -1,39 +1,7 @@
1
- import { StorageProvider } from '@casfa/storage-core';
2
-
3
1
  /**
4
- * In-Memory Storage Provider for CAS
2
+ * CAS Storage Memory
5
3
  *
6
- * Useful for testing and local development.
4
+ * In-memory storage provider for CAS (testing and development).
7
5
  */
8
-
9
- /**
10
- * Memory Storage configuration
11
- */
12
- type MemoryStorageConfig = {
13
- /** Optional initial data */
14
- initialData?: Map<string, Uint8Array>;
15
- };
16
- /**
17
- * Create an in-memory storage provider
18
- */
19
- declare const createMemoryStorage: (config?: MemoryStorageConfig) => StorageProvider;
20
- /**
21
- * Create memory storage with inspection methods (for testing)
22
- */
23
- declare const createMemoryStorageWithInspection: (config?: MemoryStorageConfig) => {
24
- /** Clear all stored data */
25
- clear: () => void;
26
- /** Get number of stored items */
27
- size: () => number;
28
- /** Get all stored keys */
29
- keys: () => string[];
30
- /** Delete a specific key */
31
- delete: (key: string) => boolean;
32
- /** Get raw data map (for inspection) */
33
- getData: () => Map<string, Uint8Array<ArrayBufferLike>>;
34
- has: (key: string) => Promise<boolean>;
35
- get: (key: string) => Promise<Uint8Array | null>;
36
- put: (key: string, value: Uint8Array) => Promise<void>;
37
- };
38
-
39
- export { type MemoryStorageConfig, createMemoryStorage, createMemoryStorageWithInspection };
6
+ export { createMemoryStorage, createMemoryStorageWithInspection, type MemoryStorageConfig, } from "./memory-storage.ts";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,iCAAiC,EACjC,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  // src/memory-storage.ts
2
2
  var createMemoryStorage = (config = {}) => {
3
- const data = config.initialData ?? /* @__PURE__ */ new Map();
3
+ const data = config.initialData ?? new Map;
4
4
  return {
5
- has: async (key) => data.has(key),
6
5
  get: async (key) => data.get(key) ?? null,
7
6
  put: async (key, value) => {
8
7
  data.set(key, value);
@@ -10,9 +9,8 @@ var createMemoryStorage = (config = {}) => {
10
9
  };
11
10
  };
12
11
  var createMemoryStorageWithInspection = (config = {}) => {
13
- const data = config.initialData ?? /* @__PURE__ */ new Map();
12
+ const data = config.initialData ?? new Map;
14
13
  const storage = {
15
- has: async (key) => data.has(key),
16
14
  get: async (key) => data.get(key) ?? null,
17
15
  put: async (key, value) => {
18
16
  data.set(key, value);
@@ -20,20 +18,16 @@ var createMemoryStorageWithInspection = (config = {}) => {
20
18
  };
21
19
  return {
22
20
  ...storage,
23
- /** Clear all stored data */
24
21
  clear: () => data.clear(),
25
- /** Get number of stored items */
26
22
  size: () => data.size,
27
- /** Get all stored keys */
28
23
  keys: () => Array.from(data.keys()),
29
- /** Delete a specific key */
30
24
  delete: (key) => data.delete(key),
31
- /** Get raw data map (for inspection) */
32
25
  getData: () => data
33
26
  };
34
27
  };
35
28
  export {
36
- createMemoryStorage,
37
- createMemoryStorageWithInspection
29
+ createMemoryStorageWithInspection,
30
+ createMemoryStorage
38
31
  };
39
- //# sourceMappingURL=index.js.map
32
+
33
+ //# debugId=64ED1D2374BB756B64756E2164756E21
package/dist/index.js.map CHANGED
@@ -1 +1,10 @@
1
- {"version":3,"sources":["../src/memory-storage.ts"],"sourcesContent":["/**\n * In-Memory Storage Provider for CAS\n *\n * Useful for testing and local development.\n */\n\nimport type { StorageProvider } from \"@casfa/storage-core\";\n\n/**\n * Memory Storage configuration\n */\nexport type MemoryStorageConfig = {\n /** Optional initial data */\n initialData?: Map<string, Uint8Array>;\n};\n\n/**\n * Create an in-memory storage provider\n */\nexport const createMemoryStorage = (config: MemoryStorageConfig = {}): StorageProvider => {\n const data = config.initialData ?? new Map<string, Uint8Array>();\n\n return {\n has: async (key) => data.has(key),\n get: async (key) => data.get(key) ?? null,\n put: async (key, value) => {\n data.set(key, value);\n },\n };\n};\n\n/**\n * Create memory storage with inspection methods (for testing)\n */\nexport const createMemoryStorageWithInspection = (config: MemoryStorageConfig = {}) => {\n const data = config.initialData ?? new Map<string, Uint8Array>();\n\n const storage: StorageProvider = {\n has: async (key) => data.has(key),\n get: async (key) => data.get(key) ?? null,\n put: async (key, value) => {\n data.set(key, value);\n },\n };\n\n return {\n ...storage,\n /** Clear all stored data */\n clear: () => data.clear(),\n /** Get number of stored items */\n size: () => data.size,\n /** Get all stored keys */\n keys: () => Array.from(data.keys()),\n /** Delete a specific key */\n delete: (key: string) => data.delete(key),\n /** Get raw data map (for inspection) */\n getData: () => data,\n };\n};\n"],"mappings":";AAmBO,IAAM,sBAAsB,CAAC,SAA8B,CAAC,MAAuB;AACxF,QAAM,OAAO,OAAO,eAAe,oBAAI,IAAwB;AAE/D,SAAO;AAAA,IACL,KAAK,OAAO,QAAQ,KAAK,IAAI,GAAG;AAAA,IAChC,KAAK,OAAO,QAAQ,KAAK,IAAI,GAAG,KAAK;AAAA,IACrC,KAAK,OAAO,KAAK,UAAU;AACzB,WAAK,IAAI,KAAK,KAAK;AAAA,IACrB;AAAA,EACF;AACF;AAKO,IAAM,oCAAoC,CAAC,SAA8B,CAAC,MAAM;AACrF,QAAM,OAAO,OAAO,eAAe,oBAAI,IAAwB;AAE/D,QAAM,UAA2B;AAAA,IAC/B,KAAK,OAAO,QAAQ,KAAK,IAAI,GAAG;AAAA,IAChC,KAAK,OAAO,QAAQ,KAAK,IAAI,GAAG,KAAK;AAAA,IACrC,KAAK,OAAO,KAAK,UAAU;AACzB,WAAK,IAAI,KAAK,KAAK;AAAA,IACrB;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA;AAAA,IAEH,OAAO,MAAM,KAAK,MAAM;AAAA;AAAA,IAExB,MAAM,MAAM,KAAK;AAAA;AAAA,IAEjB,MAAM,MAAM,MAAM,KAAK,KAAK,KAAK,CAAC;AAAA;AAAA,IAElC,QAAQ,CAAC,QAAgB,KAAK,OAAO,GAAG;AAAA;AAAA,IAExC,SAAS,MAAM;AAAA,EACjB;AACF;","names":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/memory-storage.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * In-Memory Storage Provider for CAS\n *\n * Useful for testing and local development.\n */\n\nimport type { StorageProvider } from \"@casfa/storage-core\";\n\n/**\n * Memory Storage configuration\n */\nexport type MemoryStorageConfig = {\n /** Optional initial data */\n initialData?: Map<string, Uint8Array>;\n};\n\n/**\n * Create an in-memory storage provider\n */\nexport const createMemoryStorage = (config: MemoryStorageConfig = {}): StorageProvider => {\n const data = config.initialData ?? new Map<string, Uint8Array>();\n\n return {\n get: async (key) => data.get(key) ?? null,\n put: async (key, value) => {\n data.set(key, value);\n },\n };\n};\n\n/**\n * Create memory storage with inspection methods (for testing)\n */\nexport const createMemoryStorageWithInspection = (config: MemoryStorageConfig = {}) => {\n const data = config.initialData ?? new Map<string, Uint8Array>();\n\n const storage: StorageProvider = {\n get: async (key) => data.get(key) ?? null,\n put: async (key, value) => {\n data.set(key, value);\n },\n };\n\n return {\n ...storage,\n /** Clear all stored data */\n clear: () => data.clear(),\n /** Get number of stored items */\n size: () => data.size,\n /** Get all stored keys */\n keys: () => Array.from(data.keys()),\n /** Delete a specific key */\n delete: (key: string) => data.delete(key),\n /** Get raw data map (for inspection) */\n getData: () => data,\n };\n};\n"
6
+ ],
7
+ "mappings": ";AAmBO,IAAM,sBAAsB,CAAC,SAA8B,CAAC,MAAuB;AAAA,EACxF,MAAM,OAAO,OAAO,eAAe,IAAI;AAAA,EAEvC,OAAO;AAAA,IACL,KAAK,OAAO,QAAQ,KAAK,IAAI,GAAG,KAAK;AAAA,IACrC,KAAK,OAAO,KAAK,UAAU;AAAA,MACzB,KAAK,IAAI,KAAK,KAAK;AAAA;AAAA,EAEvB;AAAA;AAMK,IAAM,oCAAoC,CAAC,SAA8B,CAAC,MAAM;AAAA,EACrF,MAAM,OAAO,OAAO,eAAe,IAAI;AAAA,EAEvC,MAAM,UAA2B;AAAA,IAC/B,KAAK,OAAO,QAAQ,KAAK,IAAI,GAAG,KAAK;AAAA,IACrC,KAAK,OAAO,KAAK,UAAU;AAAA,MACzB,KAAK,IAAI,KAAK,KAAK;AAAA;AAAA,EAEvB;AAAA,EAEA,OAAO;AAAA,OACF;AAAA,IAEH,OAAO,MAAM,KAAK,MAAM;AAAA,IAExB,MAAM,MAAM,KAAK;AAAA,IAEjB,MAAM,MAAM,MAAM,KAAK,KAAK,KAAK,CAAC;AAAA,IAElC,QAAQ,CAAC,QAAgB,KAAK,OAAO,GAAG;AAAA,IAExC,SAAS,MAAM;AAAA,EACjB;AAAA;",
8
+ "debugId": "64ED1D2374BB756B64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * In-Memory Storage Provider for CAS
3
+ *
4
+ * Useful for testing and local development.
5
+ */
6
+ import type { StorageProvider } from "@casfa/storage-core";
7
+ /**
8
+ * Memory Storage configuration
9
+ */
10
+ export type MemoryStorageConfig = {
11
+ /** Optional initial data */
12
+ initialData?: Map<string, Uint8Array>;
13
+ };
14
+ /**
15
+ * Create an in-memory storage provider
16
+ */
17
+ export declare const createMemoryStorage: (config?: MemoryStorageConfig) => StorageProvider;
18
+ /**
19
+ * Create memory storage with inspection methods (for testing)
20
+ */
21
+ export declare const createMemoryStorageWithInspection: (config?: MemoryStorageConfig) => {
22
+ /** Clear all stored data */
23
+ clear: () => void;
24
+ /** Get number of stored items */
25
+ size: () => number;
26
+ /** Get all stored keys */
27
+ keys: () => string[];
28
+ /** Delete a specific key */
29
+ delete: (key: string) => boolean;
30
+ /** Get raw data map (for inspection) */
31
+ getData: () => Map<string, Uint8Array<ArrayBufferLike>>;
32
+ get: (key: string) => Promise<Uint8Array | null>;
33
+ put: (key: string, value: Uint8Array) => Promise<void>;
34
+ };
35
+ //# sourceMappingURL=memory-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-storage.d.ts","sourceRoot":"","sources":["../src/memory-storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,4BAA4B;IAC5B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAQ,mBAAwB,KAAG,eAStE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAQ,mBAAwB;IAY9E,4BAA4B;;IAE5B,iCAAiC;;IAEjC,0BAA0B;;IAE1B,4BAA4B;kBACd,MAAM;IACpB,wCAAwC;;;;CAG3C,CAAC"}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@casfa/storage-memory",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "In-memory storage provider for CAS (testing)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "bun": "./src/index.ts",
10
11
  "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.js"
12
13
  }
13
14
  },
14
15
  "scripts": {
15
- "build": "tsup",
16
- "dev": "tsup --watch",
16
+ "build": "bun ../../scripts/build-pkg.ts",
17
17
  "typecheck": "tsc --noEmit",
18
18
  "lint": "biome check .",
19
19
  "lint:fix": "biome check --write .",