memfs 4.1.0-next.2 → 4.1.0-next.3
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 +5 -4
- package/demo/runkit.js +5 -0
- package/lib/Dirent.js +1 -0
- package/lib/Dirent.js.map +1 -0
- package/lib/Stats.js +2 -2
- package/lib/Stats.js.map +1 -0
- package/lib/__tests__/util.js +1 -0
- package/lib/__tests__/util.js.map +1 -0
- package/lib/cas/types.js +1 -0
- package/lib/cas/types.js.map +1 -0
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -0
- package/lib/consts/AMODE.js +1 -0
- package/lib/consts/AMODE.js.map +1 -0
- package/lib/consts/FLAG.d.ts +6 -0
- package/lib/consts/FLAG.js +1 -0
- package/lib/consts/FLAG.js.map +1 -0
- package/lib/crud/__tests__/matryoshka.test.d.ts +1 -0
- package/lib/crud/__tests__/matryoshka.test.js +69 -0
- package/lib/crud/__tests__/matryoshka.test.js.map +1 -0
- package/lib/crud/__tests__/testCrudfs.d.ts +6 -0
- package/lib/crud/__tests__/testCrudfs.js +279 -0
- package/lib/crud/__tests__/testCrudfs.js.map +1 -0
- package/lib/crud/types.d.ts +7 -0
- package/lib/crud/types.js +1 -0
- package/lib/crud/types.js.map +1 -0
- package/lib/crud/util.d.ts +2 -0
- package/lib/crud/util.js +11 -0
- package/lib/crud/util.js.map +1 -0
- package/lib/crud-to-cas/CrudCas.js +10 -17
- package/lib/crud-to-cas/CrudCas.js.map +1 -0
- package/lib/crud-to-cas/__tests__/CrudCas.test.js +29 -116
- package/lib/crud-to-cas/__tests__/CrudCas.test.js.map +1 -0
- package/lib/crud-to-cas/__tests__/testCasfs.d.ts +9 -0
- package/lib/crud-to-cas/__tests__/testCasfs.js +109 -0
- package/lib/crud-to-cas/__tests__/testCasfs.js.map +1 -0
- package/lib/crud-to-cas/index.d.ts +1 -0
- package/lib/crud-to-cas/index.js +6 -0
- package/lib/crud-to-cas/index.js.map +1 -0
- package/lib/crud-to-cas/util.js +1 -0
- package/lib/crud-to-cas/util.js.map +1 -0
- package/lib/encoding.js +1 -0
- package/lib/encoding.js.map +1 -0
- package/lib/fsa/types.js +1 -0
- package/lib/fsa/types.js.map +1 -0
- package/lib/fsa-to-crud/FsaCrud.d.ts +1 -0
- package/lib/fsa-to-crud/FsaCrud.js +36 -54
- package/lib/fsa-to-crud/FsaCrud.js.map +1 -0
- package/lib/fsa-to-crud/__tests__/FsaCrud.test.js +3 -280
- package/lib/fsa-to-crud/__tests__/FsaCrud.test.js.map +1 -0
- package/lib/fsa-to-crud/index.d.ts +1 -0
- package/lib/fsa-to-crud/index.js +6 -0
- package/lib/fsa-to-crud/index.js.map +1 -0
- package/lib/fsa-to-crud/util.d.ts +5 -2
- package/lib/fsa-to-crud/util.js +10 -8
- package/lib/fsa-to-crud/util.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeCore.d.ts +3 -2
- package/lib/fsa-to-node/FsaNodeCore.js +61 -22
- package/lib/fsa-to-node/FsaNodeCore.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeDirent.js +1 -0
- package/lib/fsa-to-node/FsaNodeDirent.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeFs.d.ts +14 -2
- package/lib/fsa-to-node/FsaNodeFs.js +97 -82
- package/lib/fsa-to-node/FsaNodeFs.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeFsOpenFile.js +4 -11
- package/lib/fsa-to-node/FsaNodeFsOpenFile.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeReadStream.js +4 -11
- package/lib/fsa-to-node/FsaNodeReadStream.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeStats.js +1 -0
- package/lib/fsa-to-node/FsaNodeStats.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeWriteStream.js +7 -14
- package/lib/fsa-to-node/FsaNodeWriteStream.js.map +1 -0
- package/lib/fsa-to-node/__tests__/FsaNodeFs.test.js +107 -93
- package/lib/fsa-to-node/__tests__/FsaNodeFs.test.js.map +1 -0
- package/lib/fsa-to-node/__tests__/util.test.js +4 -0
- package/lib/fsa-to-node/__tests__/util.test.js.map +1 -0
- package/lib/fsa-to-node/constants.js +1 -0
- package/lib/fsa-to-node/constants.js.map +1 -0
- package/lib/fsa-to-node/index.js +1 -0
- package/lib/fsa-to-node/index.js.map +1 -0
- package/lib/fsa-to-node/json.js +1 -0
- package/lib/fsa-to-node/json.js.map +1 -0
- package/lib/fsa-to-node/types.js +1 -0
- package/lib/fsa-to-node/types.js.map +1 -0
- package/lib/fsa-to-node/util.js +5 -10
- package/lib/fsa-to-node/util.js.map +1 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js +3 -10
- package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js.map +1 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js +23 -30
- package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js.map +1 -0
- package/lib/fsa-to-node/worker/SyncMessenger.js +3 -10
- package/lib/fsa-to-node/worker/SyncMessenger.js.map +1 -0
- package/lib/fsa-to-node/worker/constants.js +1 -0
- package/lib/fsa-to-node/worker/constants.js.map +1 -0
- package/lib/fsa-to-node/worker/types.js +1 -0
- package/lib/fsa-to-node/worker/types.js.map +1 -0
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -0
- package/lib/internal/buffer.js +1 -0
- package/lib/internal/buffer.js.map +1 -0
- package/lib/internal/errors.js +1 -0
- package/lib/internal/errors.js.map +1 -0
- package/lib/node/FileHandle.js +1 -0
- package/lib/node/FileHandle.js.map +1 -0
- package/lib/node/FsPromises.d.ts +86 -0
- package/lib/node/FsPromises.js +54 -0
- package/lib/node/FsPromises.js.map +1 -0
- package/lib/node/constants.js +2 -1
- package/lib/node/constants.js.map +1 -0
- package/lib/node/lists/fsCallbackApiList.d.ts +2 -0
- package/lib/node/lists/fsCallbackApiList.js +47 -0
- package/lib/node/lists/fsCallbackApiList.js.map +1 -0
- package/lib/node/lists/fsCommonObjectsList.d.ts +2 -0
- package/lib/node/lists/fsCommonObjectsList.js +19 -0
- package/lib/node/lists/fsCommonObjectsList.js.map +1 -0
- package/lib/node/lists/fsSynchronousApiList.d.ts +2 -0
- package/lib/node/lists/fsSynchronousApiList.js +46 -0
- package/lib/node/lists/fsSynchronousApiList.js.map +1 -0
- package/lib/node/options.js +1 -0
- package/lib/node/options.js.map +1 -0
- package/lib/node/types/{callback.d.ts → FsCallbackApi.d.ts} +49 -40
- package/lib/node/types/{callback.js → FsCallbackApi.js} +1 -0
- package/lib/node/types/FsCallbackApi.js.map +1 -0
- package/lib/node/types/FsCommonObjects.d.ts +4 -4
- package/lib/node/types/FsCommonObjects.js +1 -0
- package/lib/node/types/FsCommonObjects.js.map +1 -0
- package/lib/node/types/{promises.d.ts → FsPromisesApi.d.ts} +11 -0
- package/lib/node/types/{promises.js → FsPromisesApi.js} +1 -0
- package/lib/node/types/FsPromisesApi.js.map +1 -0
- package/lib/node/types/FsSynchronousApi.d.ts +64 -58
- package/lib/node/types/FsSynchronousApi.js +1 -0
- package/lib/node/types/FsSynchronousApi.js.map +1 -0
- package/lib/node/types/index.d.ts +2 -2
- package/lib/node/types/index.js +1 -0
- package/lib/node/types/index.js.map +1 -0
- package/lib/node/types/misc.d.ts +20 -0
- package/lib/node/types/misc.js +1 -0
- package/lib/node/types/misc.js.map +1 -0
- package/lib/node/types/options.d.ts +62 -0
- package/lib/node/types/options.js +1 -0
- package/lib/node/types/options.js.map +1 -0
- package/lib/node/util.d.ts +2 -1
- package/lib/node/util.js +30 -1
- package/lib/node/util.js.map +1 -0
- package/lib/node-to-crud/NodeCrud.d.ts +22 -0
- package/lib/node-to-crud/NodeCrud.js +235 -0
- package/lib/node-to-crud/NodeCrud.js.map +1 -0
- package/lib/node-to-crud/__tests__/FsaCrud.test.d.ts +1 -0
- package/lib/node-to-crud/__tests__/FsaCrud.test.js +18 -0
- package/lib/node-to-crud/__tests__/FsaCrud.test.js.map +1 -0
- package/lib/node-to-crud/index.d.ts +1 -0
- package/lib/node-to-crud/index.js +6 -0
- package/lib/node-to-crud/index.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.d.ts +3 -2
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js +24 -55
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemFileHandle.js +5 -12
- package/lib/node-to-fsa/NodeFileSystemFileHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemHandle.js +3 -10
- package/lib/node-to-fsa/NodeFileSystemHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js +8 -15
- package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js +11 -18
- package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js.map +1 -0
- package/lib/node-to-fsa/NodePermissionStatus.js +1 -0
- package/lib/node-to-fsa/NodePermissionStatus.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.js +75 -134
- package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.js +16 -23
- package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.js +5 -12
- package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.js +15 -22
- package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.js +8 -15
- package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/scenarios.test.js +3 -10
- package/lib/node-to-fsa/__tests__/scenarios.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/util.test.js +5 -0
- package/lib/node-to-fsa/__tests__/util.test.js.map +1 -0
- package/lib/node-to-fsa/index.js +6 -18
- package/lib/node-to-fsa/index.js.map +1 -0
- package/lib/node-to-fsa/types.d.ts +5 -2
- package/lib/node-to-fsa/types.js +1 -0
- package/lib/node-to-fsa/types.js.map +1 -0
- package/lib/node-to-fsa/util.js +3 -0
- package/lib/node-to-fsa/util.js.map +1 -0
- package/lib/node.js +1 -0
- package/lib/node.js.map +1 -0
- package/lib/process.js +1 -0
- package/lib/process.js.map +1 -0
- package/lib/setImmediate.js +1 -0
- package/lib/setImmediate.js.map +1 -0
- package/lib/setTimeoutUnref.js +1 -0
- package/lib/setTimeoutUnref.js.map +1 -0
- package/lib/volume-localstorage.js +1 -0
- package/lib/volume-localstorage.js.map +1 -0
- package/lib/volume.d.ts +15 -7
- package/lib/volume.js +20 -16
- package/lib/volume.js.map +1 -0
- package/lib/webfs/index.js +1 -0
- package/lib/webfs/index.js.map +1 -0
- package/package.json +60 -26
- package/lib/getBigInt.js +0 -5
- package/lib/node/promises.d.ts +0 -2
- package/lib/node/promises.js +0 -86
|
@@ -1,294 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const thingies_1 = require("thingies");
|
|
13
3
|
const __1 = require("../..");
|
|
14
4
|
const util_1 = require("../../__tests__/util");
|
|
15
5
|
const node_to_fsa_1 = require("../../node-to-fsa");
|
|
16
6
|
const FsaCrud_1 = require("../FsaCrud");
|
|
7
|
+
const testCrudfs_1 = require("../../crud/__tests__/testCrudfs");
|
|
17
8
|
const setup = () => {
|
|
18
9
|
const fs = (0, __1.memfs)();
|
|
19
10
|
const fsa = new node_to_fsa_1.NodeFileSystemDirectoryHandle(fs, '/', { mode: 'readwrite' });
|
|
20
11
|
const crud = new FsaCrud_1.FsaCrud(fsa);
|
|
21
12
|
return { fs, fsa, crud, snapshot: () => fs.__vol.toJSON() };
|
|
22
13
|
};
|
|
23
|
-
const b = (str) => {
|
|
24
|
-
const buf = Buffer.from(str);
|
|
25
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
26
|
-
};
|
|
27
14
|
(0, util_1.onlyOnNode20)('FsaCrud', () => {
|
|
28
|
-
|
|
29
|
-
test('throws if the type is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const { crud } = setup();
|
|
31
|
-
const [, err] = yield (0, thingies_1.of)(crud.put(['.', 'foo'], 'bar', new Uint8Array()));
|
|
32
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
33
|
-
expect(err.message).toBe("Failed to execute 'put' on 'crudfs': Name is not allowed.");
|
|
34
|
-
}));
|
|
35
|
-
test('throws if id is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
const { crud } = setup();
|
|
37
|
-
const [, err] = yield (0, thingies_1.of)(crud.put(['foo'], '..', new Uint8Array()));
|
|
38
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
39
|
-
expect(err.message).toBe("Failed to execute 'put' on 'crudfs': Name is not allowed.");
|
|
40
|
-
}));
|
|
41
|
-
test('can store a resource at root', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
const { crud, snapshot } = setup();
|
|
43
|
-
yield crud.put([], 'bar', b('abc'));
|
|
44
|
-
expect(snapshot()).toStrictEqual({
|
|
45
|
-
'/bar': 'abc',
|
|
46
|
-
});
|
|
47
|
-
}));
|
|
48
|
-
test('can store a resource in two levels deep collection', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
const { crud, snapshot } = setup();
|
|
50
|
-
yield crud.put(['a', 'b'], 'bar', b('abc'));
|
|
51
|
-
expect(snapshot()).toStrictEqual({
|
|
52
|
-
'/a/b/bar': 'abc',
|
|
53
|
-
});
|
|
54
|
-
}));
|
|
55
|
-
test('can overwrite existing resource', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
const { crud, snapshot } = setup();
|
|
57
|
-
yield crud.put(['a', 'b'], 'bar', b('abc'));
|
|
58
|
-
yield crud.put(['a', 'b'], 'bar', b('efg'));
|
|
59
|
-
expect(snapshot()).toStrictEqual({
|
|
60
|
-
'/a/b/bar': 'efg',
|
|
61
|
-
});
|
|
62
|
-
}));
|
|
63
|
-
test('can choose to throw if item already exists', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
const { crud } = setup();
|
|
65
|
-
yield crud.put(['a', 'b'], 'bar', b('abc'), { throwIf: 'exists' });
|
|
66
|
-
const [, err] = yield (0, thingies_1.of)(crud.put(['a', 'b'], 'bar', b('efg'), { throwIf: 'exists' }));
|
|
67
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
68
|
-
expect(err.name).toBe('Exists');
|
|
69
|
-
}));
|
|
70
|
-
test('can choose to throw if item does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
const { crud, snapshot } = setup();
|
|
72
|
-
const [, err] = yield (0, thingies_1.of)(crud.put(['a', 'b'], 'bar', b('1'), { throwIf: 'missing' }));
|
|
73
|
-
yield crud.put(['a', 'b'], 'bar', b('2'));
|
|
74
|
-
yield crud.put(['a', 'b'], 'bar', b('3'), { throwIf: 'missing' });
|
|
75
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
76
|
-
expect(err.name).toBe('Missing');
|
|
77
|
-
expect(snapshot()).toStrictEqual({
|
|
78
|
-
'/a/b/bar': '3',
|
|
79
|
-
});
|
|
80
|
-
}));
|
|
81
|
-
});
|
|
82
|
-
describe('.get()', () => {
|
|
83
|
-
test('throws if the type is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
-
const { crud } = setup();
|
|
85
|
-
const [, err] = yield (0, thingies_1.of)(crud.get(['', 'foo'], 'bar'));
|
|
86
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
87
|
-
expect(err.message).toBe("Failed to execute 'get' on 'crudfs': Name is not allowed.");
|
|
88
|
-
}));
|
|
89
|
-
test('throws if id is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
const { crud } = setup();
|
|
91
|
-
const [, err] = yield (0, thingies_1.of)(crud.get(['foo'], ''));
|
|
92
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
93
|
-
expect(err.message).toBe("Failed to execute 'get' on 'crudfs': Name is not allowed.");
|
|
94
|
-
}));
|
|
95
|
-
test('throws if collection does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
const { crud } = setup();
|
|
97
|
-
const [, err] = yield (0, thingies_1.of)(crud.get(['foo'], 'bar'));
|
|
98
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
99
|
-
expect(err.name).toBe('CollectionNotFound');
|
|
100
|
-
}));
|
|
101
|
-
test('throws if resource does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
-
const { crud } = setup();
|
|
103
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
104
|
-
const [, err] = yield (0, thingies_1.of)(crud.get(['foo'], 'baz'));
|
|
105
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
106
|
-
expect(err.name).toBe('ResourceNotFound');
|
|
107
|
-
}));
|
|
108
|
-
test('can fetch an existing resource', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
-
const { crud } = setup();
|
|
110
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
111
|
-
const blob = yield crud.get(['foo'], 'bar');
|
|
112
|
-
expect(blob).toStrictEqual(b('abc'));
|
|
113
|
-
}));
|
|
114
|
-
});
|
|
115
|
-
describe('.del()', () => {
|
|
116
|
-
test('throws if the type is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
-
const { crud } = setup();
|
|
118
|
-
const [, err] = yield (0, thingies_1.of)(crud.del(['sdf\\dd', 'foo'], 'bar'));
|
|
119
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
120
|
-
expect(err.message).toBe("Failed to execute 'del' on 'crudfs': Name is not allowed.");
|
|
121
|
-
}));
|
|
122
|
-
test('throws if id is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
const { crud } = setup();
|
|
124
|
-
const [, err] = yield (0, thingies_1.of)(crud.del(['foo'], 'asdf/asdf'));
|
|
125
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
126
|
-
expect(err.message).toBe("Failed to execute 'del' on 'crudfs': Name is not allowed.");
|
|
127
|
-
}));
|
|
128
|
-
describe('when collection does not exist', () => {
|
|
129
|
-
test('throws by default', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
-
const { crud } = setup();
|
|
131
|
-
const [, err] = yield (0, thingies_1.of)(crud.del(['foo'], 'bar'));
|
|
132
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
133
|
-
expect(err.name).toBe('CollectionNotFound');
|
|
134
|
-
}));
|
|
135
|
-
test('does not throw when "silent" flag set', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
-
const { crud } = setup();
|
|
137
|
-
yield crud.del(['foo'], 'bar', true);
|
|
138
|
-
}));
|
|
139
|
-
});
|
|
140
|
-
describe('when collection is found but resource is not', () => {
|
|
141
|
-
test('throws by default', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
-
const { crud } = setup();
|
|
143
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
144
|
-
const [, err] = yield (0, thingies_1.of)(crud.del(['foo'], 'baz'));
|
|
145
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
146
|
-
expect(err.name).toBe('ResourceNotFound');
|
|
147
|
-
}));
|
|
148
|
-
test('does not throw when "silent" flag set', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
-
const { crud } = setup();
|
|
150
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
151
|
-
yield crud.del(['foo'], 'baz', true);
|
|
152
|
-
}));
|
|
153
|
-
});
|
|
154
|
-
test('deletes an existing resource', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
-
const { crud } = setup();
|
|
156
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
157
|
-
yield crud.get(['foo'], 'bar');
|
|
158
|
-
yield crud.del(['foo'], 'bar');
|
|
159
|
-
const [, err] = yield (0, thingies_1.of)(crud.get(['foo'], 'bar'));
|
|
160
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
161
|
-
expect(err.name).toBe('ResourceNotFound');
|
|
162
|
-
}));
|
|
163
|
-
});
|
|
164
|
-
describe('.info()', () => {
|
|
165
|
-
test('throws if the type is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
-
const { crud } = setup();
|
|
167
|
-
const [, err] = yield (0, thingies_1.of)(crud.info(['', 'foo'], 'bar'));
|
|
168
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
169
|
-
expect(err.message).toBe("Failed to execute 'info' on 'crudfs': Name is not allowed.");
|
|
170
|
-
}));
|
|
171
|
-
test('throws if id is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
172
|
-
const { crud } = setup();
|
|
173
|
-
const [, err] = yield (0, thingies_1.of)(crud.info(['foo'], '/'));
|
|
174
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
175
|
-
expect(err.message).toBe("Failed to execute 'info' on 'crudfs': Name is not allowed.");
|
|
176
|
-
}));
|
|
177
|
-
test('can retrieve information about a resource', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
|
-
const { crud } = setup();
|
|
179
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
180
|
-
const info = yield crud.info(['foo'], 'bar');
|
|
181
|
-
expect(info).toMatchObject({
|
|
182
|
-
type: 'resource',
|
|
183
|
-
id: 'bar',
|
|
184
|
-
size: 3,
|
|
185
|
-
modified: expect.any(Number),
|
|
186
|
-
});
|
|
187
|
-
}));
|
|
188
|
-
test('can retrieve information about a collection', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
189
|
-
const { crud } = setup();
|
|
190
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
191
|
-
const info = yield crud.info(['foo']);
|
|
192
|
-
expect(info).toMatchObject({
|
|
193
|
-
type: 'collection',
|
|
194
|
-
});
|
|
195
|
-
}));
|
|
196
|
-
test('throws when resource not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
197
|
-
const { crud } = setup();
|
|
198
|
-
yield crud.put(['foo'], 'bar', b('abc'));
|
|
199
|
-
const [, err] = yield (0, thingies_1.of)(crud.info(['foo'], 'baz'));
|
|
200
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
201
|
-
expect(err.name).toBe('ResourceNotFound');
|
|
202
|
-
}));
|
|
203
|
-
test('throws when collection not found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
204
|
-
const { crud } = setup();
|
|
205
|
-
yield crud.put(['foo', 'a'], 'bar', b('abc'));
|
|
206
|
-
const [, err] = yield (0, thingies_1.of)(crud.info(['foo', 'b'], 'baz'));
|
|
207
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
208
|
-
expect(err.name).toBe('CollectionNotFound');
|
|
209
|
-
}));
|
|
210
|
-
});
|
|
211
|
-
describe('.drop()', () => {
|
|
212
|
-
test('throws if the collection is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
|
-
const { crud } = setup();
|
|
214
|
-
const [, err] = yield (0, thingies_1.of)(crud.drop(['', 'foo']));
|
|
215
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
216
|
-
expect(err.message).toBe("Failed to execute 'drop' on 'crudfs': Name is not allowed.");
|
|
217
|
-
}));
|
|
218
|
-
test('can recursively delete a collection', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
219
|
-
const { crud } = setup();
|
|
220
|
-
yield crud.put(['foo', 'a'], 'bar', b('1'));
|
|
221
|
-
yield crud.put(['foo', 'a'], 'baz', b('2'));
|
|
222
|
-
yield crud.put(['foo', 'b'], 'xyz', b('3'));
|
|
223
|
-
const info = yield crud.info(['foo', 'a']);
|
|
224
|
-
expect(info.type).toBe('collection');
|
|
225
|
-
yield crud.drop(['foo', 'a']);
|
|
226
|
-
const [, err] = yield (0, thingies_1.of)(crud.info(['foo', 'a']));
|
|
227
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
228
|
-
expect(err.name).toBe('CollectionNotFound');
|
|
229
|
-
}));
|
|
230
|
-
test('throws if collection does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
231
|
-
const { crud } = setup();
|
|
232
|
-
yield crud.put(['foo', 'a'], 'bar', b('1'));
|
|
233
|
-
yield crud.put(['foo', 'a'], 'baz', b('2'));
|
|
234
|
-
yield crud.put(['foo', 'b'], 'xyz', b('3'));
|
|
235
|
-
const [, err] = yield (0, thingies_1.of)(crud.drop(['gg']));
|
|
236
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
237
|
-
expect(err.name).toBe('CollectionNotFound');
|
|
238
|
-
}));
|
|
239
|
-
test('when "silent" flag set, does not throw if collection does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
240
|
-
const { crud } = setup();
|
|
241
|
-
yield crud.put(['foo', 'a'], 'bar', b('1'));
|
|
242
|
-
yield crud.put(['foo', 'a'], 'baz', b('2'));
|
|
243
|
-
yield crud.put(['foo', 'b'], 'xyz', b('3'));
|
|
244
|
-
yield crud.drop(['gg'], true);
|
|
245
|
-
}));
|
|
246
|
-
test('can recursively delete everything from root', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
|
-
const { crud, snapshot } = setup();
|
|
248
|
-
yield crud.put(['foo', 'a'], 'bar', b('1'));
|
|
249
|
-
yield crud.put(['baz', 'a'], 'baz', b('2'));
|
|
250
|
-
yield crud.put(['bar', 'b'], 'xyz', b('3'));
|
|
251
|
-
const info = yield crud.info(['foo', 'a']);
|
|
252
|
-
expect(info.type).toBe('collection');
|
|
253
|
-
yield crud.drop([]);
|
|
254
|
-
expect(snapshot()).toEqual({});
|
|
255
|
-
}));
|
|
256
|
-
});
|
|
257
|
-
describe('.list()', () => {
|
|
258
|
-
test('throws if the collection is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
259
|
-
const { crud } = setup();
|
|
260
|
-
const [, err] = yield (0, thingies_1.of)(crud.list(['./..', 'foo']));
|
|
261
|
-
expect(err).toBeInstanceOf(TypeError);
|
|
262
|
-
expect(err.message).toBe("Failed to execute 'drop' on 'crudfs': Name is not allowed.");
|
|
263
|
-
}));
|
|
264
|
-
test('can retrieve a list of resources and collections at root', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
265
|
-
const { crud } = setup();
|
|
266
|
-
yield crud.put(['foo'], 'bar', b('1'));
|
|
267
|
-
yield crud.put([], 'baz', b('1'));
|
|
268
|
-
yield crud.put([], 'qux', b('2'));
|
|
269
|
-
const list = yield crud.list([]);
|
|
270
|
-
expect(list.length).toBe(3);
|
|
271
|
-
expect(list.find(x => x.id === 'baz')).toMatchObject({
|
|
272
|
-
type: 'resource',
|
|
273
|
-
id: 'baz',
|
|
274
|
-
});
|
|
275
|
-
expect(list.find(x => x.id === 'qux')).toMatchObject({
|
|
276
|
-
type: 'resource',
|
|
277
|
-
id: 'qux',
|
|
278
|
-
});
|
|
279
|
-
expect(list.find(x => x.id === 'foo')).toMatchObject({
|
|
280
|
-
type: 'collection',
|
|
281
|
-
id: 'foo',
|
|
282
|
-
});
|
|
283
|
-
}));
|
|
284
|
-
test('throws when try to list a non-existing collection', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
285
|
-
const { crud } = setup();
|
|
286
|
-
yield crud.put(['foo'], 'bar', b('1'));
|
|
287
|
-
yield crud.put([], 'baz', b('1'));
|
|
288
|
-
yield crud.put([], 'qux', b('2'));
|
|
289
|
-
const [, err] = yield (0, thingies_1.of)(crud.list(['gg']));
|
|
290
|
-
expect(err).toBeInstanceOf(DOMException);
|
|
291
|
-
expect(err.name).toBe('CollectionNotFound');
|
|
292
|
-
}));
|
|
293
|
-
});
|
|
15
|
+
(0, testCrudfs_1.testCrudfs)(setup);
|
|
294
16
|
});
|
|
17
|
+
//# sourceMappingURL=FsaCrud.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsaCrud.test.js","sourceRoot":"","sources":["../../../src/fsa-to-crud/__tests__/FsaCrud.test.ts"],"names":[],"mappings":";;AAAA,6BAA8B;AAC9B,+CAAoD;AACpD,mDAAkE;AAClE,wCAAqC;AACrC,gEAA6D;AAE7D,MAAM,KAAK,GAAG,GAAG,EAAE;IACjB,MAAM,EAAE,GAAG,IAAA,SAAK,GAAE,CAAC;IACnB,MAAM,GAAG,GAAG,IAAI,2CAA6B,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,IAAI,iBAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAO,EAAG,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;AACrE,CAAC,CAAC;AAEF,IAAA,mBAAY,EAAC,SAAS,EAAE,GAAG,EAAE;IAC3B,IAAA,uBAAU,EAAC,KAAK,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FsaCrud } from './FsaCrud';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FsaCrud = void 0;
|
|
4
|
+
var FsaCrud_1 = require("./FsaCrud");
|
|
5
|
+
Object.defineProperty(exports, "FsaCrud", { enumerable: true, get: function () { return FsaCrud_1.FsaCrud; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fsa-to-crud/index.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAA3B,kGAAA,OAAO,OAAA"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const
|
|
1
|
+
import type * as crud from '../crud/types';
|
|
2
|
+
export declare const newFile404Error: (collection: crud.CrudCollection, id: string) => DOMException;
|
|
3
|
+
export declare const newFolder404Error: (collection: crud.CrudCollection) => DOMException;
|
|
4
|
+
export declare const newExistsError: () => DOMException;
|
|
5
|
+
export declare const newMissingError: () => DOMException;
|
package/lib/fsa-to-crud/util.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
exports.newMissingError = exports.newExistsError = exports.newFolder404Error = exports.newFile404Error = void 0;
|
|
4
|
+
const newFile404Error = (collection, id) => new DOMException(`Resource "${id}" in /${collection.join('/')} not found`, 'ResourceNotFound');
|
|
5
|
+
exports.newFile404Error = newFile404Error;
|
|
6
|
+
const newFolder404Error = (collection) => new DOMException(`Collection /${collection.join('/')} does not exist`, 'CollectionNotFound');
|
|
7
|
+
exports.newFolder404Error = newFolder404Error;
|
|
8
|
+
const newExistsError = () => new DOMException('Resource already exists', 'Exists');
|
|
9
|
+
exports.newExistsError = newExistsError;
|
|
10
|
+
const newMissingError = () => new DOMException('Resource is missing', 'Missing');
|
|
11
|
+
exports.newMissingError = newMissingError;
|
|
12
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/fsa-to-crud/util.ts"],"names":[],"mappings":";;;AAEO,MAAM,eAAe,GAAG,CAAC,UAA+B,EAAE,EAAU,EAAE,EAAE,CAC7E,IAAI,YAAY,CAAC,aAAa,EAAE,SAAS,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;AADpF,QAAA,eAAe,mBACqE;AAE1F,MAAM,iBAAiB,GAAG,CAAC,UAA+B,EAAE,EAAE,CACnE,IAAI,YAAY,CAAC,eAAe,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AADlF,QAAA,iBAAiB,qBACiE;AAExF,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;AAA7E,QAAA,cAAc,kBAA+D;AAEnF,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;AAA3E,QAAA,eAAe,mBAA4D"}
|
|
@@ -21,12 +21,13 @@ export declare class FsaNodeCore {
|
|
|
21
21
|
*/
|
|
22
22
|
protected getDir(path: string[], create: boolean, funcName?: string): Promise<fsa.IFileSystemDirectoryHandle>;
|
|
23
23
|
protected getFile(path: string[], name: string, funcName?: string, create?: boolean): Promise<fsa.IFileSystemFileHandle>;
|
|
24
|
-
protected getFileOrDir(path: string[], name: string, funcName?: string
|
|
24
|
+
protected getFileOrDir(path: string[], name: string, funcName?: string): Promise<fsa.IFileSystemFileHandle | fsa.IFileSystemDirectoryHandle>;
|
|
25
25
|
protected getFileByFd(fd: number, funcName?: string): FsaNodeFsOpenFile;
|
|
26
26
|
protected getFileByFdAsync(fd: number, funcName?: string): Promise<FsaNodeFsOpenFile>;
|
|
27
|
-
__getFileById(id: misc.TFileId, funcName?: string
|
|
27
|
+
__getFileById(id: misc.TFileId, funcName?: string): Promise<fsa.IFileSystemFileHandle>;
|
|
28
28
|
protected getFileByIdOrCreate(id: misc.TFileId, funcName?: string): Promise<fsa.IFileSystemFileHandle>;
|
|
29
29
|
protected __open(filename: string, flags: number, mode: number): Promise<FsaNodeFsOpenFile>;
|
|
30
30
|
protected __open2(fsaFile: fsa.IFileSystemFileHandle, filename: string, flags: number, mode: number): FsaNodeFsOpenFile;
|
|
31
|
+
protected __close(fd: number): Promise<void>;
|
|
31
32
|
protected getFileName(id: misc.TFileId): string;
|
|
32
33
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.FsaNodeCore = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
13
5
|
const util_1 = require("../node/util");
|
|
14
6
|
const util_2 = require("./util");
|
|
15
7
|
const constants_1 = require("../node/constants");
|
|
16
8
|
const FsaNodeFsOpenFile_1 = require("./FsaNodeFsOpenFile");
|
|
9
|
+
const util = require("../node/util");
|
|
17
10
|
class FsaNodeCore {
|
|
18
11
|
constructor(root, syncAdapter) {
|
|
19
12
|
this.root = root;
|
|
@@ -47,7 +40,7 @@ class FsaNodeCore {
|
|
|
47
40
|
* @param create Whether to create the folders if they don't exist.
|
|
48
41
|
*/
|
|
49
42
|
getDir(path, create, funcName) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
44
|
let curr = yield this.root;
|
|
52
45
|
const options = { create };
|
|
53
46
|
try {
|
|
@@ -70,15 +63,17 @@ class FsaNodeCore {
|
|
|
70
63
|
});
|
|
71
64
|
}
|
|
72
65
|
getFile(path, name, funcName, create) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
67
|
const dir = yield this.getDir(path, false, funcName);
|
|
75
68
|
const file = yield dir.getFileHandle(name, { create });
|
|
76
69
|
return file;
|
|
77
70
|
});
|
|
78
71
|
}
|
|
79
|
-
getFileOrDir(path, name, funcName
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
getFileOrDir(path, name, funcName) {
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
81
74
|
const dir = yield this.getDir(path, false, funcName);
|
|
75
|
+
if (!name)
|
|
76
|
+
return dir;
|
|
82
77
|
try {
|
|
83
78
|
const file = yield dir.getFileHandle(name);
|
|
84
79
|
return file;
|
|
@@ -117,21 +112,21 @@ class FsaNodeCore {
|
|
|
117
112
|
return file;
|
|
118
113
|
}
|
|
119
114
|
getFileByFdAsync(fd, funcName) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
121
116
|
return this.getFileByFd(fd, funcName);
|
|
122
117
|
});
|
|
123
118
|
}
|
|
124
|
-
__getFileById(id, funcName
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
__getFileById(id, funcName) {
|
|
120
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
126
121
|
if (typeof id === 'number')
|
|
127
122
|
return (yield this.getFileByFd(id, funcName)).file;
|
|
128
123
|
const filename = (0, util_1.pathToFilename)(id);
|
|
129
124
|
const [folder, name] = (0, util_2.pathToLocation)(filename);
|
|
130
|
-
return yield this.getFile(folder, name, funcName
|
|
125
|
+
return yield this.getFile(folder, name, funcName);
|
|
131
126
|
});
|
|
132
127
|
}
|
|
133
128
|
getFileByIdOrCreate(id, funcName) {
|
|
134
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
135
130
|
if (typeof id === 'number')
|
|
136
131
|
return (yield this.getFileByFd(id, funcName)).file;
|
|
137
132
|
const filename = (0, util_1.pathToFilename)(id);
|
|
@@ -141,11 +136,45 @@ class FsaNodeCore {
|
|
|
141
136
|
});
|
|
142
137
|
}
|
|
143
138
|
__open(filename, flags, mode) {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
145
140
|
const [folder, name] = (0, util_2.pathToLocation)(filename);
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
const throwIfExists = !!(flags & 128 /* FLAG.O_EXCL */);
|
|
142
|
+
if (throwIfExists) {
|
|
143
|
+
try {
|
|
144
|
+
yield this.getFile(folder, name, 'open', false);
|
|
145
|
+
throw util.createError('EEXIST', 'writeFile');
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
const file404 = error && typeof error === 'object' && (error.code === 'ENOENT' || error.name === 'NotFoundError');
|
|
149
|
+
if (!file404) {
|
|
150
|
+
if (error && typeof error === 'object') {
|
|
151
|
+
switch (error.name) {
|
|
152
|
+
case 'TypeMismatchError':
|
|
153
|
+
throw (0, util_1.createError)('ENOTDIR', 'open', filename);
|
|
154
|
+
case 'NotFoundError':
|
|
155
|
+
throw (0, util_1.createError)('ENOENT', 'open', filename);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const createIfMissing = !!(flags & 64 /* FLAG.O_CREAT */);
|
|
164
|
+
const fsaFile = yield this.getFile(folder, name, 'open', createIfMissing);
|
|
165
|
+
return this.__open2(fsaFile, filename, flags, mode);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (error && typeof error === 'object') {
|
|
169
|
+
switch (error.name) {
|
|
170
|
+
case 'TypeMismatchError':
|
|
171
|
+
throw (0, util_1.createError)('ENOTDIR', 'open', filename);
|
|
172
|
+
case 'NotFoundError':
|
|
173
|
+
throw (0, util_1.createError)('ENOENT', 'open', filename);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
149
178
|
});
|
|
150
179
|
}
|
|
151
180
|
__open2(fsaFile, filename, flags, mode) {
|
|
@@ -154,6 +183,15 @@ class FsaNodeCore {
|
|
|
154
183
|
this.fds.set(fd, file);
|
|
155
184
|
return file;
|
|
156
185
|
}
|
|
186
|
+
__close(fd) {
|
|
187
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
const openFile = yield this.getFileByFdAsync(fd, 'close');
|
|
189
|
+
yield openFile.close();
|
|
190
|
+
const deleted = this.fds.delete(fd);
|
|
191
|
+
if (deleted)
|
|
192
|
+
this.releasedFds.push(fd);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
157
195
|
getFileName(id) {
|
|
158
196
|
if (typeof id === 'number') {
|
|
159
197
|
const openFile = this.fds.get(id);
|
|
@@ -166,3 +204,4 @@ class FsaNodeCore {
|
|
|
166
204
|
}
|
|
167
205
|
exports.FsaNodeCore = FsaNodeCore;
|
|
168
206
|
FsaNodeCore.fd = 0x7fffffff;
|
|
207
|
+
//# sourceMappingURL=FsaNodeCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsaNodeCore.js","sourceRoot":"","sources":["../../src/fsa-to-node/FsaNodeCore.ts"],"names":[],"mappings":";;;;AAAA,uCAAiE;AACjE,iCAAwC;AACxC,iDAA2C;AAE3C,2DAAwD;AAExD,qCAAqC;AAKrC,MAAa,WAAW;IAItB,YACqB,IAA8E,EAC1F,WAAgC;QADpB,SAAI,GAAJ,IAAI,CAA0E;QAC1F,gBAAW,GAAX,WAAW,CAAqB;QAJtB,QAAG,GAAG,IAAI,GAAG,EAA6B,CAAC;QAqB9D;;;WAGG;QACH,gBAAW,GAAa,EAAE,CAAC;QAnBzB,IAAI,IAAI,YAAY,OAAO,EAAE;YAC3B,IAAI;iBACD,IAAI,CAAC,IAAI,CAAC,EAAE;gBACV,IAAY,CAAC,IAAI,GAAG,IAAI,CAAC;YAC5B,CAAC,CAAC;iBACD,KAAK,CAAC,KAAK,CAAC,EAAE,GAAE,CAAC,CAAC,CAAC;SACvB;IACH,CAAC;IAES,cAAc;QACtB,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC;QACjC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,OAAO,CAAC;IACjB,CAAC;IAQS,WAAW;QACnB,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;QAC1C,OAAO,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;IACxE,CAAC;IAED;;;OAGG;IACa,MAAM,CAAC,IAAc,EAAE,MAAe,EAAE,QAAiB;;YACvE,IAAI,IAAI,GAAmC,MAAM,IAAI,CAAC,IAAI,CAAC;YAC3D,MAAM,OAAO,GAAkC,EAAE,MAAM,EAA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ent.js","sourceRoot":"","sources":["../../src/fsa-to-node/FsaNodeDirent.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IACxB,YAAmC,IAAc,EAAqB,IAA0B;QAA7D,SAAI,GAAJ,IAAI,CAAU;QAAqB,SAAI,GAAJ,IAAI,CAAsB;IAAG,CAAC;IAE7F,WAAW;QAChB,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC;IACnC,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;IAC9B,CAAC;IAEM,aAAa;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,iBAAiB;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,cAAc;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,MAAM;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,QAAQ;QACb,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA9BD,sCA8BC"}
|
|
@@ -60,8 +60,12 @@ export declare class FsaNodeFs extends FsaNodeCore implements FsCallbackApi, FsS
|
|
|
60
60
|
readonly lchown: FsCallbackApi['lchown'];
|
|
61
61
|
readonly createWriteStream: FsCallbackApi['createWriteStream'];
|
|
62
62
|
readonly createReadStream: FsCallbackApi['createReadStream'];
|
|
63
|
-
readonly
|
|
64
|
-
readonly
|
|
63
|
+
readonly cp: FsCallbackApi['cp'];
|
|
64
|
+
readonly lutimes: FsCallbackApi['lutimes'];
|
|
65
|
+
readonly openAsBlob: FsCallbackApi['openAsBlob'];
|
|
66
|
+
readonly opendir: FsCallbackApi['opendir'];
|
|
67
|
+
readonly readv: FsCallbackApi['readv'];
|
|
68
|
+
readonly statfs: FsCallbackApi['statfs'];
|
|
65
69
|
/**
|
|
66
70
|
* @todo Watchers could be implemented in the future on top of `FileSystemObserver`,
|
|
67
71
|
* which is currently a proposal.
|
|
@@ -70,6 +74,8 @@ export declare class FsaNodeFs extends FsaNodeCore implements FsCallbackApi, FsS
|
|
|
70
74
|
readonly watchFile: FsCallbackApi['watchFile'];
|
|
71
75
|
readonly unwatchFile: FsCallbackApi['unwatchFile'];
|
|
72
76
|
readonly watch: FsCallbackApi['watch'];
|
|
77
|
+
readonly symlink: FsCallbackApi['symlink'];
|
|
78
|
+
readonly link: FsCallbackApi['link'];
|
|
73
79
|
readonly statSync: FsSynchronousApi['statSync'];
|
|
74
80
|
readonly lstatSync: FsSynchronousApi['lstatSync'];
|
|
75
81
|
readonly fstatSync: FsSynchronousApi['fstatSync'];
|
|
@@ -94,6 +100,7 @@ export declare class FsaNodeFs extends FsaNodeCore implements FsCallbackApi, FsS
|
|
|
94
100
|
readonly readSync: FsSynchronousApi['readSync'];
|
|
95
101
|
readonly writeSync: FsSynchronousApi['writeSync'];
|
|
96
102
|
readonly openSync: FsSynchronousApi['openSync'];
|
|
103
|
+
readonly writevSync: FsSynchronousApi['writevSync'];
|
|
97
104
|
readonly fdatasyncSync: FsSynchronousApi['fdatasyncSync'];
|
|
98
105
|
readonly fsyncSync: FsSynchronousApi['fsyncSync'];
|
|
99
106
|
readonly chmodSync: FsSynchronousApi['chmodSync'];
|
|
@@ -104,6 +111,11 @@ export declare class FsaNodeFs extends FsaNodeCore implements FsCallbackApi, FsS
|
|
|
104
111
|
readonly lchmodSync: FsSynchronousApi['lchmodSync'];
|
|
105
112
|
readonly lchownSync: FsSynchronousApi['lchownSync'];
|
|
106
113
|
readonly utimesSync: FsSynchronousApi['utimesSync'];
|
|
114
|
+
readonly lutimesSync: FsSynchronousApi['lutimesSync'];
|
|
115
|
+
readonly cpSync: FsSynchronousApi['cpSync'];
|
|
116
|
+
readonly opendirSync: FsSynchronousApi['opendirSync'];
|
|
117
|
+
readonly statfsSync: FsSynchronousApi['statfsSync'];
|
|
118
|
+
readonly readvSync: FsSynchronousApi['readvSync'];
|
|
107
119
|
readonly symlinkSync: FsSynchronousApi['symlinkSync'];
|
|
108
120
|
readonly linkSync: FsSynchronousApi['linkSync'];
|
|
109
121
|
readonly F_OK: number;
|