@atlaspack/utils 2.12.1-dev.3478 → 2.12.1-dev.3502
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/lib/index.js +15 -15
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/DefaultMap.js +3 -1
- package/src/dependency-location.js +2 -2
- package/test/PromiseQueue.test.js +25 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/utils",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3502+c2daeab5a",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaspack/codeframe": "2.12.1-dev.
|
|
33
|
-
"@atlaspack/diagnostic": "2.12.1-dev.
|
|
34
|
-
"@atlaspack/logger": "2.12.1-dev.
|
|
35
|
-
"@atlaspack/markdown-ansi": "2.12.1-dev.
|
|
36
|
-
"@atlaspack/rust": "2.12.1-dev.
|
|
32
|
+
"@atlaspack/codeframe": "2.12.1-dev.3502+c2daeab5a",
|
|
33
|
+
"@atlaspack/diagnostic": "2.12.1-dev.3502+c2daeab5a",
|
|
34
|
+
"@atlaspack/logger": "2.12.1-dev.3502+c2daeab5a",
|
|
35
|
+
"@atlaspack/markdown-ansi": "2.12.1-dev.3502+c2daeab5a",
|
|
36
|
+
"@atlaspack/rust": "2.12.1-dev.3502+c2daeab5a",
|
|
37
37
|
"@parcel/source-map": "^2.1.1",
|
|
38
38
|
"chalk": "^4.1.0",
|
|
39
39
|
"nullthrows": "^1.1.1"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"./src/openInBrowser.js": false,
|
|
64
64
|
"@atlaspack/markdown-ansi": false
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "c2daeab5a12461903159dec34df5671eaaa9b749"
|
|
67
67
|
}
|
package/src/DefaultMap.js
CHANGED
|
@@ -22,9 +22,11 @@ export class DefaultMap<K, V> extends Map<K, V> {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
interface Key {}
|
|
26
|
+
|
|
25
27
|
// Duplicated from DefaultMap implementation for Flow
|
|
26
28
|
// Roughly mirrors https://github.com/facebook/flow/blob/2eb5a78d92c167117ba9caae070afd2b9f598599/lib/core.js#L617
|
|
27
|
-
export class DefaultWeakMap<K:
|
|
29
|
+
export class DefaultWeakMap<K: Key, V> extends WeakMap<K, V> {
|
|
28
30
|
_getDefault: (K) => V;
|
|
29
31
|
|
|
30
32
|
constructor(getDefault: (K) => V, entries?: Iterable<[K, V]>) {
|
|
@@ -87,6 +87,31 @@ describe('PromiseQueue', () => {
|
|
|
87
87
|
assert(subscribedFn.called);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
+
it('runs functions concurrently', () => {
|
|
91
|
+
const queue = new PromiseQueue();
|
|
92
|
+
|
|
93
|
+
const fn1 = sinon
|
|
94
|
+
.stub()
|
|
95
|
+
.returns(new Promise((resolve) => setTimeout(resolve, 5000)));
|
|
96
|
+
|
|
97
|
+
queue.add(fn1); // queue does not work if nothing is running, this is broken behaviour
|
|
98
|
+
queue.run();
|
|
99
|
+
|
|
100
|
+
const fn2 = sinon
|
|
101
|
+
.stub()
|
|
102
|
+
.returns(new Promise((resolve) => setTimeout(resolve, 5000)));
|
|
103
|
+
const fn3 = sinon
|
|
104
|
+
.stub()
|
|
105
|
+
.returns(new Promise((resolve) => setTimeout(resolve, 5000)));
|
|
106
|
+
|
|
107
|
+
queue.add(fn2);
|
|
108
|
+
queue.add(fn3);
|
|
109
|
+
|
|
110
|
+
assert(fn1.calledOnce);
|
|
111
|
+
assert(fn2.calledOnce);
|
|
112
|
+
assert(fn3.calledOnce);
|
|
113
|
+
});
|
|
114
|
+
|
|
90
115
|
it('.subscribeToAdd() should allow unsubscribing', async () => {
|
|
91
116
|
const queue = new PromiseQueue();
|
|
92
117
|
|