fable 3.0.6 → 3.0.10

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
  *
@@ -56,7 +754,7 @@
56
754
  class BaseLogger {
57
755
  constructor(pLogStreamSettings, pFableLog) {
58
756
  // This should not possibly be able to be instantiated without a settings object
59
- this._Settings = pLogStreamSettings;
757
+ this._Settings = typeof pLogStreamSettings == 'object' ? pLogStreamSettings : {};
60
758
 
61
759
  // The base logger does nothing but associate a UUID with itself
62
760
  // We added this as the mechanism for tracking loggers to allow multiple simultaneous streams
@@ -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,27 +824,27 @@
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) {
142
840
  super(pLogStreamSettings);
143
- this._ShowTimeStamps = pLogStreamSettings.hasOwnProperty('showtimestamps') ? pLogStreamSettings.showtimestamps == true : false;
144
- this._FormattedTimeStamps = pLogStreamSettings.hasOwnProperty('formattedtimestamps') ? pLogStreamSettings.formattedtimestamps == true : false;
145
- this._ContextMessage = pLogStreamSettings.hasOwnProperty('Context') ? `(${pLogStreamSettings.Context})` : pFableLog._Settings.hasOwnProperty('Product') ? `(${pFableLog._Settings.Product})` : 'Unnamed_Log_Context';
841
+ this._ShowTimeStamps = this._Settings.hasOwnProperty('showtimestamps') ? this._Settings.showtimestamps == true : false;
842
+ this._FormattedTimeStamps = this._Settings.hasOwnProperty('formattedtimestamps') ? this._Settings.formattedtimestamps == true : false;
843
+ this._ContextMessage = this._Settings.hasOwnProperty('Context') ? `(${this._Settings.Context})` : pFableLog._Settings.hasOwnProperty('Product') ? `(${pFableLog._Settings.Product})` : 'Unnamed_Log_Context';
146
844
 
147
845
  // Allow the user to decide what gets output to the console
148
- this._OutputLogLinesToConsole = pLogStreamSettings.hasOwnProperty('outputloglinestoconsole') ? pLogStreamSettings.outputloglinestoconsole : true;
149
- this._OutputObjectsToConsole = pLogStreamSettings.hasOwnProperty('outputobjectstoconsole') ? pLogStreamSettings.outputobjectstoconsole : true;
846
+ this._OutputLogLinesToConsole = this._Settings.hasOwnProperty('outputloglinestoconsole') ? this._Settings.outputloglinestoconsole : true;
847
+ this._OutputObjectsToConsole = this._Settings.hasOwnProperty('outputobjectstoconsole') ? this._Settings.outputobjectstoconsole : true;
150
848
 
151
849
  // Precompute the prefix for each level
152
850
  this.prefixCache = {};
@@ -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
  *
@@ -360,15 +1058,15 @@
360
1058
  function autoConstruct(pSettings) {
361
1059
  return new FableLog(pSettings);
362
1060
  }
363
- module.exports = {
364
- new: autoConstruct,
365
- FableLog: FableLog
366
- };
1061
+ module.exports = FableLog;
1062
+ module.exports.new = autoConstruct;
1063
+ module.exports.LogProviderBase = require('./Fable-Log-BaseLogger.js');
367
1064
  }, {
368
- "./Fable-Log-DefaultProviders-Node.js": 2,
369
- "./Fable-Log-DefaultStreams.json": 3
1065
+ "./Fable-Log-BaseLogger.js": 17,
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
  *
@@ -564,16 +1262,15 @@
564
1262
  function autoConstruct(pSettings) {
565
1263
  return new FableSettings(pSettings);
566
1264
  }
567
- module.exports = {
568
- new: autoConstruct,
569
- FableSettings: FableSettings
570
- };
1265
+ module.exports = FableSettings;
1266
+ module.exports.new = autoConstruct;
1267
+ module.exports.precedent = libPrecedent;
571
1268
  }, {
572
- "./Fable-Settings-Default": 6,
573
- "./Fable-Settings-TemplateProcessor.js": 7,
574
- "precedent": 11
1269
+ "./Fable-Settings-Default": 22,
1270
+ "./Fable-Settings-TemplateProcessor.js": 23,
1271
+ "precedent": 27
575
1272
  }],
