fyn 1.1.46 → 2.0.0
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 -2
- package/dist/fyn.js +135731 -89243
- package/dist/node_modules_f___cacache_20_0_1_cacache_node_modules_f___p-map_7_0_3_p-map_index_js +314 -0
- package/dist/node_modules_f___p-map_7_0_3_p-map_index_js +314 -0
- package/package.json +11 -11
- package/addon.gypi +0 -185
- package/bin/node-gyp.js +0 -3
- package/dist/Find-VisualStudio.cs +0 -250
- package/gyp/AUTHORS +0 -16
- package/gyp/LICENSE +0 -28
- package/gyp/data/win/large-pdb-shim.cc +0 -12
- package/gyp/gyp +0 -8
- package/gyp/gyp.bat +0 -5
- package/gyp/gyp_main.py +0 -45
- package/gyp/pylib/gyp/MSVSNew.py +0 -367
- package/gyp/pylib/gyp/MSVSProject.py +0 -206
- package/gyp/pylib/gyp/MSVSSettings.py +0 -1270
- package/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
- package/gyp/pylib/gyp/MSVSToolFile.py +0 -59
- package/gyp/pylib/gyp/MSVSUserFile.py +0 -153
- package/gyp/pylib/gyp/MSVSUtil.py +0 -271
- package/gyp/pylib/gyp/MSVSVersion.py +0 -574
- package/gyp/pylib/gyp/__init__.py +0 -666
- package/gyp/pylib/gyp/common.py +0 -654
- package/gyp/pylib/gyp/common_test.py +0 -78
- package/gyp/pylib/gyp/easy_xml.py +0 -165
- package/gyp/pylib/gyp/easy_xml_test.py +0 -109
- package/gyp/pylib/gyp/flock_tool.py +0 -55
- package/gyp/pylib/gyp/generator/__init__.py +0 -0
- package/gyp/pylib/gyp/generator/analyzer.py +0 -808
- package/gyp/pylib/gyp/generator/android.py +0 -1173
- package/gyp/pylib/gyp/generator/cmake.py +0 -1321
- package/gyp/pylib/gyp/generator/compile_commands_json.py +0 -120
- package/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
- package/gyp/pylib/gyp/generator/eclipse.py +0 -464
- package/gyp/pylib/gyp/generator/gypd.py +0 -89
- package/gyp/pylib/gyp/generator/gypsh.py +0 -58
- package/gyp/pylib/gyp/generator/make.py +0 -2518
- package/gyp/pylib/gyp/generator/msvs.py +0 -3978
- package/gyp/pylib/gyp/generator/msvs_test.py +0 -44
- package/gyp/pylib/gyp/generator/ninja.py +0 -2936
- package/gyp/pylib/gyp/generator/ninja_test.py +0 -55
- package/gyp/pylib/gyp/generator/xcode.py +0 -1394
- package/gyp/pylib/gyp/generator/xcode_test.py +0 -25
- package/gyp/pylib/gyp/input.py +0 -3137
- package/gyp/pylib/gyp/input_test.py +0 -98
- package/gyp/pylib/gyp/mac_tool.py +0 -771
- package/gyp/pylib/gyp/msvs_emulation.py +0 -1271
- package/gyp/pylib/gyp/ninja_syntax.py +0 -174
- package/gyp/pylib/gyp/simple_copy.py +0 -61
- package/gyp/pylib/gyp/win_tool.py +0 -374
- package/gyp/pylib/gyp/xcode_emulation.py +0 -1939
- package/gyp/pylib/gyp/xcode_ninja.py +0 -302
- package/gyp/pylib/gyp/xcodeproj_file.py +0 -3197
- package/gyp/pylib/gyp/xml_fix.py +0 -65
- package/gyp/requirements_dev.txt +0 -2
- package/gyp/setup.py +0 -42
- package/gyp/test_gyp.py +0 -260
- package/gyp/tools/README +0 -15
- package/gyp/tools/Xcode/README +0 -5
- package/gyp/tools/Xcode/Specifications/gyp.pbfilespec +0 -27
- package/gyp/tools/Xcode/Specifications/gyp.xclangspec +0 -226
- package/gyp/tools/emacs/README +0 -12
- package/gyp/tools/emacs/gyp-tests.el +0 -63
- package/gyp/tools/emacs/gyp.el +0 -275
- package/gyp/tools/emacs/run-unit-tests.sh +0 -7
- package/gyp/tools/emacs/testdata/media.gyp +0 -1105
- package/gyp/tools/emacs/testdata/media.gyp.fontified +0 -1107
- package/gyp/tools/graphviz.py +0 -102
- package/gyp/tools/pretty_gyp.py +0 -156
- package/gyp/tools/pretty_sln.py +0 -181
- package/gyp/tools/pretty_vcproj.py +0 -339
- package/node-gyp-bin/node-gyp +0 -6
- package/node-gyp-bin/node-gyp.cmd +0 -5
- package/src/win_delay_load_hook.cc +0 -39
package/dist/node_modules_f___cacache_20_0_1_cacache_node_modules_f___p-map_7_0_3_p-map_index_js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
exports.id = "node_modules_f___cacache_20_0_1_cacache_node_modules_f___p-map_7_0_3_p-map_index_js";
|
|
4
|
+
exports.ids = ["node_modules_f___cacache_20_0_1_cacache_node_modules_f___p-map_7_0_3_p-map_index_js"];
|
|
5
|
+
exports.modules = {
|
|
6
|
+
|
|
7
|
+
/***/ "./node_modules/.f/_/cacache/20.0.1/cacache/node_modules/.f/_/p-map/7.0.3/p-map/index.js":
|
|
8
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
9
|
+
|
|
10
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
/* harmony export */ "default": () => (/* binding */ pMap)
|
|
12
|
+
/* harmony export */ });
|
|
13
|
+
/* unused harmony exports pMapIterable, pMapSkip */
|
|
14
|
+
function _awaitAsyncGenerator(value) { return new _AwaitValue(value); }
|
|
15
|
+
|
|
16
|
+
function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; }
|
|
17
|
+
|
|
18
|
+
function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } }
|
|
19
|
+
|
|
20
|
+
_AsyncGenerator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; };
|
|
21
|
+
|
|
22
|
+
_AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
|
|
23
|
+
|
|
24
|
+
_AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
|
|
25
|
+
|
|
26
|
+
_AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };
|
|
27
|
+
|
|
28
|
+
function _AwaitValue(value) { this.wrapped = value; }
|
|
29
|
+
|
|
30
|
+
async function pMap(iterable, mapper, {
|
|
31
|
+
concurrency = Number.POSITIVE_INFINITY,
|
|
32
|
+
stopOnError = true,
|
|
33
|
+
signal
|
|
34
|
+
} = {}) {
|
|
35
|
+
return new Promise((resolve_, reject_) => {
|
|
36
|
+
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
|
37
|
+
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof mapper !== 'function') {
|
|
41
|
+
throw new TypeError('Mapper function is required');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === Number.POSITIVE_INFINITY)) {
|
|
45
|
+
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const result = [];
|
|
49
|
+
const errors = [];
|
|
50
|
+
const skippedIndexesMap = new Map();
|
|
51
|
+
let isRejected = false;
|
|
52
|
+
let isResolved = false;
|
|
53
|
+
let isIterableDone = false;
|
|
54
|
+
let resolvingCount = 0;
|
|
55
|
+
let currentIndex = 0;
|
|
56
|
+
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
57
|
+
|
|
58
|
+
const signalListener = () => {
|
|
59
|
+
reject(signal.reason);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const cleanup = () => {
|
|
63
|
+
signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', signalListener);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const resolve = value => {
|
|
67
|
+
resolve_(value);
|
|
68
|
+
cleanup();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const reject = reason => {
|
|
72
|
+
isRejected = true;
|
|
73
|
+
isResolved = true;
|
|
74
|
+
reject_(reason);
|
|
75
|
+
cleanup();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
if (signal) {
|
|
79
|
+
if (signal.aborted) {
|
|
80
|
+
reject(signal.reason);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
signal.addEventListener('abort', signalListener, {
|
|
84
|
+
once: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const next = async () => {
|
|
89
|
+
if (isResolved) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const nextItem = await iterator.next();
|
|
94
|
+
const index = currentIndex;
|
|
95
|
+
currentIndex++; // Note: `iterator.next()` can be called many times in parallel.
|
|
96
|
+
// This can cause multiple calls to this `next()` function to
|
|
97
|
+
// receive a `nextItem` with `done === true`.
|
|
98
|
+
// The shutdown logic that rejects/resolves must be protected
|
|
99
|
+
// so it runs only one time as the `skippedIndex` logic is
|
|
100
|
+
// non-idempotent.
|
|
101
|
+
|
|
102
|
+
if (nextItem.done) {
|
|
103
|
+
isIterableDone = true;
|
|
104
|
+
|
|
105
|
+
if (resolvingCount === 0 && !isResolved) {
|
|
106
|
+
if (!stopOnError && errors.length > 0) {
|
|
107
|
+
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
|
|
108
|
+
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
isResolved = true;
|
|
113
|
+
|
|
114
|
+
if (skippedIndexesMap.size === 0) {
|
|
115
|
+
resolve(result);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const pureResult = []; // Support multiple `pMapSkip`'s.
|
|
120
|
+
|
|
121
|
+
for (const [index, value] of result.entries()) {
|
|
122
|
+
if (skippedIndexesMap.get(index) === pMapSkip) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pureResult.push(value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
resolve(pureResult);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
resolvingCount++; // Intentionally detached
|
|
136
|
+
|
|
137
|
+
(async () => {
|
|
138
|
+
try {
|
|
139
|
+
const element = await nextItem.value;
|
|
140
|
+
|
|
141
|
+
if (isResolved) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const value = await mapper(element, index); // Use Map to stage the index of the element.
|
|
146
|
+
|
|
147
|
+
if (value === pMapSkip) {
|
|
148
|
+
skippedIndexesMap.set(index, value);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
result[index] = value;
|
|
152
|
+
resolvingCount--;
|
|
153
|
+
await next();
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (stopOnError) {
|
|
156
|
+
reject(error);
|
|
157
|
+
} else {
|
|
158
|
+
errors.push(error);
|
|
159
|
+
resolvingCount--; // In that case we can't really continue regardless of `stopOnError` state
|
|
160
|
+
// since an iterable is likely to continue throwing after it throws once.
|
|
161
|
+
// If we continue calling `next()` indefinitely we will likely end up
|
|
162
|
+
// in an infinite loop of failed iteration.
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
await next();
|
|
166
|
+
} catch (error) {
|
|
167
|
+
reject(error);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
})();
|
|
172
|
+
}; // Create the concurrent runners in a detached (non-awaited)
|
|
173
|
+
// promise. We need this so we can await the `next()` calls
|
|
174
|
+
// to stop creating runners before hitting the concurrency limit
|
|
175
|
+
// if the iterable has already been marked as done.
|
|
176
|
+
// NOTE: We *must* do this for async iterators otherwise we'll spin up
|
|
177
|
+
// infinite `next()` calls by default and never start the event loop.
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
(async () => {
|
|
181
|
+
for (let index = 0; index < concurrency; index++) {
|
|
182
|
+
try {
|
|
183
|
+
// eslint-disable-next-line no-await-in-loop
|
|
184
|
+
await next();
|
|
185
|
+
} catch (error) {
|
|
186
|
+
reject(error);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (isIterableDone || isRejected) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
})();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function pMapIterable(iterable, mapper, {
|
|
198
|
+
concurrency = Number.POSITIVE_INFINITY,
|
|
199
|
+
backpressure = concurrency
|
|
200
|
+
} = {}) {
|
|
201
|
+
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
|
202
|
+
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (typeof mapper !== 'function') {
|
|
206
|
+
throw new TypeError('Mapper function is required');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === Number.POSITIVE_INFINITY)) {
|
|
210
|
+
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!(Number.isSafeInteger(backpressure) && backpressure >= concurrency || backpressure === Number.POSITIVE_INFINITY)) {
|
|
214
|
+
throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${concurrency}) and up or \`Infinity\`, got \`${backpressure}\` (${typeof backpressure})`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
[Symbol.asyncIterator]() {
|
|
219
|
+
return _wrapAsyncGenerator(function* () {
|
|
220
|
+
const iterator = iterable[Symbol.asyncIterator] === undefined ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
|
|
221
|
+
const promises = [];
|
|
222
|
+
let runningMappersCount = 0;
|
|
223
|
+
let isDone = false;
|
|
224
|
+
let index = 0;
|
|
225
|
+
|
|
226
|
+
function trySpawn() {
|
|
227
|
+
if (isDone || !(runningMappersCount < concurrency && promises.length < backpressure)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const promise = (async () => {
|
|
232
|
+
const {
|
|
233
|
+
done,
|
|
234
|
+
value
|
|
235
|
+
} = await iterator.next();
|
|
236
|
+
|
|
237
|
+
if (done) {
|
|
238
|
+
return {
|
|
239
|
+
done: true
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
runningMappersCount++; // Spawn if still below concurrency and backpressure limit
|
|
244
|
+
|
|
245
|
+
trySpawn();
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
const returnValue = await mapper(await value, index++);
|
|
249
|
+
runningMappersCount--;
|
|
250
|
+
|
|
251
|
+
if (returnValue === pMapSkip) {
|
|
252
|
+
const index = promises.indexOf(promise);
|
|
253
|
+
|
|
254
|
+
if (index > 0) {
|
|
255
|
+
promises.splice(index, 1);
|
|
256
|
+
}
|
|
257
|
+
} // Spawn if still below backpressure limit and just dropped below concurrency limit
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
trySpawn();
|
|
261
|
+
return {
|
|
262
|
+
done: false,
|
|
263
|
+
value: returnValue
|
|
264
|
+
};
|
|
265
|
+
} catch (error) {
|
|
266
|
+
isDone = true;
|
|
267
|
+
return {
|
|
268
|
+
error
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
})();
|
|
272
|
+
|
|
273
|
+
promises.push(promise);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
trySpawn();
|
|
277
|
+
|
|
278
|
+
while (promises.length > 0) {
|
|
279
|
+
const {
|
|
280
|
+
error,
|
|
281
|
+
done,
|
|
282
|
+
value
|
|
283
|
+
} = yield _awaitAsyncGenerator(promises[0]); // eslint-disable-line no-await-in-loop
|
|
284
|
+
|
|
285
|
+
promises.shift();
|
|
286
|
+
|
|
287
|
+
if (error) {
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (done) {
|
|
292
|
+
return;
|
|
293
|
+
} // Spawn if just dropped below backpressure limit and below the concurrency limit
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
trySpawn();
|
|
297
|
+
|
|
298
|
+
if (value === pMapSkip) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
yield value;
|
|
303
|
+
}
|
|
304
|
+
})();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const pMapSkip = Symbol('skip');
|
|
310
|
+
|
|
311
|
+
/***/ })
|
|
312
|
+
|
|
313
|
+
};
|
|
314
|
+
;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
exports.id = "node_modules_f___p-map_7_0_3_p-map_index_js";
|
|
4
|
+
exports.ids = ["node_modules_f___p-map_7_0_3_p-map_index_js"];
|
|
5
|
+
exports.modules = {
|
|
6
|
+
|
|
7
|
+
/***/ "./node_modules/.f/_/p-map/7.0.3/p-map/index.js":
|
|
8
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
9
|
+
|
|
10
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
/* harmony export */ "default": () => (/* binding */ pMap)
|
|
12
|
+
/* harmony export */ });
|
|
13
|
+
/* unused harmony exports pMapIterable, pMapSkip */
|
|
14
|
+
function _awaitAsyncGenerator(value) { return new _AwaitValue(value); }
|
|
15
|
+
|
|
16
|
+
function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; }
|
|
17
|
+
|
|
18
|
+
function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } }
|
|
19
|
+
|
|
20
|
+
_AsyncGenerator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; };
|
|
21
|
+
|
|
22
|
+
_AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
|
|
23
|
+
|
|
24
|
+
_AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
|
|
25
|
+
|
|
26
|
+
_AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };
|
|
27
|
+
|
|
28
|
+
function _AwaitValue(value) { this.wrapped = value; }
|
|
29
|
+
|
|
30
|
+
async function pMap(iterable, mapper, {
|
|
31
|
+
concurrency = Number.POSITIVE_INFINITY,
|
|
32
|
+
stopOnError = true,
|
|
33
|
+
signal
|
|
34
|
+
} = {}) {
|
|
35
|
+
return new Promise((resolve_, reject_) => {
|
|
36
|
+
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
|
37
|
+
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof mapper !== 'function') {
|
|
41
|
+
throw new TypeError('Mapper function is required');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === Number.POSITIVE_INFINITY)) {
|
|
45
|
+
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const result = [];
|
|
49
|
+
const errors = [];
|
|
50
|
+
const skippedIndexesMap = new Map();
|
|
51
|
+
let isRejected = false;
|
|
52
|
+
let isResolved = false;
|
|
53
|
+
let isIterableDone = false;
|
|
54
|
+
let resolvingCount = 0;
|
|
55
|
+
let currentIndex = 0;
|
|
56
|
+
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
57
|
+
|
|
58
|
+
const signalListener = () => {
|
|
59
|
+
reject(signal.reason);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const cleanup = () => {
|
|
63
|
+
signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', signalListener);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const resolve = value => {
|
|
67
|
+
resolve_(value);
|
|
68
|
+
cleanup();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const reject = reason => {
|
|
72
|
+
isRejected = true;
|
|
73
|
+
isResolved = true;
|
|
74
|
+
reject_(reason);
|
|
75
|
+
cleanup();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
if (signal) {
|
|
79
|
+
if (signal.aborted) {
|
|
80
|
+
reject(signal.reason);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
signal.addEventListener('abort', signalListener, {
|
|
84
|
+
once: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const next = async () => {
|
|
89
|
+
if (isResolved) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const nextItem = await iterator.next();
|
|
94
|
+
const index = currentIndex;
|
|
95
|
+
currentIndex++; // Note: `iterator.next()` can be called many times in parallel.
|
|
96
|
+
// This can cause multiple calls to this `next()` function to
|
|
97
|
+
// receive a `nextItem` with `done === true`.
|
|
98
|
+
// The shutdown logic that rejects/resolves must be protected
|
|
99
|
+
// so it runs only one time as the `skippedIndex` logic is
|
|
100
|
+
// non-idempotent.
|
|
101
|
+
|
|
102
|
+
if (nextItem.done) {
|
|
103
|
+
isIterableDone = true;
|
|
104
|
+
|
|
105
|
+
if (resolvingCount === 0 && !isResolved) {
|
|
106
|
+
if (!stopOnError && errors.length > 0) {
|
|
107
|
+
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
|
|
108
|
+
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
isResolved = true;
|
|
113
|
+
|
|
114
|
+
if (skippedIndexesMap.size === 0) {
|
|
115
|
+
resolve(result);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const pureResult = []; // Support multiple `pMapSkip`'s.
|
|
120
|
+
|
|
121
|
+
for (const [index, value] of result.entries()) {
|
|
122
|
+
if (skippedIndexesMap.get(index) === pMapSkip) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pureResult.push(value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
resolve(pureResult);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
resolvingCount++; // Intentionally detached
|
|
136
|
+
|
|
137
|
+
(async () => {
|
|
138
|
+
try {
|
|
139
|
+
const element = await nextItem.value;
|
|
140
|
+
|
|
141
|
+
if (isResolved) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const value = await mapper(element, index); // Use Map to stage the index of the element.
|
|
146
|
+
|
|
147
|
+
if (value === pMapSkip) {
|
|
148
|
+
skippedIndexesMap.set(index, value);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
result[index] = value;
|
|
152
|
+
resolvingCount--;
|
|
153
|
+
await next();
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (stopOnError) {
|
|
156
|
+
reject(error);
|
|
157
|
+
} else {
|
|
158
|
+
errors.push(error);
|
|
159
|
+
resolvingCount--; // In that case we can't really continue regardless of `stopOnError` state
|
|
160
|
+
// since an iterable is likely to continue throwing after it throws once.
|
|
161
|
+
// If we continue calling `next()` indefinitely we will likely end up
|
|
162
|
+
// in an infinite loop of failed iteration.
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
await next();
|
|
166
|
+
} catch (error) {
|
|
167
|
+
reject(error);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
})();
|
|
172
|
+
}; // Create the concurrent runners in a detached (non-awaited)
|
|
173
|
+
// promise. We need this so we can await the `next()` calls
|
|
174
|
+
// to stop creating runners before hitting the concurrency limit
|
|
175
|
+
// if the iterable has already been marked as done.
|
|
176
|
+
// NOTE: We *must* do this for async iterators otherwise we'll spin up
|
|
177
|
+
// infinite `next()` calls by default and never start the event loop.
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
(async () => {
|
|
181
|
+
for (let index = 0; index < concurrency; index++) {
|
|
182
|
+
try {
|
|
183
|
+
// eslint-disable-next-line no-await-in-loop
|
|
184
|
+
await next();
|
|
185
|
+
} catch (error) {
|
|
186
|
+
reject(error);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (isIterableDone || isRejected) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
})();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function pMapIterable(iterable, mapper, {
|
|
198
|
+
concurrency = Number.POSITIVE_INFINITY,
|
|
199
|
+
backpressure = concurrency
|
|
200
|
+
} = {}) {
|
|
201
|
+
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
|
202
|
+
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (typeof mapper !== 'function') {
|
|
206
|
+
throw new TypeError('Mapper function is required');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === Number.POSITIVE_INFINITY)) {
|
|
210
|
+
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!(Number.isSafeInteger(backpressure) && backpressure >= concurrency || backpressure === Number.POSITIVE_INFINITY)) {
|
|
214
|
+
throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${concurrency}) and up or \`Infinity\`, got \`${backpressure}\` (${typeof backpressure})`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
[Symbol.asyncIterator]() {
|
|
219
|
+
return _wrapAsyncGenerator(function* () {
|
|
220
|
+
const iterator = iterable[Symbol.asyncIterator] === undefined ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
|
|
221
|
+
const promises = [];
|
|
222
|
+
let runningMappersCount = 0;
|
|
223
|
+
let isDone = false;
|
|
224
|
+
let index = 0;
|
|
225
|
+
|
|
226
|
+
function trySpawn() {
|
|
227
|
+
if (isDone || !(runningMappersCount < concurrency && promises.length < backpressure)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const promise = (async () => {
|
|
232
|
+
const {
|
|
233
|
+
done,
|
|
234
|
+
value
|
|
235
|
+
} = await iterator.next();
|
|
236
|
+
|
|
237
|
+
if (done) {
|
|
238
|
+
return {
|
|
239
|
+
done: true
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
runningMappersCount++; // Spawn if still below concurrency and backpressure limit
|
|
244
|
+
|
|
245
|
+
trySpawn();
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
const returnValue = await mapper(await value, index++);
|
|
249
|
+
runningMappersCount--;
|
|
250
|
+
|
|
251
|
+
if (returnValue === pMapSkip) {
|
|
252
|
+
const index = promises.indexOf(promise);
|
|
253
|
+
|
|
254
|
+
if (index > 0) {
|
|
255
|
+
promises.splice(index, 1);
|
|
256
|
+
}
|
|
257
|
+
} // Spawn if still below backpressure limit and just dropped below concurrency limit
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
trySpawn();
|
|
261
|
+
return {
|
|
262
|
+
done: false,
|
|
263
|
+
value: returnValue
|
|
264
|
+
};
|
|
265
|
+
} catch (error) {
|
|
266
|
+
isDone = true;
|
|
267
|
+
return {
|
|
268
|
+
error
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
})();
|
|
272
|
+
|
|
273
|
+
promises.push(promise);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
trySpawn();
|
|
277
|
+
|
|
278
|
+
while (promises.length > 0) {
|
|
279
|
+
const {
|
|
280
|
+
error,
|
|
281
|
+
done,
|
|
282
|
+
value
|
|
283
|
+
} = yield _awaitAsyncGenerator(promises[0]); // eslint-disable-line no-await-in-loop
|
|
284
|
+
|
|
285
|
+
promises.shift();
|
|
286
|
+
|
|
287
|
+
if (error) {
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (done) {
|
|
292
|
+
return;
|
|
293
|
+
} // Spawn if just dropped below backpressure limit and below the concurrency limit
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
trySpawn();
|
|
297
|
+
|
|
298
|
+
if (value === pMapSkip) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
yield value;
|
|
303
|
+
}
|
|
304
|
+
})();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const pMapSkip = Symbol('skip');
|
|
310
|
+
|
|
311
|
+
/***/ })
|
|
312
|
+
|
|
313
|
+
};
|
|
314
|
+
;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fyn",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "fyn is the NPM for fynpo -- a zero setup monorepo tool",
|
|
5
5
|
"main": "./bin/fyn.js",
|
|
6
6
|
"homepage": "https://jchip.github.io/fynpo/",
|
|
@@ -10,14 +10,18 @@
|
|
|
10
10
|
"debug-test": "node --inspect-brk node_modules/.bin/mocha --extension ts,js,tsx,jsx,cjs,mjs -c test/spec",
|
|
11
11
|
"lint": "xrun xarc/lint",
|
|
12
12
|
"compile-yarn": "babel yarn/src --out-dir yarn/lib",
|
|
13
|
-
"build": "xrun --serial
|
|
13
|
+
"build": "xrun --serial fyn/create-tgz compile-yarn bundle",
|
|
14
14
|
"analyze": "ANALYZE_BUNDLE=1 xrun compile-yarn bundle",
|
|
15
15
|
"coverage": "xrun xarc/check",
|
|
16
16
|
"ci:check": "xrun xarc/check",
|
|
17
17
|
"coveralls": "cat coverage/lcov.info | coveralls",
|
|
18
18
|
"prepublishOnly": "xrun build",
|
|
19
19
|
"postpack": "publish-util-postpack",
|
|
20
|
-
"blah": "exit 5"
|
|
20
|
+
"blah": "exit 5",
|
|
21
|
+
"test-npm-a": "npm run test-npm-b",
|
|
22
|
+
"test-npm-b": "env",
|
|
23
|
+
"hello1": "npm run hello -- from npm",
|
|
24
|
+
"hello": "echo hello"
|
|
21
25
|
},
|
|
22
26
|
"bin": {
|
|
23
27
|
"0-npx-please-run-this-for-fyn": "./bin/fyn.js",
|
|
@@ -27,15 +31,13 @@
|
|
|
27
31
|
"author": "Walmart GTP.js Team and Contributors",
|
|
28
32
|
"publishConfig": {
|
|
29
33
|
"access": "public",
|
|
30
|
-
"registry": "https://registry.npmjs.com/"
|
|
34
|
+
"registry": "https://registry.npmjs.com/",
|
|
35
|
+
"tag": "v2"
|
|
31
36
|
},
|
|
32
37
|
"files": [
|
|
33
38
|
"bin",
|
|
34
39
|
"dist",
|
|
35
|
-
"
|
|
36
|
-
"src",
|
|
37
|
-
"node-gyp-bin",
|
|
38
|
-
"addon.gypi"
|
|
40
|
+
"src"
|
|
39
41
|
],
|
|
40
42
|
"keywords": [
|
|
41
43
|
"node",
|
|
@@ -73,11 +75,9 @@
|
|
|
73
75
|
"Divya Karippath"
|
|
74
76
|
],
|
|
75
77
|
"engines": {
|
|
76
|
-
"node": ">=
|
|
78
|
+
"node": ">=14.14"
|
|
77
79
|
},
|
|
78
80
|
"opfs": {
|
|
79
|
-
"mkdirp": true,
|
|
80
|
-
"rimraf": true,
|
|
81
81
|
"bluebird": true
|
|
82
82
|
}
|
|
83
83
|
}
|