@mojir/lits 1.2.2-alpha.2 → 1.2.2-alpha.4
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 +58 -1
- package/dist/cli/src/Lits/Lits.d.ts +2 -1
- package/dist/cli/src/index.d.ts +1 -1
- package/dist/cli/src/transformer/index.d.ts +2 -0
- package/dist/cli/src/untokenizer/index.d.ts +2 -0
- package/dist/index.esm.js +58 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +58 -1
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +58 -1
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/Lits/Lits.d.ts +2 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/transformer/index.d.ts +2 -0
- package/dist/src/untokenizer/index.d.ts +2 -0
- package/dist/testFramework.esm.js +58 -1
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +58 -1
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/lits.iife.js
CHANGED
|
@@ -2867,7 +2867,7 @@ var Lits = (function (exports) {
|
|
|
2867
2867
|
},
|
|
2868
2868
|
};
|
|
2869
2869
|
|
|
2870
|
-
var version = "1.2.2-alpha.
|
|
2870
|
+
var version = "1.2.2-alpha.4";
|
|
2871
2871
|
|
|
2872
2872
|
var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
2873
2873
|
var xyRegexp = /[xy]/g;
|
|
@@ -8054,6 +8054,12 @@ var Lits = (function (exports) {
|
|
|
8054
8054
|
throw new LitsError("Expected newline token, got ".concat(token === null || token === void 0 ? void 0 : token.t, "."));
|
|
8055
8055
|
}
|
|
8056
8056
|
|
|
8057
|
+
function transformTokens(tokenStram, transformer) {
|
|
8058
|
+
return __assign(__assign({}, tokenStram), { tokens: tokenStram.tokens.map(function (token) {
|
|
8059
|
+
return __assign(__assign({}, token), { v: transformer(token.v) });
|
|
8060
|
+
}) });
|
|
8061
|
+
}
|
|
8062
|
+
|
|
8057
8063
|
var UnparseOptions = /** @class */ (function () {
|
|
8058
8064
|
function UnparseOptions(unparse, lineLength, col, inlined, locked) {
|
|
8059
8065
|
if (col === void 0) { col = 0; }
|
|
@@ -8572,6 +8578,51 @@ var Lits = (function (exports) {
|
|
|
8572
8578
|
return result.trim();
|
|
8573
8579
|
}
|
|
8574
8580
|
|
|
8581
|
+
function isNoSpaceNeededBefore(token) {
|
|
8582
|
+
switch (token.t) {
|
|
8583
|
+
case exports.TokenType.Bracket:
|
|
8584
|
+
return [')', ']'].includes(token.v);
|
|
8585
|
+
case exports.TokenType.CollectionAccessor:
|
|
8586
|
+
return true;
|
|
8587
|
+
case exports.TokenType.NewLine:
|
|
8588
|
+
return true;
|
|
8589
|
+
default:
|
|
8590
|
+
return false;
|
|
8591
|
+
}
|
|
8592
|
+
}
|
|
8593
|
+
function isNoSpaceNeededAfter(token) {
|
|
8594
|
+
switch (token.t) {
|
|
8595
|
+
case exports.TokenType.Bracket:
|
|
8596
|
+
return ['(', '['].includes(token.v);
|
|
8597
|
+
case exports.TokenType.CollectionAccessor:
|
|
8598
|
+
return true;
|
|
8599
|
+
case exports.TokenType.FnShorthand:
|
|
8600
|
+
return true;
|
|
8601
|
+
case exports.TokenType.NewLine:
|
|
8602
|
+
return true;
|
|
8603
|
+
case exports.TokenType.RegexpShorthand:
|
|
8604
|
+
return true;
|
|
8605
|
+
default:
|
|
8606
|
+
return false;
|
|
8607
|
+
}
|
|
8608
|
+
}
|
|
8609
|
+
function untokenize(tokenStream) {
|
|
8610
|
+
var lastToken;
|
|
8611
|
+
return tokenStream.tokens.reduce(function (acc, token) {
|
|
8612
|
+
var joiner = !lastToken || isNoSpaceNeededAfter(lastToken) || isNoSpaceNeededBefore(token) ? '' : ' ';
|
|
8613
|
+
lastToken = token;
|
|
8614
|
+
return "".concat(acc).concat(joiner).concat(untokenizeToken(token));
|
|
8615
|
+
}, '');
|
|
8616
|
+
}
|
|
8617
|
+
function untokenizeToken(token) {
|
|
8618
|
+
switch (token.t) {
|
|
8619
|
+
case exports.TokenType.String:
|
|
8620
|
+
return "\"".concat(token.v, "\"");
|
|
8621
|
+
default:
|
|
8622
|
+
return token.v;
|
|
8623
|
+
}
|
|
8624
|
+
}
|
|
8625
|
+
|
|
8575
8626
|
var Cache = /** @class */ (function () {
|
|
8576
8627
|
function Cache(maxSize) {
|
|
8577
8628
|
this.cache = {};
|
|
@@ -8703,6 +8754,12 @@ var Lits = (function (exports) {
|
|
|
8703
8754
|
var contextStack = createContextStack(params);
|
|
8704
8755
|
return evaluate(ast, contextStack);
|
|
8705
8756
|
};
|
|
8757
|
+
Lits.prototype.transform = function (tokenStream, transformer) {
|
|
8758
|
+
return transformTokens(tokenStream, transformer);
|
|
8759
|
+
};
|
|
8760
|
+
Lits.prototype.untokenize = function (tokenStream) {
|
|
8761
|
+
return untokenize(tokenStream);
|
|
8762
|
+
};
|
|
8706
8763
|
Lits.prototype.apply = function (fn, fnParams, params) {
|
|
8707
8764
|
var _a;
|
|
8708
8765
|
if (params === void 0) { params = {}; }
|