@feathersjs/transport-commons 5.0.0-pre.29 → 5.0.0-pre.30
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/CHANGELOG.md +101 -369
- package/lib/channels/index.js.map +1 -1
- package/lib/routing/index.js +12 -0
- package/lib/routing/index.js.map +1 -1
- package/lib/routing/router.d.ts +3 -0
- package/lib/routing/router.js +29 -1
- package/lib/routing/router.js.map +1 -1
- package/package.json +10 -10
- package/src/channels/index.ts +1 -0
- package/src/routing/index.ts +17 -2
- package/src/routing/router.ts +37 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,mDAAsF;AACtF,iDAAiD;AACjD,mCAAmD;AACnD,yCAA4D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,mDAAsF;AACtF,iDAAiD;AACjD,mCAAmD;AACnD,yCAA4D;AAkHnD,wFAlHA,cAAO,OAkHA;AAjHhB,iDAAoD;AAiHlC,gGAjHT,0BAAe,OAiHS;AAhHjC,qCAA2F;AAoClF,qFApC4B,aAAI,OAoC5B;AAjCb,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,wCAAwC,CAAC,CAAA;AACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAI,CAAA;AAkCzB,SAAgB,QAAQ;IACtB,OAAO,CAAC,GAAgB,EAAE,EAAE;QAC1B,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE;YAC1E,OAAM;SACP;QAED,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAA,qBAAY,GAAE,EAAE,IAAA,qBAAY,GAAE,CAAC,CAAA;QAClD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YACrC,GA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CAAC;wBACpB,kCAAkC;wBAClC,aAAa,CAAC,aAAI,CAAC,UAAU,CAAC;wBAC9B,kBAAkB;wBAClB,aAAI,CAAA;oBAEN,IAAI;wBACF,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;6BACnC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;4BACpB,IAAI,CAAC,MAAM,EAAE;gCACX,OAAM;6BACP;4BAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAA,gBAAO,EAAC,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,MAAM,CAAe,CAAA;4BAC9F,MAAM,OAAO,GAAG,IAAI,0BAAe,CAAC,OAAO,CAAC,CAAA;4BAE5C,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gCACjC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;6BAChD;iCAAM;gCACL,KAAK,CAAC,8BAA8B,CAAC,CAAA;6BACtC;wBACH,CAAC,CAAC;6BACD,KAAK,CAAC,QAAQ,CAAC,CAAA;qBACnB;oBAAC,OAAO,KAAU,EAAE;wBACnB,QAAQ,CAAC,KAAK,CAAC,CAAA;qBAChB;gBACH,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAxED,4BAwEC"}
|
package/lib/routing/index.js
CHANGED
|
@@ -32,6 +32,18 @@ const routing = () => (app) => {
|
|
|
32
32
|
}
|
|
33
33
|
app.routes = new router_1.Router();
|
|
34
34
|
app.lookup = lookup;
|
|
35
|
+
// This mixin allows us to unregister a service. It needs to run
|
|
36
|
+
// first so that `teardown` hooks still get registered properly
|
|
37
|
+
app.mixins.unshift((service) => {
|
|
38
|
+
const { teardown } = service;
|
|
39
|
+
service.teardown = async function (app, path) {
|
|
40
|
+
if (typeof teardown === 'function') {
|
|
41
|
+
await teardown.call(this, app, path);
|
|
42
|
+
}
|
|
43
|
+
app.routes.remove(path);
|
|
44
|
+
app.routes.remove(`${path}/:__id`);
|
|
45
|
+
};
|
|
46
|
+
});
|
|
35
47
|
// Add a mixin that registers a service on the router
|
|
36
48
|
app.mixins.push((service, path, options) => {
|
|
37
49
|
const { routeParams: params = {} } = options;
|
package/lib/routing/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,qCAAiC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,qCAAiC;AAmBjC,2CAAwB;AAExB,MAAM,MAAM,GAAG,UAA6B,IAAY;IACtD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAEvC,IAAI,MAAM,KAAK,IAAI,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,EACJ,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EACtC,GAAG,MAAM,CAAA;IAEV,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAA;IAE3E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA;AAC5B,CAAC,CAAA;AAEM,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,GAAgB,EAAE,EAAE;IAChD,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,EAAE;QACpC,OAAM;KACP;IAED,GAAG,CAAC,MAAM,GAAG,IAAI,eAAM,EAAE,CAAA;IACzB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;IAEnB,gEAAgE;IAChE,+DAA+D;IAC/D,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAgB,EAAE,EAAE;QACtC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;QAE5B,OAAO,CAAC,QAAQ,GAAG,KAAK,WAAW,GAAgB,EAAE,IAAY;YAC/D,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;gBAClC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;aACrC;YACD,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACvB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAA;QACpC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,qDAAqD;IACrD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAwB,EAAE,IAAY,EAAE,OAAuB,EAAE,EAAE;QAClF,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,CAAA;QAE5C,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;QAC5C,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AA7BY,QAAA,OAAO,WA6BnB"}
|
package/lib/routing/router.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export declare class RouteNode<T = any> {
|
|
|
15
15
|
};
|
|
16
16
|
placeholders: RouteNode[];
|
|
17
17
|
constructor(name: string, depth: number);
|
|
18
|
+
get hasChildren(): boolean;
|
|
18
19
|
insert(path: string[], data: T): RouteNode<T>;
|
|
20
|
+
remove(path: string[]): void;
|
|
19
21
|
lookup(path: string[], info: LookupData): LookupResult<T> | null;
|
|
20
22
|
}
|
|
21
23
|
export declare class Router<T = any> {
|
|
@@ -23,5 +25,6 @@ export declare class Router<T = any> {
|
|
|
23
25
|
constructor(root?: RouteNode<T>);
|
|
24
26
|
getPath(path: string): string[];
|
|
25
27
|
insert(path: string, data: T): RouteNode<T>;
|
|
28
|
+
remove(path: string): void;
|
|
26
29
|
lookup(path: string): LookupResult<T>;
|
|
27
30
|
}
|
package/lib/routing/router.js
CHANGED
|
@@ -9,6 +9,9 @@ class RouteNode {
|
|
|
9
9
|
this.children = {};
|
|
10
10
|
this.placeholders = [];
|
|
11
11
|
}
|
|
12
|
+
get hasChildren() {
|
|
13
|
+
return Object.keys(this.children).length !== 0 || this.placeholders.length !== 0;
|
|
14
|
+
}
|
|
12
15
|
insert(path, data) {
|
|
13
16
|
if (this.depth === path.length) {
|
|
14
17
|
if (this.data !== undefined) {
|
|
@@ -33,6 +36,25 @@ class RouteNode {
|
|
|
33
36
|
this.children[current] = child;
|
|
34
37
|
return child.insert(path, data);
|
|
35
38
|
}
|
|
39
|
+
remove(path) {
|
|
40
|
+
if (path.length === this.depth) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const current = path[this.depth];
|
|
44
|
+
if (current.startsWith(':')) {
|
|
45
|
+
const placeholderName = current.substring(1);
|
|
46
|
+
const placeholder = this.placeholders.find((p) => p.name === placeholderName);
|
|
47
|
+
placeholder.remove(path);
|
|
48
|
+
this.placeholders = this.placeholders.filter((p) => p !== placeholder);
|
|
49
|
+
}
|
|
50
|
+
else if (this.children[current]) {
|
|
51
|
+
const child = this.children[current];
|
|
52
|
+
child.remove(path);
|
|
53
|
+
if (!child.hasChildren) {
|
|
54
|
+
delete this.children[current];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
36
58
|
lookup(path, info) {
|
|
37
59
|
if (path.length === this.depth) {
|
|
38
60
|
return this.data === undefined
|
|
@@ -45,7 +67,10 @@ class RouteNode {
|
|
|
45
67
|
const current = path[this.depth];
|
|
46
68
|
const child = this.children[current];
|
|
47
69
|
if (child) {
|
|
48
|
-
|
|
70
|
+
const lookup = child.lookup(path, info);
|
|
71
|
+
if (lookup !== null) {
|
|
72
|
+
return lookup;
|
|
73
|
+
}
|
|
49
74
|
}
|
|
50
75
|
// This will return the first placeholder that matches early
|
|
51
76
|
for (const placeholder of this.placeholders) {
|
|
@@ -69,6 +94,9 @@ class Router {
|
|
|
69
94
|
insert(path, data) {
|
|
70
95
|
return this.root.insert(this.getPath(path), data);
|
|
71
96
|
}
|
|
97
|
+
remove(path) {
|
|
98
|
+
return this.root.remove(this.getPath(path));
|
|
99
|
+
}
|
|
72
100
|
lookup(path) {
|
|
73
101
|
if (typeof path !== 'string') {
|
|
74
102
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/routing/router.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAUlD,MAAa,SAAS;IAKpB,YAAmB,IAAY,EAAS,KAAa;QAAlC,SAAI,GAAJ,IAAI,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAQ;QAHrD,aAAQ,GAAiC,EAAE,CAAA;QAC3C,iBAAY,GAAgB,EAAE,CAAA;IAE0B,CAAC;IAEzD,MAAM,CAAC,IAAc,EAAE,IAAO;QAC5B,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE;YAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC3B,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;aACzD;YAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;YAChB,OAAO,IAAI,CAAA;SACZ;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,C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,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACtC,CAAC;IAED,MAAM,CAAC,IAAY,EAAE,IAAO;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,OAAO,IAAI,CAAA;SACZ;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;IAC7D,CAAC;CACF;AAtBD,wBAsBC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/transport-commons",
|
|
3
3
|
"description": "Shared functionality for websocket providers",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.30",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"prepublish": "npm run compile",
|
|
36
|
-
"pack": "npm pack --pack-destination ../cli/test",
|
|
36
|
+
"pack": "npm pack --pack-destination ../cli/test/build",
|
|
37
37
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
|
38
38
|
"test": "npm run mocha",
|
|
39
39
|
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
|
@@ -54,21 +54,21 @@
|
|
|
54
54
|
"*.js"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
58
|
-
"@feathersjs/errors": "^5.0.0-pre.
|
|
59
|
-
"@feathersjs/feathers": "^5.0.0-pre.
|
|
57
|
+
"@feathersjs/commons": "^5.0.0-pre.30",
|
|
58
|
+
"@feathersjs/errors": "^5.0.0-pre.30",
|
|
59
|
+
"@feathersjs/feathers": "^5.0.0-pre.30",
|
|
60
60
|
"encodeurl": "^1.0.2",
|
|
61
61
|
"lodash": "^4.17.21"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/encodeurl": "^1.0.0",
|
|
65
|
-
"@types/lodash": "^4.14.
|
|
66
|
-
"@types/mocha": "^
|
|
67
|
-
"@types/node": "^18.
|
|
65
|
+
"@types/lodash": "^4.14.186",
|
|
66
|
+
"@types/mocha": "^10.0.0",
|
|
67
|
+
"@types/node": "^18.8.2",
|
|
68
68
|
"mocha": "^10.0.0",
|
|
69
69
|
"shx": "^0.3.4",
|
|
70
70
|
"ts-node": "^10.9.1",
|
|
71
|
-
"typescript": "^4.8.
|
|
71
|
+
"typescript": "^4.8.4"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b535c91197f4b997520e0a0e608793eeba791931"
|
|
74
74
|
}
|
package/src/channels/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ declare module '@feathersjs/feathers/lib/declarations' {
|
|
|
19
19
|
registerPublisher(event: Event, publisher: Publisher<ServiceGenericType<S>, A, this>): this
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
23
|
interface Application<Services, Settings> {
|
|
23
24
|
// eslint-disable-line
|
|
24
25
|
channels: string[]
|
package/src/routing/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Application, Service, ServiceOptions } from '@feathersjs/feathers'
|
|
1
|
+
import { Application, FeathersService, Service, ServiceOptions } from '@feathersjs/feathers'
|
|
2
2
|
import { Router } from './router'
|
|
3
3
|
|
|
4
4
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
@@ -7,6 +7,7 @@ declare module '@feathersjs/feathers/lib/declarations' {
|
|
|
7
7
|
params: { [key: string]: any }
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
11
|
interface Application<Services, Settings> {
|
|
11
12
|
// eslint-disable-line
|
|
12
13
|
routes: Router<{
|
|
@@ -44,8 +45,22 @@ export const routing = () => (app: Application) => {
|
|
|
44
45
|
app.routes = new Router()
|
|
45
46
|
app.lookup = lookup
|
|
46
47
|
|
|
48
|
+
// This mixin allows us to unregister a service. It needs to run
|
|
49
|
+
// first so that `teardown` hooks still get registered properly
|
|
50
|
+
app.mixins.unshift((service: Service) => {
|
|
51
|
+
const { teardown } = service
|
|
52
|
+
|
|
53
|
+
service.teardown = async function (app: Application, path: string) {
|
|
54
|
+
if (typeof teardown === 'function') {
|
|
55
|
+
await teardown.call(this, app, path)
|
|
56
|
+
}
|
|
57
|
+
app.routes.remove(path)
|
|
58
|
+
app.routes.remove(`${path}/:__id`)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
47
62
|
// Add a mixin that registers a service on the router
|
|
48
|
-
app.mixins.push((service:
|
|
63
|
+
app.mixins.push((service: FeathersService, path: string, options: ServiceOptions) => {
|
|
49
64
|
const { routeParams: params = {} } = options
|
|
50
65
|
|
|
51
66
|
app.routes.insert(path, { service, params })
|
package/src/routing/router.ts
CHANGED
|
@@ -15,6 +15,10 @@ export class RouteNode<T = any> {
|
|
|
15
15
|
|
|
16
16
|
constructor(public name: string, public depth: number) {}
|
|
17
17
|
|
|
18
|
+
get hasChildren() {
|
|
19
|
+
return Object.keys(this.children).length !== 0 || this.placeholders.length !== 0
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
insert(path: string[], data: T): RouteNode<T> {
|
|
19
23
|
if (this.depth === path.length) {
|
|
20
24
|
if (this.data !== undefined) {
|
|
@@ -48,6 +52,30 @@ export class RouteNode<T = any> {
|
|
|
48
52
|
return child.insert(path, data)
|
|
49
53
|
}
|
|
50
54
|
|
|
55
|
+
remove(path: string[]) {
|
|
56
|
+
if (path.length === this.depth) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const current = path[this.depth]
|
|
61
|
+
|
|
62
|
+
if (current.startsWith(':')) {
|
|
63
|
+
const placeholderName = current.substring(1)
|
|
64
|
+
const placeholder = this.placeholders.find((p) => p.name === placeholderName)
|
|
65
|
+
|
|
66
|
+
placeholder.remove(path)
|
|
67
|
+
this.placeholders = this.placeholders.filter((p) => p !== placeholder)
|
|
68
|
+
} else if (this.children[current]) {
|
|
69
|
+
const child = this.children[current]
|
|
70
|
+
|
|
71
|
+
child.remove(path)
|
|
72
|
+
|
|
73
|
+
if (!child.hasChildren) {
|
|
74
|
+
delete this.children[current]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
51
79
|
lookup(path: string[], info: LookupData): LookupResult<T> | null {
|
|
52
80
|
if (path.length === this.depth) {
|
|
53
81
|
return this.data === undefined
|
|
@@ -62,7 +90,11 @@ export class RouteNode<T = any> {
|
|
|
62
90
|
const child = this.children[current]
|
|
63
91
|
|
|
64
92
|
if (child) {
|
|
65
|
-
|
|
93
|
+
const lookup = child.lookup(path, info)
|
|
94
|
+
|
|
95
|
+
if (lookup !== null) {
|
|
96
|
+
return lookup
|
|
97
|
+
}
|
|
66
98
|
}
|
|
67
99
|
|
|
68
100
|
// This will return the first placeholder that matches early
|
|
@@ -90,6 +122,10 @@ export class Router<T = any> {
|
|
|
90
122
|
return this.root.insert(this.getPath(path), data)
|
|
91
123
|
}
|
|
92
124
|
|
|
125
|
+
remove(path: string) {
|
|
126
|
+
return this.root.remove(this.getPath(path))
|
|
127
|
+
}
|
|
128
|
+
|
|
93
129
|
lookup(path: string) {
|
|
94
130
|
if (typeof path !== 'string') {
|
|
95
131
|
return null
|