fable 3.0.18 → 3.0.21
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/.babelrc +3 -0
- package/.browserslistrc +1 -0
- package/.browserslistrc_compatible +1 -0
- package/.browserslistrc_default +1 -0
- package/dist/fable.compatible.js +3219 -0
- package/dist/fable.compatible.min.js +117 -0
- package/dist/fable.compatible.min.js.map +1 -0
- package/dist/fable.js +600 -138
- package/dist/fable.min.js +19 -14
- package/dist/fable.min.js.map +1 -1
- package/gulpfile-config.json +11 -0
- package/gulpfile-config_compatible.json +11 -0
- package/gulpfile-config_default.json +11 -0
- package/gulpfile.js +97 -16
- package/package.json +6 -1
- package/source/Fable-Service-DataArithmatic.js +16 -0
- package/source/{Fable-Utility.js → Fable-Service-Utility.js} +16 -4
- package/source/Fable.js +14 -4
- package/test/FableDataArithmatic_tests.js +223 -0
- package/test/Fable_tests.js +0 -1
package/dist/fable.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
(function (f) {
|
|
2
4
|
if (typeof exports === "object" && typeof module !== "undefined") {
|
|
3
5
|
module.exports = f();
|
|
@@ -264,7 +266,7 @@
|
|
|
264
266
|
'use strict';
|
|
265
267
|
|
|
266
268
|
var _setImmediate = typeof setImmediate === 'function' && setImmediate;
|
|
267
|
-
var fallback = function (fn) {
|
|
269
|
+
var fallback = function fallback(fn) {
|
|
268
270
|
setTimeout(fn, 0);
|
|
269
271
|
};
|
|
270
272
|
module.exports = function setImmediate(fn) {
|
|
@@ -274,7 +276,7 @@
|
|
|
274
276
|
}).call(this);
|
|
275
277
|
}).call(this, require("timers").setImmediate);
|
|
276
278
|
}, {
|
|
277
|
-
"timers":
|
|
279
|
+
"timers": 34
|
|
278
280
|
}],
|
|
279
281
|
14: [function (require, module, exports) {
|
|
280
282
|
'use strict';
|
|
@@ -325,6 +327,424 @@
|
|
|
325
327
|
}],
|
|
326
328
|
16: [function (require, module, exports) {}, {}],
|
|
327
329
|
17: [function (require, module, exports) {
|
|
330
|
+
/**
|
|
331
|
+
* @license MIT
|
|
332
|
+
* @author <steven@velozo.com>
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Data Arithmatic
|
|
337
|
+
*
|
|
338
|
+
* @class DataArithmatic
|
|
339
|
+
*/
|
|
340
|
+
class DataArithmatic {
|
|
341
|
+
constructor() {
|
|
342
|
+
// Regular Expressions (so they don't have to be recompiled every time)
|
|
343
|
+
// These could be defined as static, but I'm not sure if that will work with browserify ... and specifically the QT browser.
|
|
344
|
+
this._Regex_formatterInsertCommas = /.{1,3}/g;
|
|
345
|
+
// Match Function:
|
|
346
|
+
// function(pMatch, pSign, pZeros, pBefore, pDecimal, pAfter)
|
|
347
|
+
// Thoughts about below: /^([+-]?)(0*)(\d+)(\.(\d+))?$/;
|
|
348
|
+
this._Regex_formatterAddCommasToNumber = /^([-+]?)(0?)(\d+)(.?)(\d+)$/g;
|
|
349
|
+
this._Regex_formatterDollarsRemoveCommas = /,/gi;
|
|
350
|
+
this._Regex_formatterCleanNonAlpha = /[^a-z0-9]/gi;
|
|
351
|
+
|
|
352
|
+
// TODO: Potentially pull these in from a configuration.
|
|
353
|
+
// TODO: Use locale data for this if it's defaults all the way down.
|
|
354
|
+
this._Value_MoneySign_Currency = '$';
|
|
355
|
+
this._Value_NaN_Currency = '--';
|
|
356
|
+
this._Value_GroupSeparator_Number = ',';
|
|
357
|
+
this._Value_Prefix_StringHash = 'HSH';
|
|
358
|
+
this._Value_Clean_formatterCleanNonAlpha = '_';
|
|
359
|
+
this._UseEngineStringStartsWith = typeof String.prototype.startsWith === 'function';
|
|
360
|
+
this._UseEngineStringEndsWith = typeof String.prototype.endsWith === 'function';
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/*************************************************************************
|
|
364
|
+
* String Manipulation and Comparison Functions
|
|
365
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Reverse a string
|
|
369
|
+
*
|
|
370
|
+
* @param {string} pString - The string to reverse
|
|
371
|
+
* @returns {string}
|
|
372
|
+
*/
|
|
373
|
+
stringReverse(pString) {
|
|
374
|
+
// TODO: Benchmark if there are faster ways we want to do this with all the newer JS stuff
|
|
375
|
+
// ... and if it will work with browserify in a clean way.
|
|
376
|
+
return pString.split('').reverse().join('');
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Test if a string starts with a given substring.
|
|
381
|
+
*
|
|
382
|
+
* @param {*} pString
|
|
383
|
+
* @param {*} pSearchString
|
|
384
|
+
* @param {*} pStartIndex
|
|
385
|
+
* @returns {*}
|
|
386
|
+
*/
|
|
387
|
+
stringStartsWith(pString, pSearchString, pStartIndex) {
|
|
388
|
+
if (this._UseEngineStringStartsWith) {
|
|
389
|
+
return pString.startsWith(pSearchString, pStartIndex);
|
|
390
|
+
} else {
|
|
391
|
+
return this.stringStartsWith_Polyfill.call(pString, pSearchString, pStartIndex);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Check if a string starts with a given substring. This is a safe polyfill for the ES6 string.startsWith() function.
|
|
397
|
+
*
|
|
398
|
+
* @param {*} pSearchString - The string to search for
|
|
399
|
+
* @param {*} pStartIndex - The index to start the search at
|
|
400
|
+
* @returns {boolean}
|
|
401
|
+
*/
|
|
402
|
+
stringStartsWith_Polyfill(pSearchString, pStartIndex) {
|
|
403
|
+
return this.slice(pStartIndex || 0, pSearchString.length) === pSearchString;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Test if a string starts with a given substring.
|
|
408
|
+
*
|
|
409
|
+
* @param {*} pString
|
|
410
|
+
* @param {*} pSearchString
|
|
411
|
+
* @param {*} pEndIndex
|
|
412
|
+
* @returns {*}
|
|
413
|
+
*/
|
|
414
|
+
stringEndsWith(pString, pSearchString, pEndIndex) {
|
|
415
|
+
if (this._UseEngineStringEndsWith) {
|
|
416
|
+
return pString.endsWith(pSearchString, pEndIndex);
|
|
417
|
+
} else {
|
|
418
|
+
return this.stringEndsWith_Polyfill.call(pString, pSearchString, pEndIndex);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Check if a string starts with a given substring. This is a safe polyfill for the ES6 string.startsWith() function.
|
|
424
|
+
*
|
|
425
|
+
* @param {*} pSearchString - The string to search for
|
|
426
|
+
* @param {*} pEndIndex - The index to end the search at
|
|
427
|
+
* @returns {boolean}
|
|
428
|
+
*/
|
|
429
|
+
stringEndsWith_Polyfill(pSearchString, pEndIndex) {
|
|
430
|
+
// This works much better than >= because
|
|
431
|
+
// it compensates for NaN:
|
|
432
|
+
if (!(pEndIndex < this.length)) {
|
|
433
|
+
pEndIndex = this.length;
|
|
434
|
+
} else {
|
|
435
|
+
pEndIndex |= 0; // round position
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return this.substr(pEndIndex - pSearchString.length, pSearchString.length) === pSearchString;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Generate an insecure string hash. Not meant to be secure, just a quick way to generate a hash for a string. This is not a cryptographic hash. Additional warranty and disclaimer ... this is not for passwords!
|
|
443
|
+
*
|
|
444
|
+
* @param {string} pString
|
|
445
|
+
* @returns {string}
|
|
446
|
+
*/
|
|
447
|
+
insecureStringHash(pString) {
|
|
448
|
+
let tmpHash = 0;
|
|
449
|
+
let tmpStringLength = pString.length;
|
|
450
|
+
let tmpCharacterIndex = 0;
|
|
451
|
+
while (tmpCharacterIndex < tmpStringLength) {
|
|
452
|
+
tmpHash = (tmpHash << 5) - tmpHash + pString.charCodeAt(tmpCharacterIndex++) | 0;
|
|
453
|
+
}
|
|
454
|
+
return "".concat(this._Value_Prefix_StringHash).concat(tmpHash);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Clean wrapping characters if they exist consistently around the string. If they do not, the string is returned unchanged.
|
|
459
|
+
*
|
|
460
|
+
* @param {string} pWrapCharacter - The character expected as the wrapping character
|
|
461
|
+
* @param {string} pString - the string to clean
|
|
462
|
+
* @returns {string}
|
|
463
|
+
*/
|
|
464
|
+
cleanEnclosureWrapCharacters(pWrapCharacter, pString) {
|
|
465
|
+
// # Use case from ManyFest DSL:
|
|
466
|
+
//
|
|
467
|
+
// When a boxed property is passed in, it should have quotes of some
|
|
468
|
+
// kind around it.
|
|
469
|
+
//
|
|
470
|
+
// For instance:
|
|
471
|
+
// MyValues['Name']
|
|
472
|
+
// MyValues["Age"]
|
|
473
|
+
// MyValues[`Cost`]
|
|
474
|
+
//
|
|
475
|
+
// This function is necessary to remove the wrapping quotes before object
|
|
476
|
+
// resolution can occur.
|
|
477
|
+
if (pString.startsWith(pWrapCharacter) && pString.endsWith(pWrapCharacter)) {
|
|
478
|
+
return pString.substring(1, pString.length - 1);
|
|
479
|
+
} else {
|
|
480
|
+
return pString;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
*
|
|
486
|
+
* @param {*} pString
|
|
487
|
+
* @returns
|
|
488
|
+
*/
|
|
489
|
+
cleanNonAlphaCharacters(pString) {
|
|
490
|
+
if (typeof pString == 'string' && pString != '') {
|
|
491
|
+
return pString.replace(this._Regex_formatterCleanNonAlpha, this._Value_Clean_formatterCleanNonAlpha);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/*************************************************************************
|
|
496
|
+
* Number Formatting Functions
|
|
497
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Insert commas every 3 characters from the right. Used by formatterAddCommasToNumber().
|
|
501
|
+
*
|
|
502
|
+
* @param {*} pString
|
|
503
|
+
* @returns {*}
|
|
504
|
+
*/
|
|
505
|
+
formatterInsertCommas(pString) {
|
|
506
|
+
// Reverse, because it's easier to do things from the left, given arbitrary digit counts
|
|
507
|
+
let tmpReversed = this.stringReverse(pString);
|
|
508
|
+
// Add commas every three characters
|
|
509
|
+
let tmpReversedWithCommas = tmpReversed.match(this._Regex_formatterInsertCommas).join(',');
|
|
510
|
+
// Reverse again (back to normal direction)
|
|
511
|
+
return this.stringReverse(tmpReversedWithCommas);
|
|
512
|
+
}
|
|
513
|
+
processAddCommasToNumberRegex(pMatch, pSign, pZeros, pBefore, pDecimal, pAfter) {
|
|
514
|
+
// If there was no decimal, the last capture grabs the final digit, so
|
|
515
|
+
// we have to put it back together with the 'before' substring
|
|
516
|
+
return pSign + (pDecimal ? this.formatterInsertCommas(pBefore) + pDecimal + pAfter : this.formatterInsertCommas(pBefore + pAfter));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Add Commas to a Number for readability.
|
|
521
|
+
*
|
|
522
|
+
* @param {*} pNumber
|
|
523
|
+
* @returns {string}
|
|
524
|
+
*/
|
|
525
|
+
formatterAddCommasToNumber(pNumber) {
|
|
526
|
+
// If the regex doesn't match, `replace` returns the string unmodified
|
|
527
|
+
return pNumber.toString().replace(this._Regex_formatterAddCommasToNumber, this.processAddCommasToNumberRegex.bind(this));
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* This will take a number and format it as a dollar string. It will also add commas to the number. If the number is not a number, it will return '--'.
|
|
532
|
+
*
|
|
533
|
+
* @param {*} pValue
|
|
534
|
+
* @returns {string}
|
|
535
|
+
*/
|
|
536
|
+
formatterDollars(pValue) {
|
|
537
|
+
let tmpDollarAmount = parseFloat(pValue).toFixed(2);
|
|
538
|
+
if (isNaN(tmpDollarAmount)) {
|
|
539
|
+
// Try again and see if what was passed in was a dollars string.
|
|
540
|
+
if (typeof pValue == 'string') {
|
|
541
|
+
// TODO: Better rounding function? This is a hack to get rid of the currency symbol and commas.
|
|
542
|
+
tmpDollarAmount = parseFloat(pValue.replace(this._Value_MoneySign_Currency, '').replace(this._Regex_formatterDollarsRemoveCommas, '')).toFixed(2);
|
|
543
|
+
}
|
|
544
|
+
// If we didn't get a number, return the "not a number" string.
|
|
545
|
+
if (isNaN(tmpDollarAmount)) {
|
|
546
|
+
return this._Value_NaN_Currency;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// TODO: Get locale data and use that for this stuff.
|
|
551
|
+
return "$".concat(this.formatterAddCommasToNumber(tmpDollarAmount));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Round a number to a certain number of digits. If the number is not a number, it will return 0. If no digits are specified, it will default to 2 significant digits.
|
|
556
|
+
*
|
|
557
|
+
* @param {*} pValue
|
|
558
|
+
* @param {number} pDigits
|
|
559
|
+
* @returns {string}
|
|
560
|
+
*/
|
|
561
|
+
formatterRoundNumber(pValue, pDigits) {
|
|
562
|
+
let tmpDigits = typeof pDigits == 'undefined' ? 2 : pDigits;
|
|
563
|
+
let tmpValue = Number.parseFloat(pValue).toFixed(tmpDigits);
|
|
564
|
+
if (isNaN(tmpValue)) {
|
|
565
|
+
let tmpZed = 0;
|
|
566
|
+
return tmpZed.toFixed(tmpDigits);
|
|
567
|
+
} else {
|
|
568
|
+
return tmpValue;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/*************************************************************************
|
|
573
|
+
* String Tokenization Functions
|
|
574
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Return the string before the matched substring.
|
|
578
|
+
*
|
|
579
|
+
* If the substring is not found, the entire string is returned. This only deals with the *first* match.
|
|
580
|
+
*
|
|
581
|
+
* @param {string} pString
|
|
582
|
+
* @param {string} pMatch
|
|
583
|
+
* @returns {string}
|
|
584
|
+
*/
|
|
585
|
+
stringBeforeMatch(pString, pMatch) {
|
|
586
|
+
return pString.split(pMatch)[0];
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Return the string after the matched substring.
|
|
591
|
+
*
|
|
592
|
+
* If the substring is not found, an empty string is returned. This only deals with the *first* match.
|
|
593
|
+
*
|
|
594
|
+
* @param {string} pString
|
|
595
|
+
* @param {string} pMatch
|
|
596
|
+
* @returns {string}
|
|
597
|
+
*/
|
|
598
|
+
stringAfterMatch(pString, pMatch) {
|
|
599
|
+
let tmpStringSplitLocation = pString.indexOf(pMatch);
|
|
600
|
+
if (tmpStringSplitLocation < 0 || tmpStringSplitLocation + pMatch.length >= pString.length) {
|
|
601
|
+
return '';
|
|
602
|
+
}
|
|
603
|
+
return pString.substring(tmpStringSplitLocation + pMatch.length);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Count the number of enclosures in a string based on the start and end characters.
|
|
608
|
+
*
|
|
609
|
+
* If no start or end characters are specified, it will default to parentheses. If the string is not a string, it will return 0.
|
|
610
|
+
*
|
|
611
|
+
* @param {string} pString
|
|
612
|
+
* @param {string} pEnclosureStart
|
|
613
|
+
* @param {string} pEnclosureEnd
|
|
614
|
+
* @returns the count of full in the string
|
|
615
|
+
*/
|
|
616
|
+
stringCountEnclosures(pString, pEnclosureStart, pEnclosureEnd) {
|
|
617
|
+
let tmpString = typeof pString == 'string' ? pString : '';
|
|
618
|
+
let tmpEnclosureStart = typeof pEnclosureStart == 'string' ? pEnclosureStart : '(';
|
|
619
|
+
let tmpEnclosureEnd = typeof pEnclosureEnd == 'string' ? pEnclosureEnd : ')';
|
|
620
|
+
let tmpEnclosureCount = 0;
|
|
621
|
+
let tmpEnclosureDepth = 0;
|
|
622
|
+
for (let i = 0; i < tmpString.length; i++) {
|
|
623
|
+
// This is the start of an enclosure
|
|
624
|
+
if (tmpString[i] == tmpEnclosureStart) {
|
|
625
|
+
if (tmpEnclosureDepth == 0) {
|
|
626
|
+
tmpEnclosureCount++;
|
|
627
|
+
}
|
|
628
|
+
tmpEnclosureDepth++;
|
|
629
|
+
} else if (tmpString[i] == tmpEnclosureEnd) {
|
|
630
|
+
tmpEnclosureDepth--;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return tmpEnclosureCount;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Get the value of the enclosure at the specified index.
|
|
638
|
+
*
|
|
639
|
+
* If the index is not a number, it will default to 0. If the string is not a string, it will return an empty string. If the enclosure is not found, it will return an empty string. If the enclosure
|
|
640
|
+
*
|
|
641
|
+
* @param {string} pString
|
|
642
|
+
* @param {number} pEnclosureIndexToGet
|
|
643
|
+
* @param {string} pEnclosureStart
|
|
644
|
+
* @param {string}} pEnclosureEnd
|
|
645
|
+
* @returns {string}
|
|
646
|
+
*/
|
|
647
|
+
stringGetEnclosureValueByIndex(pString, pEnclosureIndexToGet, pEnclosureStart, pEnclosureEnd) {
|
|
648
|
+
let tmpString = typeof pString == 'string' ? pString : '';
|
|
649
|
+
let tmpEnclosureIndexToGet = typeof pEnclosureIndexToGet == 'number' ? pEnclosureIndexToGet : 0;
|
|
650
|
+
let tmpEnclosureStart = typeof pEnclosureStart == 'string' ? pEnclosureStart : '(';
|
|
651
|
+
let tmpEnclosureEnd = typeof pEnclosureEnd == 'string' ? pEnclosureEnd : ')';
|
|
652
|
+
let tmpEnclosureCount = 0;
|
|
653
|
+
let tmpEnclosureDepth = 0;
|
|
654
|
+
let tmpMatchedEnclosureIndex = false;
|
|
655
|
+
let tmpEnclosedValueStartIndex = 0;
|
|
656
|
+
let tmpEnclosedValueEndIndex = 0;
|
|
657
|
+
for (let i = 0; i < tmpString.length; i++) {
|
|
658
|
+
// This is the start of an enclosure
|
|
659
|
+
if (tmpString[i] == tmpEnclosureStart) {
|
|
660
|
+
tmpEnclosureDepth++;
|
|
661
|
+
|
|
662
|
+
// Only count enclosures at depth 1, but still this parses both pairs of all of them.
|
|
663
|
+
if (tmpEnclosureDepth == 1) {
|
|
664
|
+
tmpEnclosureCount++;
|
|
665
|
+
if (tmpEnclosureIndexToGet == tmpEnclosureCount - 1) {
|
|
666
|
+
// This is the start of *the* enclosure
|
|
667
|
+
tmpMatchedEnclosureIndex = true;
|
|
668
|
+
tmpEnclosedValueStartIndex = i;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
// This is the end of an enclosure
|
|
673
|
+
else if (tmpString[i] == tmpEnclosureEnd) {
|
|
674
|
+
tmpEnclosureDepth--;
|
|
675
|
+
|
|
676
|
+
// Again, only count enclosures at depth 1, but still this parses both pairs of all of them.
|
|
677
|
+
if (tmpEnclosureDepth == 0 && tmpMatchedEnclosureIndex && tmpEnclosedValueEndIndex <= tmpEnclosedValueStartIndex) {
|
|
678
|
+
tmpEnclosedValueEndIndex = i;
|
|
679
|
+
tmpMatchedEnclosureIndex = false;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
if (tmpEnclosureCount <= tmpEnclosureIndexToGet) {
|
|
684
|
+
// Return an empty string if the enclosure is not found
|
|
685
|
+
return '';
|
|
686
|
+
}
|
|
687
|
+
if (tmpEnclosedValueEndIndex > 0 && tmpEnclosedValueEndIndex > tmpEnclosedValueStartIndex) {
|
|
688
|
+
return tmpString.substring(tmpEnclosedValueStartIndex + 1, tmpEnclosedValueEndIndex);
|
|
689
|
+
} else {
|
|
690
|
+
return tmpString.substring(tmpEnclosedValueStartIndex + 1);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Remove an enclosure from a string based on the index of the enclosure.
|
|
696
|
+
*
|
|
697
|
+
* @param {string} pString
|
|
698
|
+
* @param {number} pEnclosureIndexToRemove
|
|
699
|
+
* @param {number} pEnclosureStart
|
|
700
|
+
* @param {number} pEnclosureEnd
|
|
701
|
+
* @returns {string}
|
|
702
|
+
*/
|
|
703
|
+
stringRemoveEnclosureByIndex(pString, pEnclosureIndexToRemove, pEnclosureStart, pEnclosureEnd) {
|
|
704
|
+
let tmpString = typeof pString == 'string' ? pString : '';
|
|
705
|
+
let tmpEnclosureIndexToRemove = typeof pEnclosureIndexToRemove == 'number' ? pEnclosureIndexToRemove : 0;
|
|
706
|
+
let tmpEnclosureStart = typeof pEnclosureStart == 'string' ? pEnclosureStart : '(';
|
|
707
|
+
let tmpEnclosureEnd = typeof pEnclosureEnd == 'string' ? pEnclosureEnd : ')';
|
|
708
|
+
let tmpEnclosureCount = 0;
|
|
709
|
+
let tmpEnclosureDepth = 0;
|
|
710
|
+
let tmpMatchedEnclosureIndex = false;
|
|
711
|
+
let tmpEnclosureStartIndex = 0;
|
|
712
|
+
let tmpEnclosureEndIndex = 0;
|
|
713
|
+
for (let i = 0; i < tmpString.length; i++) {
|
|
714
|
+
// This is the start of an enclosure
|
|
715
|
+
if (tmpString[i] == tmpEnclosureStart) {
|
|
716
|
+
tmpEnclosureDepth++;
|
|
717
|
+
if (tmpEnclosureDepth == 1) {
|
|
718
|
+
tmpEnclosureCount++;
|
|
719
|
+
if (tmpEnclosureIndexToRemove == tmpEnclosureCount - 1) {
|
|
720
|
+
tmpMatchedEnclosureIndex = true;
|
|
721
|
+
tmpEnclosureStartIndex = i;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
} else if (tmpString[i] == tmpEnclosureEnd) {
|
|
725
|
+
tmpEnclosureDepth--;
|
|
726
|
+
if (tmpEnclosureDepth == 0 && tmpMatchedEnclosureIndex && tmpEnclosureEndIndex <= tmpEnclosureStartIndex) {
|
|
727
|
+
tmpEnclosureEndIndex = i;
|
|
728
|
+
tmpMatchedEnclosureIndex = false;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if (tmpEnclosureCount <= tmpEnclosureIndexToRemove) {
|
|
733
|
+
return tmpString;
|
|
734
|
+
}
|
|
735
|
+
let tmpReturnString = '';
|
|
736
|
+
if (tmpEnclosureStartIndex > 1) {
|
|
737
|
+
tmpReturnString = tmpString.substring(0, tmpEnclosureStartIndex);
|
|
738
|
+
}
|
|
739
|
+
if (tmpString.length > tmpEnclosureEndIndex + 1 && tmpEnclosureEndIndex > tmpEnclosureStartIndex) {
|
|
740
|
+
tmpReturnString += tmpString.substring(tmpEnclosureEndIndex + 1);
|
|
741
|
+
}
|
|
742
|
+
return tmpReturnString;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
module.exports = DataArithmatic;
|
|
746
|
+
}, {}],
|
|
747
|
+
18: [function (require, module, exports) {
|
|
328
748
|
/**
|
|
329
749
|
* Base Logger Class
|
|
330
750
|
*
|
|
@@ -388,7 +808,7 @@
|
|
|
388
808
|
}
|
|
389
809
|
module.exports = BaseLogger;
|
|
390
810
|
}, {}],
|
|
391
|
-
|
|
811
|
+
19: [function (require, module, exports) {
|
|
392
812
|
/**
|
|
393
813
|
* Default Logger Provider Function
|
|
394
814
|
*
|
|
@@ -406,23 +826,23 @@
|
|
|
406
826
|
};
|
|
407
827
|
module.exports = getDefaultProviders();
|
|
408
828
|
}, {
|
|
409
|
-
"./Fable-Log-Logger-Console.js":
|
|
829
|
+
"./Fable-Log-Logger-Console.js": 21
|
|
410
830
|
}],
|
|
411
|
-
|
|
831
|
+
20: [function (require, module, exports) {
|
|
412
832
|
module.exports = [{
|
|
413
833
|
"loggertype": "console",
|
|
414
834
|
"streamtype": "console",
|
|
415
835
|
"level": "trace"
|
|
416
836
|
}];
|
|
417
837
|
}, {}],
|
|
418
|
-
|
|
838
|
+
21: [function (require, module, exports) {
|
|
419
839
|
let libBaseLogger = require('./Fable-Log-BaseLogger.js');
|
|
420
840
|
class ConsoleLogger extends libBaseLogger {
|
|
421
841
|
constructor(pLogStreamSettings, pFableLog) {
|
|
422
842
|
super(pLogStreamSettings);
|
|
423
843
|
this._ShowTimeStamps = this._Settings.hasOwnProperty('showtimestamps') ? this._Settings.showtimestamps == true : true;
|
|
424
844
|
this._FormattedTimeStamps = this._Settings.hasOwnProperty('formattedtimestamps') ? this._Settings.formattedtimestamps == true : true;
|
|
425
|
-
this._ContextMessage = this._Settings.hasOwnProperty('Context') ?
|
|
845
|
+
this._ContextMessage = this._Settings.hasOwnProperty('Context') ? "(".concat(this._Settings.Context, ")") : pFableLog._Settings.hasOwnProperty('Product') ? "(".concat(pFableLog._Settings.Product, ")") : 'Unnamed_Log_Context';
|
|
426
846
|
|
|
427
847
|
// Allow the user to decide what gets output to the console
|
|
428
848
|
this._OutputLogLinesToConsole = this._Settings.hasOwnProperty('outputloglinestoconsole') ? this._Settings.outputloglinestoconsole : true;
|
|
@@ -431,7 +851,7 @@
|
|
|
431
851
|
// Precompute the prefix for each level
|
|
432
852
|
this.prefixCache = {};
|
|
433
853
|
for (let i = 0; i <= this.levels.length; i++) {
|
|
434
|
-
this.prefixCache[this.levels[i]] =
|
|
854
|
+
this.prefixCache[this.levels[i]] = "[".concat(this.levels[i], "] ").concat(this._ContextMessage, ": ");
|
|
435
855
|
if (this._ShowTimeStamps) {
|
|
436
856
|
// If there is a timestamp we need a to prepend space before the prefixcache string, since the timestamp comes first
|
|
437
857
|
this.prefixCache[this.levels[i]] = ' ' + this.prefixCache[this.levels[i]];
|
|
@@ -445,7 +865,7 @@
|
|
|
445
865
|
} else if (this._ShowTimeStamps) {
|
|
446
866
|
tmpTimeStamp = +new Date();
|
|
447
867
|
}
|
|
448
|
-
let tmpLogLine =
|
|
868
|
+
let tmpLogLine = "".concat(tmpTimeStamp).concat(this.prefixCache[pLevel]).concat(pLogText);
|
|
449
869
|
if (this._OutputLogLinesToConsole) {
|
|
450
870
|
console.log(tmpLogLine);
|
|
451
871
|
}
|
|
@@ -461,9 +881,9 @@
|
|
|
461
881
|
}
|
|
462
882
|
module.exports = ConsoleLogger;
|
|
463
883
|
}, {
|
|
464
|
-
"./Fable-Log-BaseLogger.js":
|
|
884
|
+
"./Fable-Log-BaseLogger.js": 18
|
|
465
885
|
}],
|
|
466
|
-
|
|
886
|
+
22: [function (require, module, exports) {
|
|
467
887
|
const libConsoleLog = require('./Fable-Log-Logger-Console.js');
|
|
468
888
|
const libFS = require('fs');
|
|
469
889
|
const libPath = require('path');
|
|
@@ -472,7 +892,7 @@
|
|
|
472
892
|
super(pLogStreamSettings, pFableLog);
|
|
473
893
|
|
|
474
894
|
// 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 :
|
|
895
|
+
this.logFileRawPath = this._Settings.hasOwnProperty('path') ? this._Settings.path : "./".concat(this._ContextMessage, ".log");
|
|
476
896
|
this.logFilePath = libPath.normalize(this.logFileRawPath);
|
|
477
897
|
this.logFileStreamOptions = this._Settings.hasOwnProperty('fileStreamoptions') ? this._Settings.fileStreamOptions : {
|
|
478
898
|
"flags": "a",
|
|
@@ -519,9 +939,9 @@
|
|
|
519
939
|
let tmpConstructedBufferOutputString = '';
|
|
520
940
|
for (let i = 0; i < tmpLineStrings.length; i++) {
|
|
521
941
|
// TODO: Windows Newline? ....... yo no se!
|
|
522
|
-
tmpConstructedBufferOutputString +=
|
|
942
|
+
tmpConstructedBufferOutputString += "".concat(tmpLineStrings[i], "\n");
|
|
523
943
|
if (tmpObjectStrings[i] !== false) {
|
|
524
|
-
tmpConstructedBufferOutputString +=
|
|
944
|
+
tmpConstructedBufferOutputString += "".concat(tmpObjectStrings[i], "\n");
|
|
525
945
|
}
|
|
526
946
|
}
|
|
527
947
|
if (!this.fileWriter.write(tmpConstructedBufferOutputString, 'utf8')) {
|
|
@@ -549,11 +969,11 @@
|
|
|
549
969
|
}
|
|
550
970
|
module.exports = SimpleFlatFileLogger;
|
|
551
971
|
}, {
|
|
552
|
-
"./Fable-Log-Logger-Console.js":
|
|
972
|
+
"./Fable-Log-Logger-Console.js": 21,
|
|
553
973
|
"fs": 16,
|
|
554
|
-
"path":
|
|
974
|
+
"path": 29
|
|
555
975
|
}],
|
|
556
|
-
|
|
976
|
+
23: [function (require, module, exports) {
|
|
557
977
|
/**
|
|
558
978
|
* Fable Logging Add-on
|
|
559
979
|
*
|
|
@@ -672,7 +1092,7 @@
|
|
|
672
1092
|
level: 'info'
|
|
673
1093
|
}, this._StreamDefinitions[i]);
|
|
674
1094
|
if (!this._Providers.hasOwnProperty(tmpStreamDefinition.loggertype)) {
|
|
675
|
-
console.log(
|
|
1095
|
+
console.log("Error initializing log stream: bad loggertype in stream definition ".concat(JSON.stringify(tmpStreamDefinition)));
|
|
676
1096
|
} else {
|
|
677
1097
|
this.addLogger(new this._Providers[tmpStreamDefinition.loggertype](tmpStreamDefinition, this), tmpStreamDefinition.level);
|
|
678
1098
|
}
|
|
@@ -686,7 +1106,7 @@
|
|
|
686
1106
|
logTime(pMessage, pDatum) {
|
|
687
1107
|
let tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time';
|
|
688
1108
|
let tmpTime = new Date();
|
|
689
|
-
this.info(
|
|
1109
|
+
this.info("".concat(tmpMessage, " ").concat(tmpTime, " (epoch ").concat(+tmpTime, ")"), pDatum);
|
|
690
1110
|
}
|
|
691
1111
|
|
|
692
1112
|
// Get a timestamp
|
|
@@ -703,7 +1123,7 @@
|
|
|
703
1123
|
let tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time Measurement';
|
|
704
1124
|
let tmpDatum = typeof pDatum === 'object' ? pDatum : {};
|
|
705
1125
|
let tmpEndTime = +new Date();
|
|
706
|
-
this.info(
|
|
1126
|
+
this.info("".concat(tmpMessage, " logged at (epoch ").concat(+tmpEndTime, ") took (").concat(pTimeDelta, "ms)"), pDatum);
|
|
707
1127
|
}
|
|
708
1128
|
logTimeDeltaHuman(pTimeDelta, pMessage, pDatum) {
|
|
709
1129
|
let tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time Measurement';
|
|
@@ -716,7 +1136,7 @@
|
|
|
716
1136
|
tmpSeconds = tmpSeconds < 10 ? "0" + tmpSeconds : tmpSeconds;
|
|
717
1137
|
tmpMinutes = tmpMinutes < 10 ? "0" + tmpMinutes : tmpMinutes;
|
|
718
1138
|
tmpHours = tmpHours < 10 ? "0" + tmpHours : tmpHours;
|
|
719
|
-
this.info(
|
|
1139
|
+
this.info("".concat(tmpMessage, " logged at (epoch ").concat(+tmpEndTime, ") took (").concat(pTimeDelta, "ms) or (").concat(tmpHours, ":").concat(tmpMinutes, ":").concat(tmpSeconds, ".").concat(tmpMs, ")"), pDatum);
|
|
720
1140
|
}
|
|
721
1141
|
logTimeDeltaRelative(pStartTime, pMessage, pDatum) {
|
|
722
1142
|
this.logTimeDelta(this.getTimeDelta(pStartTime), pMessage, pDatum);
|
|
@@ -736,13 +1156,13 @@
|
|
|
736
1156
|
module.exports.LogProviderConsole = require('./Fable-Log-Logger-Console.js');
|
|
737
1157
|
module.exports.LogProviderConsole = require('./Fable-Log-Logger-SimpleFlatFile.js');
|
|
738
1158
|
}, {
|
|
739
|
-
"./Fable-Log-BaseLogger.js":
|
|
740
|
-
"./Fable-Log-DefaultProviders-Node.js":
|
|
741
|
-
"./Fable-Log-DefaultStreams.json":
|
|
742
|
-
"./Fable-Log-Logger-Console.js":
|
|
743
|
-
"./Fable-Log-Logger-SimpleFlatFile.js":
|
|
1159
|
+
"./Fable-Log-BaseLogger.js": 18,
|
|
1160
|
+
"./Fable-Log-DefaultProviders-Node.js": 19,
|
|
1161
|
+
"./Fable-Log-DefaultStreams.json": 20,
|
|
1162
|
+
"./Fable-Log-Logger-Console.js": 21,
|
|
1163
|
+
"./Fable-Log-Logger-SimpleFlatFile.js": 22
|
|
744
1164
|
}],
|
|
745
|
-
|
|
1165
|
+
24: [function (require, module, exports) {
|
|
746
1166
|
module.exports = {
|
|
747
1167
|
"Product": "ApplicationNameHere",
|
|
748
1168
|
"ProductVersion": "0.0.0",
|
|
@@ -752,7 +1172,7 @@
|
|
|
752
1172
|
}]
|
|
753
1173
|
};
|
|
754
1174
|
}, {}],
|
|
755
|
-
|
|
1175
|
+
25: [function (require, module, exports) {
|
|
756
1176
|
(function (process) {
|
|
757
1177
|
(function () {
|
|
758
1178
|
/**
|
|
@@ -794,9 +1214,9 @@
|
|
|
794
1214
|
}).call(this);
|
|
795
1215
|
}).call(this, require('_process'));
|
|
796
1216
|
}, {
|
|
797
|
-
"_process":
|
|
1217
|
+
"_process": 33
|
|
798
1218
|
}],
|
|
799
|
-
|
|
1219
|
+
26: [function (require, module, exports) {
|
|
800
1220
|
/**
|
|
801
1221
|
* Fable Settings Add-on
|
|
802
1222
|
*
|
|
@@ -942,11 +1362,11 @@
|
|
|
942
1362
|
module.exports.new = autoConstruct;
|
|
943
1363
|
module.exports.precedent = libPrecedent;
|
|
944
1364
|
}, {
|
|
945
|
-
"./Fable-Settings-Default":
|
|
946
|
-
"./Fable-Settings-TemplateProcessor.js":
|
|
947
|
-
"precedent":
|
|
1365
|
+
"./Fable-Settings-Default": 24,
|
|
1366
|
+
"./Fable-Settings-TemplateProcessor.js": 25,
|
|
1367
|
+
"precedent": 30
|
|
948
1368
|
}],
|
|
949
|
-
|
|
1369
|
+
27: [function (require, module, exports) {
|
|
950
1370
|
/**
|
|
951
1371
|
* Random Byte Generator - Browser version
|
|
952
1372
|
*
|
|
@@ -999,7 +1419,7 @@
|
|
|
999
1419
|
}
|
|
1000
1420
|
module.exports = RandomBytes;
|
|
1001
1421
|
}, {}],
|
|
1002
|
-
|
|
1422
|
+
28: [function (require, module, exports) {
|
|
1003
1423
|
/**
|
|
1004
1424
|
* Fable UUID Generator
|
|
1005
1425
|
*
|
|
@@ -1080,9 +1500,9 @@
|
|
|
1080
1500
|
module.exports = FableUUID;
|
|
1081
1501
|
module.exports.new = autoConstruct;
|
|
1082
1502
|
}, {
|
|
1083
|
-
"./Fable-UUID-Random.js":
|
|
1503
|
+
"./Fable-UUID-Random.js": 27
|
|
1084
1504
|
}],
|
|
1085
|
-
|
|
1505
|
+
29: [function (require, module, exports) {
|
|
1086
1506
|
(function (process) {
|
|
1087
1507
|
(function () {
|
|
1088
1508
|
// 'path' module extracted from Node.js v8.11.1 (only the posix part)
|
|
@@ -1551,9 +1971,9 @@
|
|
|
1551
1971
|
}).call(this);
|
|
1552
1972
|
}).call(this, require('_process'));
|
|
1553
1973
|
}, {
|
|
1554
|
-
"_process":
|
|
1974
|
+
"_process": 33
|
|
1555
1975
|
}],
|
|
1556
|
-
|
|
1976
|
+
30: [function (require, module, exports) {
|
|
1557
1977
|
/**
|
|
1558
1978
|
* Precedent Meta-Templating
|
|
1559
1979
|
*
|
|
@@ -1563,8 +1983,8 @@
|
|
|
1563
1983
|
*
|
|
1564
1984
|
* @description Process text streams, parsing out meta-template expressions.
|
|
1565
1985
|
*/
|
|
1566
|
-
var libWordTree = require(
|
|
1567
|
-
var libStringParser = require(
|
|
1986
|
+
var libWordTree = require("./WordTree.js");
|
|
1987
|
+
var libStringParser = require("./StringParser.js");
|
|
1568
1988
|
class Precedent {
|
|
1569
1989
|
/**
|
|
1570
1990
|
* Precedent Constructor
|
|
@@ -1599,10 +2019,10 @@
|
|
|
1599
2019
|
}
|
|
1600
2020
|
module.exports = Precedent;
|
|
1601
2021
|
}, {
|
|
1602
|
-
"./StringParser.js":
|
|
1603
|
-
"./WordTree.js":
|
|
2022
|
+
"./StringParser.js": 31,
|
|
2023
|
+
"./WordTree.js": 32
|
|
1604
2024
|
}],
|
|
1605
|
-
|
|
2025
|
+
31: [function (require, module, exports) {
|
|
1606
2026
|
/**
|
|
1607
2027
|
* String Parser
|
|
1608
2028
|
*
|
|
@@ -1748,7 +2168,7 @@
|
|
|
1748
2168
|
}
|
|
1749
2169
|
module.exports = StringParser;
|
|
1750
2170
|
}, {}],
|
|
1751
|
-
|
|
2171
|
+
32: [function (require, module, exports) {
|
|
1752
2172
|
/**
|
|
1753
2173
|
* Word Tree
|
|
1754
2174
|
*
|
|
@@ -1807,7 +2227,7 @@
|
|
|
1807
2227
|
}
|
|
1808
2228
|
module.exports = WordTree;
|
|
1809
2229
|
}, {}],
|
|
1810
|
-
|
|
2230
|
+
33: [function (require, module, exports) {
|
|
1811
2231
|
// shim for using process in browser
|
|
1812
2232
|
var process = module.exports = {};
|
|
1813
2233
|
|
|
@@ -1984,7 +2404,7 @@
|
|
|
1984
2404
|
return 0;
|
|
1985
2405
|
};
|
|
1986
2406
|
}, {}],
|
|
1987
|
-
|
|
2407
|
+
34: [function (require, module, exports) {
|
|
1988
2408
|
(function (setImmediate, clearImmediate) {
|
|
1989
2409
|
(function () {
|
|
1990
2410
|
var nextTick = require('process/browser.js').nextTick;
|
|
@@ -2058,19 +2478,19 @@
|
|
|
2058
2478
|
}).call(this);
|
|
2059
2479
|
}).call(this, require("timers").setImmediate, require("timers").clearImmediate);
|
|
2060
2480
|
}, {
|
|
2061
|
-
"process/browser.js":
|
|
2062
|
-
"timers":
|
|
2481
|
+
"process/browser.js": 33,
|
|
2482
|
+
"timers": 34
|
|
2063
2483
|
}],
|
|
2064
|
-
|
|
2484
|
+
35: [function (require, module, exports) {
|
|
2065
2485
|
var libNPMModuleWrapper = require('./Fable.js');
|
|
2066
2486
|
if (typeof window === 'object' && !window.hasOwnProperty('Fable')) {
|
|
2067
2487
|
window.Fable = libNPMModuleWrapper;
|
|
2068
2488
|
}
|
|
2069
2489
|
module.exports = libNPMModuleWrapper;
|
|
2070
2490
|
}, {
|
|
2071
|
-
"./Fable.js":
|
|
2491
|
+
"./Fable.js": 42
|
|
2072
2492
|
}],
|
|
2073
|
-
|
|
2493
|
+
36: [function (require, module, exports) {
|
|
2074
2494
|
const _OperationStatePrototype = JSON.stringify({
|
|
2075
2495
|
"Metadata": {
|
|
2076
2496
|
"GUID": false,
|
|
@@ -2112,13 +2532,13 @@
|
|
|
2112
2532
|
return this;
|
|
2113
2533
|
}
|
|
2114
2534
|
writeOperationLog(pLogLevel, pLogText, pLogObject) {
|
|
2115
|
-
this.state.Log.push(
|
|
2535
|
+
this.state.Log.push("".concat(new Date().toUTCString(), " [").concat(pLogLevel, "]: ").concat(pLogText));
|
|
2116
2536
|
if (typeof pLogObject == 'object') {
|
|
2117
2537
|
this.state.Log.push(JSON.stringify(pLogObject));
|
|
2118
2538
|
}
|
|
2119
2539
|
}
|
|
2120
2540
|
writeOperationErrors(pLogText, pLogObject) {
|
|
2121
|
-
this.state.Errors.push(
|
|
2541
|
+
this.state.Errors.push("".concat(pLogText));
|
|
2122
2542
|
if (typeof pLogObject == 'object') {
|
|
2123
2543
|
this.state.Errors.push(JSON.stringify(pLogObject));
|
|
2124
2544
|
}
|
|
@@ -2152,7 +2572,22 @@
|
|
|
2152
2572
|
}
|
|
2153
2573
|
module.exports = FableOperation;
|
|
2154
2574
|
}, {}],
|
|
2155
|
-
|
|
2575
|
+
37: [function (require, module, exports) {
|
|
2576
|
+
const libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
2577
|
+
const libDataArithmatic = require('data-arithmatic');
|
|
2578
|
+
class FableServiceDataArithmatic extends libFableServiceBase {
|
|
2579
|
+
constructor(pFable, pOptions, pServiceHash) {
|
|
2580
|
+
super(pFable, pOptions, pServiceHash);
|
|
2581
|
+
this.serviceType = 'DataArithmatic';
|
|
2582
|
+
this._DataArithmaticLibrary = new libDataArithmatic();
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
module.exports = FableServiceDataArithmatic;
|
|
2586
|
+
}, {
|
|
2587
|
+
"./Fable-ServiceProviderBase.js": 41,
|
|
2588
|
+
"data-arithmatic": 17
|
|
2589
|
+
}],
|
|
2590
|
+
38: [function (require, module, exports) {
|
|
2156
2591
|
const libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
2157
2592
|
class FableServiceTemplate extends libFableServiceBase {
|
|
2158
2593
|
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
@@ -2212,14 +2647,14 @@
|
|
|
2212
2647
|
// For now this is being kept in a weird form ... this is to mimic the old
|
|
2213
2648
|
// underscore code until this is rewritten using precedent.
|
|
2214
2649
|
this.TemplateSource = "__p+='" + pTemplateText.replace(this.Matchers.Escaper, pMatch => {
|
|
2215
|
-
return
|
|
2650
|
+
return "\\".concat(this.templateEscapes[pMatch]);
|
|
2216
2651
|
}).replace(this.Matchers.Interpolate || this.Matchers.GuaranteedNonMatch, (pMatch, pCode) => {
|
|
2217
|
-
return
|
|
2652
|
+
return "'+\n(".concat(decodeURIComponent(pCode), ")+\n'");
|
|
2218
2653
|
}).replace(this.Matchers.Evaluate || this.Matchers.GuaranteedNonMatch, (pMatch, pCode) => {
|
|
2219
|
-
return
|
|
2220
|
-
}) +
|
|
2221
|
-
this.TemplateSource =
|
|
2222
|
-
this.TemplateSource =
|
|
2654
|
+
return "';\n".concat(decodeURIComponent(pCode), "\n;__p+='");
|
|
2655
|
+
}) + "';\n";
|
|
2656
|
+
this.TemplateSource = "with(pTemplateDataObject||{}){\n".concat(this.TemplateSource, "}\n");
|
|
2657
|
+
this.TemplateSource = "var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n".concat(this.TemplateSource, "return __p;\n");
|
|
2223
2658
|
this.renderFunction = new Function('pTemplateDataObject', this.TemplateSource);
|
|
2224
2659
|
if (typeof pData != 'undefined') {
|
|
2225
2660
|
return this.renderFunction(pData);
|
|
@@ -2233,9 +2668,83 @@
|
|
|
2233
2668
|
}
|
|
2234
2669
|
module.exports = FableServiceTemplate;
|
|
2235
2670
|
}, {
|
|
2236
|
-
"./Fable-ServiceProviderBase.js":
|
|
2671
|
+
"./Fable-ServiceProviderBase.js": 41
|
|
2237
2672
|
}],
|
|
2238
|
-
|
|
2673
|
+
39: [function (require, module, exports) {
|
|
2674
|
+
const libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
2675
|
+
|
|
2676
|
+
// TODO: These are still pretty big -- consider the smaller polyfills
|
|
2677
|
+
const libAsyncWaterfall = require('async.waterfall');
|
|
2678
|
+
const libAsyncEachLimit = require('async.eachlimit');
|
|
2679
|
+
class FableServiceUtility extends libFableServiceBase {
|
|
2680
|
+
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2681
|
+
// string-based template with code snippets into simple executable pieces,
|
|
2682
|
+
// with the added twist of returning a precompiled function ready to go.
|
|
2683
|
+
//
|
|
2684
|
+
// NOTE: This does not implement underscore escape expressions
|
|
2685
|
+
// NOTE: This does not implement underscore magic browser variable assignment
|
|
2686
|
+
//
|
|
2687
|
+
// This is an implementation of that.
|
|
2688
|
+
// TODO: Make this use precedent, add configuration, add debugging.
|
|
2689
|
+
constructor(pFable, pOptions, pServiceHash) {
|
|
2690
|
+
super(pFable, pOptions, pServiceHash);
|
|
2691
|
+
this.templates = {};
|
|
2692
|
+
|
|
2693
|
+
// These two functions are used extensively throughout
|
|
2694
|
+
this.waterfall = libAsyncWaterfall;
|
|
2695
|
+
this.eachLimit = libAsyncEachLimit;
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
2699
|
+
// Now that es6 gives us this, use the native thingy.
|
|
2700
|
+
extend(pDestinationObject) {
|
|
2701
|
+
for (var _len = arguments.length, pSourceObjects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2702
|
+
pSourceObjects[_key - 1] = arguments[_key];
|
|
2703
|
+
}
|
|
2704
|
+
return Object.assign(pDestinationObject, ...pSourceObjects);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2708
|
+
// string-based template with code snippets into simple executable pieces,
|
|
2709
|
+
// with the added twist of returning a precompiled function ready to go.
|
|
2710
|
+
template(pTemplateText, pData) {
|
|
2711
|
+
let tmpTemplate = this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('Template');
|
|
2712
|
+
return tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
// Build a template function from a template hash, and, register it with the service provider
|
|
2716
|
+
buildHashedTemplate(pTemplateHash, pTemplateText, pData) {
|
|
2717
|
+
let tmpTemplate = this.fable.serviceManager.instantiateServiceProvider('Template', {}, pTemplateHash);
|
|
2718
|
+
this.templates[pTemplateHash] = tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2719
|
+
return this.templates[pTemplateHash];
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
// This is a safe, modern version of chunk from underscore
|
|
2723
|
+
// Algorithm pulled from a mix of these two polyfills:
|
|
2724
|
+
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_chunk
|
|
2725
|
+
// https://youmightnotneed.com/lodash
|
|
2726
|
+
// This implementation was most tolerant in browsers. Uglify can fix the rest.
|
|
2727
|
+
chunk(pInput, pChunkSize, pChunkCache) {
|
|
2728
|
+
let tmpInputArray = [...pInput];
|
|
2729
|
+
// Note lodash defaults to 1, underscore defaults to 0
|
|
2730
|
+
let tmpChunkSize = typeof pChunkSize == 'number' ? pChunkSize : 0;
|
|
2731
|
+
let tmpChunkCache = typeof pChunkCache != 'undefined' ? pChunkCache : [];
|
|
2732
|
+
if (tmpChunkSize <= 0) {
|
|
2733
|
+
return tmpChunkCache;
|
|
2734
|
+
}
|
|
2735
|
+
while (tmpInputArray.length) {
|
|
2736
|
+
tmpChunkCache.push(tmpInputArray.splice(0, tmpChunkSize));
|
|
2737
|
+
}
|
|
2738
|
+
return tmpChunkCache;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
module.exports = FableServiceUtility;
|
|
2742
|
+
}, {
|
|
2743
|
+
"./Fable-ServiceProviderBase.js": 41,
|
|
2744
|
+
"async.eachlimit": 1,
|
|
2745
|
+
"async.waterfall": 15
|
|
2746
|
+
}],
|
|
2747
|
+
40: [function (require, module, exports) {
|
|
2239
2748
|
/**
|
|
2240
2749
|
* Fable Application Services Management
|
|
2241
2750
|
* @license MIT
|
|
@@ -2302,9 +2811,9 @@
|
|
|
2302
2811
|
module.exports = FableService;
|
|
2303
2812
|
module.exports.ServiceProviderBase = libFableServiceBase;
|
|
2304
2813
|
}, {
|
|
2305
|
-
"./Fable-ServiceProviderBase.js":
|
|
2814
|
+
"./Fable-ServiceProviderBase.js": 41
|
|
2306
2815
|
}],
|
|
2307
|
-
|
|
2816
|
+
41: [function (require, module, exports) {
|
|
2308
2817
|
/**
|
|
2309
2818
|
* Fable Service Base
|
|
2310
2819
|
* @license MIT
|
|
@@ -2317,71 +2826,12 @@
|
|
|
2317
2826
|
this.options = typeof pOptions === 'object' ? pOptions : {};
|
|
2318
2827
|
this.serviceType = 'Unknown';
|
|
2319
2828
|
this.UUID = pFable.getUUID();
|
|
2320
|
-
this.Hash = typeof pServiceHash === 'string' ? pServiceHash :
|
|
2829
|
+
this.Hash = typeof pServiceHash === 'string' ? pServiceHash : "".concat(this.UUID);
|
|
2321
2830
|
}
|
|
2322
2831
|
}
|
|
2323
2832
|
module.exports = FableServiceProviderBase;
|
|
2324
2833
|
}, {}],
|
|
2325
|
-
|
|
2326
|
-
// TODO: These are still pretty big -- consider the smaller polyfills
|
|
2327
|
-
const libAsyncWaterfall = require('async.waterfall');
|
|
2328
|
-
const libAsyncEachLimit = require('async.eachlimit');
|
|
2329
|
-
class FableUtility {
|
|
2330
|
-
constructor(pFable) {
|
|
2331
|
-
this.fable = pFable;
|
|
2332
|
-
this.templates = {};
|
|
2333
|
-
|
|
2334
|
-
// These two functions are used extensively throughout
|
|
2335
|
-
this.waterfall = libAsyncWaterfall;
|
|
2336
|
-
this.eachLimit = libAsyncEachLimit;
|
|
2337
|
-
}
|
|
2338
|
-
|
|
2339
|
-
// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
2340
|
-
// Now that es6 gives us this, use the native thingy.
|
|
2341
|
-
extend(pDestinationObject, ...pSourceObjects) {
|
|
2342
|
-
return Object.assign(pDestinationObject, ...pSourceObjects);
|
|
2343
|
-
}
|
|
2344
|
-
|
|
2345
|
-
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2346
|
-
// string-based template with code snippets into simple executable pieces,
|
|
2347
|
-
// with the added twist of returning a precompiled function ready to go.
|
|
2348
|
-
template(pTemplateText, pData) {
|
|
2349
|
-
let tmpTemplate = this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('Template');
|
|
2350
|
-
return tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
// Build a template function from a template hash, and, register it with the service provider
|
|
2354
|
-
buildHashedTemplate(pTemplateHash, pTemplateText, pData) {
|
|
2355
|
-
let tmpTemplate = this.fable.serviceManager.instantiateServiceProvider('Template', {}, pTemplateHash);
|
|
2356
|
-
this.templates[pTemplateHash] = tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2357
|
-
return this.templates[pTemplateHash];
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
// This is a safe, modern version of chunk from underscore
|
|
2361
|
-
// Algorithm pulled from a mix of these two polyfills:
|
|
2362
|
-
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_chunk
|
|
2363
|
-
// https://youmightnotneed.com/lodash
|
|
2364
|
-
// This implementation was most tolerant in browsers. Uglify can fix the rest.
|
|
2365
|
-
chunk(pInput, pChunkSize, pChunkCache) {
|
|
2366
|
-
let tmpInputArray = [...pInput];
|
|
2367
|
-
// Note lodash defaults to 1, underscore defaults to 0
|
|
2368
|
-
let tmpChunkSize = typeof pChunkSize == 'number' ? pChunkSize : 0;
|
|
2369
|
-
let tmpChunkCache = typeof pChunkCache != 'undefined' ? pChunkCache : [];
|
|
2370
|
-
if (tmpChunkSize <= 0) {
|
|
2371
|
-
return tmpChunkCache;
|
|
2372
|
-
}
|
|
2373
|
-
while (tmpInputArray.length) {
|
|
2374
|
-
tmpChunkCache.push(tmpInputArray.splice(0, tmpChunkSize));
|
|
2375
|
-
}
|
|
2376
|
-
return tmpChunkCache;
|
|
2377
|
-
}
|
|
2378
|
-
}
|
|
2379
|
-
module.exports = FableUtility;
|
|
2380
|
-
}, {
|
|
2381
|
-
"async.eachlimit": 1,
|
|
2382
|
-
"async.waterfall": 15
|
|
2383
|
-
}],
|
|
2384
|
-
40: [function (require, module, exports) {
|
|
2834
|
+
42: [function (require, module, exports) {
|
|
2385
2835
|
/**
|
|
2386
2836
|
* Fable Application Services Support Library
|
|
2387
2837
|
* @license MIT
|
|
@@ -2390,9 +2840,10 @@
|
|
|
2390
2840
|
const libFableSettings = require('fable-settings');
|
|
2391
2841
|
const libFableUUID = require('fable-uuid');
|
|
2392
2842
|
const libFableLog = require('fable-log');
|
|
2393
|
-
const libFableUtility = require('./Fable-Utility.js');
|
|
2394
2843
|
const libFableServiceManager = require('./Fable-ServiceManager.js');
|
|
2844
|
+
const libFableServiceDataArithmatic = require('./Fable-Service-DataArithmatic.js');
|
|
2395
2845
|
const libFableServiceTemplate = require('./Fable-Service-Template.js');
|
|
2846
|
+
const libFableServiceUtility = require('./Fable-Service-Utility.js');
|
|
2396
2847
|
const libFableOperation = require('./Fable-Operation.js');
|
|
2397
2848
|
class Fable {
|
|
2398
2849
|
constructor(pSettings) {
|
|
@@ -2404,9 +2855,6 @@
|
|
|
2404
2855
|
this.log = new libFableLog(this.settingsManager.settings);
|
|
2405
2856
|
this.log.initialize();
|
|
2406
2857
|
|
|
2407
|
-
// Built-in utility belt functions
|
|
2408
|
-
this.Utility = new libFableUtility(this);
|
|
2409
|
-
|
|
2410
2858
|
// Built-in dependencies
|
|
2411
2859
|
this.Dependencies = {
|
|
2412
2860
|
precedent: libFableSettings.precedent
|
|
@@ -2415,7 +2863,20 @@
|
|
|
2415
2863
|
// Location for Operation state
|
|
2416
2864
|
this.Operations = {};
|
|
2417
2865
|
this.serviceManager = new libFableServiceManager(this);
|
|
2866
|
+
|
|
2867
|
+
// Initialize and instantiate the default baked-in Data Arithmatic service
|
|
2868
|
+
this.serviceManager.addServiceType('DataArithmatic', libFableServiceDataArithmatic);
|
|
2869
|
+
this.fable.serviceManager.instantiateServiceProvider('DataArithmatic', {}, 'Default-Service-DataArithmatic');
|
|
2870
|
+
// This service is passing through the data arithmatic library
|
|
2871
|
+
this.DataArithmatic = this.serviceManager.defaultServices.DataArithmatic._DataArithmaticLibrary;
|
|
2872
|
+
|
|
2873
|
+
// Initialize the template service
|
|
2418
2874
|
this.serviceManager.addServiceType('Template', libFableServiceTemplate);
|
|
2875
|
+
|
|
2876
|
+
// Initialize and instantiate the default baked-in Utility service
|
|
2877
|
+
this.serviceManager.addServiceType('Utility', libFableServiceUtility);
|
|
2878
|
+
this.fable.serviceManager.instantiateServiceProvider('Utility', {}, 'Default-Service-Utility');
|
|
2879
|
+
this.Utility = this.serviceManager.defaultServices.Utility;
|
|
2419
2880
|
this.services = this.serviceManager.services;
|
|
2420
2881
|
this.defaultServices = this.serviceManager.defaultServices;
|
|
2421
2882
|
}
|
|
@@ -2457,13 +2918,14 @@
|
|
|
2457
2918
|
module.exports.ServiceProviderBase = libFableServiceManager.ServiceProviderBase;
|
|
2458
2919
|
module.exports.precedent = libFableSettings.precedent;
|
|
2459
2920
|
}, {
|
|
2460
|
-
"./Fable-Operation.js":
|
|
2461
|
-
"./Fable-Service-
|
|
2462
|
-
"./Fable-
|
|
2463
|
-
"./Fable-Utility.js": 39,
|
|
2464
|
-
"
|
|
2465
|
-
"fable-
|
|
2466
|
-
"fable-
|
|
2921
|
+
"./Fable-Operation.js": 36,
|
|
2922
|
+
"./Fable-Service-DataArithmatic.js": 37,
|
|
2923
|
+
"./Fable-Service-Template.js": 38,
|
|
2924
|
+
"./Fable-Service-Utility.js": 39,
|
|
2925
|
+
"./Fable-ServiceManager.js": 40,
|
|
2926
|
+
"fable-log": 23,
|
|
2927
|
+
"fable-settings": 26,
|
|
2928
|
+
"fable-uuid": 28
|
|
2467
2929
|
}]
|
|
2468
|
-
}, {}, [
|
|
2930
|
+
}, {}, [35])(35);
|
|
2469
2931
|
});
|