@node-core/utils 7.3.1 → 7.4.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/bin/ncu-ci.js +39 -0
- package/lib/ci/availability.js +24 -0
- package/lib/ci/ci_utils.js +13 -0
- package/lib/ci/failure_file_scanner.js +72 -21
- package/lib/ci/jenkins.js +23 -0
- package/lib/ci/resumable_build.js +86 -0
- package/lib/ci/resume_ci.js +64 -25
- package/lib/ci/run_ci.js +39 -9
- package/lib/ci/workload.js +72 -0
- package/lib/update-v8/deps.js +4 -1
- package/node_modules/branch-diff/.github/dependabot.yml +14 -2
- package/node_modules/branch-diff/.github/workflows/test-and-release.yml +4 -15
- package/node_modules/branch-diff/CHANGELOG.md +24 -0
- package/node_modules/branch-diff/package.json +35 -3
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +2 -2
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +1 -1
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.cjs.js +2 -1
- package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.mjs +2 -1
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
- package/node_modules/js-yaml/package.json +1 -1
- package/node_modules/smol-toml/README.md +460 -273
- package/node_modules/smol-toml/dist/date.js +50 -21
- package/node_modules/smol-toml/dist/error.d.ts +1 -2
- package/node_modules/smol-toml/dist/error.js +6 -2
- package/node_modules/smol-toml/dist/extract.js +240 -20
- package/node_modules/smol-toml/dist/index.cjs +409 -373
- package/node_modules/smol-toml/dist/index.d.ts +5 -4
- package/node_modules/smol-toml/dist/index.js +2 -1
- package/node_modules/smol-toml/dist/parse.d.ts +38 -1
- package/node_modules/smol-toml/dist/parse.js +52 -37
- package/node_modules/smol-toml/dist/primitive.js +23 -110
- package/node_modules/smol-toml/dist/stringify.d.ts +2 -1
- package/node_modules/smol-toml/dist/stringify.js +74 -36
- package/node_modules/smol-toml/dist/struct.js +76 -99
- package/node_modules/smol-toml/dist/util.d.ts +6 -1
- package/node_modules/smol-toml/dist/util.js +4 -36
- package/node_modules/smol-toml/package.json +8 -8
- package/package.json +1 -1
|
@@ -25,39 +25,68 @@
|
|
|
25
25
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
26
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
|
-
let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[
|
|
28
|
+
let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;
|
|
29
29
|
export class TomlDate extends Date {
|
|
30
30
|
#hasDate = false;
|
|
31
31
|
#hasTime = false;
|
|
32
32
|
#offset = null;
|
|
33
|
-
constructor(date) {
|
|
33
|
+
constructor(date, fasttype, unsafeDelim) {
|
|
34
34
|
let hasDate = true;
|
|
35
35
|
let hasTime = true;
|
|
36
36
|
let offset = 'Z';
|
|
37
|
+
let c;
|
|
37
38
|
if (typeof date === 'string') {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
if (fasttype)
|
|
40
|
+
prep: {
|
|
41
|
+
// Date-time
|
|
42
|
+
if (fasttype < 3) {
|
|
43
|
+
if (+date.slice(11, 13) > 23) {
|
|
44
|
+
date = '';
|
|
45
|
+
break prep;
|
|
46
|
+
}
|
|
47
|
+
// Local
|
|
48
|
+
if (fasttype === 2) {
|
|
49
|
+
offset = null;
|
|
50
|
+
date += 'Z';
|
|
51
|
+
}
|
|
52
|
+
// Offset; keep track of offset if not Z
|
|
53
|
+
else if ((c = date.charCodeAt(date.length - 1)) !== 0x5a /* Z */ && c !== 0x7a /* z */) {
|
|
54
|
+
offset = date.slice(date.length - 6);
|
|
55
|
+
}
|
|
56
|
+
if (unsafeDelim)
|
|
57
|
+
date = date.slice(0, 10) + 'T' + date.slice(11);
|
|
58
|
+
}
|
|
59
|
+
// Time
|
|
60
|
+
else if (fasttype === 4) {
|
|
61
|
+
date = +date.slice(0, 2) > 23 ? '' : `0000-01-01T${date}Z`;
|
|
62
|
+
}
|
|
63
|
+
hasDate = fasttype !== 4;
|
|
64
|
+
hasTime = fasttype !== 3;
|
|
43
65
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
66
|
+
else {
|
|
67
|
+
let match = date.match(DATE_TIME_RE);
|
|
68
|
+
if (match) {
|
|
69
|
+
if (!match[1]) {
|
|
70
|
+
hasDate = false;
|
|
71
|
+
date = `0000-01-01T${date}`;
|
|
72
|
+
}
|
|
73
|
+
hasTime = !!match[2];
|
|
74
|
+
// Make sure to use T instead of a space. Breaks in case of extreme values otherwise.
|
|
75
|
+
hasTime && date[10] === ' ' && (date = date.replace(' ', 'T'));
|
|
76
|
+
// Do not allow rollover hours.
|
|
77
|
+
if (match[2] && +match[2] > 23) {
|
|
78
|
+
date = '';
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
offset = match[3] || null;
|
|
82
|
+
if (!offset && hasTime)
|
|
83
|
+
date += 'Z';
|
|
84
|
+
}
|
|
50
85
|
}
|
|
51
86
|
else {
|
|
52
|
-
|
|
53
|
-
date = date.toUpperCase();
|
|
54
|
-
if (!offset && hasTime)
|
|
55
|
-
date += 'Z';
|
|
87
|
+
date = '';
|
|
56
88
|
}
|
|
57
89
|
}
|
|
58
|
-
else {
|
|
59
|
-
date = '';
|
|
60
|
-
}
|
|
61
90
|
}
|
|
62
91
|
super(date);
|
|
63
92
|
if (!isNaN(this.getTime())) {
|
|
@@ -93,7 +122,7 @@ export class TomlDate extends Date {
|
|
|
93
122
|
if (this.#offset === null)
|
|
94
123
|
return iso.slice(0, -1);
|
|
95
124
|
// Offset DateTime
|
|
96
|
-
if (this.#offset === 'Z')
|
|
125
|
+
if (this.#offset === 'Z' || this.#offset === 'z')
|
|
97
126
|
return iso;
|
|
98
127
|
// This part is quite annoying: JS strips the original timezone from the ISO string representation
|
|
99
128
|
// Instead of using a "modified" date and "Z", we restore the representation "as authored"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
26
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
|
-
type TomlErrorOptions = ErrorOptions & {
|
|
28
|
+
export type TomlErrorOptions = ErrorOptions & {
|
|
29
29
|
toml: string;
|
|
30
30
|
ptr: number;
|
|
31
31
|
};
|
|
@@ -35,4 +35,3 @@ export declare class TomlError extends Error {
|
|
|
35
35
|
codeblock: string;
|
|
36
36
|
constructor(message: string, options: TomlErrorOptions);
|
|
37
37
|
}
|
|
38
|
-
export {};
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
28
|
function getLineColFromPtr(string, ptr) {
|
|
29
|
-
let lines = string.slice(0, ptr).split(/\r
|
|
29
|
+
let lines = string.slice(0, ptr).split(/\r?\n/);
|
|
30
30
|
return [lines.length, lines.pop().length + 1];
|
|
31
31
|
}
|
|
32
32
|
function makeCodeBlock(string, line, column) {
|
|
33
|
-
let lines = string.split(/\r
|
|
33
|
+
let lines = string.split(/\r?\n/);
|
|
34
34
|
let codeblock = '';
|
|
35
35
|
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
36
36
|
for (let i = line - 1; i <= line + 1; i++) {
|
|
@@ -60,4 +60,8 @@ export class TomlError extends Error {
|
|
|
60
60
|
this.column = column;
|
|
61
61
|
this.codeblock = codeblock;
|
|
62
62
|
}
|
|
63
|
+
/** @internal */
|
|
64
|
+
static x(message, ctx, ptr) {
|
|
65
|
+
throw new TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p });
|
|
66
|
+
}
|
|
63
67
|
}
|
|
@@ -25,24 +25,33 @@
|
|
|
25
25
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
26
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
|
-
import { parseString
|
|
28
|
+
import { parseString } from './primitive.js';
|
|
29
29
|
import { parseArray, parseInlineTable } from './struct.js';
|
|
30
30
|
import { TomlError } from './error.js';
|
|
31
|
+
import { TomlDate } from './date.js';
|
|
32
|
+
function isDigit(char, base = 10) {
|
|
33
|
+
return base === 16
|
|
34
|
+
? (char > 0x2f && char < 0x3a) || (char > 0x40 && char < 0x47) || (char > 0x60 && char < 0x67)
|
|
35
|
+
: (char > 0x2f && char < 0x30 + base);
|
|
36
|
+
}
|
|
37
|
+
function isEndOfValue(char, delim) {
|
|
38
|
+
// Whitespace -- we're permissive on `\r` for performance; it'll be dealt with later anyway
|
|
39
|
+
return char === 0x20 || char === 0x9 /* \t */ || char === 0xa /* \n */ || char === 0xd /* \r */ ||
|
|
40
|
+
// Structure end or next value delimiter
|
|
41
|
+
(delim && (char === delim || char === 0x2c /* , */)) ||
|
|
42
|
+
// Comment
|
|
43
|
+
char === 0x23; /* # */
|
|
44
|
+
}
|
|
31
45
|
/** @internal */
|
|
32
|
-
export function extractValue(ctx, end
|
|
33
|
-
let
|
|
34
|
-
let c = ctx.s.charCodeAt(
|
|
46
|
+
export function extractValue(ctx, end) {
|
|
47
|
+
let errPtr = ctx.p;
|
|
48
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
35
49
|
// Structs
|
|
36
50
|
if (c === 0x5b /* [ */ || c === 0x7b /* { */) {
|
|
37
|
-
|
|
38
|
-
throw new TomlError('document contains excessively nested structures. aborting.', {
|
|
39
|
-
toml: ctx.s,
|
|
40
|
-
ptr,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
51
|
+
ctx.d-- || TomlError.x('document contains excessively nested structures. aborting.', ctx);
|
|
43
52
|
let value = c === 0x5b /* [ */
|
|
44
|
-
? parseArray(ctx
|
|
45
|
-
: parseInlineTable(ctx
|
|
53
|
+
? parseArray(ctx)
|
|
54
|
+
: parseInlineTable(ctx);
|
|
46
55
|
ctx.d++;
|
|
47
56
|
return value;
|
|
48
57
|
}
|
|
@@ -54,16 +63,227 @@ export function extractValue(ctx, end, integersAsBigInt) {
|
|
|
54
63
|
// We can fast-path because the first character is enough to know the only possible value
|
|
55
64
|
if (c === 0x74 /* t */) { // Only possible valid value is `true`
|
|
56
65
|
if (ctx.s.charCodeAt(++ctx.p) !== 0x72 || ctx.s.charCodeAt(++ctx.p) !== 0x75 || ctx.s.charCodeAt(++ctx.p) !== 0x65)
|
|
57
|
-
|
|
58
|
-
ctx.p
|
|
59
|
-
return true;
|
|
66
|
+
TomlError.x('invalid value', ctx, errPtr);
|
|
67
|
+
return ctx.p++, true;
|
|
60
68
|
}
|
|
61
69
|
if (c === 0x66 /* f */) { // Only possible valid value is `false`
|
|
62
70
|
if (ctx.s.charCodeAt(++ctx.p) !== 0x61 || ctx.s.charCodeAt(++ctx.p) !== 0x6c || ctx.s.charCodeAt(++ctx.p) !== 0x73 || ctx.s.charCodeAt(++ctx.p) !== 0x65)
|
|
63
|
-
|
|
64
|
-
ctx.p
|
|
65
|
-
|
|
71
|
+
TomlError.x('invalid value', ctx, errPtr);
|
|
72
|
+
return ctx.p++, false;
|
|
73
|
+
}
|
|
74
|
+
if (c === 0x2b /* + */ || c === 0x2d /* - */) {
|
|
75
|
+
return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 0x2c - c, end);
|
|
76
|
+
}
|
|
77
|
+
// Rough heuristic, but `parseDate` falls back to number parsing if it's a false positive.
|
|
78
|
+
// e.g.: `a = 1\n-------------- = 1` would match this heuristic, but gracefully fallback to numbers.
|
|
79
|
+
if (ctx.s.charCodeAt(ctx.p + 4) === 0x2d /* - */ && ctx.s.charCodeAt(ctx.p + 7) === 0x2d /* - */) {
|
|
80
|
+
return parseDate(ctx, c, end);
|
|
81
|
+
}
|
|
82
|
+
// Same logic as above; `parseTime` falls back to number parsing if it's a false positive.
|
|
83
|
+
if (ctx.s.charCodeAt(ctx.p + 2) === 0x3a /* : */) {
|
|
84
|
+
return parseTime(ctx, c, end);
|
|
85
|
+
}
|
|
86
|
+
return parseNumber(ctx, ctx.p, c, 0, end);
|
|
87
|
+
}
|
|
88
|
+
// State:
|
|
89
|
+
// 0: init
|
|
90
|
+
// 1: integer
|
|
91
|
+
// 2: fractional dot
|
|
92
|
+
// 3: fractional
|
|
93
|
+
// 4: exponent letter
|
|
94
|
+
// 5: exponent
|
|
95
|
+
// >9: underscore; see below
|
|
96
|
+
// -> 12: was integer
|
|
97
|
+
// -> 14: was fractional
|
|
98
|
+
// -> 16: was exponent
|
|
99
|
+
// states 2-5, 14, 16 are ONLY permitted iif base === 10
|
|
100
|
+
function parseNumber(ctx, startPtr, startChr, sign, endChr) {
|
|
101
|
+
let c = startChr;
|
|
102
|
+
let state = 0;
|
|
103
|
+
let hasUnderscores = false;
|
|
104
|
+
// (+/-)inf
|
|
105
|
+
if (c === 0x69 /* i */) {
|
|
106
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 0x6e || ctx.s.charCodeAt(++ctx.p) !== 0x66)
|
|
107
|
+
TomlError.x('invalid value', ctx, startPtr);
|
|
108
|
+
return ctx.p++, (sign || 1) / 0;
|
|
109
|
+
}
|
|
110
|
+
// (+/-)nan
|
|
111
|
+
if (c === 0x6e /* n */) {
|
|
112
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 0x61 || ctx.s.charCodeAt(++ctx.p) !== 0x6e)
|
|
113
|
+
TomlError.x('invalid value', ctx, startPtr);
|
|
114
|
+
return ctx.p++, NaN;
|
|
115
|
+
}
|
|
116
|
+
// Leading zero
|
|
117
|
+
// Only allowed cases: `0<EOV>`, `0.(...)`, `0e(...)`, `0x(...)`, `0b(...)`, `0o(...)`
|
|
118
|
+
// FWIW, `0e(...)` is a stupid case, but it's not banned per-se so we have to parse it
|
|
119
|
+
if (c === 0x30 /* 0 */) {
|
|
120
|
+
if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr))
|
|
121
|
+
return ctx.bi === true ? 0n : 0; // note: conveniently deals with `-0`
|
|
122
|
+
if (!sign) {
|
|
123
|
+
if (c === 0x78 /* x */)
|
|
124
|
+
return parseIntegerBaseN(ctx, startPtr, 16, endChr);
|
|
125
|
+
else if (c === 0x62 /* b */)
|
|
126
|
+
return parseIntegerBaseN(ctx, startPtr, 2, endChr);
|
|
127
|
+
else if (c === 0x6f /* o */)
|
|
128
|
+
return parseIntegerBaseN(ctx, startPtr, 8, endChr);
|
|
129
|
+
}
|
|
130
|
+
if (c === 0x2e /* . */)
|
|
131
|
+
state = 2;
|
|
132
|
+
else if (c === 0x65 /* e */ || c === 0x45 /* E */)
|
|
133
|
+
state = 4;
|
|
134
|
+
else
|
|
135
|
+
TomlError.x('illegal leading zero', ctx, startPtr);
|
|
136
|
+
}
|
|
137
|
+
// If the 1st char is not a digit by now, then it's not a valid TOML value at all
|
|
138
|
+
else if (!isDigit(c))
|
|
139
|
+
TomlError.x('invalid value', ctx, startPtr);
|
|
140
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
141
|
+
if (!state)
|
|
142
|
+
state = 1; // Detects single-digit numbers we can use a fast parse path for
|
|
143
|
+
// The way the states are numbered is not random: underscores are always permitted in odd-numbered states and
|
|
144
|
+
// never permitted in even-numbered ones.
|
|
145
|
+
if (c === 0x5f /* _ */) {
|
|
146
|
+
if (!(state & 1))
|
|
147
|
+
TomlError.x('illegal underscore', ctx);
|
|
148
|
+
state += 11; // 11 is a marker that makes the state even and greater than 9; see the numbering + rationale above
|
|
149
|
+
hasUnderscores = true;
|
|
150
|
+
}
|
|
151
|
+
// Transition to fractional part.
|
|
152
|
+
else if (state === 1 && c === 0x2e /* . */)
|
|
153
|
+
state = 2;
|
|
154
|
+
// Transition to exponent part.
|
|
155
|
+
else if ((state === 1 || state === 3) && (c === 0x65 /* e */ || c === 0x45 /* E */))
|
|
156
|
+
state = 4;
|
|
157
|
+
// + and - are permitted in state 4 only (handled before entering the function for state 0)
|
|
158
|
+
else if (state === 4 && (c === 0x2b /* + */ || c === 0x2d /* - */)) { /* no-op */ }
|
|
159
|
+
// All special cases have been handled; only digits are allowed here
|
|
160
|
+
else if (!isDigit(c))
|
|
161
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
162
|
+
// Clear state flags
|
|
163
|
+
else if (state > 9)
|
|
164
|
+
state -= 11;
|
|
165
|
+
else if (!(state & 1))
|
|
166
|
+
state++;
|
|
167
|
+
}
|
|
168
|
+
// Single-char number; we can fast-path these very easily.
|
|
169
|
+
if (!state) {
|
|
170
|
+
let val = (startChr - 0x30 /* 0 */) * (sign || 1);
|
|
171
|
+
return ctx.bi === true ? BigInt(val) : val;
|
|
172
|
+
}
|
|
173
|
+
// Even-numbered states absolutely require a digit next; not even end of value is permitted
|
|
174
|
+
if (!(state & 1))
|
|
175
|
+
TomlError.x('unfinished numeric value', ctx, startPtr);
|
|
176
|
+
let str = ctx.s.slice(startPtr, ctx.p);
|
|
177
|
+
if (hasUnderscores)
|
|
178
|
+
str = str.replaceAll('_', ''); // perf: replaceAll 1.25x faster than replace with a regex
|
|
179
|
+
return state > 1
|
|
180
|
+
? parseFloat(str)
|
|
181
|
+
: parseInteger(ctx, str, 10, startPtr);
|
|
182
|
+
}
|
|
183
|
+
function parseIntegerBaseN(ctx, startPtr, base, endChr) {
|
|
184
|
+
let c, underscore = 1;
|
|
185
|
+
while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
|
|
186
|
+
if (c === 0x5f /* _ */) {
|
|
187
|
+
if (underscore & 1)
|
|
188
|
+
TomlError.x('illegal underscore', ctx);
|
|
189
|
+
underscore = 3;
|
|
190
|
+
}
|
|
191
|
+
// We only need to check if the number is a valid digit, nothing else is permitted
|
|
192
|
+
else if (!isDigit(c, base))
|
|
193
|
+
TomlError.x(`illegal character in numeric literal`, ctx);
|
|
194
|
+
// Clear underscore flag
|
|
195
|
+
else if (underscore & 1)
|
|
196
|
+
underscore--;
|
|
197
|
+
}
|
|
198
|
+
// Trailing underscore is not allowed
|
|
199
|
+
if (underscore & 1)
|
|
200
|
+
TomlError.x('unfinished numeric value', ctx);
|
|
201
|
+
let str = ctx.s.slice(startPtr + 2, ctx.p);
|
|
202
|
+
if (underscore)
|
|
203
|
+
str = str.replaceAll('_', ''); // perf: replaceAll 1.25x faster than replace with a regex
|
|
204
|
+
return parseInteger(ctx, str, base, startPtr);
|
|
205
|
+
}
|
|
206
|
+
function parseInteger(ctx, str, base, startPtr) {
|
|
207
|
+
if (ctx.bi !== true)
|
|
208
|
+
int: {
|
|
209
|
+
let val = parseInt(str, base);
|
|
210
|
+
if (!Number.isSafeInteger(val)) {
|
|
211
|
+
if (ctx.bi)
|
|
212
|
+
break int;
|
|
213
|
+
TomlError.x('integer value cannot be represented losslessly', ctx, startPtr);
|
|
214
|
+
}
|
|
215
|
+
return val;
|
|
216
|
+
}
|
|
217
|
+
return base === 10 ? BigInt(str) : BigInt((base === 2 ? '0b' : base === 8 ? '0o' : '0x') + str);
|
|
218
|
+
}
|
|
219
|
+
function parseDate(ctx, c, endChr) {
|
|
220
|
+
let startPtr = ctx.p++, unsafeSeparator;
|
|
221
|
+
if (!isDigit(c) ||
|
|
222
|
+
!isDigit(ctx.s.charCodeAt(ctx.p++)) ||
|
|
223
|
+
!isDigit(ctx.s.charCodeAt(ctx.p++)) ||
|
|
224
|
+
!isDigit(ctx.s.charCodeAt(ctx.p++))) {
|
|
225
|
+
return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr);
|
|
226
|
+
}
|
|
227
|
+
ctx.p += 5;
|
|
228
|
+
if (!isDigit(ctx.s.charCodeAt(ctx.p++)))
|
|
229
|
+
TomlError.x('invalid date-time: date part is malformed', ctx, startPtr);
|
|
230
|
+
if (ctx.p >= ctx.s.length || (((c = ctx.s.charCodeAt(ctx.p)) !== 0x20 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 0x54 /* T */ && c !== 0x74 /* t */)) {
|
|
231
|
+
let t = ctx.s.slice(startPtr, ctx.p);
|
|
232
|
+
return readDate(ctx, t, 3, false, startPtr);
|
|
233
|
+
}
|
|
234
|
+
if (ctx.s.charCodeAt(ctx.p += 3) !== 0x3a /* : */)
|
|
235
|
+
TomlError.x('invalid date-time: time part is malformed', ctx, startPtr);
|
|
236
|
+
if (ctx.s.charCodeAt(ctx.p += 3) === 0x3a /* : */)
|
|
237
|
+
ctx.p += 3;
|
|
238
|
+
if (ctx.s.charCodeAt(ctx.p) === 0x2e /* . */)
|
|
239
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
240
|
+
;
|
|
241
|
+
if (c = ctx.s.charCodeAt(ctx.p)) {
|
|
242
|
+
if (c === 0x5a /* Z */ || c === 0x7a /* z */) {
|
|
243
|
+
let t = ctx.s.slice(startPtr, ++ctx.p);
|
|
244
|
+
return readDate(ctx, t, 1, unsafeSeparator, startPtr, '[+00:00]');
|
|
245
|
+
}
|
|
246
|
+
if (c === 0x2b /* + */ || c === 0x2d /* - */) {
|
|
247
|
+
// Temporal's ZonedDateTime is weird asf when it comes to dealing with traditional offsets...
|
|
248
|
+
// It's 1.2x faster to allocate a new string to pass to ZDT than use Instant.toZonedDateTimeISO
|
|
249
|
+
let t = ctx.s.slice(startPtr, ctx.p += 6);
|
|
250
|
+
return readDate(ctx, t, 1, unsafeSeparator, startPtr, !ctx.ld && ('[' + ctx.s.slice(ctx.p - 6, ctx.p) + ']'));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
let t = ctx.s.slice(startPtr, ctx.p);
|
|
254
|
+
return readDate(ctx, t, 2, unsafeSeparator, startPtr);
|
|
255
|
+
}
|
|
256
|
+
function parseTime(ctx, c, endChr) {
|
|
257
|
+
let start = ctx.p;
|
|
258
|
+
if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(++ctx.p))) {
|
|
259
|
+
return parseNumber(ctx, --ctx.p, c, 0, endChr);
|
|
260
|
+
}
|
|
261
|
+
if (ctx.s.charCodeAt(ctx.p += 4) === 0x3a /* : */)
|
|
262
|
+
ctx.p += 3;
|
|
263
|
+
if (ctx.s.charCodeAt(ctx.p) === 0x2e /* . */)
|
|
264
|
+
while (isDigit(ctx.s.charCodeAt(++ctx.p)))
|
|
265
|
+
;
|
|
266
|
+
let t = ctx.s.slice(start, ctx.p);
|
|
267
|
+
return readDate(ctx, t, 4, false, start);
|
|
268
|
+
}
|
|
269
|
+
function readDate(ctx, str, type, unsafeDelim, errPtr, temporalSuffix) {
|
|
270
|
+
if (ctx.ld) {
|
|
271
|
+
let date = new TomlDate(str, type, unsafeDelim);
|
|
272
|
+
if (!date.isValid())
|
|
273
|
+
TomlError.x('invalid date', ctx, errPtr);
|
|
274
|
+
return date;
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
if (temporalSuffix)
|
|
278
|
+
str += temporalSuffix;
|
|
279
|
+
switch (type) {
|
|
280
|
+
case 1: return Temporal.ZonedDateTime.from(str);
|
|
281
|
+
case 2: return Temporal.PlainDateTime.from(str);
|
|
282
|
+
case 3: return Temporal.PlainDate.from(str);
|
|
283
|
+
case 4: return Temporal.PlainTime.from(str);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (e) {
|
|
287
|
+
TomlError.x(e instanceof Error ? e.message : '' + e, ctx, errPtr);
|
|
66
288
|
}
|
|
67
|
-
// Legacy logic for numbers and dates. Slow and needs to be rewritten.
|
|
68
|
-
return parseValue(ctx, integersAsBigInt, end);
|
|
69
289
|
}
|