fable 3.0.6 → 3.0.7

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/dist/fable.js CHANGED
@@ -45,6 +45,704 @@
45
45
  return r;
46
46
  }()({
47
47
  1: [function (require, module, exports) {
48
+ 'use strict';
49
+
50
+ Object.defineProperty(exports, "__esModule", {
51
+ value: true
52
+ });
53
+ exports.default = asyncify;
54
+ var _initialParams = require('./internal/initialParams.js');
55
+ var _initialParams2 = _interopRequireDefault(_initialParams);
56
+ var _setImmediate = require('./internal/setImmediate.js');
57
+ var _setImmediate2 = _interopRequireDefault(_setImmediate);
58
+ var _wrapAsync = require('./internal/wrapAsync.js');
59
+ function _interopRequireDefault(obj) {
60
+ return obj && obj.__esModule ? obj : {
61
+ default: obj
62
+ };
63
+ }
64
+
65
+ /**
66
+ * Take a sync function and make it async, passing its return value to a
67
+ * callback. This is useful for plugging sync functions into a waterfall,
68
+ * series, or other async functions. Any arguments passed to the generated
69
+ * function will be passed to the wrapped function (except for the final
70
+ * callback argument). Errors thrown will be passed to the callback.
71
+ *
72
+ * If the function passed to `asyncify` returns a Promise, that promises's
73
+ * resolved/rejected state will be used to call the callback, rather than simply
74
+ * the synchronous return value.
75
+ *
76
+ * This also means you can asyncify ES2017 `async` functions.
77
+ *
78
+ * @name asyncify
79
+ * @static
80
+ * @memberOf module:Utils
81
+ * @method
82
+ * @alias wrapSync
83
+ * @category Util
84
+ * @param {Function} func - The synchronous function, or Promise-returning
85
+ * function to convert to an {@link AsyncFunction}.
86
+ * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
87
+ * invoked with `(args..., callback)`.
88
+ * @example
89
+ *
90
+ * // passing a regular synchronous function
91
+ * async.waterfall([
92
+ * async.apply(fs.readFile, filename, "utf8"),
93
+ * async.asyncify(JSON.parse),
94
+ * function (data, next) {
95
+ * // data is the result of parsing the text.
96
+ * // If there was a parsing error, it would have been caught.
97
+ * }
98
+ * ], callback);
99
+ *
100
+ * // passing a function returning a promise
101
+ * async.waterfall([
102
+ * async.apply(fs.readFile, filename, "utf8"),
103
+ * async.asyncify(function (contents) {
104
+ * return db.model.create(contents);
105
+ * }),
106
+ * function (model, next) {
107
+ * // `model` is the instantiated model object.
108
+ * // If there was an error, this function would be skipped.
109
+ * }
110
+ * ], callback);
111
+ *
112
+ * // es2017 example, though `asyncify` is not needed if your JS environment
113
+ * // supports async functions out of the box
114
+ * var q = async.queue(async.asyncify(async function(file) {
115
+ * var intermediateStep = await processFile(file);
116
+ * return await somePromise(intermediateStep)
117
+ * }));
118
+ *
119
+ * q.push(files);
120
+ */
121
+ function asyncify(func) {
122
+ if ((0, _wrapAsync.isAsync)(func)) {
123
+ return function (...args /*, callback*/) {
124
+ const callback = args.pop();
125
+ const promise = func.apply(this, args);
126
+ return handlePromise(promise, callback);
127
+ };
128
+ }
129
+ return (0, _initialParams2.default)(function (args, callback) {
130
+ var result;
131
+ try {
132
+ result = func.apply(this, args);
133
+ } catch (e) {
134
+ return callback(e);
135
+ }
136
+ // if result is Promise object
137
+ if (result && typeof result.then === 'function') {
138
+ return handlePromise(result, callback);
139
+ } else {
140
+ callback(null, result);
141
+ }
142
+ });
143
+ }
144
+ function handlePromise(promise, callback) {
145
+ return promise.then(value => {
146
+ invokeCallback(callback, null, value);
147
+ }, err => {
148
+ invokeCallback(callback, err && err.message ? err : new Error(err));
149
+ });
150
+ }
151
+ function invokeCallback(callback, error, value) {
152
+ try {
153
+ callback(error, value);
154
+ } catch (err) {
155
+ (0, _setImmediate2.default)(e => {
156
+ throw e;
157
+ }, err);
158
+ }
159
+ }
160
+ module.exports = exports['default'];
161
+ }, {
162
+ "./internal/initialParams.js": 8,
163
+ "./internal/setImmediate.js": 13,
164
+ "./internal/wrapAsync.js": 15
165
+ }],
166
+ 2: [function (require, module, exports) {
167
+ 'use strict';
168
+
169
+ Object.defineProperty(exports, "__esModule", {
170
+ value: true
171
+ });
172
+ var _eachOfLimit = require('./internal/eachOfLimit.js');
173
+ var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
174
+ var _withoutIndex = require('./internal/withoutIndex.js');
175
+ var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
176
+ var _wrapAsync = require('./internal/wrapAsync.js');
177
+ var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
178
+ var _awaitify = require('./internal/awaitify.js');
179
+ var _awaitify2 = _interopRequireDefault(_awaitify);
180
+ function _interopRequireDefault(obj) {
181
+ return obj && obj.__esModule ? obj : {
182
+ default: obj
183
+ };
184
+ }
185
+
186
+ /**
187
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
188
+ *
189
+ * @name eachLimit
190
+ * @static
191
+ * @memberOf module:Collections
192
+ * @method
193
+ * @see [async.each]{@link module:Collections.each}
194
+ * @alias forEachLimit
195
+ * @category Collection
196
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
197
+ * @param {number} limit - The maximum number of async operations at a time.
198
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
199
+ * `coll`.
200
+ * The array index is not passed to the iteratee.
201
+ * If you need the index, use `eachOfLimit`.
202
+ * Invoked with (item, callback).
203
+ * @param {Function} [callback] - A callback which is called when all
204
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
205
+ * @returns {Promise} a promise, if a callback is omitted
206
+ */
207
+ function eachLimit(coll, limit, iteratee, callback) {
208
+ return (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
209
+ }
210
+ exports.default = (0, _awaitify2.default)(eachLimit, 4);
211
+ module.exports = exports['default'];
212
+ }, {
213
+ "./internal/awaitify.js": 4,
214
+ "./internal/eachOfLimit.js": 6,
215
+ "./internal/withoutIndex.js": 14,
216
+ "./internal/wrapAsync.js": 15
217
+ }],
218
+ 3: [function (require, module, exports) {
219
+ 'use strict';
220
+
221
+ Object.defineProperty(exports, "__esModule", {
222
+ value: true
223
+ });
224
+ exports.default = asyncEachOfLimit;
225
+ var _breakLoop = require('./breakLoop.js');
226
+ var _breakLoop2 = _interopRequireDefault(_breakLoop);
227
+ function _interopRequireDefault(obj) {
228
+ return obj && obj.__esModule ? obj : {
229
+ default: obj
230
+ };
231
+ }
232
+
233
+ // for async generators
234
+ function asyncEachOfLimit(generator, limit, iteratee, callback) {
235
+ let done = false;
236
+ let canceled = false;
237
+ let awaiting = false;
238
+ let running = 0;
239
+ let idx = 0;
240
+ function replenish() {
241
+ //console.log('replenish')
242
+ if (running >= limit || awaiting || done) return;
243
+ //console.log('replenish awaiting')
244
+ awaiting = true;
245
+ generator.next().then(({
246
+ value,
247
+ done: iterDone
248
+ }) => {
249
+ //console.log('got value', value)
250
+ if (canceled || done) return;
251
+ awaiting = false;
252
+ if (iterDone) {
253
+ done = true;
254
+ if (running <= 0) {
255
+ //console.log('done nextCb')
256
+ callback(null);
257
+ }
258
+ return;
259
+ }
260
+ running++;
261
+ iteratee(value, idx, iterateeCallback);
262
+ idx++;
263
+ replenish();
264
+ }).catch(handleError);
265
+ }
266
+ function iterateeCallback(err, result) {
267
+ //console.log('iterateeCallback')
268
+ running -= 1;
269
+ if (canceled) return;
270
+ if (err) return handleError(err);
271
+ if (err === false) {
272
+ done = true;
273
+ canceled = true;
274
+ return;
275
+ }
276
+ if (result === _breakLoop2.default || done && running <= 0) {
277
+ done = true;
278
+ //console.log('done iterCb')
279
+ return callback(null);
280
+ }
281
+ replenish();
282
+ }
283
+ function handleError(err) {
284
+ if (canceled) return;
285
+ awaiting = false;
286
+ done = true;
287
+ callback(err);
288
+ }
289
+ replenish();
290
+ }
291
+ module.exports = exports['default'];
292
+ }, {
293
+ "./breakLoop.js": 5
294
+ }],
295
+ 4: [function (require, module, exports) {
296
+ 'use strict';
297
+
298
+ Object.defineProperty(exports, "__esModule", {
299
+ value: true
300
+ });
301
+ exports.default = awaitify;
302
+ // conditionally promisify a function.
303
+ // only return a promise if a callback is omitted
304
+ function awaitify(asyncFn, arity = asyncFn.length) {
305
+ if (!arity) throw new Error('arity is undefined');
306
+ function awaitable(...args) {
307
+ if (typeof args[arity - 1] === 'function') {
308
+ return asyncFn.apply(this, args);
309
+ }
310
+ return new Promise((resolve, reject) => {
311
+ args[arity - 1] = (err, ...cbArgs) => {
312
+ if (err) return reject(err);
313
+ resolve(cbArgs.length > 1 ? cbArgs : cbArgs[0]);
314
+ };
315
+ asyncFn.apply(this, args);
316
+ });
317
+ }
318
+ return awaitable;
319
+ }
320
+ module.exports = exports['default'];
321
+ }, {}],
322
+ 5: [function (require, module, exports) {
323
+ "use strict";
324
+
325
+ Object.defineProperty(exports, "__esModule", {
326
+ value: true
327
+ });
328
+ // A temporary value used to identify if the loop should be broken.
329
+ // See #1064, #1293
330
+ const breakLoop = {};
331
+ exports.default = breakLoop;
332
+ module.exports = exports["default"];
333
+ }, {}],
334
+ 6: [function (require, module, exports) {
335
+ 'use strict';
336
+
337
+ Object.defineProperty(exports, "__esModule", {
338
+ value: true
339
+ });
340
+ var _once = require('./once.js');
341
+ var _once2 = _interopRequireDefault(_once);
342
+ var _iterator = require('./iterator.js');
343
+ var _iterator2 = _interopRequireDefault(_iterator);
344
+ var _onlyOnce = require('./onlyOnce.js');
345
+ var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
346
+ var _wrapAsync = require('./wrapAsync.js');
347
+ var _asyncEachOfLimit = require('./asyncEachOfLimit.js');
348
+ var _asyncEachOfLimit2 = _interopRequireDefault(_asyncEachOfLimit);
349
+ var _breakLoop = require('./breakLoop.js');
350
+ var _breakLoop2 = _interopRequireDefault(_breakLoop);
351
+ function _interopRequireDefault(obj) {
352
+ return obj && obj.__esModule ? obj : {
353
+ default: obj
354
+ };
355
+ }
356
+ exports.default = limit => {
357
+ return (obj, iteratee, callback) => {
358
+ callback = (0, _once2.default)(callback);
359
+ if (limit <= 0) {
360
+ throw new RangeError('concurrency limit cannot be less than 1');
361
+ }
362
+ if (!obj) {
363
+ return callback(null);
364
+ }
365
+ if ((0, _wrapAsync.isAsyncGenerator)(obj)) {
366
+ return (0, _asyncEachOfLimit2.default)(obj, limit, iteratee, callback);
367
+ }
368
+ if ((0, _wrapAsync.isAsyncIterable)(obj)) {
369
+ return (0, _asyncEachOfLimit2.default)(obj[Symbol.asyncIterator](), limit, iteratee, callback);
370
+ }
371
+ var nextElem = (0, _iterator2.default)(obj);
372
+ var done = false;
373
+ var canceled = false;
374
+ var running = 0;
375
+ var looping = false;
376
+ function iterateeCallback(err, value) {
377
+ if (canceled) return;
378
+ running -= 1;
379
+ if (err) {
380
+ done = true;
381
+ callback(err);
382
+ } else if (err === false) {
383
+ done = true;
384
+ canceled = true;
385
+ } else if (value === _breakLoop2.default || done && running <= 0) {
386
+ done = true;
387
+ return callback(null);
388
+ } else if (!looping) {
389
+ replenish();
390
+ }
391
+ }
392
+ function replenish() {
393
+ looping = true;
394
+ while (running < limit && !done) {
395
+ var elem = nextElem();
396
+ if (elem === null) {
397
+ done = true;
398
+ if (running <= 0) {
399
+ callback(null);
400
+ }
401
+ return;
402
+ }
403
+ running += 1;
404
+ iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
405
+ }
406
+ looping = false;
407
+ }
408
+ replenish();
409
+ };
410
+ };
411
+ module.exports = exports['default'];
412
+ }, {
413
+ "./asyncEachOfLimit.js": 3,
414
+ "./breakLoop.js": 5,
415
+ "./iterator.js": 10,
416
+ "./once.js": 11,
417
+ "./onlyOnce.js": 12,
418
+ "./wrapAsync.js": 15
419
+ }],
420
+ 7: [function (require, module, exports) {
421
+ "use strict";
422
+
423
+ Object.defineProperty(exports, "__esModule", {
424
+ value: true
425
+ });
426
+ exports.default = function (coll) {
427
+ return coll[Symbol.iterator] && coll[Symbol.iterator]();
428
+ };
429
+ module.exports = exports["default"];
430
+ }, {}],
431
+ 8: [function (require, module, exports) {
432
+ "use strict";
433
+
434
+ Object.defineProperty(exports, "__esModule", {
435
+ value: true
436
+ });
437
+ exports.default = function (fn) {
438
+ return function (...args /*, callback*/) {
439
+ var callback = args.pop();
440
+ return fn.call(this, args, callback);
441
+ };
442
+ };
443
+ module.exports = exports["default"];
444
+ }, {}],
445
+ 9: [function (require, module, exports) {
446
+ 'use strict';
447
+
448
+ Object.defineProperty(exports, "__esModule", {
449
+ value: true
450
+ });
451
+ exports.default = isArrayLike;
452
+ function isArrayLike(value) {
453
+ return value && typeof value.length === 'number' && value.length >= 0 && value.length % 1 === 0;
454
+ }
455
+ module.exports = exports['default'];
456
+ }, {}],
457
+ 10: [function (require, module, exports) {
458
+ 'use strict';
459
+
460
+ Object.defineProperty(exports, "__esModule", {
461
+ value: true
462
+ });
463
+ exports.default = createIterator;
464
+ var _isArrayLike = require('./isArrayLike.js');
465
+ var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
466
+ var _getIterator = require('./getIterator.js');
467
+ var _getIterator2 = _interopRequireDefault(_getIterator);
468
+ function _interopRequireDefault(obj) {
469
+ return obj && obj.__esModule ? obj : {
470
+ default: obj
471
+ };
472
+ }
473
+ function createArrayIterator(coll) {
474
+ var i = -1;
475
+ var len = coll.length;
476
+ return function next() {
477
+ return ++i < len ? {
478
+ value: coll[i],
479
+ key: i
480
+ } : null;
481
+ };
482
+ }
483
+ function createES2015Iterator(iterator) {
484
+ var i = -1;
485
+ return function next() {
486
+ var item = iterator.next();
487
+ if (item.done) return null;
488
+ i++;
489
+ return {
490
+ value: item.value,
491
+ key: i
492
+ };
493
+ };
494
+ }
495
+ function createObjectIterator(obj) {
496
+ var okeys = obj ? Object.keys(obj) : [];
497
+ var i = -1;
498
+ var len = okeys.length;
499
+ return function next() {
500
+ var key = okeys[++i];
501
+ if (key === '__proto__') {
502
+ return next();
503
+ }
504
+ return i < len ? {
505
+ value: obj[key],
506
+ key
507
+ } : null;
508
+ };
509
+ }
510
+ function createIterator(coll) {
511
+ if ((0, _isArrayLike2.default)(coll)) {
512
+ return createArrayIterator(coll);
513
+ }
514
+ var iterator = (0, _getIterator2.default)(coll);
515
+ return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
516
+ }
517
+ module.exports = exports['default'];
518
+ }, {
519
+ "./getIterator.js": 7,
520
+ "./isArrayLike.js": 9
521
+ }],
522
+ 11: [function (require, module, exports) {
523
+ "use strict";
524
+
525
+ Object.defineProperty(exports, "__esModule", {
526
+ value: true
527
+ });
528
+ exports.default = once;
529
+ function once(fn) {
530
+ function wrapper(...args) {
531
+ if (fn === null) return;
532
+ var callFn = fn;
533
+ fn = null;
534
+ callFn.apply(this, args);
535
+ }
536
+ Object.assign(wrapper, fn);
537
+ return wrapper;
538
+ }
539
+ module.exports = exports["default"];
540
+ }, {}],
541
+ 12: [function (require, module, exports) {
542
+ "use strict";
543
+
544
+ Object.defineProperty(exports, "__esModule", {
545
+ value: true
546
+ });
547
+ exports.default = onlyOnce;
548
+ function onlyOnce(fn) {
549
+ return function (...args) {
550
+ if (fn === null) throw new Error("Callback was already called.");
551
+ var callFn = fn;
552
+ fn = null;
553
+ callFn.apply(this, args);
554
+ };
555
+ }
556
+ module.exports = exports["default"];
557
+ }, {}],
558
+ 13: [function (require, module, exports) {
559
+ (function (process, setImmediate) {
560
+ (function () {
561
+ 'use strict';
562
+
563
+ Object.defineProperty(exports, "__esModule", {
564
+ value: true
565
+ });
566
+ exports.fallback = fallback;
567
+ exports.wrap = wrap;
568
+ /* istanbul ignore file */
569
+
570
+ var hasQueueMicrotask = exports.hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask;
571
+ var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
572
+ var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
573
+ function fallback(fn) {
574
+ setTimeout(fn, 0);
575
+ }
576
+ function wrap(defer) {
577
+ return (fn, ...args) => defer(() => fn(...args));
578
+ }
579
+ var _defer;
580
+ if (hasQueueMicrotask) {
581
+ _defer = queueMicrotask;
582
+ } else if (hasSetImmediate) {
583
+ _defer = setImmediate;
584
+ } else if (hasNextTick) {
585
+ _defer = process.nextTick;
586
+ } else {
587
+ _defer = fallback;
588
+ }
589
+ exports.default = wrap(_defer);
590
+ }).call(this);
591
+ }).call(this, require('_process'), require("timers").setImmediate);
592
+ }, {
593
+ "_process": 30,
594
+ "timers": 31
595
+ }],
596
+ 14: [function (require, module, exports) {
597
+ "use strict";
598
+
599
+ Object.defineProperty(exports, "__esModule", {
600
+ value: true
601
+ });
602
+ exports.default = _withoutIndex;
603
+ function _withoutIndex(iteratee) {
604
+ return (value, index, callback) => iteratee(value, callback);
605
+ }
606
+ module.exports = exports["default"];
607
+ }, {}],
608
+ 15: [function (require, module, exports) {
609
+ 'use strict';
610
+
611
+ Object.defineProperty(exports, "__esModule", {
612
+ value: true
613
+ });
614
+ exports.isAsyncIterable = exports.isAsyncGenerator = exports.isAsync = undefined;
615
+ var _asyncify = require('../asyncify.js');
616
+ var _asyncify2 = _interopRequireDefault(_asyncify);
617
+ function _interopRequireDefault(obj) {
618
+ return obj && obj.__esModule ? obj : {
619
+ default: obj
620
+ };
621
+ }
622
+ function isAsync(fn) {
623
+ return fn[Symbol.toStringTag] === 'AsyncFunction';
624
+ }
625
+ function isAsyncGenerator(fn) {
626
+ return fn[Symbol.toStringTag] === 'AsyncGenerator';
627
+ }
628
+ function isAsyncIterable(obj) {
629
+ return typeof obj[Symbol.asyncIterator] === 'function';
630
+ }
631
+ function wrapAsync(asyncFn) {
632
+ if (typeof asyncFn !== 'function') throw new Error('expected a function');
633
+ return isAsync(asyncFn) ? (0, _asyncify2.default)(asyncFn) : asyncFn;
634
+ }
635
+ exports.default = wrapAsync;
636
+ exports.isAsync = isAsync;
637
+ exports.isAsyncGenerator = isAsyncGenerator;
638
+ exports.isAsyncIterable = isAsyncIterable;
639
+ }, {
640
+ "../asyncify.js": 1
641
+ }],
642
+ 16: [function (require, module, exports) {
643
+ 'use strict';
644
+
645
+ Object.defineProperty(exports, "__esModule", {
646
+ value: true
647
+ });
648
+ var _once = require('./internal/once.js');
649
+ var _once2 = _interopRequireDefault(_once);
650
+ var _onlyOnce = require('./internal/onlyOnce.js');
651
+ var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
652
+ var _wrapAsync = require('./internal/wrapAsync.js');
653
+ var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
654
+ var _awaitify = require('./internal/awaitify.js');
655
+ var _awaitify2 = _interopRequireDefault(_awaitify);
656
+ function _interopRequireDefault(obj) {
657
+ return obj && obj.__esModule ? obj : {
658
+ default: obj
659
+ };
660
+ }
661
+
662
+ /**
663
+ * Runs the `tasks` array of functions in series, each passing their results to
664
+ * the next in the array. However, if any of the `tasks` pass an error to their
665
+ * own callback, the next function is not executed, and the main `callback` is
666
+ * immediately called with the error.
667
+ *
668
+ * @name waterfall
669
+ * @static
670
+ * @memberOf module:ControlFlow
671
+ * @method
672
+ * @category Control Flow
673
+ * @param {Array} tasks - An array of [async functions]{@link AsyncFunction}
674
+ * to run.
675
+ * Each function should complete with any number of `result` values.
676
+ * The `result` values will be passed as arguments, in order, to the next task.
677
+ * @param {Function} [callback] - An optional callback to run once all the
678
+ * functions have completed. This will be passed the results of the last task's
679
+ * callback. Invoked with (err, [results]).
680
+ * @returns {Promise} a promise, if a callback is omitted
681
+ * @example
682
+ *
683
+ * async.waterfall([
684
+ * function(callback) {
685
+ * callback(null, 'one', 'two');
686
+ * },
687
+ * function(arg1, arg2, callback) {
688
+ * // arg1 now equals 'one' and arg2 now equals 'two'
689
+ * callback(null, 'three');
690
+ * },
691
+ * function(arg1, callback) {
692
+ * // arg1 now equals 'three'
693
+ * callback(null, 'done');
694
+ * }
695
+ * ], function (err, result) {
696
+ * // result now equals 'done'
697
+ * });
698
+ *
699
+ * // Or, with named functions:
700
+ * async.waterfall([
701
+ * myFirstFunction,
702
+ * mySecondFunction,
703
+ * myLastFunction,
704
+ * ], function (err, result) {
705
+ * // result now equals 'done'
706
+ * });
707
+ * function myFirstFunction(callback) {
708
+ * callback(null, 'one', 'two');
709
+ * }
710
+ * function mySecondFunction(arg1, arg2, callback) {
711
+ * // arg1 now equals 'one' and arg2 now equals 'two'
712
+ * callback(null, 'three');
713
+ * }
714
+ * function myLastFunction(arg1, callback) {
715
+ * // arg1 now equals 'three'
716
+ * callback(null, 'done');
717
+ * }
718
+ */
719
+ function waterfall(tasks, callback) {
720
+ callback = (0, _once2.default)(callback);
721
+ if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
722
+ if (!tasks.length) return callback();
723
+ var taskIndex = 0;
724
+ function nextTask(args) {
725
+ var task = (0, _wrapAsync2.default)(tasks[taskIndex++]);
726
+ task(...args, (0, _onlyOnce2.default)(next));
727
+ }
728
+ function next(err, ...args) {
729
+ if (err === false) return;
730
+ if (err || taskIndex === tasks.length) {
731
+ return callback(err, ...args);
732
+ }
733
+ nextTask(args);
734
+ }
735
+ nextTask([]);
736
+ }
737
+ exports.default = (0, _awaitify2.default)(waterfall);
738
+ module.exports = exports['default'];
739
+ }, {
740
+ "./internal/awaitify.js": 4,
741
+ "./internal/once.js": 11,
742
+ "./internal/onlyOnce.js": 12,
743
+ "./internal/wrapAsync.js": 15
744
+ }],
745
+ 17: [function (require, module, exports) {
48
746
  /**
49
747
  * Base Logger Class
50
748
  *
@@ -108,7 +806,7 @@
108
806
  }
109
807
  module.exports = BaseLogger;
110
808
  }, {}],
111
- 2: [function (require, module, exports) {
809
+ 18: [function (require, module, exports) {
112
810
  /**
113
811
  * Default Logger Provider Function
114
812
  *
@@ -126,16 +824,16 @@
126
824
  };
127
825
  module.exports = getDefaultProviders();
128
826
  }, {
129
- "./Fable-Log-Logger-Console.js": 4
827
+ "./Fable-Log-Logger-Console.js": 20
130
828
  }],
131
- 3: [function (require, module, exports) {
829
+ 19: [function (require, module, exports) {
132
830
  module.exports = [{
133
831
  "loggertype": "console",
134
832
  "streamtype": "console",
135
833
  "level": "trace"
136
834
  }];
137
835
  }, {}],
138
- 4: [function (require, module, exports) {
836
+ 20: [function (require, module, exports) {
139
837
  let libBaseLogger = require('./Fable-Log-BaseLogger.js');
140
838
  class ConsoleLogger extends libBaseLogger {
141
839
  constructor(pLogStreamSettings, pFableLog) {
@@ -181,9 +879,9 @@
181
879
  }
182
880
  module.exports = ConsoleLogger;
183
881
  }, {
184
- "./Fable-Log-BaseLogger.js": 1
882
+ "./Fable-Log-BaseLogger.js": 17
185
883
  }],
186
- 5: [function (require, module, exports) {
884
+ 21: [function (require, module, exports) {
187
885
  /**
188
886
  * Fable Logging Add-on
189
887
  *
@@ -365,10 +1063,10 @@
365
1063
  FableLog: FableLog
366
1064
  };
367
1065
  }, {
368
- "./Fable-Log-DefaultProviders-Node.js": 2,
369
- "./Fable-Log-DefaultStreams.json": 3
1066
+ "./Fable-Log-DefaultProviders-Node.js": 18,
1067
+ "./Fable-Log-DefaultStreams.json": 19
370
1068
  }],
371
- 6: [function (require, module, exports) {
1069
+ 22: [function (require, module, exports) {
372
1070
  module.exports = {
373
1071
  "Product": "ApplicationNameHere",
374
1072
  "ProductVersion": "0.0.0",
@@ -378,7 +1076,7 @@
378
1076
  }]
379
1077
  };
380
1078
  }, {}],
381
- 7: [function (require, module, exports) {
1079
+ 23: [function (require, module, exports) {
382
1080
  (function (process) {
383
1081
  (function () {
384
1082
  /**
@@ -420,9 +1118,9 @@
420
1118
  }).call(this);
421
1119
  }).call(this, require('_process'));
422
1120
  }, {
423
- "_process": 14
1121
+ "_process": 30
424
1122
  }],
425
- 8: [function (require, module, exports) {
1123
+ 24: [function (require, module, exports) {
426
1124
  /**
427
1125
  * Fable Settings Add-on
428
1126
  *
@@ -569,11 +1267,11 @@
569
1267
  FableSettings: FableSettings
570
1268
  };
571
1269
  }, {
572
- "./Fable-Settings-Default": 6,
573
- "./Fable-Settings-TemplateProcessor.js": 7,
574
- "precedent": 11
1270
+ "./Fable-Settings-Default": 22,
1271
+ "./Fable-Settings-TemplateProcessor.js": 23,
1272
+ "precedent": 27
575
1273
  }],
576
- 9: [function (require, module, exports) {
1274
+ 25: [function (require, module, exports) {
577
1275
  /**
578
1276
  * Random Byte Generator - Browser version
579
1277
  *
@@ -626,7 +1324,7 @@
626
1324
  }
627
1325
  module.exports = RandomBytes;
628
1326
  }, {}],
629
- 10: [function (require, module, exports) {
1327
+ 26: [function (require, module, exports) {
630
1328
  /**
631
1329
  * Fable UUID Generator
632
1330
  *
@@ -709,9 +1407,9 @@
709
1407
  FableUUID: FableUUID
710
1408
  };
711
1409
  }, {
712
- "./Fable-UUID-Random.js": 9
1410
+ "./Fable-UUID-Random.js": 25
713
1411
  }],
714
- 11: [function (require, module, exports) {
1412
+ 27: [function (require, module, exports) {
715
1413
  /**
716
1414
  * Precedent Meta-Templating
717
1415
  *
@@ -757,10 +1455,10 @@
757
1455
  }
758
1456
  module.exports = Precedent;
759
1457
  }, {
760
- "./StringParser.js": 12,
761
- "./WordTree.js": 13
1458
+ "./StringParser.js": 28,
1459
+ "./WordTree.js": 29
762
1460
  }],
763
- 12: [function (require, module, exports) {
1461
+ 28: [function (require, module, exports) {
764
1462
  /**
765
1463
  * String Parser
766
1464
  *
@@ -906,7 +1604,7 @@
906
1604
  }
907
1605
  module.exports = StringParser;
908
1606
  }, {}],
909
- 13: [function (require, module, exports) {
1607
+ 29: [function (require, module, exports) {
910
1608
  /**
911
1609
  * Word Tree
912
1610
  *
@@ -965,7 +1663,7 @@
965
1663
  }
966
1664
  module.exports = WordTree;
967
1665
  }, {}],
968
- 14: [function (require, module, exports) {
1666
+ 30: [function (require, module, exports) {
969
1667
  // shim for using process in browser
970
1668
  var process = module.exports = {};
971
1669
 
@@ -1142,17 +1840,103 @@
1142
1840
  return 0;
1143
1841
  };
1144
1842
  }, {}],
1145
- 15: [function (require, module, exports) {
1843
+ 31: [function (require, module, exports) {
1844
+ (function (setImmediate, clearImmediate) {
1845
+ (function () {
1846
+ var nextTick = require('process/browser.js').nextTick;
1847
+ var apply = Function.prototype.apply;
1848
+ var slice = Array.prototype.slice;
1849
+ var immediateIds = {};
1850
+ var nextImmediateId = 0;
1851
+
1852
+ // DOM APIs, for completeness
1853
+
1854
+ exports.setTimeout = function () {
1855
+ return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
1856
+ };
1857
+ exports.setInterval = function () {
1858
+ return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
1859
+ };
1860
+ exports.clearTimeout = exports.clearInterval = function (timeout) {
1861
+ timeout.close();
1862
+ };
1863
+ function Timeout(id, clearFn) {
1864
+ this._id = id;
1865
+ this._clearFn = clearFn;
1866
+ }
1867
+ Timeout.prototype.unref = Timeout.prototype.ref = function () {};
1868
+ Timeout.prototype.close = function () {
1869
+ this._clearFn.call(window, this._id);
1870
+ };
1871
+
1872
+ // Does not start the time, just sets up the members needed.
1873
+ exports.enroll = function (item, msecs) {
1874
+ clearTimeout(item._idleTimeoutId);
1875
+ item._idleTimeout = msecs;
1876
+ };
1877
+ exports.unenroll = function (item) {
1878
+ clearTimeout(item._idleTimeoutId);
1879
+ item._idleTimeout = -1;
1880
+ };
1881
+ exports._unrefActive = exports.active = function (item) {
1882
+ clearTimeout(item._idleTimeoutId);
1883
+ var msecs = item._idleTimeout;
1884
+ if (msecs >= 0) {
1885
+ item._idleTimeoutId = setTimeout(function onTimeout() {
1886
+ if (item._onTimeout) item._onTimeout();
1887
+ }, msecs);
1888
+ }
1889
+ };
1890
+
1891
+ // That's not how node.js implements it but the exposed api is the same.
1892
+ exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function (fn) {
1893
+ var id = nextImmediateId++;
1894
+ var args = arguments.length < 2 ? false : slice.call(arguments, 1);
1895
+ immediateIds[id] = true;
1896
+ nextTick(function onNextTick() {
1897
+ if (immediateIds[id]) {
1898
+ // fn.call() is faster so we optimize for the common use-case
1899
+ // @see http://jsperf.com/call-apply-segu
1900
+ if (args) {
1901
+ fn.apply(null, args);
1902
+ } else {
1903
+ fn.call(null);
1904
+ }
1905
+ // Prevent ids from leaking
1906
+ exports.clearImmediate(id);
1907
+ }
1908
+ });
1909
+ return id;
1910
+ };
1911
+ exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function (id) {
1912
+ delete immediateIds[id];
1913
+ };
1914
+ }).call(this);
1915
+ }).call(this, require("timers").setImmediate, require("timers").clearImmediate);
1916
+ }, {
1917
+ "process/browser.js": 30,
1918
+ "timers": 31
1919
+ }],
1920
+ 32: [function (require, module, exports) {
1146
1921
  var libNPMModuleWrapper = require('./Fable.js');
1147
1922
  if (typeof window === 'object' && !window.hasOwnProperty('Fable')) {
1148
1923
  window.Fable = libNPMModuleWrapper;
1149
1924
  }
1150
1925
  module.exports = libNPMModuleWrapper;
1151
1926
  }, {
1152
- "./Fable.js": 18
1927
+ "./Fable.js": 35
1153
1928
  }],
1154
- 16: [function (require, module, exports) {
1929
+ 33: [function (require, module, exports) {
1155
1930
  class FableUtility {
1931
+ // Underscore and lodash have a behavior, _.template, which compiles a
1932
+ // string-based template with code snippets into simple executable pieces,
1933
+ // with the added twist of returning a precompiled function ready to go.
1934
+ //
1935
+ // NOTE: This does not implement underscore escape expressions
1936
+ // NOTE: This does not implement underscore magic browser variable assignment
1937
+ //
1938
+ // This is an implementation of that.
1939
+ // TODO: Make this use precedent, add configuration, add debugging.
1156
1940
  constructor(pFable, pTemplateText) {
1157
1941
  this.fable = pFable;
1158
1942
 
@@ -1203,16 +1987,6 @@
1203
1987
  let fRenderTemplateBound = this.renderTemplate.bind(this);
1204
1988
  return fRenderTemplateBound;
1205
1989
  }
1206
-
1207
- // Underscore and lodash have a behavior, _.template, which compiles a
1208
- // string-based template with code snippets into simple executable pieces,
1209
- // with the added twist of returning a precompiled function ready to go.
1210
- //
1211
- // NOTE: This does not implement underscore escape expressions
1212
- // NOTE: This does not implement underscore magic browser variable assignment
1213
- //
1214
- // This is an implementation of that.
1215
- // TODO: Make this use precedent, add configuration, add debugging.
1216
1990
  buildTemplateFunction(pTemplateText, pData) {
1217
1991
  // For now this is being kept in a weird form ... this is to mimic the old
1218
1992
  // underscore code until this is rewritten using precedent.
@@ -1238,11 +2012,17 @@
1238
2012
  }
1239
2013
  module.exports = FableUtility;
1240
2014
  }, {}],
1241
- 17: [function (require, module, exports) {
2015
+ 34: [function (require, module, exports) {
1242
2016
  const libFableUtilityTemplate = require('./Fable-Utility-Template.js');
2017
+ const libAsyncWaterfall = require('async/waterfall');
2018
+ const libAsyncEachLimit = require('async/eachLimit');
1243
2019
  class FableUtility {
1244
2020
  constructor(pFable) {
1245
2021
  this.fable = pFable;
2022
+
2023
+ // These two functions are used extensively throughout
2024
+ this.waterfall = libAsyncWaterfall;
2025
+ this.eachLimit = libAsyncEachLimit;
1246
2026
  }
1247
2027
 
1248
2028
  // Underscore and lodash have a behavior, _.extend, which merges objects.
@@ -1280,9 +2060,11 @@
1280
2060
  }
1281
2061
  module.exports = FableUtility;
1282
2062
  }, {
1283
- "./Fable-Utility-Template.js": 16
2063
+ "./Fable-Utility-Template.js": 33,
2064
+ "async/eachLimit": 2,
2065
+ "async/waterfall": 16
1284
2066
  }],
1285
- 18: [function (require, module, exports) {
2067
+ 35: [function (require, module, exports) {
1286
2068
  /**
1287
2069
  * Fable Application Services Support Library
1288
2070
  * @license MIT
@@ -1315,10 +2097,10 @@
1315
2097
  }
1316
2098
  module.exports = Fable;
1317
2099
  }, {
1318
- "./Fable-Utility.js": 17,
1319
- "fable-log": 5,
1320
- "fable-settings": 8,
1321
- "fable-uuid": 10
2100
+ "./Fable-Utility.js": 34,
2101
+ "fable-log": 21,
2102
+ "fable-settings": 24,
2103
+ "fable-uuid": 26
1322
2104
  }]
1323
- }, {}, [15])(15);
2105
+ }, {}, [32])(32);
1324
2106
  });