fyn 2.0.4 → 2.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fyn",
3
- "version": "2.0.4",
3
+ "version": "2.1.1",
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/",
@@ -1,314 +0,0 @@
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
- ;