MCPcopy Index your code
hub / github.com/pyscript/pyscript / to_idb

Function to_idb

core/src/storage.js:6–22  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

4const { isView } = ArrayBuffer;
5
6const to_idb = (value) => {
7 if (value == null) return stringify(["null", 0]);
8 /* eslint-disable no-fallthrough */
9 switch (typeof value) {
10 case "object": {
11 if (isView(value)) return stringify(["memoryview", [...value]]);
12 if (value instanceof ArrayBuffer)
13 return stringify(["bytearray", [...new Uint8Array(value)]]);
14 }
15 case "string":
16 case "number":
17 case "boolean":
18 return stringify(["generic", value]);
19 default:
20 throw new TypeError(`Unexpected value: ${String(value)}`);
21 }
22};
23
24const from_idb = (value) => {
25 const [kind, result] = parse(value);

Callers 1

storageFunction · 0.85

Calls 1

stringifyFunction · 0.90

Tested by

no test coverage detected