-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobals.js
More file actions
34 lines (33 loc) · 1.03 KB
/
globals.js
File metadata and controls
34 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as fs from "fs";
import * as hdf5 from "h5wasm/node";
import { TestH5Group } from "./h5.js";
export const test_globals = {
get: (path, { asBuffer = false } = {}) => {
if (!asBuffer) {
return path;
} else {
return new Uint8Array(fs.readFileSync(path, null));
}
},
exists: path => fs.existsSync(path),
write: (path, contents) => {
if (!(contents instanceof Uint8Array)) {
throw new Error("expected 'contents' to be a Uint8Array");
}
fs.writeFileSync(path, contents);
},
clean: (path) => {}, // no-op
mkdir: path => fs.mkdirSync(path),
h5open: async function(path) {
await hdf5.ready;
let handle = new hdf5.File(path, "r");
return new TestH5Group(handle);
},
h5close: (handle) => {}, // no-op.
h5create: async function(path) {
await hdf5.ready;
let handle = new hdf5.File(path, "w");
return new TestH5Group(handle);
},
h5finish: (handle, failed) => null // no-op.
};