fable 3.0.12 → 3.0.17

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
@@ -47,701 +47,283 @@
47
47
  1: [function (require, module, exports) {
48
48
  'use strict';
49
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'];
50
+ var eachOfLimit = require('async.util.eachoflimit');
51
+ var withoutIndex = require('async.util.withoutindex');
52
+ module.exports = function eachLimit(arr, limit, iterator, cb) {
53
+ return eachOfLimit(limit)(arr, withoutIndex(iterator), cb);
54
+ };
161
55
  }, {
162
- "./internal/initialParams.js": 8,
163
- "./internal/setImmediate.js": 13,
164
- "./internal/wrapAsync.js": 15
56
+ "async.util.eachoflimit": 3,
57
+ "async.util.withoutindex": 14
165
58
  }],
166
59
  2: [function (require, module, exports) {
167
60
  'use strict';
168
61
 
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;
62
+ module.exports = function (tasks) {
63
+ function makeCallback(index) {
64
+ function fn() {
65
+ if (tasks.length) {
66
+ tasks[index].apply(null, arguments);
259
67
  }
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);
68
+ return fn.next();
280
69
  }
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
- });
70
+ fn.next = function () {
71
+ return index < tasks.length - 1 ? makeCallback(index + 1) : null;
72
+ };
73
+ return fn;
317
74
  }
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"];
75
+ return makeCallback(0);
76
+ };
333
77
  }, {}],
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);
78
+ 3: [function (require, module, exports) {
79
+ var once = require('async.util.once');
80
+ var noop = require('async.util.noop');
81
+ var onlyOnce = require('async.util.onlyonce');
82
+ var keyIterator = require('async.util.keyiterator');
83
+ module.exports = function eachOfLimit(limit) {
84
+ return function (obj, iterator, cb) {
85
+ cb = once(cb || noop);
86
+ obj = obj || [];
87
+ var nextKey = keyIterator(obj);
359
88
  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);
89
+ return cb(null);
367
90
  }
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
91
  var done = false;
373
- var canceled = false;
374
92
  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();
93
+ var errored = false;
94
+ (function replenish() {
95
+ if (done && running <= 0) {
96
+ return cb(null);
390
97
  }
391
- }
392
- function replenish() {
393
- looping = true;
394
- while (running < limit && !done) {
395
- var elem = nextElem();
396
- if (elem === null) {
98
+ while (running < limit && !errored) {
99
+ var key = nextKey();
100
+ if (key === null) {
397
101
  done = true;
398
102
  if (running <= 0) {
399
- callback(null);
103
+ cb(null);
400
104
  }
401
105
  return;
402
106
  }
403
107
  running += 1;
404
- iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
108
+ iterator(obj[key], key, onlyOnce(function (err) {
109
+ running -= 1;
110
+ if (err) {
111
+ cb(err);
112
+ errored = true;
113
+ } else {
114
+ replenish();
115
+ }
116
+ }));
405
117
  }
406
- looping = false;
407
- }
408
- replenish();
118
+ })();
409
119
  };
410
120
  };
411
- module.exports = exports['default'];
412
121
  }, {
413
- "./asyncEachOfLimit.js": 3,
414
- "./breakLoop.js": 5,
415
- "./iterator.js": 10,
416
- "./once.js": 11,
417
- "./onlyOnce.js": 12,
418
- "./wrapAsync.js": 15
122
+ "async.util.keyiterator": 7,
123
+ "async.util.noop": 9,
124
+ "async.util.once": 10,
125
+ "async.util.onlyonce": 11
419
126
  }],
420
- 7: [function (require, module, exports) {
421
- "use strict";
127
+ 4: [function (require, module, exports) {
128
+ 'use strict';
422
129
 
423
- Object.defineProperty(exports, "__esModule", {
424
- value: true
425
- });
426
- exports.default = function (coll) {
427
- return coll[Symbol.iterator] && coll[Symbol.iterator]();
130
+ var setImmediate = require('async.util.setimmediate');
131
+ var restParam = require('async.util.restparam');
132
+ module.exports = function (fn) {
133
+ return restParam(function (args) {
134
+ var callback = args.pop();
135
+ args.push(function () {
136
+ var innerArgs = arguments;
137
+ if (sync) {
138
+ setImmediate(function () {
139
+ callback.apply(null, innerArgs);
140
+ });
141
+ } else {
142
+ callback.apply(null, innerArgs);
143
+ }
144
+ });
145
+ var sync = true;
146
+ fn.apply(this, args);
147
+ sync = false;
148
+ });
149
+ };
150
+ }, {
151
+ "async.util.restparam": 12,
152
+ "async.util.setimmediate": 13
153
+ }],
154
+ 5: [function (require, module, exports) {
155
+ 'use strict';
156
+
157
+ module.exports = Array.isArray || function isArray(obj) {
158
+ return Object.prototype.toString.call(obj) === '[object Array]';
428
159
  };
429
- module.exports = exports["default"];
430
160
  }, {}],
161
+ 6: [function (require, module, exports) {
162
+ 'use strict';
163
+
164
+ var isArray = require('async.util.isarray');
165
+ module.exports = function isArrayLike(arr) {
166
+ return isArray(arr) ||
167
+ // has a positive integer length property
168
+ typeof arr.length === 'number' && arr.length >= 0 && arr.length % 1 === 0;
169
+ };
170
+ }, {
171
+ "async.util.isarray": 5
172
+ }],
173
+ 7: [function (require, module, exports) {
174
+ 'use strict';
175
+
176
+ var _keys = require('async.util.keys');
177
+ var isArrayLike = require('async.util.isarraylike');
178
+ module.exports = function keyIterator(coll) {
179
+ var i = -1;
180
+ var len;
181
+ var keys;
182
+ if (isArrayLike(coll)) {
183
+ len = coll.length;
184
+ return function next() {
185
+ i++;
186
+ return i < len ? i : null;
187
+ };
188
+ } else {
189
+ keys = _keys(coll);
190
+ len = keys.length;
191
+ return function next() {
192
+ i++;
193
+ return i < len ? keys[i] : null;
194
+ };
195
+ }
196
+ };
197
+ }, {
198
+ "async.util.isarraylike": 6,
199
+ "async.util.keys": 8
200
+ }],
431
201
  8: [function (require, module, exports) {
432
- "use strict";
202
+ 'use strict';
433
203
 
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
- };
204
+ module.exports = Object.keys || function keys(obj) {
205
+ var _keys = [];
206
+ for (var k in obj) {
207
+ if (obj.hasOwnProperty(k)) {
208
+ _keys.push(k);
209
+ }
210
+ }
211
+ return _keys;
442
212
  };
443
- module.exports = exports["default"];
444
213
  }, {}],
445
214
  9: [function (require, module, exports) {
446
215
  'use strict';
447
216
 
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'];
217
+ module.exports = function noop() {};
456
218
  }, {}],
457
219
  10: [function (require, module, exports) {
458
220
  'use strict';
459
221
 
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;
222
+ module.exports = function once(fn) {
223
+ return function () {
224
+ if (fn === null) return;
225
+ fn.apply(this, arguments);
226
+ fn = null;
508
227
  };
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
- }],
228
+ };
229
+ }, {}],
522
230
  11: [function (require, module, exports) {
523
- "use strict";
231
+ 'use strict';
524
232
 
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;
233
+ module.exports = function only_once(fn) {
234
+ return function () {
235
+ if (fn === null) throw new Error('Callback was already called.');
236
+ fn.apply(this, arguments);
533
237
  fn = null;
534
- callFn.apply(this, args);
535
- }
536
- Object.assign(wrapper, fn);
537
- return wrapper;
538
- }
539
- module.exports = exports["default"];
238
+ };
239
+ };
540
240
  }, {}],
