occam-languages 2.2.17 → 2.2.20

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.
@@ -7,18 +7,24 @@ const { filter: arrayFilter } = arrayUtilities,
7
7
  forwardsForEach: asynchronousForwardsForEach,
8
8
  backwardsForEach: asynchronousBackwardsForEach } = asynchronousUtilities;
9
9
 
10
- export function one(array, callback, ...remainingArguments) {
11
- let found = false;
10
+ export function one(array, callback, ...initialArguments) {
11
+ let success = false;
12
+
13
+ const continuation = initialArguments.pop();
12
14
 
13
- const continuation = remainingArguments.pop();
15
+ let intermediateArguments = initialArguments; ///
14
16
 
15
17
  return asynchronousForEach(array, (element, next, done) => {
16
- return callback(element, ...remainingArguments, (passed) => {
18
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
19
+ const passed = callbackArguments.shift();
20
+
21
+ intermediateArguments = callbackArguments; ///
22
+
17
23
  if (passed) {
18
- if (!found) {
19
- found = true;
24
+ if (!success) {
25
+ success = true;
20
26
  } else {
21
- found = false;
27
+ success = false;
22
28
 
23
29
  done();
24
30
 
@@ -29,17 +35,25 @@ export function one(array, callback, ...remainingArguments) {
29
35
  next();
30
36
  });
31
37
  }, () => {
32
- return continuation(found, ...remainingArguments);
38
+ const finalArguments = intermediateArguments; ///
39
+
40
+ return continuation(success, ...finalArguments);
33
41
  });
34
42
  }
35
43
 
36
- export function some(array, callback, ...remainingArguments) {
44
+ export function some(array, callback, ...initialArguments) {
37
45
  let success = false;
38
46
 
39
- const continuation = remainingArguments.pop();
47
+ const continuation = initialArguments.pop();
48
+
49
+ let intermediateArguments = initialArguments; ///
40
50
 
41
51
  return asynchronousForEach(array, (element, next, done) => {
42
- return callback(element, ...remainingArguments, (passed) => {
52
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
53
+ const passed = callbackArguments.shift();
54
+
55
+ intermediateArguments = callbackArguments; ///
56
+
43
57
  if (passed) {
44
58
  success = true;
45
59
 
@@ -51,21 +65,29 @@ export function some(array, callback, ...remainingArguments) {
51
65
  next();
52
66
  });
53
67
  }, () => {
54
- return continuation(success, ...remainingArguments);
68
+ const finalArguments = intermediateArguments; ///
69
+
70
+ return continuation(success, ...finalArguments);
55
71
  });
56
72
  }
57
73
 
58
- export function each(array, callback, ...remainingArguments) {
59
- let found = false;
74
+ export function each(array, callback, ...initialArguments) {
75
+ let success = false;
76
+
77
+ const continuation = initialArguments.pop();
60
78
 
61
- const continuation = remainingArguments.pop();
79
+ let intermediateArguments = initialArguments; ///
62
80
 
63
81
  return asynchronousForEach(array, (element, next, done) => {
64
- return callback(element, ...remainingArguments, (passed) => {
82
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
83
+ const passed = callbackArguments.shift();
84
+
85
+ intermediateArguments = callbackArguments; ///
86
+
65
87
  if (passed) {
66
- found = true;
88
+ success = true;
67
89
  } else {
68
- found = false;
90
+ success = false;
69
91
 
70
92
  done();
71
93
 
@@ -75,17 +97,25 @@ export function each(array, callback, ...remainingArguments) {
75
97
  next();
76
98
  });
77
99
  }, () => {
78
- return continuation(found, ...remainingArguments);
100
+ const finalArguments = intermediateArguments; ///
101
+
102
+ return continuation(success, ...finalArguments);
79
103
  });
80
104
  }
81
105
 
82
- export function every(array, callback, ...remainingArguments) {
106
+ export function every(array, callback, ...initialArguments) {
83
107
  let success = true;
84
108
 
85
- const continuation = remainingArguments.pop();
109
+ const continuation = initialArguments.pop();
110
+
111
+ let intermediateArguments = initialArguments; ///
86
112
 
87
113
  return asynchronousForEach(array, (element, next, done) => {
88
- return callback(element, ...remainingArguments, (passed) => {
114
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
115
+ const passed = callbackArguments.shift();
116
+
117
+ intermediateArguments = callbackArguments; ///
118
+
89
119
  if (!passed) {
90
120
  success = false;
91
121
 
@@ -97,45 +127,67 @@ export function every(array, callback, ...remainingArguments) {
97
127
  next();
98
128
  });
99
129
  }, () => {
100
- return continuation(success, ...remainingArguments);
130
+ const finalArguments = intermediateArguments; ///
131
+
132
+ return continuation(success, ...finalArguments);
101
133
  });
102
134
  }
103
135
 
104
- export function reduce(array, initialValue, callback, ...remainingArguments) {
136
+ export function reduce(array, initialValue, callback, ...initialArguments) {
105
137
  let value = initialValue; ///
106
138
 
107
- const continuation = remainingArguments.pop();
139
+ const continuation = initialArguments.pop();
140
+
141
+ let intermediateArguments = initialArguments; ///
108
142
 
109
143
  return asynchronousForEach(array, (element, next, done) => {
110
- return callback(value, element, ...remainingArguments, (currentValue) => {
144
+ return callback(value, element, ...intermediateArguments, (...callbackArguments) => {
145
+ const currentValue = callbackArguments.shift();
146
+
147
+ intermediateArguments = callbackArguments; ///
148
+
111
149
  value = currentValue; ///
112
150
 
113
151
  next();
114
152
  });
115
153
  }, () => {
116
- return continuation(value, ...remainingArguments);
154
+ const finalArguments = intermediateArguments; ///
155
+
156
+ return continuation(value, ...finalArguments);
117
157
  });
118
158
  }
119
159
 
120
- export function forEach(array, callback, ...remainingArguments) {
121
- const continuation = remainingArguments.pop();
160
+ export function forEach(array, callback, ...initialArguments) {
161
+ const continuation = initialArguments.pop();
162
+
163
+ let intermediateArguments = initialArguments; ///
122
164
 
123
165
  return asynchronousForEach(array, (element, next, done) => {
124
- return callback(element, ...remainingArguments, () => {
166
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
167
+ intermediateArguments = callbackArguments; ///
168
+
125
169
  next();
126
170
  });
127
171
  }, () => {
128
- return continuation(...remainingArguments);
172
+ const finalArguments = intermediateArguments; ///
173
+
174
+ return continuation(...finalArguments);
129
175
  });
130
176
  }
131
177
 
132
- export function forwardsEvery(array, callback, ...remainingArguments) {
178
+ export function forwardsEvery(array, callback, ...initialArguments) {
133
179
  let success = true;
134
180
 
135
- const continuation = remainingArguments.pop();
181
+ const continuation = initialArguments.pop();
182
+
183
+ let intermediateArguments = initialArguments; ///
136
184
 
137
185
  return asynchronousForwardsForEach(array, (element, next, done) => {
138
- return callback(element, ...remainingArguments, (passed) => {
186
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
187
+ const passed = callbackArguments.shift();
188
+
189
+ intermediateArguments = callbackArguments; ///
190
+
139
191
  if (!passed) {
140
192
  success = false;
141
193
 
@@ -147,17 +199,25 @@ export function forwardsEvery(array, callback, ...remainingArguments) {
147
199
  next();
148
200
  });
149
201
  }, () => {
150
- return continuation(success, ...remainingArguments);
202
+ const finalArguments = intermediateArguments; ///
203
+
204
+ return continuation(success, ...finalArguments);
151
205
  });
152
206
  }
153
207
 
154
- export function backwardsEvery(array, callback, ...remainingArguments) {
208
+ export function backwardsEvery(array, callback, ...initialArguments) {
155
209
  let success = true;
156
210
 
157
- const continuation = remainingArguments.pop();
211
+ const continuation = initialArguments.pop();
212
+
213
+ let intermediateArguments = initialArguments; ///
158
214
 
159
215
  return asynchronousBackwardsForEach(array, (element, next, done) => {
160
- return callback(element, ...remainingArguments, (passed) => {
216
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
217
+ const passed = callbackArguments.shift();
218
+
219
+ intermediateArguments = callbackArguments; ///
220
+
161
221
  if (!passed) {
162
222
  success = false;
163
223
 
@@ -169,45 +229,65 @@ export function backwardsEvery(array, callback, ...remainingArguments) {
169
229
  next();
170
230
  });
171
231
  }, () => {
172
- return continuation(success, ...remainingArguments);
232
+ const finalArguments = intermediateArguments; ///
233
+
234
+ return continuation(success, ...finalArguments);
173
235
  });
174
236
  }
175
237
 
176
- export function forwardsForEach(array, callback, ...remainingArguments) {
177
- const continuation = remainingArguments.pop();
238
+ export function forwardsForEach(array, callback, ...initialArguments) {
239
+ const continuation = initialArguments.pop();
240
+
241
+ let intermediateArguments = initialArguments; ///
178
242
 
179
243
  return asynchronousForwardsForEach(array, (element, next, done) => {
180
- return callback(element, ...remainingArguments, () => {
244
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
245
+ intermediateArguments = callbackArguments; ///
246
+
181
247
  next();
182
248
  });
183
249
  }, () => {
184
- return continuation(...remainingArguments);
250
+ const finalArguments = intermediateArguments; ///
251
+
252
+ return continuation(...finalArguments);
185
253
  });
186
254
  }
187
255
 
188
- export function backwardsForEach(array, callback, ...remainingArguments) {
189
- const continuation = remainingArguments.pop();
256
+ export function backwardsForEach(array, callback, ...initialArguments) {
257
+ const continuation = initialArguments.pop();
258
+
259
+ let intermediateArguments = initialArguments; ///
190
260
 
191
261
  return asynchronousBackwardsForEach(array, (element, next, done) => {
192
- return callback(element, ...remainingArguments, () => {
262
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
263
+ intermediateArguments = callbackArguments; ///
264
+
193
265
  next();
194
266
  });
195
267
  }, () => {
196
- return continuation(...remainingArguments);
268
+ const finalArguments = intermediateArguments; ///
269
+
270
+ return continuation(...finalArguments);
197
271
  });
198
272
  }
199
273
 
200
- export function filter(array, callback, ...remainingArguments) {
274
+ export function filter(array, callback, ...initialArguments) {
201
275
  const deletedElements = [];
202
276
 
203
- const continuation = remainingArguments.pop();
277
+ const continuation = initialArguments.pop();
278
+
279
+ let intermediateArguments = initialArguments; ///
204
280
 
205
281
  let index = array.length;
206
282
 
207
- return backwardsForEach(array, (element, continuation) => {
283
+ return asynchronousBackwardsForEach(array, (element, next, done) => {
208
284
  index--;
209
285
 
210
- return callback(element, ...remainingArguments, (passed) => {
286
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
287
+ const passed = callbackArguments.shift();
288
+
289
+ intermediateArguments = callbackArguments; ///
290
+
211
291
  if (!passed) {
212
292
  const start = index, ///
213
293
  deleteCount = 1,
@@ -216,119 +296,170 @@ export function filter(array, callback, ...remainingArguments) {
216
296
  deletedElements.unshift(deletedElement); ///
217
297
  }
218
298
 
219
- return continuation();
299
+ next();
220
300
  });
221
301
  }, () => {
222
- return continuation(deletedElements, ...remainingArguments);
302
+ const finalArguments = intermediateArguments; ///
303
+
304
+ return continuation(deletedElements, ...finalArguments);
223
305
  });
224
306
  }
225
307
 
226
- export function prune(array, callback, ...remainingArguments) {
308
+ export function prune(array, callback, ...initialArguments) {
227
309
  let deletedElement = undefined; ///
228
310
 
229
- const continuation = remainingArguments.pop();
311
+ const continuation = initialArguments.pop();
312
+
313
+ let intermediateArguments = initialArguments; ///
230
314
 
231
315
  let index = -1;
232
316
 
233
- return some(array, (element, continuation) => {
317
+ return asynchronousForEach(array, (element, next, done) => {
234
318
  index++;
235
319
 
236
- return callback(element, ...remainingArguments, (passed) => {
320
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
321
+ const passed = callbackArguments.shift();
322
+
323
+ intermediateArguments = callbackArguments; ///
324
+
237
325
  if (!passed) {
238
326
  const start = index, ///
239
327
  deleteCount = 1;
240
328
 
241
- deletedElement = array.splice(start, deleteCount).pop() ///
329
+ deletedElement = array.splice(start, deleteCount).pop(); ///
330
+
331
+ done();
332
+
333
+ return;
242
334
  }
243
335
 
244
- return continuation(passed);
336
+ next();
245
337
  });
246
338
  }, () => {
247
- return continuation(deletedElement, ...remainingArguments);
339
+ const finalArguments = intermediateArguments; ///
340
+
341
+ return continuation(deletedElement, ...finalArguments);
248
342
  });
249
343
  }
250
344
 
251
- export function extract(array, callback, ...remainingArguments) {
345
+ export function extract(array, callback, ...initialArguments) {
252
346
  let deletedElement = undefined; ///
253
347
 
254
- const continuation = remainingArguments.pop();
348
+ const continuation = initialArguments.pop();
349
+
350
+ let intermediateArguments = initialArguments; ///
255
351
 
256
352
  let index = -1;
257
353
 
258
- return some(array, (element, continuation) => {
354
+ return asynchronousForEach(array, (element, next, done) => {
259
355
  index++;
260
356
 
261
- return callback(element, ...remainingArguments, (passed) => {
357
+ return callback(element, ...intermediateArguments, (...callbackArguments) => {
358
+ const passed = callbackArguments.shift();
359
+
360
+ intermediateArguments = callbackArguments; ///
361
+
262
362
  if (passed) {
263
363
  const start = index, ///
264
364
  deleteCount = 1;
265
365
 
266
- deletedElement = array.splice(start, deleteCount).pop() ///
366
+ deletedElement = array.splice(start, deleteCount).pop(); ///
367
+
368
+ done();
369
+
370
+ return;
267
371
  }
268
372
 
269
- return continuation(passed);
373
+ next();
270
374
  });
271
375
  }, () => {
272
- return continuation(deletedElement, ...remainingArguments);
376
+ const finalArguments = intermediateArguments; ///
377
+
378
+ return continuation(deletedElement, ...finalArguments);
273
379
  });
274
380
  }
275
381
 
276
- export function match(arrayA, arrayB, callback, ...remainingArguments) {
277
- const continuation = remainingArguments.pop(),
278
- arrayALength = arrayA.length,
382
+ export function match(arrayA, arrayB, callback, ...initialArguments) {
383
+ let success = true;
384
+
385
+ const continuation = initialArguments.pop();
386
+
387
+ const arrayALength = arrayA.length,
279
388
  arrayBLength = arrayB.length;
280
389
 
281
390
  if (arrayALength !== arrayBLength) {
282
- const matches = false;
391
+ success = false;
283
392
 
284
- return continuation(matches, ...remainingArguments);
393
+ return continuation(success, ...initialArguments);
285
394
  }
286
395
 
287
396
  let index = -1;
288
397
 
289
- return every(arrayA, (elementA, continuation) => {
398
+ let intermediateArguments = initialArguments; ///
399
+
400
+ return asynchronousForEach(arrayA, (elementA, next, done) => {
290
401
  index++;
291
402
 
292
403
  const elementB = arrayB[index];
293
404
 
294
- return callback(elementA, elementB, ...remainingArguments, continuation);
295
- }, (success) => {
296
- const matches = success; ///
405
+ return callback(elementA, elementB, ...intermediateArguments, (...callbackArguments) => {
406
+ const passed = callbackArguments.shift();
407
+
408
+ intermediateArguments = callbackArguments; ///
409
+
410
+ if (!passed) {
411
+ success = false;
412
+
413
+ done();
414
+
415
+ return;
416
+ }
297
417
 
298
- return continuation(matches, ...remainingArguments);
418
+ next();
419
+ });
420
+ }, () => {
421
+ const finalArguments = intermediateArguments; ///
422
+
423
+ return continuation(success, ...finalArguments);
299
424
  });
300
425
  }
301
426
 
302
- export function resolve(arrayA, arrayB, callback, ...remainingArguments) {
427
+ export function resolve(arrayA, arrayB, callback, ...initialArguments) {
303
428
  arrayA = [ ///
304
429
  ...arrayA
305
430
  ];
306
431
 
307
- const continuation = remainingArguments.pop();
432
+ const continuation = initialArguments.pop();
433
+
434
+ let intermediateArguments = initialArguments; ///
308
435
 
309
436
  function nextPass() {
437
+ let success = false;
438
+
310
439
  const arrayALength = arrayA.length;
311
440
 
312
441
  if (arrayALength === 0) {
313
- const success = true; ///
442
+ success = true;
314
443
 
315
- return continuation(success, ...remainingArguments);
316
- }
444
+ const finalArguments = intermediateArguments; ///
317
445
 
318
- let success = false;
446
+ return continuation(success, ...finalArguments);
447
+ }
319
448
 
320
- let count = -1;
449
+ let index = -1;
321
450
 
322
451
  function nextElement() {
323
- count++;
452
+ index++;
324
453
 
325
- const terminate = (count === arrayALength);
454
+ const terminate = (index === arrayALength);
326
455
 
327
456
  if (terminate) {
328
457
  if (!success) {
329
- const success = false; ///
458
+ success = false;
459
+
460
+ const finalArguments = intermediateArguments; ///
330
461
 
331
- return continuation(success, ...remainingArguments);
462
+ return continuation(success, ...finalArguments);
332
463
  }
333
464
 
334
465
  arrayFilter(arrayA, (elementA) => {
@@ -341,10 +472,13 @@ export function resolve(arrayA, arrayB, callback, ...remainingArguments) {
341
472
 
342
473
  nextPass();
343
474
  } else {
344
- const index = count, ///
345
- elementA = arrayA[index];
475
+ const elementA = arrayA[index];
476
+
477
+ return callback(elementA, ...intermediateArguments, (...callbackArguments) => {
478
+ const passed = callbackArguments.shift();
479
+
480
+ intermediateArguments = callbackArguments; ///
346
481
 
347
- return callback(elementA, ...remainingArguments, (passed) => {
348
482
  if (passed) {
349
483
  const elementB = elementA; ///
350
484
 
@@ -36,7 +36,7 @@ export function initialiseReleaseContexts(context) {
36
36
  export function verifyReleaseContexts(context, contiunation) {
37
37
  const { releaseContexts } = context;
38
38
 
39
- every(releaseContexts, verifyReleaseContext, context, contiunation);
39
+ return every(releaseContexts, verifyReleaseContext, context, contiunation);
40
40
  }
41
41
 
42
42
  export default {
@@ -46,15 +46,13 @@ export default {
46
46
  };
47
47
 
48
48
  function verifyReleaseContext(releaseContext, context, contiunation) {
49
- let releaseContextVerifies;
50
-
51
49
  const released = releaseContext.isReleased(),
52
50
  verified = releaseContext.hasVerified();
53
51
 
54
52
  if (released || verified) {
55
- releaseContextVerifies = true;
53
+ const releaseContextVerifies = true;
56
54
 
57
- return contiunation(releaseContextVerifies);
55
+ return contiunation(releaseContextVerifies, context);
58
56
  }
59
57
 
60
58
  const { log } = context,
@@ -63,16 +61,16 @@ function verifyReleaseContext(releaseContext, context, contiunation) {
63
61
 
64
62
  log.info(`Verifying the '${releaseName}' project...`);
65
63
 
66
- releaseContextVerifies = false;
64
+ return releaseContext.verify((verifies) => {
65
+ let releaseContextVerifies = false;
67
66
 
68
- releaseContext.verify((verifies) => {
69
67
  if (verifies) {
70
68
  log.info(`...verified the '${releaseName}' project.`);
71
69
 
72
70
  releaseContextVerifies = true;
73
71
  }
74
72
 
75
- contiunation(releaseContextVerifies);
73
+ return contiunation(releaseContextVerifies, context);
76
74
  });
77
75
  }
78
76
 
@@ -7,8 +7,8 @@ import { resolve } from "../utilities/continuation";
7
7
  const { first, filter, compress } = arrayUtilities;
8
8
 
9
9
  export function verifyFileContexts(fileContexts, verifiedFileContexts, contiunation) {
10
- resolve(fileContexts, verifiedFileContexts, (fileContext, contiunation) => {
11
- fileContext.verify(contiunation);
10
+ return resolve(fileContexts, verifiedFileContexts, (fileContext, contiunation) => {
11
+ return fileContext.verify(contiunation);
12
12
  }, contiunation);
13
13
  }
14
14