entropic-bond 1.45.0 → 1.45.1
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.
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { CloudStorage, StorableData, UploadControl } from './cloud-storage';
|
|
2
2
|
export declare class MockCloudStorage extends CloudStorage {
|
|
3
3
|
constructor(pathToMockFiles?: string);
|
|
4
|
+
/**
|
|
5
|
+
* Introduce a delay in the execution of operations to simulate a real data source
|
|
6
|
+
* @param miliSeconds the number of milliseconds to delay the execution of operations
|
|
7
|
+
* @returns a chainable reference to this object
|
|
8
|
+
*/
|
|
9
|
+
simulateDelay(miliSeconds: number): this;
|
|
10
|
+
private resolveWithDelay;
|
|
4
11
|
save(id: string, data: StorableData): Promise<string>;
|
|
5
12
|
uploadControl(): UploadControl;
|
|
6
13
|
getUrl(reference: string): Promise<string>;
|
|
7
14
|
delete(reference: string): Promise<void>;
|
|
15
|
+
private _simulateDelay;
|
|
16
|
+
private _pendingPromises;
|
|
8
17
|
private _onProgress;
|
|
9
18
|
private _pathToMockFiles;
|
|
10
19
|
mockFileSystem: {};
|
|
@@ -12,9 +12,30 @@ const cloud_storage_1 = require("./cloud-storage");
|
|
|
12
12
|
let MockCloudStorage = exports.MockCloudStorage = MockCloudStorage_1 = class MockCloudStorage extends cloud_storage_1.CloudStorage {
|
|
13
13
|
constructor(pathToMockFiles = '') {
|
|
14
14
|
super();
|
|
15
|
+
this._simulateDelay = 0;
|
|
16
|
+
this._pendingPromises = [];
|
|
15
17
|
this.mockFileSystem = {};
|
|
16
18
|
this._pathToMockFiles = pathToMockFiles;
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Introduce a delay in the execution of operations to simulate a real data source
|
|
22
|
+
* @param miliSeconds the number of milliseconds to delay the execution of operations
|
|
23
|
+
* @returns a chainable reference to this object
|
|
24
|
+
*/
|
|
25
|
+
simulateDelay(miliSeconds) {
|
|
26
|
+
this._simulateDelay = miliSeconds;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
resolveWithDelay(data) {
|
|
30
|
+
if (this._simulateDelay <= 0)
|
|
31
|
+
return Promise.resolve(data);
|
|
32
|
+
const promise = new Promise(resolve => {
|
|
33
|
+
setTimeout(() => resolve(data), this._simulateDelay);
|
|
34
|
+
});
|
|
35
|
+
this._pendingPromises.push(promise);
|
|
36
|
+
promise.finally(() => this._pendingPromises = this._pendingPromises.filter(p => p === promise));
|
|
37
|
+
return promise;
|
|
38
|
+
}
|
|
18
39
|
save(id, data) {
|
|
19
40
|
const fullPath = id;
|
|
20
41
|
if (this._onProgress)
|
|
@@ -23,7 +44,7 @@ let MockCloudStorage = exports.MockCloudStorage = MockCloudStorage_1 = class Moc
|
|
|
23
44
|
if (this._onProgress)
|
|
24
45
|
this._onProgress(100, 100);
|
|
25
46
|
const ref = data instanceof File ? data.name : fullPath;
|
|
26
|
-
return
|
|
47
|
+
return this.resolveWithDelay(ref);
|
|
27
48
|
}
|
|
28
49
|
uploadControl() {
|
|
29
50
|
return {
|
|
@@ -38,7 +59,7 @@ let MockCloudStorage = exports.MockCloudStorage = MockCloudStorage_1 = class Moc
|
|
|
38
59
|
}
|
|
39
60
|
delete(reference) {
|
|
40
61
|
delete this.mockFileSystem[reference];
|
|
41
|
-
return
|
|
62
|
+
return this.resolveWithDelay();
|
|
42
63
|
}
|
|
43
64
|
};
|
|
44
65
|
exports.MockCloudStorage = MockCloudStorage = MockCloudStorage_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-cloud-storage.js","sourceRoot":"","sources":["../../src/cloud-storage/mock-cloud-storage.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,mDAAiH;AAG1G,IAAM,gBAAgB,mDAAtB,MAAM,gBAAiB,SAAQ,4BAAY;IACjD,YAAa,kBAA0B,EAAE;QACxC,KAAK,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"mock-cloud-storage.js","sourceRoot":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