541
241
  12: [function (require, module, exports) {
542
- "use strict";
242
+ 'use strict';
543
243
 
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);
244
+ module.exports = function restParam(func, startIndex) {
245
+ startIndex = startIndex == null ? func.length - 1 : +startIndex;
246
+ return function () {
247
+ var length = Math.max(arguments.length - startIndex, 0);
248
+ var rest = new Array(length);
249
+ for (var index = 0; index < length; index++) {
250
+ rest[index] = arguments[index + startIndex];
251
+ }
252
+ switch (startIndex) {
253
+ case 0:
254
+ return func.call(this, rest);
255
+ case 1:
256
+ return func.call(this, arguments[0], rest);
257
+ }
554
258
  };
555
- }
556
- module.exports = exports["default"];
259
+ };
557
260
  }, {}],
558
261
  13: [function (require, module, exports) {
559
- (function (process, setImmediate) {
262
+ (function (setImmediate) {
560
263
  (function () {
561
264
  'use strict';
562
265
 
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) {
266
+ var _setImmediate = typeof setImmediate === 'function' && setImmediate;
267
+ var fallback = function (fn) {
574
268
  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);
269
+ };
270
+ module.exports = function setImmediate(fn) {
271
+ // not a direct alias for IE10 compatibility
272
+ return (_setImmediate || fallback)(fn);
273
+ };
590
274
  }).call(this);
591
- }).call(this, require('_process'), require("timers").setImmediate);
275
+ }).call(this, require("timers").setImmediate);
592
276
  }, {
593
- "_process": 30,
594
- "timers": 31
277
+ "timers": 33
595
278
  }],
596
279
  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
280
  'use strict';
610
281
 
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
282
+ module.exports = function withoutIndex(iterator) {
283
+ return function (value, index, callback) {
284
+ return iterator(value, callback);
620
285
  };
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) {
286
+ };
287
+ }, {}],
288
+ 15: [function (require, module, exports) {
643
289
  'use strict';
644
290
 
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'];
291
+ var once = require('async.util.once');
292
+ var noop = require('async.util.noop');
293
+ var isArray = require('async.util.isarray');
294
+ var restParam = require('async.util.restparam');
295
+ var ensureAsync = require('async.util.ensureasync');
296
+ var iterator = require('async.iterator');
297
+ module.exports = function (tasks, cb) {
298
+ cb = once(cb || noop);
299
+ if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions'));
300
+ if (!tasks.length) return cb();
301
+ function wrapIterator(iterator) {
302
+ return restParam(function (err, args) {
303
+ if (err) {
304
+ cb.apply(null, [err].concat(args));
305
+ } else {
306
+ var next = iterator.next();
307
+ if (next) {
308
+ args.push(wrapIterator(next));
309
+ } else {
310
+ args.push(cb);
311
+ }
312
+ ensureAsync(iterator).apply(null, args);
313
+ }
314
+ });
315
+ }
316
+ wrapIterator(iterator(tasks))();
317
+ };
739
318
  }, {
740
- "./internal/awaitify.js": 4,
741
- "./internal/once.js": 11,
742
- "./internal/onlyOnce.js": 12,
743
- "./internal/wrapAsync.js": 15
319
+ "async.iterator": 2,
320
+ "async.util.ensureasync": 4,
321
+ "async.util.isarray": 5,
322
+ "async.util.noop": 9,
323
+ "async.util.once": 10,
324
+ "async.util.restparam": 12
744
325
  }],
