@mojir/lits 1.2.0 → 1.2.1-alpha.1

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/cli/cli.js CHANGED
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
92
92
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
93
93
  };
94
94
 
95
- var version = "1.2.0";
95
+ var version = "1.2.1-alpha.1";
96
96
 
97
97
  var AstNodeType;
98
98
  (function (AstNodeType) {
@@ -8701,163 +8701,6 @@ var Lits = /** @class */ (function () {
8701
8701
  return Lits;
8702
8702
  }());
8703
8703
 
8704
- function runTest(_a) {
8705
- var filePath = _a.testPath, testNamePattern = _a.testNamePattern;
8706
- var includedFilePaths = getIncludedFilePaths(filePath);
8707
- var testResult = {
8708
- tap: 'TAP version 13\n',
8709
- success: true,
8710
- };
8711
- try {
8712
- var testChunks = getTestChunks(filePath);
8713
- testResult.tap += "1..".concat(testChunks.length, "\n");
8714
- testChunks.forEach(function (testChunkProgram, index) {
8715
- var testNumber = index + 1;
8716
- if (testNamePattern && !testNamePattern.test(testChunkProgram.name)) {
8717
- testResult.tap += "ok ".concat(testNumber, " ").concat(testChunkProgram.name, " # skip - Not matching testNamePattern ").concat(testNamePattern, "\n");
8718
- }
8719
- else if (testChunkProgram.directive === 'SKIP') {
8720
- testResult.tap += "ok ".concat(testNumber, " ").concat(testChunkProgram.name, " # skip\n");
8721
- }
8722
- else {
8723
- try {
8724
- var lits = new Lits({ debug: true });
8725
- var contexts = getContexts(includedFilePaths, lits);
8726
- lits.run(testChunkProgram.program, {
8727
- contexts: contexts,
8728
- filePath: filePath,
8729
- });
8730
- testResult.tap += "ok ".concat(testNumber, " ").concat(testChunkProgram.name, "\n");
8731
- }
8732
- catch (error) {
8733
- testResult.success = false;
8734
- testResult.tap += "not ok ".concat(testNumber, " ").concat(testChunkProgram.name).concat(getErrorYaml(error));
8735
- }
8736
- }
8737
- });
8738
- }
8739
- catch (error) {
8740
- testResult.tap += "Bail out! ".concat(getErrorMessage$1(error), "\n");
8741
- testResult.success = false;
8742
- }
8743
- return testResult;
8744
- }
8745
- function readLitsFile(litsPath) {
8746
- if (!litsPath.endsWith('.lits'))
8747
- throw new Error("Expected .lits file, got ".concat(litsPath));
8748
- return fs.readFileSync(litsPath, { encoding: 'utf-8' });
8749
- }
8750
- function getContexts(includedFilePaths, lits) {
8751
- return includedFilePaths.reduce(function (acc, filePath) {
8752
- var fileContent = readLitsFile(filePath);
8753
- acc.push(lits.context(fileContent, { filePath: filePath, contexts: acc }));
8754
- return acc;
8755
- }, []);
8756
- }
8757
- function getIncludedFilePaths(absoluteFilePath) {
8758
- var result = [];
8759
- getIncludesRecursively(absoluteFilePath, result);
8760
- return result.reduce(function (acc, entry) {
8761
- if (!acc.includes(entry))
8762
- acc.push(entry);
8763
- return acc;
8764
- }, []);
8765
- function getIncludesRecursively(filePath, includedFilePaths) {
8766
- var includeFilePaths = readIncludeDirectives(filePath);
8767
- includeFilePaths.forEach(function (includeFilePath) {
8768
- getIncludesRecursively(includeFilePath, includedFilePaths);
8769
- includedFilePaths.push(includeFilePath);
8770
- });
8771
- }
8772
- }
8773
- function readIncludeDirectives(filePath) {
8774
- var fileContent = readLitsFile(filePath);
8775
- var dirname = path.dirname(filePath);
8776
- var okToInclude = true;
8777
- return fileContent.split('\n').reduce(function (acc, line) {
8778
- var includeMatch = line.match(/^\s*;+\s*@include\s*(\S+)\s*$/);
8779
- if (includeMatch) {
8780
- if (!okToInclude)
8781
- throw new Error("@include must be in the beginning of file: ".concat(filePath, ":").concat(line + 1));
8782
- var relativeFilePath = includeMatch[1];
8783
- acc.push(path.resolve(dirname, relativeFilePath));
8784
- }
8785
- if (!line.match(/^\s*;.*$/))
8786
- okToInclude = false;
8787
- return acc;
8788
- }, []);
8789
- }
8790
- // Splitting test file based on @test annotations
8791
- function getTestChunks(testPath) {
8792
- var testProgram = readLitsFile(testPath);
8793
- var currentTest;
8794
- var setupCode = '';
8795
- return testProgram.split('\n').reduce(function (result, line, index) {
8796
- var _a;
8797
- var currentLineNbr = index + 1;
8798
- // eslint-disable-next-line regexp/no-super-linear-backtracking
8799
- var testNameAnnotationMatch = line.match(/^\s*;+\s*@(?:(skip)-)?test\s*(.*)$/);
8800
- if (testNameAnnotationMatch) {
8801
- var directive = ((_a = testNameAnnotationMatch[1]) !== null && _a !== void 0 ? _a : '').toUpperCase();
8802
- var testName_1 = testNameAnnotationMatch[2];
8803
- if (!testName_1)
8804
- throw new Error("Missing test name on line ".concat(currentLineNbr));
8805
- if (result.find(function (chunk) { return chunk.name === testName_1; }))
8806
- throw new Error("Duplicate test name ".concat(testName_1));
8807
- currentTest = {
8808
- directive: (directive || null),
8809
- name: testName_1,
8810
- // Adding new-lines to make lits debug information report correct rows
8811
- program: setupCode + __spreadArray([], __read(Array(currentLineNbr + 2 - setupCode.split('\n').length).keys()), false).map(function () { return ''; }).join('\n'),
8812
- };
8813
- result.push(currentTest);
8814
- return result;
8815
- }
8816
- if (!currentTest)
8817
- setupCode += "".concat(line, "\n");
8818
- else
8819
- currentTest.program += "".concat(line, "\n");
8820
- return result;
8821
- }, []);
8822
- }
8823
- function getErrorYaml(error) {
8824
- var message = getErrorMessage$1(error);
8825
- /* v8 ignore next 7 */
8826
- if (!isAbstractLitsError(error)) {
8827
- return "\n ---\n message: ".concat(JSON.stringify(message), "\n ...\n");
8828
- }
8829
- var sourceCodeInfo = error.sourceCodeInfo;
8830
- /* v8 ignore next 8 */
8831
- if (!sourceCodeInfo || typeof sourceCodeInfo === 'string') {
8832
- return "\n ---\n message: ".concat(JSON.stringify(message), "\n error: ").concat(JSON.stringify(error.name), "\n ...\n");
8833
- }
8834
- var formattedMessage = message.includes('\n')
8835
- ? "|\n ".concat(message.split(/\r?\n/).join('\n '))
8836
- : JSON.stringify(message);
8837
- return "\n ---\n error: ".concat(JSON.stringify(error.name), "\n message: ").concat(formattedMessage, "\n location: ").concat(JSON.stringify(getLocation(sourceCodeInfo)), "\n code:\n - \"").concat(sourceCodeInfo.code, "\"\n - \"").concat(getCodeMarker(sourceCodeInfo), "\"\n ...\n");
8838
- }
8839
- function getLocation(sourceCodeInfo) {
8840
- var terms = [];
8841
- if (sourceCodeInfo.filePath)
8842
- terms.push(sourceCodeInfo.filePath);
8843
- if (sourceCodeInfo.position) {
8844
- terms.push("".concat(sourceCodeInfo.position.line));
8845
- terms.push("".concat(sourceCodeInfo.position.column));
8846
- }
8847
- return terms.join(':');
8848
- }
8849
- function getErrorMessage$1(error) {
8850
- if (!isAbstractLitsError(error)) {
8851
- // error should always be an Error (other cases is just for kicks)
8852
- /* v8 ignore next 1 */
8853
- return typeof error === 'string' ? error : error instanceof Error ? error.message : 'Unknown error';
8854
- }
8855
- return error.shortMessage;
8856
- }
8857
- function isAbstractLitsError(error) {
8858
- return error instanceof LitsError;
8859
- }
8860
-
8861
8704
  var collectionReference = {
8862
8705
  'count': {
8863
8706
  title: 'count',
@@ -15317,257 +15160,6 @@ Object.values(apiReference).forEach(function (ref) {
15317
15160
  ref.title = ref.title.replace(/"/g, '"');
15318
15161
  });
15319
15162
 
15320
- function stringifyValue(value, html) {
15321
- var _a;
15322
- var gt = '>';
15323
- var lt = '<';
15324
- if (isLitsFunction(value)) {
15325
- if (value.t === FunctionType.Builtin)
15326
- return "".concat(lt, "builtin function ").concat(value.n).concat(gt);
15327
- else
15328
- return "".concat(lt, "function ").concat((_a = value.n) !== null && _a !== void 0 ? _a : '\u03BB').concat(gt);
15329
- }
15330
- if (value === null)
15331
- return 'null';
15332
- if (typeof value === 'object' && value instanceof Error)
15333
- return value.toString();
15334
- if (typeof value === 'object' && value instanceof RegExp)
15335
- return "".concat(value);
15336
- if (value === Number.POSITIVE_INFINITY)
15337
- return "".concat(Number.POSITIVE_INFINITY);
15338
- if (value === Number.NEGATIVE_INFINITY)
15339
- return "".concat(Number.NEGATIVE_INFINITY);
15340
- if (typeof value === 'number' && Number.isNaN(value))
15341
- return 'NaN';
15342
- if (isRegularExpression(value))
15343
- return "/".concat(value.s, "/").concat(value.f);
15344
- return JSON.stringify(value, null, 2);
15345
- }
15346
- function findAllOccurrences(input, pattern) {
15347
- var matches = __spreadArray([], __read(input.matchAll(pattern)), false);
15348
- return new Set(matches.map(function (match) { return match[0]; }));
15349
- }
15350
-
15351
- var ColorEnum;
15352
- (function (ColorEnum) {
15353
- ColorEnum["Reset"] = "\u001B[0m";
15354
- ColorEnum["Bright"] = "\u001B[1m";
15355
- ColorEnum["ResetBright"] = "\u001B[21m";
15356
- ColorEnum["Dim"] = "\u001B[2m";
15357
- ColorEnum["ResetDim"] = "\u001B[22m";
15358
- ColorEnum["Italic"] = "\u001B[3m";
15359
- ColorEnum["ResetItalic"] = "\u001B[23m";
15360
- ColorEnum["Underscore"] = "\u001B[4m";
15361
- ColorEnum["ResetUnderscore"] = "\u001B[24m";
15362
- ColorEnum["Blink"] = "\u001B[5m";
15363
- ColorEnum["ResetBlink"] = "\u001B[25m";
15364
- ColorEnum["Reverse"] = "\u001B[7m";
15365
- ColorEnum["ResetReverse"] = "\u001B[27m";
15366
- ColorEnum["Hidden"] = "\u001B[8m";
15367
- ColorEnum["ResetHidden"] = "\u001B[28m";
15368
- ColorEnum["FgBlack"] = "\u001B[30m";
15369
- ColorEnum["FgRed"] = "\u001B[31m";
15370
- ColorEnum["FgGreen"] = "\u001B[32m";
15371
- ColorEnum["FgYellow"] = "\u001B[33m";
15372
- ColorEnum["FgBlue"] = "\u001B[34m";
15373
- ColorEnum["FgMagenta"] = "\u001B[35m";
15374
- ColorEnum["FgCyan"] = "\u001B[36m";
15375
- ColorEnum["FgWhite"] = "\u001B[37m";
15376
- ColorEnum["FgGray"] = "\u001B[90m";
15377
- ColorEnum["BgBlack"] = "\u001B[40m";
15378
- ColorEnum["BgRed"] = "\u001B[41m";
15379
- ColorEnum["BgGreen"] = "\u001B[42m";
15380
- ColorEnum["BgYellow"] = "\u001B[43m";
15381
- ColorEnum["BgBlue"] = "\u001B[44m";
15382
- ColorEnum["BgMagenta"] = "\u001B[45m";
15383
- ColorEnum["BgCyan"] = "\u001B[46m";
15384
- ColorEnum["BgWhite"] = "\u001B[47m";
15385
- ColorEnum["BgGray"] = "\u001B[100m";
15386
- })(ColorEnum || (ColorEnum = {}));
15387
- function createLeftPad(length, char) {
15388
- if (char === void 0) { char = ' '; }
15389
- return function (text) {
15390
- return text.padStart(length, char);
15391
- };
15392
- }
15393
- function createRightPad(length, char) {
15394
- if (char === void 0) { char = ' '; }
15395
- return function (text) {
15396
- return text.padEnd(length, char);
15397
- };
15398
- }
15399
- function createFormatter$1(enableColors, colors, formatters) {
15400
- var fn = function (text) {
15401
- var e_1, _a;
15402
- try {
15403
- for (var formatters_1 = __values(formatters), formatters_1_1 = formatters_1.next(); !formatters_1_1.done; formatters_1_1 = formatters_1.next()) {
15404
- var formatter = formatters_1_1.value;
15405
- text = formatter(text);
15406
- }
15407
- }
15408
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
15409
- finally {
15410
- try {
15411
- if (formatters_1_1 && !formatters_1_1.done && (_a = formatters_1.return)) _a.call(formatters_1);
15412
- }
15413
- finally { if (e_1) throw e_1.error; }
15414
- }
15415
- return enableColors
15416
- ? colors.join('') + text + ColorEnum.Reset
15417
- : text;
15418
- };
15419
- Object.defineProperty(fn, 'black', {
15420
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgBlack], false), formatters); },
15421
- });
15422
- Object.defineProperty(fn, 'red', {
15423
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgRed], false), formatters); },
15424
- });
15425
- Object.defineProperty(fn, 'green', {
15426
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgGreen], false), formatters); },
15427
- });
15428
- Object.defineProperty(fn, 'yellow', {
15429
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgYellow], false), formatters); },
15430
- });
15431
- Object.defineProperty(fn, 'blue', {
15432
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgBlue], false), formatters); },
15433
- });
15434
- Object.defineProperty(fn, 'magenta', {
15435
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgMagenta], false), formatters); },
15436
- });
15437
- Object.defineProperty(fn, 'cyan', {
15438
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgCyan], false), formatters); },
15439
- });
15440
- Object.defineProperty(fn, 'white', {
15441
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgWhite], false), formatters); },
15442
- });
15443
- Object.defineProperty(fn, 'gray', {
15444
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgGray], false), formatters); },
15445
- });
15446
- Object.defineProperty(fn, 'bgBlack', {
15447
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgBlack], false), formatters); },
15448
- });
15449
- Object.defineProperty(fn, 'bgRed', {
15450
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgRed], false), formatters); },
15451
- });
15452
- Object.defineProperty(fn, 'bgGreen', {
15453
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgGreen], false), formatters); },
15454
- });
15455
- Object.defineProperty(fn, 'bgYellow', {
15456
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgYellow], false), formatters); },
15457
- });
15458
- Object.defineProperty(fn, 'bgBlue', {
15459
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgBlue], false), formatters); },
15460
- });
15461
- Object.defineProperty(fn, 'bgMagenta', {
15462
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgMagenta], false), formatters); },
15463
- });
15464
- Object.defineProperty(fn, 'bgCyan', {
15465
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgCyan], false), formatters); },
15466
- });
15467
- Object.defineProperty(fn, 'bgWhite', {
15468
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgWhite], false), formatters); },
15469
- });
15470
- Object.defineProperty(fn, 'bgGray', {
15471
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgGray], false), formatters); },
15472
- });
15473
- Object.defineProperty(fn, 'reset', {
15474
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Reset], false), formatters); },
15475
- });
15476
- Object.defineProperty(fn, 'bright', {
15477
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Bright], false), formatters); },
15478
- });
15479
- Object.defineProperty(fn, 'dim', {
15480
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Dim], false), formatters); },
15481
- });
15482
- Object.defineProperty(fn, 'italic', {
15483
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Dim], false), formatters); },
15484
- });
15485
- Object.defineProperty(fn, 'underscore', {
15486
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Underscore], false), formatters); },
15487
- });
15488
- Object.defineProperty(fn, 'blink', {
15489
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Blink], false), formatters); },
15490
- });
15491
- Object.defineProperty(fn, 'reverse', {
15492
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Reverse], false), formatters); },
15493
- });
15494
- Object.defineProperty(fn, 'hidden', {
15495
- get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Hidden], false), formatters); },
15496
- });
15497
- fn.leftPad = function (length, char) { return createFormatter$1(enableColors, colors, [createLeftPad(length, char)]); };
15498
- fn.rightPad = function (length, char) { return createFormatter$1(enableColors, colors, [createRightPad(length, char)]); };
15499
- return fn;
15500
- }
15501
- function createColorizer(enableColors) {
15502
- if (enableColors === void 0) { enableColors = true; }
15503
- return {
15504
- black: createFormatter$1(enableColors, [ColorEnum.FgBlack], []),
15505
- red: createFormatter$1(enableColors, [ColorEnum.FgRed], []),
15506
- green: createFormatter$1(enableColors, [ColorEnum.FgGreen], []),
15507
- yellow: createFormatter$1(enableColors, [ColorEnum.FgYellow], []),
15508
- blue: createFormatter$1(enableColors, [ColorEnum.FgBlue], []),
15509
- magenta: createFormatter$1(enableColors, [ColorEnum.FgMagenta], []),
15510
- cyan: createFormatter$1(enableColors, [ColorEnum.FgCyan], []),
15511
- white: createFormatter$1(enableColors, [ColorEnum.FgWhite], []),
15512
- gray: createFormatter$1(enableColors, [ColorEnum.FgGray], []),
15513
- bgBlack: createFormatter$1(enableColors, [ColorEnum.BgBlack], []),
15514
- bgRed: createFormatter$1(enableColors, [ColorEnum.BgRed], []),
15515
- bgGreen: createFormatter$1(enableColors, [ColorEnum.BgGreen], []),
15516
- bgYellow: createFormatter$1(enableColors, [ColorEnum.BgYellow], []),
15517
- bgBlue: createFormatter$1(enableColors, [ColorEnum.BgBlue], []),
15518
- bgMagenta: createFormatter$1(enableColors, [ColorEnum.BgMagenta], []),
15519
- bgCyan: createFormatter$1(enableColors, [ColorEnum.BgCyan], []),
15520
- bgWhite: createFormatter$1(enableColors, [ColorEnum.BgWhite], []),
15521
- bgGray: createFormatter$1(enableColors, [ColorEnum.BgGray], []),
15522
- reset: createFormatter$1(enableColors, [ColorEnum.Reset], []),
15523
- bright: createFormatter$1(enableColors, [ColorEnum.Bright], []),
15524
- dim: createFormatter$1(enableColors, [ColorEnum.Dim], []),
15525
- italic: createFormatter$1(enableColors, [ColorEnum.Italic], []),
15526
- underscore: createFormatter$1(enableColors, [ColorEnum.Underscore], []),
15527
- blink: createFormatter$1(enableColors, [ColorEnum.Blink], []),
15528
- reverse: createFormatter$1(enableColors, [ColorEnum.Reverse], []),
15529
- hidden: createFormatter$1(enableColors, [ColorEnum.Hidden], []),
15530
- leftPad: function (length, char) { return createFormatter$1(enableColors, [], [createLeftPad(length, char)]); },
15531
- rightPad: function (length, char) { return createFormatter$1(enableColors, [], [createRightPad(length, char)]); },
15532
- };
15533
- }
15534
-
15535
- function getCliType(fmt, arg) {
15536
- var argType = isSpecialExpressionArgument(arg) ? arg.type.slice(1) : arg.type;
15537
- var types = Array.isArray(argType) ? argType : [argType];
15538
- var typeString = types.map(function (type) {
15539
- return fmt.dim.red(type);
15540
- }).join(' | ');
15541
- return arg.array || arg.rest
15542
- ? "".concat(fmt.bright.blue('Array')).concat(fmt.bright.gray('<')).concat(fmt.white(typeString)).concat(fmt.bright.gray('>'))
15543
- : fmt.white(typeString);
15544
- }
15545
-
15546
- function getCliFunctionSignature(fmt, _a) {
15547
- var name = _a.title, variants = _a.variants, args = _a.args, returns = _a.returns;
15548
- return variants.map(function (variant) {
15549
- var form = (variant.argumentNames.length === 0)
15550
- ? "".concat(fmt.white('(')).concat(fmt.blue(name)).concat(fmt.white(')'))
15551
- : "".concat(fmt.white('(')).concat(fmt.blue(name), " ").concat(variant.argumentNames.map(function (argName) {
15552
- var result = '';
15553
- var arg = args[argName];
15554
- if (arg) {
15555
- if (arg.rest)
15556
- result += fmt.white('& ');
15557
- result += "".concat(fmt.green(argName));
15558
- if (arg.type === '*binding' || arg.type === '*for-binding')
15559
- result = "".concat(fmt.white('[')).concat(result).concat(fmt.white(']'));
15560
- else if (arg.type === '*arguments')
15561
- result = "".concat(fmt.white('[')).concat(result).concat(fmt.white(']'));
15562
- else if (arg.type === '*catch-expression')
15563
- result = "".concat(fmt.white('(')).concat(result, " ").concat(fmt.bright.blue('body')).concat(fmt.white(')'));
15564
- }
15565
- return result;
15566
- }).join(' ')).concat(fmt.white(')'));
15567
- return "".concat(form, " ").concat(fmt.gray('=>'), " ").concat(getCliType(fmt, returns));
15568
- }).join('\n');
15569
- }
15570
-
15571
15163
  var e_1, _a$1, e_2, _b;
