occam-languages 2.2.26 → 2.2.28

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,427 +1,569 @@
1
1
  "use strict";
2
2
 
3
- import { arrayUtilities, asynchronousUtilities } from "necessary";
3
+ import { arrayUtilities } from "necessary";
4
4
 
5
- const { filter: arrayFilter } = arrayUtilities,
6
- { forEach: asynchronousForEach,
7
- forwardsForEach: asynchronousForwardsForEach,
8
- backwardsForEach: asynchronousBackwardsForEach } = asynchronousUtilities;
5
+ const { filter: arrayFilter } = arrayUtilities;
9
6
 
10
7
  export function one(array, callback, ...initialArguments) {
11
- let success = false;
8
+ const continuation = initialArguments.pop(),
9
+ length = array.length;
12
10
 
13
- const continuation = initialArguments.pop();
11
+ let count = 0,
12
+ index = -1;
14
13
 
15
- let callbackArguments = initialArguments; ///
14
+ let finalArguments;
16
15
 
17
- return asynchronousForEach(array, (element, next, done) => {
18
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
19
- const passed = intermediateArguments.shift();
16
+ function next(...callbackArguments) {
17
+ index++;
20
18
 
21
- callbackArguments = intermediateArguments; ///
19
+ if (index === length) {
20
+ const success = (count === 1);
22
21
 
23
- if (passed) {
24
- if (!success) {
25
- success = true;
26
- } else {
27
- success = false;
22
+ if (!success) {
23
+ finalArguments = initialArguments; ///
24
+ }
25
+
26
+ return continuation(success, ...finalArguments);
27
+ }
28
+
29
+ const element = array[index];
28
30
 
29
- done();
31
+ return callback(element, ...callbackArguments, (success, ...intermediateArguments) => {
32
+ if (success) {
33
+ if (count === 1) {
34
+ const success = false;
30
35
 
31
- return;
36
+ finalArguments = initialArguments; ///
37
+
38
+ return continuation(success, ...finalArguments);
32
39
  }
40
+
41
+ finalArguments = intermediateArguments; ///
42
+
43
+ count++;
33
44
  }
34
45
 
35
- next();
46
+ const callbackArguments = initialArguments; ///
47
+
48
+ return next(...callbackArguments);
36
49
  });
37
- }, () => {
38
- const finalArguments = callbackArguments; ///
50
+ }
39
51
 
40
- return continuation(success, ...finalArguments);
41
- });
52
+ const callbackArguments = initialArguments; ///
53
+
54
+ return next(...callbackArguments);
42
55
  }
43
56
 
44
57
  export function some(array, callback, ...initialArguments) {
45
- let success = false;
58
+ const continuation = initialArguments.pop(),
59
+ length = array.length;
46
60
 
47
- const continuation = initialArguments.pop();
61
+ let index = -1;
48
62
 
49
- let callbackArguments = initialArguments; ///
63
+ let finalArguments;
50
64
 
51
- return asynchronousForEach(array, (element, next, done) => {
52
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
53
- const passed = intermediateArguments.shift();
65
+ function next(...callbackArguments) {
66
+ index++;
54
67
 
55
- callbackArguments = intermediateArguments; ///
68
+ if (index === length) {
69
+ const success = false;
56
70
 
57
- if (passed) {
58
- success = true;
71
+ finalArguments = initialArguments; ///
72
+
73
+ return continuation(success, ...finalArguments);
74
+ }
75
+
76
+ const element = array[index];
59
77
 
60
- done();
78
+ return callback(element, ...callbackArguments, (success, ...intermediateArguments) => {
79
+ if (success) {
80
+ finalArguments = intermediateArguments; ///
61
81
 
62
- return;
82
+ return continuation(success, ...finalArguments);
63
83
  }
64
84
 
65
- next();
85
+ const callbackArguments = initialArguments; ///
86
+
87
+ return next(...callbackArguments);
66
88
  });
67
- }, () => {
68
- const finalArguments = callbackArguments; ///
89
+ }
69
90
 
70
- return continuation(success, ...finalArguments);
71
- });
91
+ const callbackArguments = initialArguments; ///
92
+
93
+ return next(...callbackArguments);
72
94
  }
73
95
 
74
96
  export function each(array, callback, ...initialArguments) {
75
- let success = false;
97
+ const continuation = initialArguments.pop(),
98
+ length = array.length;
76
99
 
77
- const continuation = initialArguments.pop();
100
+ let count = 0,
101
+ index = -1;
78
102
 
79
- let callbackArguments = initialArguments; ///
103
+ let finalArguments;
80
104
 
81
- return asynchronousForEach(array, (element, next, done) => {
82
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
83
- const passed = intermediateArguments.shift();
105
+ function next(...callbackArguments) {
106
+ index++;
84
107
 
85
- callbackArguments = intermediateArguments; ///
108
+ if (index === length) {
109
+ const success = (count > 0);
86
110
 
87
- if (passed) {
88
- success = true;
89
- } else {
90
- success = false;
111
+ finalArguments = callbackArguments; ///
91
112
 
92
- done();
113
+ return continuation(success, ...finalArguments);
114
+ }
93
115
 
94
- return;
116
+ const element = array[index];
117
+
118
+ return callback(element, ...callbackArguments, (success, ...intermediateArguments) => {
119
+ if (!success) {
120
+ finalArguments = initialArguments; ///
121
+
122
+ return continuation(success, ...finalArguments);
95
123
  }
96
124
 
97
- next();
125
+ count++;
126
+
127
+ const callbackArguments = intermediateArguments; ///
128
+
129
+ return next(...callbackArguments);
98
130
  });
99
- }, () => {
100
- const finalArguments = callbackArguments; ///
131
+ }
101
132
 
102
- return continuation(success, ...finalArguments);
103
- });
133
+ const callbackArguments = initialArguments; ///
134
+
135
+ return next(...callbackArguments);
104
136
  }
105
137
 
106
138
  export function every(array, callback, ...initialArguments) {
107
- let success = true;
139
+ const continuation = initialArguments.pop(),
140
+ length = array.length;
108
141
 
109
- const continuation = initialArguments.pop();
142
+ let index = -1;
110
143
 
111
- let callbackArguments = initialArguments; ///
144
+ let finalArguments;
112
145
 
113
- return asynchronousForEach(array, (element, next, done) => {
114
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
115
- const passed = intermediateArguments.shift();
146
+ function next(...callbackArguments) {
147
+ index++;
116
148
 
117
- callbackArguments = intermediateArguments; ///
149
+ if (index === length) {
150
+ const success = true;
118
151
 
119
- if (!passed) {
120
- success = false;
152
+ finalArguments = callbackArguments; ///
153
+
154
+ return continuation(success, ...finalArguments);
155
+ }
156
+
157
+ const element = array[index];
121
158
 
122
- done();
159
+ return callback(element, ...callbackArguments, (success, ...intermediateArguments) => {
160
+ if (!success) {
161
+ finalArguments = initialArguments; ///
123
162
 
124
- return;
163
+ return continuation(success, ...finalArguments);
125
164
  }
126
165
 
127
- next();
166
+ const callbackArguments = intermediateArguments; ///
167
+
168
+ return next(...callbackArguments);
128
169
  });
129
- }, () => {
130
- const finalArguments = callbackArguments; ///
170
+ }
131
171
 
132
- return continuation(success, ...finalArguments);
133
- });
172
+ const callbackArguments = initialArguments; ///
173
+
174
+ return next(...callbackArguments);
134
175
  }
135
176
 
136
177
  export function reduce(array, initialValue, callback, ...initialArguments) {
137
- let value = initialValue; ///
178
+ const continuation = initialArguments.pop(),
179
+ length = array.length;
138
180
 
139
- const continuation = initialArguments.pop();
181
+ let index = -1;
140
182
 
141
- let callbackArguments = initialArguments; ///
183
+ let finalArguments;
142
184
 
143
- return asynchronousForEach(array, (element, next, done) => {
144
- return callback(value, element, ...callbackArguments, (...intermediateArguments) => {
145
- const currentValue = intermediateArguments.shift();
185
+ function next(value, ...callbackArguments) {
186
+ index++;
187
+
188
+ if (index === length) {
189
+ finalArguments = callbackArguments; ///
146
190
 
147
- callbackArguments = intermediateArguments; ///
191
+ return continuation(value, ...finalArguments);
192
+ }
148
193
 
149
- value = currentValue; ///
194
+ const element = array[index];
150
195
 
151
- next();
196
+ return callback(element, value, ...callbackArguments, (value, ...intermediateArguments) => {
197
+ const callbackArguments = intermediateArguments; ///
198
+
199
+ return next(value, ...callbackArguments);
152
200
  });
153
- }, () => {
154
- const finalArguments = callbackArguments; ///
201
+ }
155
202
 
156
- return continuation(value, ...finalArguments);
157
- });
203
+ const value = initialValue, ///
204
+ callbackArguments = initialArguments; ///
205
+
206
+ return next(value, ...callbackArguments);
158
207
  }
159
208
 
160
209
  export function forEach(array, callback, ...initialArguments) {
161
- const continuation = initialArguments.pop();
210
+ const continuation = initialArguments.pop(),
211
+ length = array.length;
212
+
213
+ let index = -1;
214
+
215
+ let finalArguments;
162
216
 
163
- let callbackArguments = initialArguments; ///
217
+ function next(...callbackArguments) {
218
+ index++;
219
+
220
+ if (index === length) {
221
+ finalArguments = callbackArguments; ///
222
+
223
+ return continuation(...finalArguments);
224
+ }
225
+
226
+ const element = array[index];
164
227
 
165
- return asynchronousForEach(array, (element, next, done) => {
166
228
  return callback(element, ...callbackArguments, (...intermediateArguments) => {
167
- callbackArguments = intermediateArguments; ///
229
+ const callbackArguments = intermediateArguments; ///
168
230
 
169
- next();
231
+ return next(...callbackArguments);
170
232
  });
171
- }, () => {
172
- const finalArguments = callbackArguments; ///
233
+ }
173
234
 
174
- return continuation(...finalArguments);
175
- });
235
+ const callbackArguments = initialArguments; ///
236
+
237
+ return next(...callbackArguments);
176
238
  }
177
239
 
178
240
  export function forwardsEvery(array, callback, ...initialArguments) {
179
- let success = true;
241
+ const continuation = initialArguments.pop(),
242
+ length = array.length;
180
243
 
181
- const continuation = initialArguments.pop();
244
+ let index = -1;
182
245
 
183
- let callbackArguments = initialArguments; ///
246
+ let finalArguments;
184
247
 
185
- return asynchronousForwardsForEach(array, (element, next, done) => {
186
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
187
- const passed = intermediateArguments.shift();
248
+ function next(...callbackArguments) {
249
+ index++;
188
250
 
189
- callbackArguments = intermediateArguments; ///
251
+ if (index === length) {
252
+ const success = true;
190
253
 
191
- if (!passed) {
192
- success = false;
254
+ finalArguments = callbackArguments; ///
193
255
 
194
- done();
256
+ return continuation(success, ...finalArguments);
257
+ }
258
+
259
+ const element = array[index];
195
260
 
196
- return;
261
+ return callback(element, ...callbackArguments, (success, ...intermediateArguments) => {
262
+ if (!success) {
263
+ finalArguments = initialArguments; ///
264
+
265
+ return continuation(success, ...finalArguments);
197
266
  }
198
267
 
199
- next();
268
+ const callbackArguments = intermediateArguments; ///
269
+
270
+ return next(...callbackArguments);
200
271
  });
201
- }, () => {
202
- const finalArguments = callbackArguments; ///
272
+ }
203
273
 
204
- return continuation(success, ...finalArguments);
205
- });
274
+ const callbackArguments = initialArguments; ///
275
+
276
+ return next(...callbackArguments);
206
277
  }
207
278
 
208
279
  export function backwardsEvery(array, callback, ...initialArguments) {
209
- let success = true;
280
+ const continuation = initialArguments.pop(),
281
+ length = array.length;
210
282
 
211
- const continuation = initialArguments.pop();
283
+ let index = length;
212
284
 
213
- let callbackArguments = initialArguments; ///
285
+ let finalArguments;
214
286
 
215
- return asynchronousBackwardsForEach(array, (element, next, done) => {
216
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
217
- const passed = intermediateArguments.shift();
287
+ function next(...callbackArguments) {
288
+ index--;
218
289
 
219
- callbackArguments = intermediateArguments; ///
290
+ if (index === -1) {
291
+ const success = true;
220
292
 
221
- if (!passed) {
222
- success = false;
293
+ finalArguments = callbackArguments; ///
294
+
295
+ return continuation(success, ...finalArguments);
296
+ }
297
+
298
+ const element = array[index];
223
299
 
224
- done();
300
+ return callback(element, ...callbackArguments, (success, ...intermediateArguments) => {
301
+ if (!success) {
302
+ finalArguments = initialArguments; ///
225
303
 
226
- return;
304
+ return continuation(success, ...finalArguments);
227
305
  }
228
306
 
229
- next();
307
+ const callbackArguments = intermediateArguments; ///
308
+
309
+ return next(...callbackArguments);
230
310
  });
231
- }, () => {
232
- const finalArguments = callbackArguments; ///
311
+ }
233
312
 
234
- return continuation(success, ...finalArguments);
235
- });
313
+ const callbackArguments = initialArguments; ///
314
+
315
+ return next(...callbackArguments);
236
316
  }
237
317
 
238
318
  export function forwardsForEach(array, callback, ...initialArguments) {
239
- const continuation = initialArguments.pop();
319
+ const continuation = initialArguments.pop(),
320
+ length = array.length;
321
+
322
+ let index = -1;
323
+
324
+ let finalArguments;
325
+
326
+ function next(...callbackArguments) {
327
+ index++;
328
+
329
+ if (index === length) {
330
+ finalArguments = callbackArguments; ///
240
331
 
241
- let callbackArguments = initialArguments; ///
332
+ return continuation(...finalArguments);
333
+ }
334
+
335
+ const element = array[index];
242
336
 
243
- return asynchronousForwardsForEach(array, (element, next, done) => {
244
337
  return callback(element, ...callbackArguments, (...intermediateArguments) => {
245
- callbackArguments = intermediateArguments; ///
338
+ const callbackArguments = intermediateArguments; ///
246
339
 
247
- next();
340
+ return next(...callbackArguments);
248
341
  });
249
- }, () => {
250
- const finalArguments = callbackArguments; ///
342
+ }
251
343
 
252
- return continuation(...finalArguments);
253
- });
344
+ const callbackArguments = initialArguments; ///
345
+
346
+ return next(...callbackArguments);
254
347
  }
255
348
 
256
349
  export function backwardsForEach(array, callback, ...initialArguments) {
257
- const continuation = initialArguments.pop();
350
+ const continuation = initialArguments.pop(),
351
+ length = array.length;
352
+
353
+ let index = length;
354
+
355
+ let finalArguments;
356
+
357
+ function next(...callbackArguments) {
358
+ index--;
359
+
360
+ if (index === -1) {
361
+ finalArguments = callbackArguments; ///
362
+
363
+ return continuation(...finalArguments);
364
+ }
258
365
 
259
- let callbackArguments = initialArguments; ///
366
+ const element = array[index];
260
367
 
261
- return asynchronousBackwardsForEach(array, (element, next, done) => {
262
368
  return callback(element, ...callbackArguments, (...intermediateArguments) => {
263
- callbackArguments = intermediateArguments; ///
369
+ const callbackArguments = intermediateArguments; ///
264
370
 
265
- next();
371
+ return next(...callbackArguments);
266
372
  });
267
- }, () => {
268
- const finalArguments = callbackArguments; ///
373
+ }
374
+
375
+ const callbackArguments = initialArguments; ///
269
376
 
270
- return continuation(...finalArguments);
271
- });
377
+ return next(...callbackArguments);
272
378
  }
273
379
 
274
380
  export function filter(array, callback, ...initialArguments) {
275
- const deletedElements = [];
381
+ const continuation = initialArguments.pop(),
382
+ length = array.length;
276
383
 
277
- const continuation = initialArguments.pop();
384
+ const deletedElements = [];
278
385
 
279
- let callbackArguments = initialArguments; ///
386
+ let index = length;
280
387
 
281
- let index = array.length;
388
+ let finalArguments;
282
389
 
283
- return asynchronousBackwardsForEach(array, (element, next, done) => {
390
+ function next(...callbackArguments) {
284
391
  index--;
285
392
 
286
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
287
- const passed = intermediateArguments.shift();
393
+ if (index === -1) {
394
+ finalArguments = callbackArguments; ///
395
+
396
+ return continuation(deletedElements, ...finalArguments);
397
+ }
288
398
 
289
- callbackArguments = intermediateArguments; ///
399
+ const element = array[index];
290
400
 
401
+ return callback(element, ...callbackArguments, (passed, ...intermediateArguments) => {
291
402
  if (!passed) {
292
- const start = index, ///
403
+ const startIndex = index, ///
293
404
  deleteCount = 1,
294
- deletedElement = array.splice(start, deleteCount).pop(); ///
405
+ deletedElement = element; ///
295
406
 
296
- deletedElements.unshift(deletedElement); ///
407
+ array.splice(startIndex, deleteCount);
408
+
409
+ deletedElements.unshift(deletedElement);
297
410
  }
298
411
 
299
- next();
412
+ const callbackArguments = intermediateArguments; ///
413
+
414
+ return next(...callbackArguments);
300
415
  });
301
- }, () => {
302
- const finalArguments = callbackArguments; ///
416
+ }
417
+
418
+ const callbackArguments = initialArguments; ///
303
419
 
304
- return continuation(deletedElements, ...finalArguments);
305
- });
420
+ return next(...callbackArguments);
306
421
  }
307
422
 
308
423
  export function prune(array, callback, ...initialArguments) {
309
- let deletedElement = undefined; ///
424
+ const continuation = initialArguments.pop(),
425
+ length = array.length;
310
426
 
311
- const continuation = initialArguments.pop();
427
+ let deletedElement;
312
428
 
313
- let callbackArguments = initialArguments; ///
429
+ let index = length;
314
430
 
315
- let index = -1;
431
+ let finalArguments;
316
432
 
317
- return asynchronousForEach(array, (element, next, done) => {
318
- index++;
433
+ function next(...callbackArguments) {
434
+ index--;
319
435
 
320
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
321
- const passed = intermediateArguments.shift();
436
+ if (index === -1) {
437
+ deletedElement = undefined;
438
+
439
+ finalArguments = initialArguments; ///
322
440
 
323
- callbackArguments = intermediateArguments; ///
441
+ return continuation(deletedElement, ...finalArguments);
442
+ }
324
443
 
444
+ const element = array[index];
445
+
446
+ return callback(element, ...callbackArguments, (passed, ...intermediateArguments) => {
325
447
  if (!passed) {
326
- const start = index, ///
327
- deleteCount = 1;
448
+ const startIndex = index, ///
449
+ deleteCount = 1,
450
+ deletedElement = element; ///
328
451
 
329
- deletedElement = array.splice(start, deleteCount).pop(); ///
452
+ array.splice(startIndex, deleteCount);
330
453
 
331
- done();
454
+ finalArguments = intermediateArguments; ///
332
455
 
333
- return;
456
+ return continuation(deletedElement, ...finalArguments);
334
457
  }
335
458
 
336
- next();
459
+ const callbackArguments = initialArguments; ///
460
+
461
+ return next(...callbackArguments);
337
462
  });
338
- }, () => {
339
- const finalArguments = callbackArguments; ///
463
+ }
464
+
465
+ const callbackArguments = initialArguments; ///
340
466
 
341
- return continuation(deletedElement, ...finalArguments);
342
- });
467
+ return next(...callbackArguments);
343
468
  }
344
469
 
345
470
  export function extract(array, callback, ...initialArguments) {
346
- let deletedElement = undefined; ///
471
+ const continuation = initialArguments.pop(),
472
+ length = array.length;
347
473
 
348
- const continuation = initialArguments.pop();
474
+ let deletedElement;
349
475
 
350
- let callbackArguments = initialArguments; ///
476
+ let index = length;
351
477
 
352
- let index = -1;
478
+ let finalArguments;
353
479
 
354
- return asynchronousForEach(array, (element, next, done) => {
355
- index++;
480
+ function next(...callbackArguments) {
481
+ index--;
356
482
 
357
- return callback(element, ...callbackArguments, (...intermediateArguments) => {
358
- const passed = intermediateArguments.shift();
483
+ if (index === -1) {
484
+ deletedElement = undefined;
485
+
486
+ finalArguments = initialArguments; ///
487
+
488
+ return continuation(deletedElement, ...finalArguments);
489
+ }
359
490
 
360
- callbackArguments = intermediateArguments; ///
491
+ const element = array[index];
361
492
 
493
+ return callback(element, ...callbackArguments, (passed, ...intermediateArguments) => {
362
494
  if (passed) {
363
- const start = index, ///
364
- deleteCount = 1;
495
+ const startIndex = index, ///
496
+ deleteCount = 1,
497
+ deletedElement = element; ///
365
498
 
366
- deletedElement = array.splice(start, deleteCount).pop(); ///
499
+ array.splice(startIndex, deleteCount);
367
500
 
368
- done();
501
+ finalArguments = intermediateArguments; ///
369
502
 
370
- return;
503
+ return continuation(deletedElement, ...finalArguments);
371
504
  }
372
505
 
373
- next();
506
+ const callbackArguments = initialArguments; ///
507
+
508
+ return next(...callbackArguments);
374
509
  });
375
- }, () => {
376
- const finalArguments = callbackArguments; ///
510
+ }
377
511
 
378
- return continuation(deletedElement, ...finalArguments);
379
- });
512
+ const callbackArguments = initialArguments; ///
513
+
514
+ return next(...callbackArguments);
380
515
  }
381
516
 
382
517
  export function match(arrayA, arrayB, callback, ...initialArguments) {
383
- let success = true;
384
-
385
518
  const continuation = initialArguments.pop();
386
519
 
387
520
  const arrayALength = arrayA.length,
388
521
  arrayBLength = arrayB.length;
389
522
 
523
+ let finalArguments;
524
+
390
525
  if (arrayALength !== arrayBLength) {
391
- success = false;
526
+ const success = false;
392
527
 
393
- return continuation(success, ...initialArguments);
528
+ finalArguments = initialArguments; ///
529
+
530
+ return continuation(success, ...finalArguments);
394
531
  }
395
532
 
396
- let index = -1;
533
+ const length = arrayALength; ///
397
534
 
398
- let callbackArguments = initialArguments; ///
535
+ let index = -1;
399
536
 
400
- return asynchronousForEach(arrayA, (elementA, next, done) => {
537
+ function next(...callbackArguments) {
401
538
  index++;
402
539
 
403
- const elementB = arrayB[index];
540
+ if (index === length) {
541
+ const success = true;
404
542
 
405
- return callback(elementA, elementB, ...callbackArguments, (...intermediateArguments) => {
406
- const passed = intermediateArguments.shift();
543
+ finalArguments = callbackArguments; ///
407
544
 
408
- callbackArguments = intermediateArguments; ///
545
+ return continuation(success, ...finalArguments);
546
+ }
409
547
 
410
- if (!passed) {
411
- success = false;
548
+ const elementA = arrayA[index],
549
+ elementB = arrayB[index];
412
550
 
413
- done();
551
+ return callback(elementA, elementB, ...callbackArguments, (success, ...intermediateArguments) => {
552
+ if (!success) {
553
+ finalArguments = initialArguments; ///
414
554
 
415
- return;
555
+ return continuation(success, ...finalArguments);
416
556
  }
417
557
 
418
- next();
558
+ const callbackArguments = intermediateArguments; ///
559
+
560
+ return next(...callbackArguments);
419
561
  });
420
- }, () => {
421
- const finalArguments = callbackArguments; ///
562
+ }
422
563
 
423
- return continuation(success, ...finalArguments);
424
- });
564
+ const callbackArguments = initialArguments; ///
565
+
566
+ return next(...callbackArguments);
425
567
  }
426
568
 
427
569
  export function resolve(arrayA, arrayB, callback, ...initialArguments) {
@@ -431,33 +573,31 @@ export function resolve(arrayA, arrayB, callback, ...initialArguments) {
431
573
 
432
574
  const continuation = initialArguments.pop();
433
575
 
434
- let callbackArguments = initialArguments; ///
576
+ let finalArguments;
435
577
 
436
- function nextPass() {
578
+ function nextPass(...callbackArguments) {
437
579
  let success = false;
438
580
 
439
- const arrayALength = arrayA.length;
581
+ const length = arrayA.length; ///
440
582
 
441
- if (arrayALength === 0) {
583
+ if (length === 0) {
442
584
  success = true;
443
585
 
444
- const finalArguments = callbackArguments; ///
586
+ finalArguments = callbackArguments; ///
445
587
 
446
588
  return continuation(success, ...finalArguments);
447
589
  }
448
590
 
449
591
  let index = -1;
450
592
 
451
- function nextElement() {
593
+ function nextElement(...callbackArguments) {
452
594
  index++;
453
595
 
454
- const terminate = (index === arrayALength);
455
-
456
- if (terminate) {
596
+ if (index === length) {
457
597
  if (!success) {
458
598
  success = false;
459
599
 
460
- const finalArguments = callbackArguments; ///
600
+ const finalArguments = initialArguments; ///
461
601
 
462
602
  return continuation(success, ...finalArguments);
463
603
  }
@@ -470,16 +610,14 @@ export function resolve(arrayA, arrayB, callback, ...initialArguments) {
470
610
  }
471
611
  });
472
612
 
473
- nextPass();
613
+ return nextPass(...callbackArguments);
474
614
  } else {
475
615
  const elementA = arrayA[index];
476
616
 
477
- return callback(elementA, ...callbackArguments, (...intermediateArguments) => {
478
- const passed = intermediateArguments.shift();
479
-
480
- callbackArguments = intermediateArguments; ///
481
-
617
+ return callback(elementA, ...callbackArguments, (passed, ...intermediateArguments) => {
482
618
  if (passed) {
619
+ callbackArguments = intermediateArguments; ///
620
+
483
621
  const elementB = elementA; ///
484
622
 
485
623
  arrayB.push(elementB);
@@ -487,15 +625,17 @@ export function resolve(arrayA, arrayB, callback, ...initialArguments) {
487
625
  success = true;
488
626
  }
489
627
 
490
- nextElement();
628
+ return nextElement(...callbackArguments);
491
629
  });
492
630
  }
493
631
  }
494
632
 
495
- nextElement();
633
+ return nextElement(...callbackArguments);
496
634
  }
497
635
 
498
- nextPass();
636
+ const callbackArguments = initialArguments; ///
637
+
638
+ return nextPass(...callbackArguments);
499
639
  }
500
640
 
501
641
  export default {