326
+ 16: [function (require, module, exports) {}, {}],
745
327
  17: [function (require, module, exports) {
746
328
  /**
747
329
  * Base Logger Class
@@ -838,8 +420,8 @@
838
420
  class ConsoleLogger extends libBaseLogger {
839
421
  constructor(pLogStreamSettings, pFableLog) {
840
422
  super(pLogStreamSettings);
841
- this._ShowTimeStamps = this._Settings.hasOwnProperty('showtimestamps') ? this._Settings.showtimestamps == true : false;
842
- this._FormattedTimeStamps = this._Settings.hasOwnProperty('formattedtimestamps') ? this._Settings.formattedtimestamps == true : false;
423
+ this._ShowTimeStamps = this._Settings.hasOwnProperty('showtimestamps') ? this._Settings.showtimestamps == true : true;
424
+ this._FormattedTimeStamps = this._Settings.hasOwnProperty('formattedtimestamps') ? this._Settings.formattedtimestamps == true : true;
843
425
  this._ContextMessage = this._Settings.hasOwnProperty('Context') ? `(${this._Settings.Context})` : pFableLog._Settings.hasOwnProperty('Product') ? `(${pFableLog._Settings.Product})` : 'Unnamed_Log_Context';
844
426
 
845
427
  // Allow the user to decide what gets output to the console
@@ -882,6 +464,96 @@
882
464
  "./Fable-Log-BaseLogger.js": 17
883
465
  }],
884
466
  21: [function (require, module, exports) {
467
+ const libConsoleLog = require('./Fable-Log-Logger-Console.js');
468
+ const libFS = require('fs');
469
+ const libPath = require('path');
470
+ class SimpleFlatFileLogger extends libConsoleLog {
471
+ constructor(pLogStreamSettings, pFableLog) {
472
+ super(pLogStreamSettings, pFableLog);
473
+
474
+ // If a path isn't provided for the logfile, it tries to use the ProductName or Context
475
+ this.logFileRawPath = this._Settings.hasOwnProperty('path') ? this._Settings.path : `./${this._ContextMessage}.log`;
476
+ this.logFilePath = libPath.normalize(this.logFileRawPath);
477
+ this.logFileStreamOptions = this._Settings.hasOwnProperty('fileStreamoptions') ? this._Settings.fileStreamOptions : {
478
+ "flags": "a",
479
+ "encoding": "utf8"
480
+ };
481
+ this.fileWriter = libFS.createWriteStream(this.logFilePath, this.logFileStreamOptions);
482
+ this.activelyWriting = false;
483
+ this.logLineStrings = [];
484
+ this.logObjectStrings = [];
485
+ this.defaultWriteCompleteCallback = () => {};
486
+ this.defaultBufferFlushCallback = () => {};
487
+ }
488
+ closeWriter(fCloseComplete) {
489
+ let tmpCloseComplete = typeof fCloseComplete == 'function' ? fCloseComplete : () => {};
490
+ if (this.fileWriter) {
491
+ this.fileWriter.end('\n');
492
+ return this.fileWriter.once('finish', tmpCloseComplete.bind(this));
493
+ }
494
+ }
495
+ completeBufferFlushToLogFile(fFlushComplete) {
496
+ this.activelyWriting = false;
497
+ let tmpFlushComplete = typeof fFlushComplete == 'function' ? fFlushComplete : this.defaultBufferFlushCallback;
498
+ if (this.logLineStrings.length > 0) {
499
+ this.flushBufferToLogFile(tmpFlushComplete);
500
+ } else {
501
+ return tmpFlushComplete();
502
+ }
503
+ }
504
+ flushBufferToLogFile(fFlushComplete) {
505
+ if (!this.activelyWriting) {
506
+ // Only want to be writing one thing at a time....
507
+ this.activelyWriting = true;
508
+ let tmpFlushComplete = typeof fFlushComplete == 'function' ? fFlushComplete : this.defaultBufferFlushCallback;
509
+
510
+ // Get the current buffer arrays. These should always have matching number of elements.
511
+ let tmpLineStrings = this.logLineStrings;
512
+ let tmpObjectStrings = this.logObjectStrings;
513
+
514
+ // Reset these to be filled while we process this queue...
515
+ this.logLineStrings = [];
516
+ this.logObjectStrings = [];
517
+
518
+ // This is where we will put each line before writing it to the file...
519
+ let tmpConstructedBufferOutputString = '';
520
+ for (let i = 0; i < tmpLineStrings.length; i++) {
521
+ // TODO: Windows Newline? ....... yo no se!
522
+ tmpConstructedBufferOutputString += `${tmpLineStrings[i]}\n`;
523
+ if (tmpObjectStrings[i] !== false) {
524
+ tmpConstructedBufferOutputString += `${tmpObjectStrings[i]}\n`;
525
+ }
526
+ }
527
+ if (!this.fileWriter.write(tmpConstructedBufferOutputString, 'utf8')) {
528
+ // If the streamwriter returns false, we need to wait for it to drain.
529
+ this.fileWriter.once('drain', this.completeBufferFlushToLogFile.bind(this, tmpFlushComplete));
530
+ } else {
531
+ return this.completeBufferFlushToLogFile(tmpFlushComplete);
532
+ }
533
+ }
534
+ }
535
+ write(pLevel, pLogText, pObject) {
536
+ let tmpLogLine = super.write(pLevel, pLogText, pObject);
537
+
538
+ // Use a very simple array as the write buffer
539
+ this.logLineStrings.push(tmpLogLine);
540
+
541
+ // Write out the object on a separate line if it is passed in
542
+ if (typeof pObject !== 'undefined') {
543
+ this.logObjectStrings.push(JSON.stringify(pObject, null, 4));
544
+ } else {
545
+ this.logObjectStrings.push(false);
546
+ }
547
+ this.flushBufferToLogFile();
548
+ }
549
+ }
550
+ module.exports = SimpleFlatFileLogger;
551
+ }, {
552
+ "./Fable-Log-Logger-Console.js": 20,
553
+ "fs": 16,
554
+ "path": 28
555
+ }],
556
+ 22: [function (require, module, exports) {
885
557
  /**
886
558
  * Fable Logging Add-on
887
559
  *
@@ -1061,12 +733,16 @@
1061
733
  module.exports = FableLog;
1062
734
  module.exports.new = autoConstruct;
1063
735
  module.exports.LogProviderBase = require('./Fable-Log-BaseLogger.js');
736
+ module.exports.LogProviderConsole = require('./Fable-Log-Logger-Console.js');
737
+ module.exports.LogProviderConsole = require('./Fable-Log-Logger-SimpleFlatFile.js');
1064
738
  }, {
1065
739
  "./Fable-Log-BaseLogger.js": 17,
1066
740
  "./Fable-Log-DefaultProviders-Node.js": 18,
1067
- "./Fable-Log-DefaultStreams.json": 19
741
+ "./Fable-Log-DefaultStreams.json": 19,
742
+ "./Fable-Log-Logger-Console.js": 20,
743
+ "./Fable-Log-Logger-SimpleFlatFile.js": 21
1068
744
  }],
1069
- 22: [function (require, module, exports) {
745
+ 23: [function (require, module, exports) {
1070
746
  module.exports = {
1071
747
  "Product": "ApplicationNameHere",
1072
748
  "ProductVersion": "0.0.0",
@@ -1076,7 +752,7 @@
1076
752
  }]
1077
753
  };
1078
754
  }, {}],
1079
- 23: [function (require, module, exports) {
755
+ 24: [function (require, module, exports) {
1080
756
  (function (process) {
1081
757
  (function () {
1082
758
  /**
@@ -1118,9 +794,9 @@
1118
794
  }).call(this);
1119
795
  }).call(this, require('_process'));
1120
796
  }, {
1121
- "_process": 30
797
+ "_process": 32
1122
798
  }],
1123
- 24: [function (require, module, exports) {
799
+ 25: [function (require, module, exports) {
1124
800
  /**
1125
801
  * Fable Settings Add-on
1126
802
  *
@@ -1266,11 +942,11 @@
1266
942
  module.exports.new = autoConstruct;
1267
943
  module.exports.precedent = libPrecedent;
1268
944
  }, {
1269
- "./Fable-Settings-Default": 22,
1270
- "./Fable-Settings-TemplateProcessor.js": 23,
1271
- "precedent": 27
945
+ "./Fable-Settings-Default": 23,
946
+ "./Fable-Settings-TemplateProcessor.js": 24,
947
+ "precedent": 29
1272
948
  }],
1273
- 25: [function (require, module, exports) {
949
+ 26: [function (require, module, exports) {
1274
950
  /**
1275
951
  * Random Byte Generator - Browser version
1276
952
  *
@@ -1323,7 +999,7 @@
1323
999
  }
1324
1000
  module.exports = RandomBytes;
1325
1001
  }, {}],
1326
- 26: [function (require, module, exports) {
1002
+ 27: [function (require, module, exports) {
1327
1003
  /**
1328
1004
  * Fable UUID Generator
1329
1005
  *
@@ -1404,9 +1080,480 @@
1404
1080
  module.exports = FableUUID;
1405
1081
  module.exports.new = autoConstruct;
1406
1082
  }, {
1407
- "./Fable-UUID-Random.js": 25
1083
+ "./Fable-UUID-Random.js": 26
1408
1084
  }],
1409
- 27: [function (require, module, exports) {
1085
+ 28: [function (require, module, exports) {
1086
+ (function (process) {
1087
+ (function () {
1088
+ // 'path' module extracted from Node.js v8.11.1 (only the posix part)
1089
+ // transplited with Babel
1090
+
1091
+ // Copyright Joyent, Inc. and other Node contributors.
1092
+ //
1093
+ // Permission is hereby granted, free of charge, to any person obtaining a
1094
+ // copy of this software and associated documentation files (the
1095
+ // "Software"), to deal in the Software without restriction, including
1096
+ // without limitation the rights to use, copy, modify, merge, publish,
1097
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
1098
+ // persons to whom the Software is furnished to do so, subject to the
1099
+ // following conditions:
1100
+ //
1101
+ // The above copyright notice and this permission notice shall be included
1102
+ // in all copies or substantial portions of the Software.
1103
+ //
1104
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1105
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1106
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1107
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1108
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1109
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1110
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
1111
+
1112
+ 'use strict';
1113
+
1114
+ function assertPath(path) {
1115
+ if (typeof path !== 'string') {
1116
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
1117
+ }
1118
+ }
1119
+
1120
+ // Resolves . and .. elements in a path with directory names
1121
+ function normalizeStringPosix(path, allowAboveRoot) {
1122
+ var res = '';
1123
+ var lastSegmentLength = 0;
1124
+ var lastSlash = -1;
1125
+ var dots = 0;
1126
+ var code;
1127
+ for (var i = 0; i <= path.length; ++i) {
1128
+ if (i < path.length) code = path.charCodeAt(i);else if (code === 47 /*/*/) break;else code = 47 /*/*/;
1129
+ if (code === 47 /*/*/) {
1130
+ if (lastSlash === i - 1 || dots === 1) {
1131
+ // NOOP
1132
+ } else if (lastSlash !== i - 1 && dots === 2) {
1133
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
1134
+ if (res.length > 2) {
1135
+ var lastSlashIndex = res.lastIndexOf('/');
1136
+ if (lastSlashIndex !== res.length - 1) {
1137
+ if (lastSlashIndex === -1) {
1138
+ res = '';
1139
+ lastSegmentLength = 0;
1140
+ } else {
1141
+ res = res.slice(0, lastSlashIndex);
1142
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
1143
+ }
1144
+ lastSlash = i;
1145
+ dots = 0;
1146
+ continue;
1147
+ }
1148
+ } else if (res.length === 2 || res.length === 1) {
1149
+ res = '';
1150
+ lastSegmentLength = 0;
1151
+ lastSlash = i;
1152
+ dots = 0;
1153
+ continue;
1154
+ }
1155
+ }
1156
+ if (allowAboveRoot) {
1157
+ if (res.length > 0) res += '/..';else res = '..';
1158
+ lastSegmentLength = 2;
1159
+ }
1160
+ } else {
1161
+ if (res.length > 0) res += '/' + path.slice(lastSlash + 1, i);else res = path.slice(lastSlash + 1, i);
1162
+ lastSegmentLength = i - lastSlash - 1;
1163
+ }
1164
+ lastSlash = i;
1165
+ dots = 0;
1166
+ } else if (code === 46 /*.*/ && dots !== -1) {
1167
+ ++dots;
1168
+ } else {
1169
+ dots = -1;
1170
+ }
1171
+ }
1172
+ return res;
1173
+ }
1174
+ function _format(sep, pathObject) {
1175
+ var dir = pathObject.dir || pathObject.root;
1176
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
1177
+ if (!dir) {
1178
+ return base;
1179
+ }
1180
+ if (dir === pathObject.root) {
1181
+ return dir + base;
1182
+ }
1183
+ return dir + sep + base;
1184
+ }
1185
+ var posix = {
1186
+ // path.resolve([from ...], to)
1187
+ resolve: function resolve() {
1188
+ var resolvedPath = '';
1189
+ var resolvedAbsolute = false;
1190
+ var cwd;
1191
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1192
+ var path;
1193
+ if (i >= 0) path = arguments[i];else {
1194
+ if (cwd === undefined) cwd = process.cwd();
1195
+ path = cwd;
1196
+ }
1197
+ assertPath(path);
1198
+
1199
+ // Skip empty entries
1200
+ if (path.length === 0) {
1201
+ continue;
1202
+ }
1203
+ resolvedPath = path + '/' + resolvedPath;
1204
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
1205
+ }
1206
+
1207
+ // At this point the path should be resolved to a full absolute path, but
1208
+ // handle relative paths to be safe (might happen when process.cwd() fails)
1209
+
1210
+ // Normalize the path
1211
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
1212
+ if (resolvedAbsolute) {
1213
+ if (resolvedPath.length > 0) return '/' + resolvedPath;else return '/';
1214
+ } else if (resolvedPath.length > 0) {
1215
+ return resolvedPath;
1216
+ } else {
1217
+ return '.';
1218
+ }
1219
+ },
1220
+ normalize: function normalize(path) {
1221
+ assertPath(path);
1222
+ if (path.length === 0) return '.';
1223
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
1224
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
1225
+
1226
+ // Normalize the path
1227
+ path = normalizeStringPosix(path, !isAbsolute);
1228
+ if (path.length === 0 && !isAbsolute) path = '.';
1229
+ if (path.length > 0 && trailingSeparator) path += '/';
1230
+ if (isAbsolute) return '/' + path;
1231
+ return path;
1232
+ },
1233
+ isAbsolute: function isAbsolute(path) {
1234
+ assertPath(path);
1235
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
1236
+ },
1237
+
1238
+ join: function join() {
1239
+ if (arguments.length === 0) return '.';
1240
+ var joined;
1241
+ for (var i = 0; i < arguments.length; ++i) {
1242
+ var arg = arguments[i];
1243
+ assertPath(arg);
1244
+ if (arg.length > 0) {
1245
+ if (joined === undefined) joined = arg;else joined += '/' + arg;
1246
+ }
1247
+ }
1248
+ if (joined === undefined) return '.';
1249
+ return posix.normalize(joined);
1250
+ },
1251
+ relative: function relative(from, to) {
1252
+ assertPath(from);
1253
+ assertPath(to);
1254
+ if (from === to) return '';
1255
+ from = posix.resolve(from);
1256
+ to = posix.resolve(to);
1257
+ if (from === to) return '';
1258
+
1259
+ // Trim any leading backslashes
1260
+ var fromStart = 1;
1261
+ for (; fromStart < from.length; ++fromStart) {
1262
+ if (from.charCodeAt(fromStart) !== 47 /*/*/) break;
1263
+ }
1264
+ var fromEnd = from.length;
1265
+ var fromLen = fromEnd - fromStart;
1266
+
1267
+ // Trim any leading backslashes
1268
+ var toStart = 1;
1269
+ for (; toStart < to.length; ++toStart) {
1270
+ if (to.charCodeAt(toStart) !== 47 /*/*/) break;
1271
+ }
1272
+ var toEnd = to.length;
1273
+ var toLen = toEnd - toStart;
1274
+
1275
+ // Compare paths to find the longest common path from root
1276
+ var length = fromLen < toLen ? fromLen : toLen;
1277
+ var lastCommonSep = -1;
1278
+ var i = 0;
1279
+ for (; i <= length; ++i) {
1280
+ if (i === length) {
1281
+ if (toLen > length) {
1282
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
1283
+ // We get here if `from` is the exact base path for `to`.
1284
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
1285
+ return to.slice(toStart + i + 1);
1286
+ } else if (i === 0) {
1287
+ // We get here if `from` is the root
1288
+ // For example: from='/'; to='/foo'
1289
+ return to.slice(toStart + i);
1290
+ }
1291
+ } else if (fromLen > length) {
1292
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
1293
+ // We get here if `to` is the exact base path for `from`.
1294
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
1295
+ lastCommonSep = i;
1296
+ } else if (i === 0) {
1297
+ // We get here if `to` is the root.
1298
+ // For example: from='/foo'; to='/'
1299
+ lastCommonSep = 0;
1300
+ }
1301
+ }
1302
+ break;
1303
+ }
1304
+ var fromCode = from.charCodeAt(fromStart + i);
1305
+ var toCode = to.charCodeAt(toStart + i);
1306
+ if (fromCode !== toCode) break;else if (fromCode === 47 /*/*/) lastCommonSep = i;
1307
+ }
1308
+ var out = '';
1309
+ // Generate the relative path based on the path difference between `to`
1310
+ // and `from`
1311
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
1312
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
1313
+ if (out.length === 0) out += '..';else out += '/..';
1314
+ }
1315
+ }
1316
+
1317
+ // Lastly, append the rest of the destination (`to`) path that comes after
1318
+ // the common path parts
1319
+ if (out.length > 0) return out + to.slice(toStart + lastCommonSep);else {
1320
+ toStart += lastCommonSep;
1321
+ if (to.charCodeAt(toStart) === 47 /*/*/) ++toStart;
1322
+ return to.slice(toStart);
1323
+ }
1324
+ },
1325
+ _makeLong: function _makeLong(path) {
1326
+ return path;
1327
+ },
1328
+ dirname: function dirname(path) {
1329
+ assertPath(path);
1330
+ if (path.length === 0) return '.';
1331
+ var code = path.charCodeAt(0);
1332
+ var hasRoot = code === 47 /*/*/;
1333
+ var end = -1;
1334
+ var matchedSlash = true;
1335
+ for (var i = path.length - 1; i >= 1; --i) {
1336
+ code = path.charCodeAt(i);
1337
+ if (code === 47 /*/*/) {
1338
+ if (!matchedSlash) {
1339
+ end = i;
1340
+ break;
1341
+ }
1342
+ } else {
1343
+ // We saw the first non-path separator
1344
+ matchedSlash = false;
1345
+ }
1346
+ }
1347
+ if (end === -1) return hasRoot ? '/' : '.';
1348
+ if (hasRoot && end === 1) return '//';
1349
+ return path.slice(0, end);
1350
+ },
1351
+ basename: function basename(path, ext) {
1352
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
1353
+ assertPath(path);
1354
+ var start = 0;
1355
+ var end = -1;
1356
+ var matchedSlash = true;
1357
+ var i;
1358
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
1359
+ if (ext.length === path.length && ext === path) return '';
1360
+ var extIdx = ext.length - 1;
1361
+ var firstNonSlashEnd = -1;
1362
+ for (i = path.length - 1; i >= 0; --i) {
1363
+ var code = path.charCodeAt(i);
1364
+ if (code === 47 /*/*/) {
1365
+ // If we reached a path separator that was not part of a set of path
1366
+ // separators at the end of the string, stop now
1367
+ if (!matchedSlash) {
1368
+ start = i + 1;
1369
+ break;
1370
+ }
1371
+ } else {
1372
+ if (firstNonSlashEnd === -1) {
1373
+ // We saw the first non-path separator, remember this index in case
1374
+ // we need it if the extension ends up not matching
1375
+ matchedSlash = false;
1376
+ firstNonSlashEnd = i + 1;
1377
+ }
1378
+ if (extIdx >= 0) {
1379
+ // Try to match the explicit extension
1380
+ if (code === ext.charCodeAt(extIdx)) {
1381
+ if (--extIdx === -1) {
1382
+ // We matched the extension, so mark this as the end of our path
1383
+ // component
1384
+ end = i;
1385
+ }
1386
+ } else {
1387
+ // Extension does not match, so our result is the entire path
1388
+ // component
1389
+ extIdx = -1;
1390
+ end = firstNonSlashEnd;
1391
+ }
1392
+ }
1393
+ }
1394
+ }
1395
+ if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
1396
+ return path.slice(start, end);
1397
+ } else {
1398
+ for (i = path.length - 1; i >= 0; --i) {
1399
+ if (path.charCodeAt(i) === 47 /*/*/) {
1400
+ // If we reached a path separator that was not part of a set of path
1401
+ // separators at the end of the string, stop now
1402
+ if (!matchedSlash) {
1403
+ start = i + 1;
1404
+ break;
1405
+ }
1406
+ } else if (end === -1) {
1407
+ // We saw the first non-path separator, mark this as the end of our
1408
+ // path component
1409
+ matchedSlash = false;
1410
+ end = i + 1;
1411
+ }
1412
+ }
1413
+ if (end === -1) return '';
1414
+ return path.slice(start, end);
1415
+ }
1416
+ },
1417
+ extname: function extname(path) {
1418
+ assertPath(path);
1419
+ var startDot = -1;
1420
+ var startPart = 0;
1421
+ var end = -1;
1422
+ var matchedSlash = true;
1423
+ // Track the state of characters (if any) we see before our first dot and
1424
+ // after any path separator we find
1425
+ var preDotState = 0;
1426
+ for (var i = path.length - 1; i >= 0; --i) {
1427
+ var code = path.charCodeAt(i);
1428
+ if (code === 47 /*/*/) {
1429
+ // If we reached a path separator that was not part of a set of path
1430
+ // separators at the end of the string, stop now
1431
+ if (!matchedSlash) {
1432
+ startPart = i + 1;
1433
+ break;
1434
+ }
1435
+ continue;
1436
+ }
1437
+ if (end === -1) {
1438
+ // We saw the first non-path separator, mark this as the end of our
1439
+ // extension
1440
+ matchedSlash = false;
1441
+ end = i + 1;
1442
+ }
1443
+ if (code === 46 /*.*/) {
1444
+ // If this is our first dot, mark it as the start of our extension
1445
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
1446
+ } else if (startDot !== -1) {
1447
+ // We saw a non-dot and non-path separator before our dot, so we should
1448
+ // have a good chance at having a non-empty extension
1449
+ preDotState = -1;
1450
+ }
1451
+ }
1452
+ if (startDot === -1 || end === -1 ||
1453
+ // We saw a non-dot character immediately before the dot
1454
+ preDotState === 0 ||
1455
+ // The (right-most) trimmed path component is exactly '..'
1456
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1457
+ return '';
1458
+ }
1459
+ return path.slice(startDot, end);
1460
+ },
1461
+ format: function format(pathObject) {
1462
+ if (pathObject === null || typeof pathObject !== 'object') {
1463
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
1464
+ }
1465
+ return _format('/', pathObject);
1466
+ },
1467
+ parse: function parse(path) {
1468
+ assertPath(path);
1469
+ var ret = {
1470
+ root: '',
1471
+ dir: '',
1472
+ base: '',
1473
+ ext: '',
1474
+ name: ''
1475
+ };
1476
+ if (path.length === 0) return ret;
1477
+ var code = path.charCodeAt(0);
1478
+ var isAbsolute = code === 47 /*/*/;
1479
+ var start;
1480
+ if (isAbsolute) {
1481
+ ret.root = '/';
1482
+ start = 1;
1483
+ } else {
1484
+ start = 0;
1485
+ }
1486
+ var startDot = -1;
1487
+ var startPart = 0;
1488
+ var end = -1;
1489
+ var matchedSlash = true;
1490
+ var i = path.length - 1;
1491
+
1492
+ // Track the state of characters (if any) we see before our first dot and
1493
+ // after any path separator we find
1494
+ var preDotState = 0;
1495
+
1496
+ // Get non-dir info
1497
+ for (; i >= start; --i) {
1498
+ code = path.charCodeAt(i);
1499
+ if (code === 47 /*/*/) {
1500
+ // If we reached a path separator that was not part of a set of path
1501
+ // separators at the end of the string, stop now
1502
+ if (!matchedSlash) {
1503
+ startPart = i + 1;
1504
+ break;
1505
+ }
1506
+ continue;
1507
+ }
1508
+ if (end === -1) {
1509
+ // We saw the first non-path separator, mark this as the end of our
1510
+ // extension
1511
+ matchedSlash = false;
1512
+ end = i + 1;
1513
+ }
1514
+ if (code === 46 /*.*/) {
1515
+ // If this is our first dot, mark it as the start of our extension
1516
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
1517
+ } else if (startDot !== -1) {
1518
+ // We saw a non-dot and non-path separator before our dot, so we should
1519
+ // have a good chance at having a non-empty extension
1520
+ preDotState = -1;
1521
+ }
1522
+ }
1523
+ if (startDot === -1 || end === -1 ||
1524
+ // We saw a non-dot character immediately before the dot
1525
+ preDotState === 0 ||
1526
+ // The (right-most) trimmed path component is exactly '..'
1527
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1528
+ if (end !== -1) {
1529
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
1530
+ }
1531
+ } else {
1532
+ if (startPart === 0 && isAbsolute) {
1533
+ ret.name = path.slice(1, startDot);
1534
+ ret.base = path.slice(1, end);
1535
+ } else {
1536
+ ret.name = path.slice(startPart, startDot);
1537
+ ret.base = path.slice(startPart, end);
1538
+ }
1539
+ ret.ext = path.slice(startDot, end);
1540
+ }
1541
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
1542
+ return ret;
1543
+ },
1544
+ sep: '/',
1545
+ delimiter: ':',
1546
+ win32: null,
1547
+ posix: null
1548
+ };
1549
+ posix.posix = posix;
1550
+ module.exports = posix;
1551
+ }).call(this);
1552
+ }).call(this, require('_process'));
1553
+ }, {
1554
+ "_process": 32
1555
+ }],
1556
+ 29: [function (require, module, exports) {
1410
1557
  /**
1411
1558
  * Precedent Meta-Templating
1412
1559
  *
@@ -1452,10 +1599,10 @@
1452
1599
  }
1453
1600
  module.exports = Precedent;
1454
1601
  }, {
1455
- "./StringParser.js": 28,
1456
- "./WordTree.js": 29
1602
+ "./StringParser.js": 30,
1603
+ "./WordTree.js": 31
1457
1604
  }],
1458
- 28: [function (require, module, exports) {
1605
+ 30: [function (require, module, exports) {
1459
1606
  /**
1460
1607
  * String Parser
1461
1608
  *
@@ -1601,7 +1748,7 @@
1601
1748
  }
1602
1749
  module.exports = StringParser;
1603
1750
  }, {}],
1604
- 29: [function (require, module, exports) {
1751
+ 31: [function (require, module, exports) {
1605
1752
  /**
1606
1753
  * Word Tree
1607
1754
  *
@@ -1660,7 +1807,7 @@
1660
1807
  }
1661
1808
  module.exports = WordTree;
1662
1809
  }, {}],
1663
- 30: [function (require, module, exports) {
1810
+ 32: [function (require, module, exports) {
1664
1811
  // shim for using process in browser
1665
1812
  var process = module.exports = {};
1666
1813
 
@@ -1837,7 +1984,7 @@
1837
1984
  return 0;
1838
1985
  };
1839
1986
  }, {}],
1840
- 31: [function (require, module, exports) {
1987
+ 33: [function (require, module, exports) {
1841
1988
  (function (setImmediate, clearImmediate) {
1842
1989
  (function () {
1843
1990
  var nextTick = require('process/browser.js').nextTick;
@@ -1911,19 +2058,19 @@
1911
2058
  }).call(this);
1912
2059
  }).call(this, require("timers").setImmediate, require("timers").clearImmediate);
1913
2060
  }, {
1914
- "process/browser.js": 30,
1915
- "timers": 31
2061
+ "process/browser.js": 32,
2062
+ "timers": 33
1916
2063
  }],
1917
- 32: [function (require, module, exports) {
2064
+ 34: [function (require, module, exports) {
1918
2065
  var libNPMModuleWrapper = require('./Fable.js');
1919
2066
  if (typeof window === 'object' && !window.hasOwnProperty('Fable')) {
1920
2067
  window.Fable = libNPMModuleWrapper;
1921
2068
  }
1922
2069
  module.exports = libNPMModuleWrapper;
1923
2070
  }, {
1924
- "./Fable.js": 36
2071
+ "./Fable.js": 40
1925
2072
  }],
1926
- 33: [function (require, module, exports) {
2073
+ 35: [function (require, module, exports) {
1927
2074
  const _OperationStatePrototype = JSON.stringify({
1928
2075
  "Metadata": {
1929
2076
  "GUID": false,
@@ -2004,7 +2151,93 @@
2004
2151
  }
2005
2152
  module.exports = FableOperation;
2006
2153
  }, {}],
2007
- 34: [function (require, module, exports) {
2154
+ 36: [function (require, module, exports) {
2155
+ /**
2156
+ * Fable Application Services Management
2157
+ * @license MIT
2158
+ * @author <steven@velozo.com>
2159
+ */
2160
+
2161
+ const libFableServiceBase = require('./Fable-ServiceProviderBase.js');
2162
+ class FableService {
2163
+ constructor(pFable) {
2164
+ this.fable = pFable;
2165
+ this.serviceTypes = [];
2166
+
2167
+ // A map of instantiated services
2168
+ this.services = {};
2169
+
2170
+ // A map of the default instantiated service by type
2171
+ this.defaultServices = {};
2172
+
2173
+ // A map of class constructors for services
2174
+ this.serviceClasses = {};
2175
+ }
2176
+ addServiceType(pServiceType, pServiceClass) {
2177
+ // Add the type to the list of types
2178
+ this.serviceTypes.push(pServiceType);
2179
+
2180
+ // Add the container for instantiated services to go in
2181
+ this.services[pServiceType] = {};
2182
+ if (typeof pServiceClass == 'object' && pServiceClass.prototype instanceof libFableServiceBase) {
2183
+ // Add the class to the list of classes
2184
+ this.serviceClasses[pServiceType] = pServiceClass;
2185
+ } else {
2186
+ // Add the base class to the list of classes
2187
+ this.serviceClasses[pServiceType] = libFableServiceBase;
2188
+ }
2189
+ }
2190
+ instantiateServiceProvider(pServiceType, pOptions, pCustomServiceHash) {
2191
+ // Instantiate the service
2192
+ let tmpService = new this.serviceClasses[pServiceType](this.fable, pOptions, pCustomServiceHash);
2193
+
2194
+ // Add the service to the service map
2195
+ this.services[pServiceType][tmpService.Hash] = tmpService;
2196
+
2197
+ // If this is the first service of this type, make it the default
2198
+ if (!this.defaultServices.hasOwnProperty(pServiceType)) {
2199
+ this.defaultServices[pServiceType] = tmpService;
2200
+ }
2201
+ return tmpService;
2202
+ }
2203
+ setDefaultServiceInstantiation(pServiceType, pServiceHash) {
2204
+ if (this.services[pServiceType].hasOwnProperty(pServiceHash)) {
2205
+ this.defaultServices[pServiceType] = this.services[pServiceType][pServiceHash];
2206
+ return true;
2207
+ }
2208
+ return false;
2209
+ }
2210
+ getServiceByHash(pServiceHash) {
2211
+ if (this.services.hasOwnProperty(pServiceHash)) {
2212
+ return this.services[pServiceHash];
2213
+ }
2214
+ return false;
2215
+ }
2216
+ }
2217
+ module.exports = FableService;
2218
+ module.exports.FableServiceBase = libFableServiceBase;
2219
+ }, {
2220
+ "./Fable-ServiceProviderBase.js": 37
2221
+ }],
2222
+ 37: [function (require, module, exports) {
2223
+ /**
2224
+ * Fable Service Base
2225
+ * @license MIT
2226
+ * @author <steven@velozo.com>
2227
+ */
2228
+
2229
+ class FableServiceProviderBase {
2230
+ constructor(pFable, pOptions, pServiceHash) {
2231
+ this.fable = pFable;
2232
+ this.options = pOptions;
2233
+ this.serviceType = 'Unknown';
2234
+ this.UUID = pFable.getUUID();
2235
+ this.Hash = typeof pServiceHash === 'string' ? pServiceHash : `${this.UUID}`;
2236
+ }
2237
+ }
2238
+ module.exports = FableServiceProviderBase;
2239
+ }, {}],
2240
+ 38: [function (require, module, exports) {
2008
2241
  class FableUtility {
2009
2242
  // Underscore and lodash have a behavior, _.template, which compiles a
2010
2243
  // string-based template with code snippets into simple executable pieces,
@@ -2090,11 +2323,11 @@
2090
2323
  }
2091
2324
  module.exports = FableUtility;
2092
2325
  }, {}],
