@better-media/adapter-storage-memory 0.1.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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +36 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 abenezeratnafu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
20
|
+
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @better-media/adapter-storage-memory
|
|
2
|
+
|
|
3
|
+
In-memory storage adapter for the Better Media framework.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
A non-persistent storage adapter intended for testing, CI/CD, and rapid development. Stores all binary data as buffers in memory.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { In-MemoryStorageAdapter } from "@better-media/adapter-storage-memory";
|
|
13
|
+
|
|
14
|
+
const storage = new In-MemoryStorageAdapter();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Visit [better-media.dev/docs/adapters/storage-memory](https://better-media.dev/docs/adapters/storage-memory) for details.
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stream = require('stream');
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
function memoryStorage() {
|
|
7
|
+
const store = /* @__PURE__ */ new Map();
|
|
8
|
+
return {
|
|
9
|
+
async get(key) {
|
|
10
|
+
return store.get(key) ?? null;
|
|
11
|
+
},
|
|
12
|
+
async put(key, value) {
|
|
13
|
+
store.set(key, value);
|
|
14
|
+
},
|
|
15
|
+
async delete(key) {
|
|
16
|
+
store.delete(key);
|
|
17
|
+
},
|
|
18
|
+
async getSize(key) {
|
|
19
|
+
const buf = store.get(key);
|
|
20
|
+
return buf != null ? buf.length : null;
|
|
21
|
+
},
|
|
22
|
+
async getStream(key) {
|
|
23
|
+
const buf = store.get(key);
|
|
24
|
+
if (buf == null) return null;
|
|
25
|
+
return stream.Readable.from(buf);
|
|
26
|
+
},
|
|
27
|
+
async exists(key) {
|
|
28
|
+
return store.has(key);
|
|
29
|
+
},
|
|
30
|
+
async clear() {
|
|
31
|
+
store.clear();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.memoryStorage = memoryStorage;
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["Readable"],"mappings":";;;;;AAOO,SAAS,aAAA,GAAgC;AAC9C,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAoB;AAEtC,EAAA,OAAO;AAAA,IACL,MAAM,IAAI,GAAA,EAAa;AACrB,MAAA,OAAO,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA,IAAK,IAAA;AAAA,IAC3B,CAAA;AAAA,IACA,MAAM,GAAA,CAAI,GAAA,EAAa,KAAA,EAAe;AACpC,MAAA,KAAA,CAAM,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,MAAM,OAAO,GAAA,EAAa;AACxB,MAAA,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA,IAClB,CAAA;AAAA,IACA,MAAM,QAAQ,GAAA,EAAa;AACzB,MAAA,MAAM,GAAA,GAAM,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA;AACzB,MAAA,OAAO,GAAA,IAAO,IAAA,GAAO,GAAA,CAAI,MAAA,GAAS,IAAA;AAAA,IACpC,CAAA;AAAA,IACA,MAAM,UAAU,GAAA,EAAa;AAC3B,MAAA,MAAM,GAAA,GAAM,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA;AACzB,MAAA,IAAI,GAAA,IAAO,MAAM,OAAO,IAAA;AACxB,MAAA,OAAOA,eAAA,CAAS,KAAK,GAAG,CAAA;AAAA,IAC1B,CAAA;AAAA,IACA,MAAM,OAAO,GAAA,EAAa;AACxB,MAAA,OAAO,KAAA,CAAM,IAAI,GAAG,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,MAAM,KAAA,GAAQ;AACZ,MAAA,KAAA,CAAM,KAAA,EAAM;AAAA,IACd;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import { Readable } from \"node:stream\";\nimport type { StorageAdapter } from \"@better-media/core\";\n\n/**\n * In-memory storage adapter for development/testing.\n * Data is lost when the process exits.\n */\nexport function memoryStorage(): StorageAdapter {\n const store = new Map<string, Buffer>();\n\n return {\n async get(key: string) {\n return store.get(key) ?? null;\n },\n async put(key: string, value: Buffer) {\n store.set(key, value);\n },\n async delete(key: string) {\n store.delete(key);\n },\n async getSize(key: string) {\n const buf = store.get(key);\n return buf != null ? buf.length : null;\n },\n async getStream(key: string) {\n const buf = store.get(key);\n if (buf == null) return null;\n return Readable.from(buf) as unknown as ReadableStream<Uint8Array>;\n },\n async exists(key: string) {\n return store.has(key);\n },\n async clear() {\n store.clear();\n },\n };\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
function memoryStorage() {
|
|
5
|
+
const store = /* @__PURE__ */ new Map();
|
|
6
|
+
return {
|
|
7
|
+
async get(key) {
|
|
8
|
+
return store.get(key) ?? null;
|
|
9
|
+
},
|
|
10
|
+
async put(key, value) {
|
|
11
|
+
store.set(key, value);
|
|
12
|
+
},
|
|
13
|
+
async delete(key) {
|
|
14
|
+
store.delete(key);
|
|
15
|
+
},
|
|
16
|
+
async getSize(key) {
|
|
17
|
+
const buf = store.get(key);
|
|
18
|
+
return buf != null ? buf.length : null;
|
|
19
|
+
},
|
|
20
|
+
async getStream(key) {
|
|
21
|
+
const buf = store.get(key);
|
|
22
|
+
if (buf == null) return null;
|
|
23
|
+
return Readable.from(buf);
|
|
24
|
+
},
|
|
25
|
+
async exists(key) {
|
|
26
|
+
return store.has(key);
|
|
27
|
+
},
|
|
28
|
+
async clear() {
|
|
29
|
+
store.clear();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { memoryStorage };
|
|
35
|
+
//# sourceMappingURL=index.mjs.map
|
|
36
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAOO,SAAS,aAAA,GAAgC;AAC9C,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAoB;AAEtC,EAAA,OAAO;AAAA,IACL,MAAM,IAAI,GAAA,EAAa;AACrB,MAAA,OAAO,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA,IAAK,IAAA;AAAA,IAC3B,CAAA;AAAA,IACA,MAAM,GAAA,CAAI,GAAA,EAAa,KAAA,EAAe;AACpC,MAAA,KAAA,CAAM,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,MAAM,OAAO,GAAA,EAAa;AACxB,MAAA,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA,IAClB,CAAA;AAAA,IACA,MAAM,QAAQ,GAAA,EAAa;AACzB,MAAA,MAAM,GAAA,GAAM,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA;AACzB,MAAA,OAAO,GAAA,IAAO,IAAA,GAAO,GAAA,CAAI,MAAA,GAAS,IAAA;AAAA,IACpC,CAAA;AAAA,IACA,MAAM,UAAU,GAAA,EAAa;AAC3B,MAAA,MAAM,GAAA,GAAM,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA;AACzB,MAAA,IAAI,GAAA,IAAO,MAAM,OAAO,IAAA;AACxB,MAAA,OAAO,QAAA,CAAS,KAAK,GAAG,CAAA;AAAA,IAC1B,CAAA;AAAA,IACA,MAAM,OAAO,GAAA,EAAa;AACxB,MAAA,OAAO,KAAA,CAAM,IAAI,GAAG,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,MAAM,KAAA,GAAQ;AACZ,MAAA,KAAA,CAAM,KAAA,EAAM;AAAA,IACd;AAAA,GACF;AACF","file":"index.mjs","sourcesContent":["import { Readable } from \"node:stream\";\nimport type { StorageAdapter } from \"@better-media/core\";\n\n/**\n * In-memory storage adapter for development/testing.\n * Data is lost when the process exits.\n */\nexport function memoryStorage(): StorageAdapter {\n const store = new Map<string, Buffer>();\n\n return {\n async get(key: string) {\n return store.get(key) ?? null;\n },\n async put(key: string, value: Buffer) {\n store.set(key, value);\n },\n async delete(key: string) {\n store.delete(key);\n },\n async getSize(key: string) {\n const buf = store.get(key);\n return buf != null ? buf.length : null;\n },\n async getStream(key: string) {\n const buf = store.get(key);\n if (buf == null) return null;\n return Readable.from(buf) as unknown as ReadableStream<Uint8Array>;\n },\n async exists(key: string) {\n return store.has(key);\n },\n async clear() {\n store.clear();\n },\n };\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@better-media/adapter-storage-memory",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "In-memory storage adapter for Better Media (development/testing)",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@better-media/core": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "Abenezer Atnafu",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/AbenezerAtnafu/better-media.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://better-media.dev",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/AbenezerAtnafu/better-media/issues"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"dev": "tsup --watch",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint": "eslint .",
|
|
41
|
+
"test": "jest"
|
|
42
|
+
}
|
|
43
|
+
}
|