@fluidframework/map 0.58.2002 → 0.59.1000
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 +2 -0
- package/dist/directory.d.ts +6 -0
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +81 -1
- package/dist/directory.js.map +1 -1
- package/dist/interfaces.d.ts +20 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/directory.d.ts +6 -0
- package/lib/directory.d.ts.map +1 -1
- package/lib/directory.js +81 -1
- package/lib/directory.js.map +1 -1
- package/lib/interfaces.d.ts +20 -2
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +25 -13
- package/src/directory.ts +90 -1
- package/src/interfaces.ts +23 -2
- package/src/packageVersion.ts +1 -1
package/README.md
CHANGED
|
@@ -52,3 +52,5 @@ To "navigate" the subdirectory structure, `IDirectory` provides a `getWorkingDir
|
|
|
52
52
|
#### Eventing
|
|
53
53
|
|
|
54
54
|
`valueChanged` events additionally provide the absolute path to the subdirectory storing the value that changed.
|
|
55
|
+
|
|
56
|
+
`dispose` events are fired on sub directory which is deleted. Any access to this sub directory will throw an error once it is disposed.
|
package/dist/directory.d.ts
CHANGED
|
@@ -221,6 +221,8 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
221
221
|
* {@inheritDoc IDirectory.set}
|
|
222
222
|
*/
|
|
223
223
|
set<T = any>(key: string, value: T): this;
|
|
224
|
+
dispose(error?: Error): void;
|
|
225
|
+
get disposed(): boolean;
|
|
224
226
|
/**
|
|
225
227
|
* Deletes the given key from within this IDirectory.
|
|
226
228
|
* @param key - The key to delete
|
|
@@ -256,6 +258,10 @@ export declare class SharedDirectory extends SharedObject<ISharedDirectoryEvents
|
|
|
256
258
|
* @returns The iterator
|
|
257
259
|
*/
|
|
258
260
|
entries(): IterableIterator<[string, any]>;
|
|
261
|
+
/**
|
|
262
|
+
* {@inheritDoc IDirectory.countSubDirectory}
|
|
263
|
+
*/
|
|
264
|
+
countSubDirectory(): number;
|
|
259
265
|
/**
|
|
260
266
|
* Get an iterator over the keys under this IDirectory.
|
|
261
267
|
* @returns The iterator
|
package/dist/directory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACH,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAa,MAAM,oCAAoC,CAAC;AAG/F,OAAO,EACH,UAAU,EAGV,kBAAkB,EAElB,gBAAgB,EAChB,sBAAsB,EAEzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEH,eAAe,EAElB,MAAM,eAAe,CAAC;AAkCvB;;GAEG;AACH,UAAU,sBAAsB;IAC5B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED;;GAEG;AACH,UAAU,yBAAyB;IAC/B;;OAEG;IACH,IAAI,EAAE,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S,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;IAI5E;;;;;;OAMG;IACI,sBAAsB,CAAC,EAAE,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO;IAI/E;;;OAGG;IACH,SAAS,CAAC,YAAY;IAEtB;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAO7D;;;OAGG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IAgBxD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,oBAAoB;IAmC7C;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IASzG;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;;;;;OASG;IACH,OAAO,CAAC,SAAS;IAYjB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgG1B;;OAEG;IACH,SAAS,CAAC,cAAc;CAG3B"}
|
package/dist/directory.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.SharedDirectory = exports.DirectoryFactory = void 0;
|
|
27
27
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
28
|
+
const container_utils_1 = require("@fluidframework/container-utils");
|
|
28
29
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
29
30
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
30
31
|
const shared_object_base_1 = require("@fluidframework/shared-object-base");
|
|
@@ -219,6 +220,12 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
219
220
|
this.root.set(key, value);
|
|
220
221
|
return this;
|
|
221
222
|
}
|
|
223
|
+
dispose(error) {
|
|
224
|
+
this.root.dispose(error);
|
|
225
|
+
}
|
|
226
|
+
get disposed() {
|
|
227
|
+
return this.root.disposed;
|
|
228
|
+
}
|
|
222
229
|
/**
|
|
223
230
|
* Deletes the given key from within this IDirectory.
|
|
224
231
|
* @param key - The key to delete
|
|
@@ -268,6 +275,12 @@ class SharedDirectory extends shared_object_base_1.SharedObject {
|
|
|
268
275
|
entries() {
|
|
269
276
|
return this.root.entries();
|
|
270
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* {@inheritDoc IDirectory.countSubDirectory}
|
|
280
|
+
*/
|
|
281
|
+
countSubDirectory() {
|
|
282
|
+
return this.root.countSubDirectory();
|
|
283
|
+
}
|
|
271
284
|
/**
|
|
272
285
|
* Get an iterator over the keys under this IDirectory.
|
|
273
286
|
* @returns The iterator
|
|
@@ -551,6 +564,10 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
551
564
|
this.runtime = runtime;
|
|
552
565
|
this.serializer = serializer;
|
|
553
566
|
this.absolutePath = absolutePath;
|
|
567
|
+
/**
|
|
568
|
+
* Tells if the sub directory is disposed or not.
|
|
569
|
+
*/
|
|
570
|
+
this._disposed = false;
|
|
554
571
|
/**
|
|
555
572
|
* String representation for the class.
|
|
556
573
|
*/
|
|
@@ -581,12 +598,25 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
581
598
|
*/
|
|
582
599
|
this.pendingClearMessageId = -1;
|
|
583
600
|
}
|
|
601
|
+
dispose(error) {
|
|
602
|
+
this._disposed = true;
|
|
603
|
+
this.emit("disposed", this);
|
|
604
|
+
}
|
|
605
|
+
get disposed() {
|
|
606
|
+
return this._disposed;
|
|
607
|
+
}
|
|
608
|
+
throwIfDisposed() {
|
|
609
|
+
if (this._disposed) {
|
|
610
|
+
throw new container_utils_1.UsageError("Cannot access Disposed subDirectory");
|
|
611
|
+
}
|
|
612
|
+
}
|
|
584
613
|
/**
|
|
585
614
|
* Checks whether the given key exists in this IDirectory.
|
|
586
615
|
* @param key - The key to check
|
|
587
616
|
* @returns True if the key exists, false otherwise
|
|
588
617
|
*/
|
|
589
618
|
has(key) {
|
|
619
|
+
this.throwIfDisposed();
|
|
590
620
|
return this._storage.has(key);
|
|
591
621
|
}
|
|
592
622
|
/**
|
|
@@ -594,12 +624,14 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
594
624
|
*/
|
|
595
625
|
get(key) {
|
|
596
626
|
var _a;
|
|
627
|
+
this.throwIfDisposed();
|
|
597
628
|
return (_a = this._storage.get(key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
598
629
|
}
|
|
599
630
|
/**
|
|
600
631
|
* {@inheritDoc IDirectory.set}
|
|
601
632
|
*/
|
|
602
633
|
set(key, value) {
|
|
634
|
+
this.throwIfDisposed();
|
|
603
635
|
// Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.
|
|
604
636
|
if (key === undefined || key === null) {
|
|
605
637
|
throw new Error("Undefined and null keys are not supported");
|
|
@@ -622,10 +654,17 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
622
654
|
this.submitKeyMessage(op);
|
|
623
655
|
return this;
|
|
624
656
|
}
|
|
657
|
+
/**
|
|
658
|
+
* {@inheritDoc IDirectory.countSubDirectory}
|
|
659
|
+
*/
|
|
660
|
+
countSubDirectory() {
|
|
661
|
+
return this._subdirectories.size;
|
|
662
|
+
}
|
|
625
663
|
/**
|
|
626
664
|
* {@inheritDoc IDirectory.createSubDirectory}
|
|
627
665
|
*/
|
|
628
666
|
createSubDirectory(subdirName) {
|
|
667
|
+
this.throwIfDisposed();
|
|
629
668
|
// Undefined/null subdirectory names can't be serialized to JSON in the manner we currently snapshot.
|
|
630
669
|
if (subdirName === undefined || subdirName === null) {
|
|
631
670
|
throw new Error("SubDirectory name may not be undefined or null");
|
|
@@ -653,18 +692,21 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
653
692
|
* {@inheritDoc IDirectory.getSubDirectory}
|
|
654
693
|
*/
|
|
655
694
|
getSubDirectory(subdirName) {
|
|
695
|
+
this.throwIfDisposed();
|
|
656
696
|
return this._subdirectories.get(subdirName);
|
|
657
697
|
}
|
|
658
698
|
/**
|
|
659
699
|
* {@inheritDoc IDirectory.hasSubDirectory}
|
|
660
700
|
*/
|
|
661
701
|
hasSubDirectory(subdirName) {
|
|
702
|
+
this.throwIfDisposed();
|
|
662
703
|
return this._subdirectories.has(subdirName);
|
|
663
704
|
}
|
|
664
705
|
/**
|
|
665
706
|
* {@inheritDoc IDirectory.deleteSubDirectory}
|
|
666
707
|
*/
|
|
667
708
|
deleteSubDirectory(subdirName) {
|
|
709
|
+
this.throwIfDisposed();
|
|
668
710
|
// Delete the sub directory locally first.
|
|
669
711
|
const successfullyRemoved = this.deleteSubDirectoryCore(subdirName, true);
|
|
670
712
|
// If we are not attached, don't submit the op.
|
|
@@ -683,12 +725,14 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
683
725
|
* {@inheritDoc IDirectory.subdirectories}
|
|
684
726
|
*/
|
|
685
727
|
subdirectories() {
|
|
728
|
+
this.throwIfDisposed();
|
|
686
729
|
return this._subdirectories.entries();
|
|
687
730
|
}
|
|
688
731
|
/**
|
|
689
732
|
* {@inheritDoc IDirectory.getWorkingDirectory}
|
|
690
733
|
*/
|
|
691
734
|
getWorkingDirectory(relativePath) {
|
|
735
|
+
this.throwIfDisposed();
|
|
692
736
|
return this.directory.getWorkingDirectory(this.makeAbsolute(relativePath));
|
|
693
737
|
}
|
|
694
738
|
/**
|
|
@@ -697,6 +741,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
697
741
|
* @returns True if the key existed and was deleted, false if it did not exist
|
|
698
742
|
*/
|
|
699
743
|
delete(key) {
|
|
744
|
+
this.throwIfDisposed();
|
|
700
745
|
// Delete the key locally first.
|
|
701
746
|
const successfullyRemoved = this.deleteCore(key, true);
|
|
702
747
|
// If we are not attached, don't submit the op.
|
|
@@ -715,6 +760,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
715
760
|
* Deletes all keys from within this IDirectory.
|
|
716
761
|
*/
|
|
717
762
|
clear() {
|
|
763
|
+
this.throwIfDisposed();
|
|
718
764
|
// Clear the data locally first.
|
|
719
765
|
this.clearCore(true);
|
|
720
766
|
// If we are not attached, don't submit the op.
|
|
@@ -732,6 +778,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
732
778
|
* @param callback - Callback to issue
|
|
733
779
|
*/
|
|
734
780
|
forEach(callback) {
|
|
781
|
+
this.throwIfDisposed();
|
|
735
782
|
this._storage.forEach((localValue, key, map) => {
|
|
736
783
|
callback(localValue.value, key, map);
|
|
737
784
|
});
|
|
@@ -740,6 +787,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
740
787
|
* The number of entries under this IDirectory.
|
|
741
788
|
*/
|
|
742
789
|
get size() {
|
|
790
|
+
this.throwIfDisposed();
|
|
743
791
|
return this._storage.size;
|
|
744
792
|
}
|
|
745
793
|
/**
|
|
@@ -747,6 +795,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
747
795
|
* @returns The iterator
|
|
748
796
|
*/
|
|
749
797
|
entries() {
|
|
798
|
+
this.throwIfDisposed();
|
|
750
799
|
const localEntriesIterator = this._storage.entries();
|
|
751
800
|
const iterator = {
|
|
752
801
|
next() {
|
|
@@ -770,6 +819,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
770
819
|
* @returns The iterator
|
|
771
820
|
*/
|
|
772
821
|
keys() {
|
|
822
|
+
this.throwIfDisposed();
|
|
773
823
|
return this._storage.keys();
|
|
774
824
|
}
|
|
775
825
|
/**
|
|
@@ -777,6 +827,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
777
827
|
* @returns The iterator
|
|
778
828
|
*/
|
|
779
829
|
values() {
|
|
830
|
+
this.throwIfDisposed();
|
|
780
831
|
const localValuesIterator = this._storage.values();
|
|
781
832
|
const iterator = {
|
|
782
833
|
next() {
|
|
@@ -800,6 +851,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
800
851
|
* @returns The iterator
|
|
801
852
|
*/
|
|
802
853
|
[Symbol.iterator]() {
|
|
854
|
+
this.throwIfDisposed();
|
|
803
855
|
return this.entries();
|
|
804
856
|
}
|
|
805
857
|
/**
|
|
@@ -812,6 +864,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
812
864
|
* @internal
|
|
813
865
|
*/
|
|
814
866
|
processClearMessage(op, local, localOpMetadata) {
|
|
867
|
+
this.throwIfDisposed();
|
|
815
868
|
if (local) {
|
|
816
869
|
common_utils_1.assert(localOpMetadata !== undefined, 0x00f /* `pendingMessageId is missing from the local client's ${op.type} operation` */);
|
|
817
870
|
const pendingMessageId = localOpMetadata;
|
|
@@ -833,6 +886,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
833
886
|
* @internal
|
|
834
887
|
*/
|
|
835
888
|
processDeleteMessage(op, local, localOpMetadata) {
|
|
889
|
+
this.throwIfDisposed();
|
|
836
890
|
if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
|
|
837
891
|
return;
|
|
838
892
|
}
|
|
@@ -848,6 +902,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
848
902
|
* @internal
|
|
849
903
|
*/
|
|
850
904
|
processSetMessage(op, context, local, localOpMetadata) {
|
|
905
|
+
this.throwIfDisposed();
|
|
851
906
|
if (!this.needProcessStorageOperation(op, local, localOpMetadata)) {
|
|
852
907
|
return;
|
|
853
908
|
}
|
|
@@ -866,6 +921,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
866
921
|
* @internal
|
|
867
922
|
*/
|
|
868
923
|
processCreateSubDirectoryMessage(op, local, localOpMetadata) {
|
|
924
|
+
this.throwIfDisposed();
|
|
869
925
|
if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
|
|
870
926
|
return;
|
|
871
927
|
}
|
|
@@ -881,6 +937,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
881
937
|
* @internal
|
|
882
938
|
*/
|
|
883
939
|
processDeleteSubDirectoryMessage(op, local, localOpMetadata) {
|
|
940
|
+
this.throwIfDisposed();
|
|
884
941
|
if (!this.needProcessSubDirectoryOperations(op, local, localOpMetadata)) {
|
|
885
942
|
return;
|
|
886
943
|
}
|
|
@@ -892,6 +949,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
892
949
|
* @internal
|
|
893
950
|
*/
|
|
894
951
|
submitClearMessage(op) {
|
|
952
|
+
this.throwIfDisposed();
|
|
895
953
|
const pendingMessageId = ++this.pendingMessageId;
|
|
896
954
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
897
955
|
this.pendingClearMessageId = pendingMessageId;
|
|
@@ -902,6 +960,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
902
960
|
* @internal
|
|
903
961
|
*/
|
|
904
962
|
submitKeyMessage(op) {
|
|
963
|
+
this.throwIfDisposed();
|
|
905
964
|
const pendingMessageId = ++this.pendingMessageId;
|
|
906
965
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
907
966
|
this.pendingKeys.set(op.key, pendingMessageId);
|
|
@@ -912,6 +971,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
912
971
|
* @internal
|
|
913
972
|
*/
|
|
914
973
|
submitSubDirectoryMessage(op) {
|
|
974
|
+
this.throwIfDisposed();
|
|
915
975
|
const pendingMessageId = ++this.pendingMessageId;
|
|
916
976
|
this.directory.submitDirectoryMessage(op, pendingMessageId);
|
|
917
977
|
this.pendingSubDirectories.set(op.subdirName, pendingMessageId);
|
|
@@ -923,6 +983,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
923
983
|
* @internal
|
|
924
984
|
*/
|
|
925
985
|
*getSerializedStorage(serializer) {
|
|
986
|
+
this.throwIfDisposed();
|
|
926
987
|
for (const [key, localValue] of this._storage) {
|
|
927
988
|
const value = localValue.makeSerialized(serializer, this.directory.handle);
|
|
928
989
|
const res = [key, value];
|
|
@@ -936,6 +997,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
936
997
|
* @internal
|
|
937
998
|
*/
|
|
938
999
|
populateStorage(key, localValue) {
|
|
1000
|
+
this.throwIfDisposed();
|
|
939
1001
|
this._storage.set(key, localValue);
|
|
940
1002
|
}
|
|
941
1003
|
/**
|
|
@@ -945,6 +1007,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
945
1007
|
* @internal
|
|
946
1008
|
*/
|
|
947
1009
|
populateSubDirectory(subdirName, newSubDir) {
|
|
1010
|
+
this.throwIfDisposed();
|
|
948
1011
|
this._subdirectories.set(subdirName, newSubDir);
|
|
949
1012
|
}
|
|
950
1013
|
/**
|
|
@@ -955,6 +1018,7 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
955
1018
|
* @internal
|
|
956
1019
|
*/
|
|
957
1020
|
getLocalValue(key) {
|
|
1021
|
+
this.throwIfDisposed();
|
|
958
1022
|
return this._storage.get(key);
|
|
959
1023
|
}
|
|
960
1024
|
/**
|
|
@@ -1098,9 +1162,25 @@ class SubDirectory extends common_utils_1.TypedEventEmitter {
|
|
|
1098
1162
|
* @param op - The message if from a remote delete, or null if from a local delete
|
|
1099
1163
|
*/
|
|
1100
1164
|
deleteSubDirectoryCore(subdirName, local) {
|
|
1165
|
+
const previousValue = this.getSubDirectory(subdirName);
|
|
1101
1166
|
// This should make the subdirectory structure unreachable so it can be GC'd and won't appear in snapshots
|
|
1102
1167
|
// Might want to consider cleaning out the structure more exhaustively though?
|
|
1103
|
-
|
|
1168
|
+
const successfullyRemoved = this._subdirectories.delete(subdirName);
|
|
1169
|
+
this.disposeSubDirectoryTree(previousValue);
|
|
1170
|
+
return successfullyRemoved;
|
|
1171
|
+
}
|
|
1172
|
+
disposeSubDirectoryTree(directory) {
|
|
1173
|
+
if (!directory) {
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
// Dispose the subdirectory tree. This will dispose the subdirectories from bottom to top.
|
|
1177
|
+
const subDirectories = directory.subdirectories();
|
|
1178
|
+
for (const [_, subDirectory] of subDirectories) {
|
|
1179
|
+
this.disposeSubDirectoryTree(subDirectory);
|
|
1180
|
+
}
|
|
1181
|
+
if (typeof directory.dispose === "function") {
|
|
1182
|
+
directory.dispose();
|
|
1183
|
+
}
|
|
1104
1184
|
}
|
|
1105
1185
|
}
|
|
1106
1186
|
//# sourceMappingURL=directory.js.map
|