2093
- 35: [function (require, module, exports) {
2326
+ 39: [function (require, module, exports) {
2094
2327
  const libFableUtilityTemplate = require('./Fable-Utility-Template.js');
2095
2328
  // TODO: These are still pretty big -- consider the smaller polyfills
2096
- const libAsyncWaterfall = require('async/waterfall');
2097
- const libAsyncEachLimit = require('async/eachLimit');
2329
+ const libAsyncWaterfall = require('async.waterfall');
2330
+ const libAsyncEachLimit = require('async.eachLimit');
2098
2331
  class FableUtility {
2099
2332
  constructor(pFable) {
2100
2333
  this.fable = pFable;
@@ -2139,11 +2372,11 @@
2139
2372
  }
2140
2373
  module.exports = FableUtility;
2141
2374
  }, {
2142
- "./Fable-Utility-Template.js": 34,
2143
- "async/eachLimit": 2,
2144
- "async/waterfall": 16
2375
+ "./Fable-Utility-Template.js": 38,
2376
+ "async.eachLimit": 1,
2377
+ "async.waterfall": 15
2145
2378
  }],
2146
- 36: [function (require, module, exports) {
2379
+ 40: [function (require, module, exports) {
2147
2380
  /**
2148
2381
  * Fable Application Services Support Library
2149
2382
  * @license MIT
@@ -2153,6 +2386,7 @@
2153
2386
  const libFableUUID = require('fable-uuid');
2154
2387
  const libFableLog = require('fable-log');
2155
2388
  const libFableUtility = require('./Fable-Utility.js');
2389
+ const libFableServiceManager = require('./Fable-ServiceManager.js');
2156
2390
  const libFableOperation = require('./Fable-Operation.js');
2157
2391
  class Fable {
2158
2392
  constructor(pSettings) {
@@ -2174,6 +2408,7 @@
2174
2408
 
2175
2409
  // Location for Operation state
2176
2410
  this.Operations = {};
2411
+ this.serviceManager = new libFableServiceManager(this);
2177
2412
  }
2178
2413
  get settings() {
2179
2414
  return this.settingsManager.settings;
@@ -2210,13 +2445,15 @@
2210
2445
  module.exports = Fable;
2211
2446
  module.exports.new = autoConstruct;
2212
2447
  module.exports.LogProviderBase = libFableLog.LogProviderBase;
2448
+ module.exports.ServiceProviderBase = libFableServiceManager.ServiceProviderBase;
2213
2449
  module.exports.precedent = libFableSettings.precedent;
2214
2450
  }, {
2215
- "./Fable-Operation.js": 33,
2216
- "./Fable-Utility.js": 35,
2217
- "fable-log": 21,
2218
- "fable-settings": 24,
2219
- "fable-uuid": 26
2451
+ "./Fable-Operation.js": 35,
2452
+ "./Fable-ServiceManager.js": 36,
2453
+ "./Fable-Utility.js": 39,
2454
+ "fable-log": 22,
2455
+ "fable-settings": 25,
2456
+ "fable-uuid": 27
2220
2457
  }]
2221
- }, {}, [32])(32);
2458
+ }, {}, [34])(34);
2222
2459
  });