576
- 9: [function (require, module, exports) {
1273
+ 25: [function (require, module, exports) {
577
1274
  /**
578
1275
  * Random Byte Generator - Browser version
579
1276
  *
@@ -626,7 +1323,7 @@
626
1323
  }
627
1324
  module.exports = RandomBytes;
628
1325
  }, {}],
629
- 10: [function (require, module, exports) {
1326
+ 26: [function (require, module, exports) {
630
1327
  /**
631
1328
  * Fable UUID Generator
632
1329
  *
@@ -704,14 +1401,12 @@
704
1401
  function autoConstruct(pSettings) {
705
1402
  return new FableUUID(pSettings);
706
1403
  }
707
- module.exports = {
708
- new: autoConstruct,
709
- FableUUID: FableUUID
710
- };
1404
+ module.exports = FableUUID;
1405
+ module.exports.new = autoConstruct;
711
1406
  }, {
712
- "./Fable-UUID-Random.js": 9
1407
+ "./Fable-UUID-Random.js": 25
713
1408
  }],
714
- 11: [function (require, module, exports) {
1409
+ 27: [function (require, module, exports) {
715
1410
  /**
716
1411
  * Precedent Meta-Templating
717
1412
  *
@@ -757,10 +1452,10 @@
757
1452
  }
758
1453
  module.exports = Precedent;
759
1454
  }, {
760
- "./StringParser.js": 12,
761
- "./WordTree.js": 13
1455
+ "./StringParser.js": 28,
1456
+ "./WordTree.js": 29
762
1457
  }],
763
- 12: [function (require, module, exports) {
1458
+ 28: [function (require, module, exports) {
764
1459
  /**
765
1460
  * String Parser
766
1461
  *
@@ -906,7 +1601,7 @@
906
1601
  }
907
1602
  module.exports = StringParser;
908
1603
  }, {}],
909
- 13: [function (require, module, exports) {
1604
+ 29: [function (require, module, exports) {
910
1605
  /**
911
1606
  * Word Tree
912
1607
  *
@@ -965,7 +1660,7 @@
965
1660
  }
966
1661
  module.exports = WordTree;
967
1662
  }, {}],
968
- 14: [function (require, module, exports) {
1663
+ 30: [function (require, module, exports) {
969
1664
  // shim for using process in browser
970
1665
  var process = module.exports = {};
971
1666
 
@@ -1142,17 +1837,103 @@
1142
1837
  return 0;
1143
1838
  };
1144
1839
  }, {}],
1145
- 15: [function (require, module, exports) {
1840
+ 31: [function (require, module, exports) {
1841
+ (function (setImmediate, clearImmediate) {
1842
+ (function () {
1843
+ var nextTick = require('process/browser.js').nextTick;
1844
+ var apply = Function.prototype.apply;
1845
+ var slice = Array.prototype.slice;
1846
+ var immediateIds = {};
1847
+ var nextImmediateId = 0;
1848
+
1849
+ // DOM APIs, for completeness
1850
+
1851
+ exports.setTimeout = function () {
1852
+ return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
1853
+ };
1854
+ exports.setInterval = function () {
1855
+ return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
1856
+ };
1857
+ exports.clearTimeout = exports.clearInterval = function (timeout) {
1858
+ timeout.close();
1859
+ };
1860
+ function Timeout(id, clearFn) {
1861
+ this._id = id;
1862
+ this._clearFn = clearFn;
1863
+ }
1864
+ Timeout.prototype.unref = Timeout.prototype.ref = function () {};
1865
+ Timeout.prototype.close = function () {
1866
+ this._clearFn.call(window, this._id);
1867
+ };
1868
+
1869
+ // Does not start the time, just sets up the members needed.
1870
+ exports.enroll = function (item, msecs) {
1871
+ clearTimeout(item._idleTimeoutId);
1872
+ item._idleTimeout = msecs;
1873
+ };
1874
+ exports.unenroll = function (item) {
1875
+ clearTimeout(item._idleTimeoutId);
1876
+ item._idleTimeout = -1;
1877
+ };
1878
+ exports._unrefActive = exports.active = function (item) {
1879
+ clearTimeout(item._idleTimeoutId);
1880
+ var msecs = item._idleTimeout;
1881
+ if (msecs >= 0) {
1882
+ item._idleTimeoutId = setTimeout(function onTimeout() {
1883
+ if (item._onTimeout) item._onTimeout();
1884
+ }, msecs);
1885
+ }
1886
+ };
1887
+
1888
+ // That's not how node.js implements it but the exposed api is the same.
1889
+ exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function (fn) {
1890
+ var id = nextImmediateId++;
1891
+ var args = arguments.length < 2 ? false : slice.call(arguments, 1);
1892
+ immediateIds[id] = true;
1893
+ nextTick(function onNextTick() {
1894
+ if (immediateIds[id]) {
1895
+ // fn.call() is faster so we optimize for the common use-case
1896
+ // @see http://jsperf.com/call-apply-segu
1897
+ if (args) {
1898
+ fn.apply(null, args);
1899
+ } else {
1900
+ fn.call(null);
1901
+ }
1902
+ // Prevent ids from leaking
1903
+ exports.clearImmediate(id);
1904
+ }
1905
+ });
1906
+ return id;
1907
+ };
1908
+ exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function (id) {
1909
+ delete immediateIds[id];
1910
+ };
1911
+ }).call(this);
1912
+ }).call(this, require("timers").setImmediate, require("timers").clearImmediate);
1913
+ }, {
1914
+ "process/browser.js": 30,
1915
+ "timers": 31
1916
+ }],
1917
+ 32: [function (require, module, exports) {
1146
1918
  var libNPMModuleWrapper = require('./Fable.js');
1147
1919
  if (typeof window === 'object' && !window.hasOwnProperty('Fable')) {
1148
1920
  window.Fable = libNPMModuleWrapper;
1149
1921
  }
1150
1922
  module.exports = libNPMModuleWrapper;
1151
1923
  }, {
1152
- "./Fable.js": 18
1924
+ "./Fable.js": 35
1153
1925
  }],
1154
- 16: [function (require, module, exports) {
1926
+ 33: [function (require, module, exports) {
1155
1927
  class FableUtility {
1928
+ // Underscore and lodash have a behavior, _.template, which compiles a
1929
+ // string-based template with code snippets into simple executable pieces,
1930
+ // with the added twist of returning a precompiled function ready to go.
1931
+ //
1932
+ // NOTE: This does not implement underscore escape expressions
1933
+ // NOTE: This does not implement underscore magic browser variable assignment
1934
+ //
1935
+ // This is an implementation of that.
1936
+ // TODO: Make this use precedent, add configuration, add debugging.
1156
1937
  constructor(pFable, pTemplateText) {
1157
1938
  this.fable = pFable;
1158
1939
 
@@ -1203,16 +1984,6 @@
1203
1984
  let fRenderTemplateBound = this.renderTemplate.bind(this);
1204
1985
  return fRenderTemplateBound;
1205
1986
  }
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
1987
  buildTemplateFunction(pTemplateText, pData) {
1217
1988
  // For now this is being kept in a weird form ... this is to mimic the old
1218
1989
  // underscore code until this is rewritten using precedent.
@@ -1238,11 +2009,17 @@
1238
2009
  }
1239
2010
  module.exports = FableUtility;
1240
2011
  }, {}],
1241
- 17: [function (require, module, exports) {
2012
+ 34: [function (require, module, exports) {
1242
2013
  const libFableUtilityTemplate = require('./Fable-Utility-Template.js');
2014
+ const libAsyncWaterfall = require('async/waterfall');
2015
+ const libAsyncEachLimit = require('async/eachLimit');
1243
2016
  class FableUtility {
1244
2017
  constructor(pFable) {
1245
2018
  this.fable = pFable;
2019
+
2020
+ // These two functions are used extensively throughout
2021
+ this.waterfall = libAsyncWaterfall;
2022
+ this.eachLimit = libAsyncEachLimit;
1246
2023
  }
1247
2024
 
1248
2025
  // Underscore and lodash have a behavior, _.extend, which merges objects.
@@ -1280,17 +2057,19 @@
1280
2057
  }
1281
2058
  module.exports = FableUtility;
1282
2059
  }, {
1283
- "./Fable-Utility-Template.js": 16
2060
+ "./Fable-Utility-Template.js": 33,
2061
+ "async/eachLimit": 2,
2062
+ "async/waterfall": 16
1284
2063
  }],
1285
- 18: [function (require, module, exports) {
2064
+ 35: [function (require, module, exports) {
1286
2065
  /**
1287
2066
  * Fable Application Services Support Library
1288
2067
  * @license MIT
1289
2068
  * @author <steven@velozo.com>
1290
2069
  */
1291
- const libFableSettings = require('fable-settings').FableSettings;
1292
- const libFableUUID = require('fable-uuid').FableUUID;
1293
- const libFableLog = require('fable-log').FableLog;
2070
+ const libFableSettings = require('fable-settings');
2071
+ const libFableUUID = require('fable-uuid');
2072
+ const libFableLog = require('fable-log');
1294
2073
  const libFableUtility = require('./Fable-Utility.js');
1295
2074
  class Fable {
1296
2075
  constructor(pSettings) {
@@ -1302,6 +2081,11 @@
1302
2081
  this.log = new libFableLog(this.settingsManager.settings);
1303
2082
  this.log.initialize();
1304
2083
  this.Utility = new libFableUtility(this);
2084
+
2085
+ // Built-in dependencies ... more can be added here.
2086
+ this.Dependencies = {
2087
+ precedent: libFableSettings.precedent
2088
+ };
1305
2089
  }
1306
2090
  get settings() {
1307
2091
  return this.settingsManager.settings;
@@ -1313,12 +2097,20 @@
1313
2097
  return this.libUUID.getUUID();
1314
2098
  }
1315
2099
  }
2100
+
2101
+ // This is for backwards compatibility
2102
+ function autoConstruct(pSettings) {
2103
+ return new Fable(pSettings);
2104
+ }
1316
2105
  module.exports = Fable;
2106
+ module.exports.new = autoConstruct;
2107
+ module.exports.LogProviderBase = libFableLog.LogProviderBase;
2108
+ module.exports.precedent = libFableSettings.precedent;
1317
2109
  }, {
1318
- "./Fable-Utility.js": 17,
1319
- "fable-log": 5,
1320
- "fable-settings": 8,
1321
- "fable-uuid": 10
2110
+ "./Fable-Utility.js": 34,
2111
+ "fable-log": 21,
2112
+ "fable-settings": 24,
2113
+ "fable-uuid": 26
1322
2114
  }]
1323
- }, {}, [15])(15);
2115
+ }, {}, [32])(32);
1324
2116
  });