15572
15164
  var api = {
15573
15165
  collection: [
@@ -15909,6 +15501,414 @@ function isApiName(arg) {
15909
15501
  return apiNames.includes(arg);
15910
15502
  }
15911
15503
 
15504
+ function runTest(_a) {
15505
+ var filePath = _a.testPath, testNamePattern = _a.testNamePattern;
15506
+ var includedFilePaths = getIncludedFilePaths(filePath);
15507
+ var testResult = {
15508
+ tap: 'TAP version 13\n',
15509
+ success: true,
15510
+ };
15511
+ try {
15512
+ var testChunks = getTestChunks(filePath);
15513
+ testResult.tap += "1..".concat(testChunks.length, "\n");
15514
+ testChunks.forEach(function (testChunkProgram, index) {
15515
+ var testNumber = index + 1;
15516
+ if (testNamePattern && !testNamePattern.test(testChunkProgram.name)) {
15517
+ testResult.tap += "ok ".concat(testNumber, " ").concat(testChunkProgram.name, " # skip - Not matching testNamePattern ").concat(testNamePattern, "\n");
15518
+ }
15519
+ else if (testChunkProgram.directive === 'SKIP') {
15520
+ testResult.tap += "ok ".concat(testNumber, " ").concat(testChunkProgram.name, " # skip\n");
15521
+ }
15522
+ else {
15523
+ try {
15524
+ var lits = new Lits({ debug: true });
15525
+ var contexts = getContexts(includedFilePaths, lits);
15526
+ lits.run(testChunkProgram.program, {
15527
+ contexts: contexts,
15528
+ filePath: filePath,
15529
+ });
15530
+ testResult.tap += "ok ".concat(testNumber, " ").concat(testChunkProgram.name, "\n");
15531
+ }
15532
+ catch (error) {
15533
+ testResult.success = false;
15534
+ testResult.tap += "not ok ".concat(testNumber, " ").concat(testChunkProgram.name).concat(getErrorYaml(error));
15535
+ }
15536
+ }
15537
+ });
15538
+ }
15539
+ catch (error) {
15540
+ testResult.tap += "Bail out! ".concat(getErrorMessage$1(error), "\n");
15541
+ testResult.success = false;
15542
+ }
15543
+ return testResult;
15544
+ }
15545
+ function readLitsFile(litsPath) {
15546
+ if (!litsPath.endsWith('.lits'))
15547
+ throw new Error("Expected .lits file, got ".concat(litsPath));
15548
+ return fs.readFileSync(litsPath, { encoding: 'utf-8' });
15549
+ }
15550
+ function getContexts(includedFilePaths, lits) {
15551
+ return includedFilePaths.reduce(function (acc, filePath) {
15552
+ var fileContent = readLitsFile(filePath);
15553
+ acc.push(lits.context(fileContent, { filePath: filePath, contexts: acc }));
15554
+ return acc;
15555
+ }, []);
15556
+ }
15557
+ function getIncludedFilePaths(absoluteFilePath) {
15558
+ var result = [];
15559
+ getIncludesRecursively(absoluteFilePath, result);
15560
+ return result.reduce(function (acc, entry) {
15561
+ if (!acc.includes(entry))
15562
+ acc.push(entry);
15563
+ return acc;
15564
+ }, []);
15565
+ function getIncludesRecursively(filePath, includedFilePaths) {
15566
+ var includeFilePaths = readIncludeDirectives(filePath);
15567
+ includeFilePaths.forEach(function (includeFilePath) {
15568
+ getIncludesRecursively(includeFilePath, includedFilePaths);
15569
+ includedFilePaths.push(includeFilePath);
15570
+ });
15571
+ }
15572
+ }
15573
+ function readIncludeDirectives(filePath) {
15574
+ var fileContent = readLitsFile(filePath);
15575
+ var dirname = path.dirname(filePath);
15576
+ var okToInclude = true;
15577
+ return fileContent.split('\n').reduce(function (acc, line) {
15578
+ var includeMatch = line.match(/^\s*;+\s*@include\s*(\S+)\s*$/);
15579
+ if (includeMatch) {
15580
+ if (!okToInclude)
15581
+ throw new Error("@include must be in the beginning of file: ".concat(filePath, ":").concat(line + 1));
15582
+ var relativeFilePath = includeMatch[1];
15583
+ acc.push(path.resolve(dirname, relativeFilePath));
15584
+ }
15585
+ if (!line.match(/^\s*;.*$/))
15586
+ okToInclude = false;
15587
+ return acc;
15588
+ }, []);
15589
+ }
15590
+ // Splitting test file based on @test annotations
15591
+ function getTestChunks(testPath) {
15592
+ var testProgram = readLitsFile(testPath);
15593
+ var currentTest;
15594
+ var setupCode = '';
15595
+ return testProgram.split('\n').reduce(function (result, line, index) {
15596
+ var _a;
15597
+ var currentLineNbr = index + 1;
15598
+ // eslint-disable-next-line regexp/no-super-linear-backtracking
15599
+ var testNameAnnotationMatch = line.match(/^\s*;+\s*@(?:(skip)-)?test\s*(.*)$/);
15600
+ if (testNameAnnotationMatch) {
15601
+ var directive = ((_a = testNameAnnotationMatch[1]) !== null && _a !== void 0 ? _a : '').toUpperCase();
15602
+ var testName_1 = testNameAnnotationMatch[2];
15603
+ if (!testName_1)
15604
+ throw new Error("Missing test name on line ".concat(currentLineNbr));
15605
+ if (result.find(function (chunk) { return chunk.name === testName_1; }))
15606
+ throw new Error("Duplicate test name ".concat(testName_1));
15607
+ currentTest = {
15608
+ directive: (directive || null),
15609
+ name: testName_1,
15610
+ // Adding new-lines to make lits debug information report correct rows
15611
+ program: setupCode + __spreadArray([], __read(Array(currentLineNbr + 2 - setupCode.split('\n').length).keys()), false).map(function () { return ''; }).join('\n'),
15612
+ };
15613
+ result.push(currentTest);
15614
+ return result;
15615
+ }
15616
+ if (!currentTest)
15617
+ setupCode += "".concat(line, "\n");
15618
+ else
15619
+ currentTest.program += "".concat(line, "\n");
15620
+ return result;
15621
+ }, []);
15622
+ }
15623
+ function getErrorYaml(error) {
15624
+ var message = getErrorMessage$1(error);
15625
+ /* v8 ignore next 7 */
15626
+ if (!isAbstractLitsError(error)) {
15627
+ return "\n ---\n message: ".concat(JSON.stringify(message), "\n ...\n");
15628
+ }
15629
+ var sourceCodeInfo = error.sourceCodeInfo;
15630
+ /* v8 ignore next 8 */
15631
+ if (!sourceCodeInfo || typeof sourceCodeInfo === 'string') {
15632
+ return "\n ---\n message: ".concat(JSON.stringify(message), "\n error: ").concat(JSON.stringify(error.name), "\n ...\n");
15633
+ }
15634
+ var formattedMessage = message.includes('\n')
15635
+ ? "|\n ".concat(message.split(/\r?\n/).join('\n '))
15636
+ : JSON.stringify(message);
15637
+ return "\n ---\n error: ".concat(JSON.stringify(error.name), "\n message: ").concat(formattedMessage, "\n location: ").concat(JSON.stringify(getLocation(sourceCodeInfo)), "\n code:\n - \"").concat(sourceCodeInfo.code, "\"\n - \"").concat(getCodeMarker(sourceCodeInfo), "\"\n ...\n");
15638
+ }
15639
+ function getLocation(sourceCodeInfo) {
15640
+ var terms = [];
15641
+ if (sourceCodeInfo.filePath)
15642
+ terms.push(sourceCodeInfo.filePath);
15643
+ if (sourceCodeInfo.position) {
15644
+ terms.push("".concat(sourceCodeInfo.position.line));
15645
+ terms.push("".concat(sourceCodeInfo.position.column));
15646
+ }
15647
+ return terms.join(':');
15648
+ }
15649
+ function getErrorMessage$1(error) {
15650
+ if (!isAbstractLitsError(error)) {
15651
+ // error should always be an Error (other cases is just for kicks)
15652
+ /* v8 ignore next 1 */
15653
+ return typeof error === 'string' ? error : error instanceof Error ? error.message : 'Unknown error';
15654
+ }
15655
+ return error.shortMessage;
15656
+ }
15657
+ function isAbstractLitsError(error) {
15658
+ return error instanceof LitsError;
15659
+ }
15660
+
15661
+ function stringifyValue(value, html) {
15662
+ var _a;
15663
+ var gt = '>';
15664
+ var lt = '<';
15665
+ if (isLitsFunction(value)) {
15666
+ if (value.t === FunctionType.Builtin)
15667
+ return "".concat(lt, "builtin function ").concat(value.n).concat(gt);
15668
+ else
15669
+ return "".concat(lt, "function ").concat((_a = value.n) !== null && _a !== void 0 ? _a : '\u03BB').concat(gt);
15670
+ }
15671
+ if (value === null)
15672
+ return 'null';
15673
+ if (typeof value === 'object' && value instanceof Error)
15674
+ return value.toString();
15675
+ if (typeof value === 'object' && value instanceof RegExp)
15676
+ return "".concat(value);
15677
+ if (value === Number.POSITIVE_INFINITY)
15678
+ return "".concat(Number.POSITIVE_INFINITY);
15679
+ if (value === Number.NEGATIVE_INFINITY)
15680
+ return "".concat(Number.NEGATIVE_INFINITY);
15681
+ if (typeof value === 'number' && Number.isNaN(value))
15682
+ return 'NaN';
15683
+ if (isRegularExpression(value))
15684
+ return "/".concat(value.s, "/").concat(value.f);
15685
+ return JSON.stringify(value, null, 2);
15686
+ }
15687
+ function findAllOccurrences(input, pattern) {
15688
+ var matches = __spreadArray([], __read(input.matchAll(pattern)), false);
15689
+ return new Set(matches.map(function (match) { return match[0]; }));
15690
+ }
15691
+
15692
+ var ColorEnum;
15693
+ (function (ColorEnum) {
15694
+ ColorEnum["Reset"] = "\u001B[0m";
15695
+ ColorEnum["Bright"] = "\u001B[1m";
15696
+ ColorEnum["ResetBright"] = "\u001B[21m";
15697
+ ColorEnum["Dim"] = "\u001B[2m";
15698
+ ColorEnum["ResetDim"] = "\u001B[22m";
15699
+ ColorEnum["Italic"] = "\u001B[3m";
15700
+ ColorEnum["ResetItalic"] = "\u001B[23m";
15701
+ ColorEnum["Underscore"] = "\u001B[4m";
15702
+ ColorEnum["ResetUnderscore"] = "\u001B[24m";
15703
+ ColorEnum["Blink"] = "\u001B[5m";
15704
+ ColorEnum["ResetBlink"] = "\u001B[25m";
15705
+ ColorEnum["Reverse"] = "\u001B[7m";
15706
+ ColorEnum["ResetReverse"] = "\u001B[27m";
15707
+ ColorEnum["Hidden"] = "\u001B[8m";
15708
+ ColorEnum["ResetHidden"] = "\u001B[28m";
15709
+ ColorEnum["FgBlack"] = "\u001B[30m";
15710
+ ColorEnum["FgRed"] = "\u001B[31m";
15711
+ ColorEnum["FgGreen"] = "\u001B[32m";
15712
+ ColorEnum["FgYellow"] = "\u001B[33m";
15713
+ ColorEnum["FgBlue"] = "\u001B[34m";
15714
+ ColorEnum["FgMagenta"] = "\u001B[35m";
15715
+ ColorEnum["FgCyan"] = "\u001B[36m";
15716
+ ColorEnum["FgWhite"] = "\u001B[37m";
15717
+ ColorEnum["FgGray"] = "\u001B[90m";
15718
+ ColorEnum["BgBlack"] = "\u001B[40m";
15719
+ ColorEnum["BgRed"] = "\u001B[41m";
15720
+ ColorEnum["BgGreen"] = "\u001B[42m";
15721
+ ColorEnum["BgYellow"] = "\u001B[43m";
15722
+ ColorEnum["BgBlue"] = "\u001B[44m";
15723
+ ColorEnum["BgMagenta"] = "\u001B[45m";
15724
+ ColorEnum["BgCyan"] = "\u001B[46m";
15725
+ ColorEnum["BgWhite"] = "\u001B[47m";
15726
+ ColorEnum["BgGray"] = "\u001B[100m";
15727
+ })(ColorEnum || (ColorEnum = {}));
15728
+ function createLeftPad(length, char) {
15729
+ if (char === void 0) { char = ' '; }
15730
+ return function (text) {
15731
+ return text.padStart(length, char);
15732
+ };
15733
+ }
15734
+ function createRightPad(length, char) {
15735
+ if (char === void 0) { char = ' '; }
15736
+ return function (text) {
15737
+ return text.padEnd(length, char);
15738
+ };
15739
+ }
15740
+ function createFormatter$1(enableColors, colors, formatters) {
15741
+ var fn = function (text) {
15742
+ var e_1, _a;
15743
+ try {
15744
+ for (var formatters_1 = __values(formatters), formatters_1_1 = formatters_1.next(); !formatters_1_1.done; formatters_1_1 = formatters_1.next()) {
15745
+ var formatter = formatters_1_1.value;
15746
+ text = formatter(text);
15747
+ }
15748
+ }
15749
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
15750
+ finally {
15751
+ try {
15752
+ if (formatters_1_1 && !formatters_1_1.done && (_a = formatters_1.return)) _a.call(formatters_1);
15753
+ }
15754
+ finally { if (e_1) throw e_1.error; }
15755
+ }
15756
+ return enableColors
15757
+ ? colors.join('') + text + ColorEnum.Reset
15758
+ : text;
15759
+ };
15760
+ Object.defineProperty(fn, 'black', {
15761
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgBlack], false), formatters); },
15762
+ });
15763
+ Object.defineProperty(fn, 'red', {
15764
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgRed], false), formatters); },
15765
+ });
15766
+ Object.defineProperty(fn, 'green', {
15767
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgGreen], false), formatters); },
15768
+ });
15769
+ Object.defineProperty(fn, 'yellow', {
15770
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgYellow], false), formatters); },
15771
+ });
15772
+ Object.defineProperty(fn, 'blue', {
15773
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgBlue], false), formatters); },
15774
+ });
15775
+ Object.defineProperty(fn, 'magenta', {
15776
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgMagenta], false), formatters); },
15777
+ });
15778
+ Object.defineProperty(fn, 'cyan', {
15779
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgCyan], false), formatters); },
15780
+ });
15781
+ Object.defineProperty(fn, 'white', {
15782
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgWhite], false), formatters); },
15783
+ });
15784
+ Object.defineProperty(fn, 'gray', {
15785
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.FgGray], false), formatters); },
15786
+ });
15787
+ Object.defineProperty(fn, 'bgBlack', {
15788
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgBlack], false), formatters); },
15789
+ });
15790
+ Object.defineProperty(fn, 'bgRed', {
15791
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgRed], false), formatters); },
15792
+ });
15793
+ Object.defineProperty(fn, 'bgGreen', {
15794
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgGreen], false), formatters); },
15795
+ });
15796
+ Object.defineProperty(fn, 'bgYellow', {
15797
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgYellow], false), formatters); },
15798
+ });
15799
+ Object.defineProperty(fn, 'bgBlue', {
15800
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgBlue], false), formatters); },
15801
+ });
15802
+ Object.defineProperty(fn, 'bgMagenta', {
15803
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgMagenta], false), formatters); },
15804
+ });
15805
+ Object.defineProperty(fn, 'bgCyan', {
15806
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgCyan], false), formatters); },
15807
+ });
15808
+ Object.defineProperty(fn, 'bgWhite', {
15809
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgWhite], false), formatters); },
15810
+ });
15811
+ Object.defineProperty(fn, 'bgGray', {
15812
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.BgGray], false), formatters); },
15813
+ });
15814
+ Object.defineProperty(fn, 'reset', {
15815
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Reset], false), formatters); },
15816
+ });
15817
+ Object.defineProperty(fn, 'bright', {
15818
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Bright], false), formatters); },
15819
+ });
15820
+ Object.defineProperty(fn, 'dim', {
15821
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Dim], false), formatters); },
15822
+ });
15823
+ Object.defineProperty(fn, 'italic', {
15824
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Dim], false), formatters); },
15825
+ });
15826
+ Object.defineProperty(fn, 'underscore', {
15827
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Underscore], false), formatters); },
15828
+ });
15829
+ Object.defineProperty(fn, 'blink', {
15830
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Blink], false), formatters); },
15831
+ });
15832
+ Object.defineProperty(fn, 'reverse', {
15833
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Reverse], false), formatters); },
15834
+ });
15835
+ Object.defineProperty(fn, 'hidden', {
15836
+ get: function () { return createFormatter$1(enableColors, __spreadArray(__spreadArray([], __read(colors), false), [ColorEnum.Hidden], false), formatters); },
15837
+ });
15838
+ fn.leftPad = function (length, char) { return createFormatter$1(enableColors, colors, [createLeftPad(length, char)]); };
15839
+ fn.rightPad = function (length, char) { return createFormatter$1(enableColors, colors, [createRightPad(length, char)]); };
15840
+ return fn;
15841
+ }
15842
+ function createColorizer(enableColors) {
15843
+ if (enableColors === void 0) { enableColors = true; }
15844
+ return {
15845
+ black: createFormatter$1(enableColors, [ColorEnum.FgBlack], []),
15846
+ red: createFormatter$1(enableColors, [ColorEnum.FgRed], []),
15847
+ green: createFormatter$1(enableColors, [ColorEnum.FgGreen], []),
15848
+ yellow: createFormatter$1(enableColors, [ColorEnum.FgYellow], []),
15849
+ blue: createFormatter$1(enableColors, [ColorEnum.FgBlue], []),
15850
+ magenta: createFormatter$1(enableColors, [ColorEnum.FgMagenta], []),
15851
+ cyan: createFormatter$1(enableColors, [ColorEnum.FgCyan], []),
15852
+ white: createFormatter$1(enableColors, [ColorEnum.FgWhite], []),
15853
+ gray: createFormatter$1(enableColors, [ColorEnum.FgGray], []),
15854
+ bgBlack: createFormatter$1(enableColors, [ColorEnum.BgBlack], []),
15855
+ bgRed: createFormatter$1(enableColors, [ColorEnum.BgRed], []),
15856
+ bgGreen: createFormatter$1(enableColors, [ColorEnum.BgGreen], []),
15857
+ bgYellow: createFormatter$1(enableColors, [ColorEnum.BgYellow], []),
15858
+ bgBlue: createFormatter$1(enableColors, [ColorEnum.BgBlue], []),
15859
+ bgMagenta: createFormatter$1(enableColors, [ColorEnum.BgMagenta], []),
15860
+ bgCyan: createFormatter$1(enableColors, [ColorEnum.BgCyan], []),
15861
+ bgWhite: createFormatter$1(enableColors, [ColorEnum.BgWhite], []),
15862
+ bgGray: createFormatter$1(enableColors, [ColorEnum.BgGray], []),
15863
+ reset: createFormatter$1(enableColors, [ColorEnum.Reset], []),
15864
+ bright: createFormatter$1(enableColors, [ColorEnum.Bright], []),
15865
+ dim: createFormatter$1(enableColors, [ColorEnum.Dim], []),
15866
+ italic: createFormatter$1(enableColors, [ColorEnum.Italic], []),
15867
+ underscore: createFormatter$1(enableColors, [ColorEnum.Underscore], []),
15868
+ blink: createFormatter$1(enableColors, [ColorEnum.Blink], []),
15869
+ reverse: createFormatter$1(enableColors, [ColorEnum.Reverse], []),
15870
+ hidden: createFormatter$1(enableColors, [ColorEnum.Hidden], []),
15871
+ leftPad: function (length, char) { return createFormatter$1(enableColors, [], [createLeftPad(length, char)]); },
15872
+ rightPad: function (length, char) { return createFormatter$1(enableColors, [], [createRightPad(length, char)]); },
15873
+ };
15874
+ }
15875
+
15876
+ function getCliType(fmt, arg) {
15877
+ var argType = isSpecialExpressionArgument(arg) ? arg.type.slice(1) : arg.type;
15878
+ var types = Array.isArray(argType) ? argType : [argType];
15879
+ var typeString = types.map(function (type) {
15880
+ return fmt.dim.red(type);
15881
+ }).join(' | ');
15882
+ return arg.array || arg.rest
15883
+ ? "".concat(fmt.bright.blue('Array')).concat(fmt.bright.gray('<')).concat(fmt.white(typeString)).concat(fmt.bright.gray('>'))
15884
+ : fmt.white(typeString);
15885
+ }
15886
+
15887
+ function getCliFunctionSignature(fmt, _a) {
15888
+ var name = _a.title, variants = _a.variants, args = _a.args, returns = _a.returns;
15889
+ return variants.map(function (variant) {
15890
+ var form = (variant.argumentNames.length === 0)
15891
+ ? "".concat(fmt.white('(')).concat(fmt.blue(name)).concat(fmt.white(')'))
15892
+ : "".concat(fmt.white('(')).concat(fmt.blue(name), " ").concat(variant.argumentNames.map(function (argName) {
15893
+ var result = '';
15894
+ var arg = args[argName];
15895
+ if (arg) {
15896
+ if (arg.rest)
15897
+ result += fmt.white('& ');
15898
+ result += "".concat(fmt.green(argName));
15899
+ if (arg.type === '*binding' || arg.type === '*for-binding')
15900
+ result = "".concat(fmt.white('[')).concat(result).concat(fmt.white(']'));
15901
+ else if (arg.type === '*arguments')
15902
+ result = "".concat(fmt.white('[')).concat(result).concat(fmt.white(']'));
15903
+ else if (arg.type === '*catch-expression')
15904
+ result = "".concat(fmt.white('(')).concat(result, " ").concat(fmt.bright.blue('body')).concat(fmt.white(')'));
15905
+ }
15906
+ return result;
15907
+ }).join(' ')).concat(fmt.white(')'));
15908
+ return "".concat(form, " ").concat(fmt.gray('=>'), " ").concat(getCliType(fmt, returns));
15909
+ }).join('\n');
15910
+ }
15911
+
15912
15912
  function getClojureDocsLink(functionName, clojureDocs) {
15913
15913
  var path = clojureDocs === null ? null : clojureDocs !== null && clojureDocs !== void 0 ? clojureDocs : functionName.replace('?', '_q');
15914
15914
  return path