@hyperjump/json-schema 0.23.3 → 0.23.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/json-schema-amd.js +71 -29
- package/dist/json-schema-amd.js.map +1 -1
- package/dist/json-schema-amd.min.js +1 -2
- package/dist/json-schema-amd.min.js.map +1 -1
- package/dist/json-schema-cjs.js +71 -29
- package/dist/json-schema-cjs.js.map +1 -1
- package/dist/json-schema-cjs.min.js +1 -2
- package/dist/json-schema-cjs.min.js.map +1 -1
- package/dist/json-schema-esm.js +71 -29
- package/dist/json-schema-esm.js.map +1 -1
- package/dist/json-schema-esm.min.js +1 -2
- package/dist/json-schema-esm.min.js.map +1 -1
- package/dist/json-schema-iife.js +71 -29
- package/dist/json-schema-iife.js.map +1 -1
- package/dist/json-schema-iife.min.js +1 -2
- package/dist/json-schema-iife.min.js.map +1 -1
- package/dist/json-schema-system.js +71 -29
- package/dist/json-schema-system.js.map +1 -1
- package/dist/json-schema-system.min.js +1 -2
- package/dist/json-schema-system.min.js.map +1 -1
- package/dist/json-schema-umd.js +71 -29
- package/dist/json-schema-umd.js.map +1 -1
- package/dist/json-schema-umd.min.js +1 -2
- package/dist/json-schema-umd.min.js.map +1 -1
- package/package.json +3 -3
package/dist/json-schema-esm.js
CHANGED
|
@@ -2286,6 +2286,38 @@ var moo$1 = {exports: {}};
|
|
|
2286
2286
|
}
|
|
2287
2287
|
}
|
|
2288
2288
|
|
|
2289
|
+
function pad(s, length) {
|
|
2290
|
+
if (s.length > length) {
|
|
2291
|
+
return s
|
|
2292
|
+
}
|
|
2293
|
+
return Array(length - s.length + 1).join(" ") + s
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
function lastNLines(string, numLines) {
|
|
2297
|
+
var position = string.length;
|
|
2298
|
+
var lineBreaks = 0;
|
|
2299
|
+
while (true) {
|
|
2300
|
+
var idx = string.lastIndexOf("\n", position - 1);
|
|
2301
|
+
if (idx === -1) {
|
|
2302
|
+
break;
|
|
2303
|
+
} else {
|
|
2304
|
+
lineBreaks++;
|
|
2305
|
+
}
|
|
2306
|
+
position = idx;
|
|
2307
|
+
if (lineBreaks === numLines) {
|
|
2308
|
+
break;
|
|
2309
|
+
}
|
|
2310
|
+
if (position === 0) {
|
|
2311
|
+
break;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
var startPosition =
|
|
2315
|
+
lineBreaks < numLines ?
|
|
2316
|
+
0 :
|
|
2317
|
+
position + 1;
|
|
2318
|
+
return string.substring(startPosition).split("\n")
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2289
2321
|
function objectToRules(object) {
|
|
2290
2322
|
var keys = Object.getOwnPropertyNames(object);
|
|
2291
2323
|
var result = [];
|
|
@@ -2568,39 +2600,31 @@ var moo$1 = {exports: {}};
|
|
|
2568
2600
|
}
|
|
2569
2601
|
|
|
2570
2602
|
function keywordTransform(map) {
|
|
2571
|
-
|
|
2572
|
-
|
|
2603
|
+
|
|
2604
|
+
// Use a JavaScript Map to map keywords to their corresponding token type
|
|
2605
|
+
// unless Map is unsupported, then fall back to using an Object:
|
|
2606
|
+
var isMap = typeof Map !== 'undefined';
|
|
2607
|
+
var reverseMap = isMap ? new Map : Object.create(null);
|
|
2608
|
+
|
|
2573
2609
|
var types = Object.getOwnPropertyNames(map);
|
|
2574
2610
|
for (var i = 0; i < types.length; i++) {
|
|
2575
2611
|
var tokenType = types[i];
|
|
2576
2612
|
var item = map[tokenType];
|
|
2577
2613
|
var keywordList = Array.isArray(item) ? item : [item];
|
|
2578
2614
|
keywordList.forEach(function(keyword) {
|
|
2579
|
-
(byLength[keyword.length] = byLength[keyword.length] || []).push(keyword);
|
|
2580
2615
|
if (typeof keyword !== 'string') {
|
|
2581
2616
|
throw new Error("keyword must be string (in keyword '" + tokenType + "')")
|
|
2582
2617
|
}
|
|
2583
|
-
|
|
2618
|
+
if (isMap) {
|
|
2619
|
+
reverseMap.set(keyword, tokenType);
|
|
2620
|
+
} else {
|
|
2621
|
+
reverseMap[keyword] = tokenType;
|
|
2622
|
+
}
|
|
2584
2623
|
});
|
|
2585
2624
|
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
// https://jsperf.com/string-lookups
|
|
2589
|
-
function str(x) { return JSON.stringify(x) }
|
|
2590
|
-
var source = '';
|
|
2591
|
-
source += 'switch (value.length) {\n';
|
|
2592
|
-
for (var length in byLength) {
|
|
2593
|
-
var keywords = byLength[length];
|
|
2594
|
-
source += 'case ' + length + ':\n';
|
|
2595
|
-
source += 'switch (value) {\n';
|
|
2596
|
-
keywords.forEach(function(keyword) {
|
|
2597
|
-
var tokenType = reverseMap[keyword];
|
|
2598
|
-
source += 'case ' + str(keyword) + ': return ' + str(tokenType) + '\n';
|
|
2599
|
-
});
|
|
2600
|
-
source += '}\n';
|
|
2625
|
+
return function(k) {
|
|
2626
|
+
return isMap ? reverseMap.get(k) : reverseMap[k]
|
|
2601
2627
|
}
|
|
2602
|
-
source += '}\n';
|
|
2603
|
-
return Function('value', source) // type
|
|
2604
2628
|
}
|
|
2605
2629
|
|
|
2606
2630
|
/***************************************************************************/
|
|
@@ -2619,6 +2643,7 @@ var moo$1 = {exports: {}};
|
|
|
2619
2643
|
this.line = info ? info.line : 1;
|
|
2620
2644
|
this.col = info ? info.col : 1;
|
|
2621
2645
|
this.queuedToken = info ? info.queuedToken : null;
|
|
2646
|
+
this.queuedText = info ? info.queuedText: "";
|
|
2622
2647
|
this.queuedThrow = info ? info.queuedThrow : null;
|
|
2623
2648
|
this.setState(info ? info.state : this.startState);
|
|
2624
2649
|
this.stack = info && info.stack ? info.stack.slice() : [];
|
|
@@ -2632,6 +2657,7 @@ var moo$1 = {exports: {}};
|
|
|
2632
2657
|
state: this.state,
|
|
2633
2658
|
stack: this.stack.slice(),
|
|
2634
2659
|
queuedToken: this.queuedToken,
|
|
2660
|
+
queuedText: this.queuedText,
|
|
2635
2661
|
queuedThrow: this.queuedThrow,
|
|
2636
2662
|
}
|
|
2637
2663
|
};
|
|
@@ -2763,7 +2789,8 @@ var moo$1 = {exports: {}};
|
|
|
2763
2789
|
|
|
2764
2790
|
// throw, if no rule with {error: true}
|
|
2765
2791
|
if (group.shouldThrow) {
|
|
2766
|
-
|
|
2792
|
+
var err = new Error(this.formatError(token, "invalid syntax"));
|
|
2793
|
+
throw err;
|
|
2767
2794
|
}
|
|
2768
2795
|
|
|
2769
2796
|
if (group.pop) this.popState();
|
|
@@ -2804,13 +2831,28 @@ var moo$1 = {exports: {}};
|
|
|
2804
2831
|
col: this.col,
|
|
2805
2832
|
};
|
|
2806
2833
|
}
|
|
2807
|
-
|
|
2808
|
-
var
|
|
2809
|
-
var
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2834
|
+
|
|
2835
|
+
var numLinesAround = 2;
|
|
2836
|
+
var firstDisplayedLine = Math.max(token.line - numLinesAround, 1);
|
|
2837
|
+
var lastDisplayedLine = token.line + numLinesAround;
|
|
2838
|
+
var lastLineDigits = String(lastDisplayedLine).length;
|
|
2839
|
+
var displayedLines = lastNLines(
|
|
2840
|
+
this.buffer,
|
|
2841
|
+
(this.line - token.line) + numLinesAround + 1
|
|
2842
|
+
)
|
|
2843
|
+
.slice(0, 5);
|
|
2844
|
+
var errorLines = [];
|
|
2845
|
+
errorLines.push(message + " at line " + token.line + " col " + token.col + ":");
|
|
2846
|
+
errorLines.push("");
|
|
2847
|
+
for (var i = 0; i < displayedLines.length; i++) {
|
|
2848
|
+
var line = displayedLines[i];
|
|
2849
|
+
var lineNo = firstDisplayedLine + i;
|
|
2850
|
+
errorLines.push(pad(String(lineNo), lastLineDigits) + " " + line);
|
|
2851
|
+
if (lineNo === token.line) {
|
|
2852
|
+
errorLines.push(pad("", lastLineDigits + token.col + 1) + "^");
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
return errorLines.join("\n")
|
|
2814
2856
|
};
|
|
2815
2857
|
|
|
2816
2858
|
Lexer.prototype.clone = function() {
|