@markuplint/types 3.0.0-canary.5 → 3.0.0-dev.176

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.
Files changed (110) hide show
  1. package/README.md +1 -1
  2. package/lib/check-multi-types.d.ts +4 -1
  3. package/lib/check-multi-types.js +5 -4
  4. package/lib/check.d.ts +6 -5
  5. package/lib/check.spec.js +64 -58
  6. package/lib/css-syntax.js +49 -47
  7. package/lib/css-syntax.spec.js +152 -149
  8. package/lib/defs.js +2 -2
  9. package/lib/enum.d.ts +2 -1
  10. package/lib/enum.js +1 -1
  11. package/lib/get-candidate.d.ts +4 -1
  12. package/lib/keyword-type.js +3 -2
  13. package/lib/list.d.ts +2 -1
  14. package/lib/list.js +2 -1
  15. package/lib/list.spec.js +118 -117
  16. package/lib/match-result.d.ts +21 -8
  17. package/lib/match-result.js +2 -1
  18. package/lib/number.d.ts +1 -1
  19. package/lib/primitive/index.spec.js +53 -52
  20. package/lib/primitive/is-quantity.d.ts +5 -1
  21. package/lib/primitive/is-uint.d.ts +6 -3
  22. package/lib/primitive/split-unit.d.ts +2 -2
  23. package/lib/primitive/split-unit.js +2 -2
  24. package/lib/rfc/is-bcp-47.spec.js +9 -8
  25. package/lib/token/token-collection.d.ts +71 -56
  26. package/lib/token/token-collection.js +30 -23
  27. package/lib/token/token-collection.spec.js +156 -134
  28. package/lib/token/token.d.ts +58 -52
  29. package/lib/token/token.js +19 -20
  30. package/lib/token/types.d.ts +3 -0
  31. package/lib/token/types.js +2 -0
  32. package/lib/types.d.ts +79 -55
  33. package/lib/types.schema.d.ts +1084 -31
  34. package/lib/w3c/check-serialized-permissions-policy.spec.js +30 -28
  35. package/lib/whatwg/check-autocomplete.js +6 -6
  36. package/lib/whatwg/check-autocomplete.spec.js +361 -360
  37. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +21 -1
  38. package/lib/whatwg/check-datetime/datetime-tokens.js +9 -6
  39. package/lib/whatwg/check-datetime/duration-string.js +12 -2
  40. package/lib/whatwg/check-datetime/index.spec.js +277 -276
  41. package/lib/whatwg/check-datetime/local-date-and-time-string.js +6 -2
  42. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +1 -1
  43. package/lib/whatwg/check-datetime/time-zone-offset-string.js +3 -2
  44. package/lib/whatwg/check-mime-type.d.ts +4 -4
  45. package/lib/whatwg/check-mime-type.js +1 -1
  46. package/lib/whatwg/check-mime-type.spec.js +53 -52
  47. package/lib/whatwg/is-abs-url.spec.js +6 -5
  48. package/lib/whatwg/is-itemprop-name.js +1 -1
  49. package/package.json +12 -10
  50. package/{src/check.spec.ts → test/check.spec.js} +7 -1
  51. package/{src/css-syntax.spec.ts → test/css-syntax.spec.js} +10 -12
  52. package/{src/list.spec.ts → test/list.spec.js} +7 -7
  53. package/{src/primitive/index.spec.ts → test/primitive/index.spec.js} +1 -1
  54. package/{src/rfc/is-bcp-47.spec.ts → test/rfc/is-bcp-47.spec.js} +1 -1
  55. package/{src/token/token-collection.spec.ts → test/token/token-collection.spec.js} +2 -3
  56. package/{src/w3c/check-serialized-permissions-policy.spec.ts → test/w3c/check-serialized-permissions-policy.spec.js} +1 -3
  57. package/{src/whatwg/check-autocomplete.spec.ts → test/whatwg/check-autocomplete.spec.js} +1 -1
  58. package/{src/whatwg/check-datetime/index.spec.ts → test/whatwg/check-datetime/index.spec.js} +18 -15
  59. package/{src/whatwg/check-mime-type.spec.ts → test/whatwg/check-mime-type.spec.js} +1 -1
  60. package/{src/whatwg/is-abs-url.spec.ts → test/whatwg/is-abs-url.spec.js} +1 -1
  61. package/types.schema.json +369 -318
  62. package/gen/specific-schema.json +0 -98
  63. package/gen/types.ts +0 -66
  64. package/src/check-multi-types.ts +0 -35
  65. package/src/check.ts +0 -48
  66. package/src/css-syntax.ts +0 -188
  67. package/src/debug.ts +0 -3
  68. package/src/defs.ts +0 -811
  69. package/src/enum.ts +0 -25
  70. package/src/get-candidate.ts +0 -24
  71. package/src/index.ts +0 -3
  72. package/src/keyword-type.ts +0 -64
  73. package/src/list.ts +0 -34
  74. package/src/match-result.ts +0 -49
  75. package/src/number.ts +0 -46
  76. package/src/primitive/index.ts +0 -7
  77. package/src/primitive/is-float.ts +0 -8
  78. package/src/primitive/is-int.ts +0 -8
  79. package/src/primitive/is-non-zero-uint.ts +0 -8
  80. package/src/primitive/is-quantity.ts +0 -38
  81. package/src/primitive/is-uint.ts +0 -15
  82. package/src/primitive/range.ts +0 -14
  83. package/src/primitive/split-unit.ts +0 -20
  84. package/src/rfc/is-bcp-47.ts +0 -13
  85. package/src/token/index.ts +0 -2
  86. package/src/token/token-collection.ts +0 -444
  87. package/src/token/token.ts +0 -144
  88. package/src/types.schema.ts +0 -1062
  89. package/src/types.ts +0 -118
  90. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  91. package/src/whatwg/check-autocomplete.ts +0 -380
  92. package/src/whatwg/check-datetime/date-string.ts +0 -44
  93. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  94. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  95. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  96. package/src/whatwg/check-datetime/index.ts +0 -36
  97. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  98. package/src/whatwg/check-datetime/month-string.ts +0 -31
  99. package/src/whatwg/check-datetime/time-string.ts +0 -49
  100. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  101. package/src/whatwg/check-datetime/week-string.ts +0 -41
  102. package/src/whatwg/check-datetime/year-string.ts +0 -26
  103. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  104. package/src/whatwg/check-mime-type.ts +0 -46
  105. package/src/whatwg/is-abs-url.ts +0 -31
  106. package/src/whatwg/is-browser-context-name.ts +0 -16
  107. package/src/whatwg/is-custom-element-name.ts +0 -76
  108. package/src/whatwg/is-itemprop-name.ts +0 -17
  109. package/tsconfig.test.json +0 -3
  110. package/tsconfig.tsbuildinfo +0 -1
@@ -5,12 +5,13 @@ const match_result_1 = require("../match-result");
5
5
  const token_1 = require("./token");
6
6
  class TokenCollection extends Array {
7
7
  static fromPatterns(value, patterns, typeOptions) {
8
- const origin = typeof value === 'string' ? value : value.origin;
8
+ var _c;
9
+ const originalValue = typeof value === 'string' ? value : value.originalValue;
9
10
  let strings = typeof value === 'string' ? value : value.value;
10
11
  let cumulativeOffset = typeof value === 'string' ? 0 : value.offset;
11
12
  const tokens = [];
12
13
  function addToken(tokenValue) {
13
- const token = new token_1.Token(tokenValue, cumulativeOffset, origin);
14
+ const token = new token_1.Token(tokenValue, cumulativeOffset, originalValue);
14
15
  tokens.push(token);
15
16
  strings = strings.slice(tokenValue.length);
16
17
  cumulativeOffset += tokenValue.length;
@@ -31,7 +32,7 @@ class TokenCollection extends Array {
31
32
  value = strings.slice(res.index + res[0].length);
32
33
  }
33
34
  else {
34
- value = res[0] || '';
35
+ value = (_c = res[0]) !== null && _c !== void 0 ? _c : '';
35
36
  }
36
37
  }
37
38
  const token = addToken(value);
@@ -51,14 +52,15 @@ class TokenCollection extends Array {
51
52
  return Array;
52
53
  }
53
54
  constructor(value, typeOptions) {
55
+ var _c, _d, _e, _f, _g, _h;
54
56
  super();
55
- this.disallowToSurroundBySpaces = (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.disallowToSurroundBySpaces) || false;
56
- this.allowEmpty = (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.allowEmpty) || true;
57
- this.ordered = (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.ordered) || false;
58
- this.unique = (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.unique) || false;
59
- this.caseInsensitive = (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.caseInsensitive) || true;
57
+ this.disallowToSurroundBySpaces = (_c = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.disallowToSurroundBySpaces) !== null && _c !== void 0 ? _c : false;
58
+ this.allowEmpty = (_d = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.allowEmpty) !== null && _d !== void 0 ? _d : true;
59
+ this.ordered = (_e = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.ordered) !== null && _e !== void 0 ? _e : false;
60
+ this.unique = (_f = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.unique) !== null && _f !== void 0 ? _f : false;
61
+ this.caseInsensitive = (_g = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.caseInsensitive) !== null && _g !== void 0 ? _g : true;
60
62
  this.number = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.number;
61
- this.separator = (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.separator) || 'space';
63
+ this.separator = (_h = typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.separator) !== null && _h !== void 0 ? _h : 'space';
62
64
  if (typeof value === 'number') {
63
65
  this.length = value;
64
66
  return;
@@ -70,12 +72,12 @@ class TokenCollection extends Array {
70
72
  if (this.separator === 'comma') {
71
73
  separators.push(',');
72
74
  }
73
- if (typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.specificSeparator) {
74
- if (Array.isArray(typeOptions.specificSeparator)) {
75
- separators.push(...typeOptions.specificSeparator);
75
+ if ((typeOptions === null || typeOptions === void 0 ? void 0 : typeOptions.specificSeparator) != null) {
76
+ if (typeof typeOptions.specificSeparator === 'string') {
77
+ separators.push(typeOptions.specificSeparator);
76
78
  }
77
79
  else {
78
- separators.push(typeOptions.specificSeparator);
80
+ separators.push(...typeOptions.specificSeparator);
79
81
  }
80
82
  }
81
83
  const chars = value.split('');
@@ -88,8 +90,9 @@ class TokenCollection extends Array {
88
90
  continue;
89
91
  }
90
92
  const lastChar = last[0];
91
- if (!separators.includes(char) &&
92
- !separators.includes(last[0]) &&
93
+ if (lastChar &&
94
+ !separators.includes(char) &&
95
+ !separators.includes(lastChar) &&
93
96
  ((token_1.Token.whitespace.includes(lastChar) && token_1.Token.whitespace.includes(char)) ||
94
97
  (!token_1.Token.whitespace.includes(lastChar) && !token_1.Token.whitespace.includes(char)))) {
95
98
  values.push(last + char);
@@ -190,7 +193,7 @@ class TokenCollection extends Array {
190
193
  chunk(split) {
191
194
  const chunks = [];
192
195
  const tokens = this.slice();
193
- while (tokens.length) {
196
+ while (tokens.length > 0) {
194
197
  const chunkTokens = tokens.splice(0, split);
195
198
  const chunk = TokenCollection._new(chunkTokens, this);
196
199
  chunks.push(chunk);
@@ -221,6 +224,7 @@ class TokenCollection extends Array {
221
224
  return [a, b];
222
225
  }
223
226
  eachCheck(...callbacks) {
227
+ var _c, _d;
224
228
  let headAndTail = this.headAndTail();
225
229
  let head = headAndTail.head;
226
230
  let tail = headAndTail.tail;
@@ -233,10 +237,10 @@ class TokenCollection extends Array {
233
237
  wait--;
234
238
  const result = callback.call(this, head, tail);
235
239
  if (result && !result.matched) {
236
- passCount += result.passCount || 0;
240
+ passCount += (_c = result.passCount) !== null && _c !== void 0 ? _c : 0;
237
241
  if (prev && result.offset === 0 && result.length === 0) {
238
242
  const { offset, line, column } = token_1.Token.shiftLocation(prev, cumulativeOffset);
239
- firstUnmatched = firstUnmatched || {
243
+ firstUnmatched = firstUnmatched !== null && firstUnmatched !== void 0 ? firstUnmatched : {
240
244
  ...result,
241
245
  offset,
242
246
  line,
@@ -244,7 +248,7 @@ class TokenCollection extends Array {
244
248
  };
245
249
  }
246
250
  if (!prev && this.value.length === 0) {
247
- firstUnmatched = firstUnmatched || {
251
+ firstUnmatched = firstUnmatched !== null && firstUnmatched !== void 0 ? firstUnmatched : {
248
252
  ...result,
249
253
  reason: 'empty-token',
250
254
  expects: undefined,
@@ -261,7 +265,7 @@ class TokenCollection extends Array {
261
265
  }
262
266
  }
263
267
  }
264
- firstUnmatched = firstUnmatched || result;
268
+ firstUnmatched = firstUnmatched !== null && firstUnmatched !== void 0 ? firstUnmatched : result;
265
269
  }
266
270
  else if (result && !firstUnmatched && result.matched) {
267
271
  return result;
@@ -271,7 +275,7 @@ class TokenCollection extends Array {
271
275
  passCount += 4 * wait;
272
276
  }
273
277
  }
274
- cumulativeOffset = (head === null || head === void 0 ? void 0 : head.length) || 0;
278
+ cumulativeOffset = (_d = head === null || head === void 0 ? void 0 : head.length) !== null && _d !== void 0 ? _d : 0;
275
279
  headAndTail = tail.headAndTail();
276
280
  prev = head;
277
281
  head = headAndTail.head;
@@ -295,7 +299,7 @@ class TokenCollection extends Array {
295
299
  return current;
296
300
  }
297
301
  });
298
- return resultToken || null;
302
+ return resultToken !== null && resultToken !== void 0 ? resultToken : null;
299
303
  }
300
304
  getDuplicated() {
301
305
  const aList = this.slice();
@@ -332,7 +336,7 @@ class TokenCollection extends Array {
332
336
  const copy = this.slice();
333
337
  const head = copy.shift();
334
338
  if (!head) {
335
- return { head: head || null, tail: TokenCollection._new([], this) };
339
+ return { head: head !== null && head !== void 0 ? head : null, tail: TokenCollection._new([], this) };
336
340
  }
337
341
  const tail = TokenCollection._new(copy, this);
338
342
  return { head, tail };
@@ -353,6 +357,9 @@ class TokenCollection extends Array {
353
357
  const tokens = this.slice();
354
358
  for (let i = 0; i < tokens.length; i++) {
355
359
  const token = tokens[i];
360
+ if (!token) {
361
+ continue;
362
+ }
356
363
  const expectedTokenNumber = tokenNumbers[i % tokenNumbers.length];
357
364
  if (token.type !== expectedTokenNumber) {
358
365
  return {
@@ -1,144 +1,166 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const token_collection_1 = require("./token-collection");
4
- const _1 = require(".");
1
+ 'use strict';
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ const token_collection_1 = require('./token-collection');
5
+
6
+ const _1 = require('.');
5
7
  test('parse', () => {
6
- expect(new token_collection_1.TokenCollection(' a b c ').toJSON()).toStrictEqual([
7
- {
8
- offset: 0,
9
- type: 13,
10
- value: ' ',
11
- },
12
- {
13
- offset: 1,
14
- type: 1,
15
- value: 'a',
16
- },
17
- {
18
- offset: 2,
19
- type: 13,
20
- value: ' ',
21
- },
22
- {
23
- offset: 4,
24
- type: 1,
25
- value: 'b',
26
- },
27
- {
28
- offset: 5,
29
- type: 13,
30
- value: ' ',
31
- },
32
- {
33
- offset: 8,
34
- type: 1,
35
- value: 'c',
36
- },
37
- {
38
- offset: 9,
39
- type: 13,
40
- value: ' ',
41
- },
42
- ]);
8
+ expect(new token_collection_1.TokenCollection(' a b c ').toJSON()).toStrictEqual([
9
+ {
10
+ offset: 0,
11
+ type: 13,
12
+ value: ' ',
13
+ },
14
+ {
15
+ offset: 1,
16
+ type: 1,
17
+ value: 'a',
18
+ },
19
+ {
20
+ offset: 2,
21
+ type: 13,
22
+ value: ' ',
23
+ },
24
+ {
25
+ offset: 4,
26
+ type: 1,
27
+ value: 'b',
28
+ },
29
+ {
30
+ offset: 5,
31
+ type: 13,
32
+ value: ' ',
33
+ },
34
+ {
35
+ offset: 8,
36
+ type: 1,
37
+ value: 'c',
38
+ },
39
+ {
40
+ offset: 9,
41
+ type: 13,
42
+ value: ' ',
43
+ },
44
+ ]);
43
45
  });
44
46
  test('parse comma separator', () => {
45
- expect(new token_collection_1.TokenCollection('a,, ,b,cde', { separator: 'comma' }).toJSON()).toStrictEqual([
46
- {
47
- offset: 0,
48
- type: 1,
49
- value: 'a',
50
- },
51
- {
52
- offset: 1,
53
- type: 18,
54
- value: ',',
55
- },
56
- {
57
- offset: 2,
58
- type: 18,
59
- value: ',',
60
- },
61
- {
62
- offset: 3,
63
- type: 13,
64
- value: ' ',
65
- },
66
- {
67
- offset: 4,
68
- type: 18,
69
- value: ',',
70
- },
71
- {
72
- offset: 5,
73
- type: 1,
74
- value: 'b',
75
- },
76
- {
77
- offset: 6,
78
- type: 18,
79
- value: ',',
80
- },
81
- {
82
- offset: 7,
83
- type: 1,
84
- value: 'cde',
85
- },
86
- ]);
47
+ expect(new token_collection_1.TokenCollection('a,, ,b,cde', { separator: 'comma' }).toJSON()).toStrictEqual([
48
+ {
49
+ offset: 0,
50
+ type: 1,
51
+ value: 'a',
52
+ },
53
+ {
54
+ offset: 1,
55
+ type: 18,
56
+ value: ',',
57
+ },
58
+ {
59
+ offset: 2,
60
+ type: 18,
61
+ value: ',',
62
+ },
63
+ {
64
+ offset: 3,
65
+ type: 13,
66
+ value: ' ',
67
+ },
68
+ {
69
+ offset: 4,
70
+ type: 18,
71
+ value: ',',
72
+ },
73
+ {
74
+ offset: 5,
75
+ type: 1,
76
+ value: 'b',
77
+ },
78
+ {
79
+ offset: 6,
80
+ type: 18,
81
+ value: ',',
82
+ },
83
+ {
84
+ offset: 7,
85
+ type: 1,
86
+ value: 'cde',
87
+ },
88
+ ]);
87
89
  });
88
90
  test('A comma is an ident if the comma is not a separator', () => {
89
- expect(new token_collection_1.TokenCollection('a ,cde , f').toJSON()).toStrictEqual([
90
- {
91
- offset: 0,
92
- type: 1,
93
- value: 'a',
94
- },
95
- {
96
- offset: 1,
97
- type: 13,
98
- value: ' ',
99
- },
100
- {
101
- offset: 2,
102
- type: 1,
103
- value: ',cde',
104
- },
105
- {
106
- offset: 6,
107
- type: 13,
108
- value: ' ',
109
- },
110
- {
111
- offset: 7,
112
- type: 1,
113
- value: ',',
114
- },
115
- {
116
- offset: 8,
117
- type: 13,
118
- value: ' ',
119
- },
120
- {
121
- offset: 9,
122
- type: 1,
123
- value: 'f',
124
- },
125
- ]);
91
+ expect(new token_collection_1.TokenCollection('a ,cde , f').toJSON()).toStrictEqual([
92
+ {
93
+ offset: 0,
94
+ type: 1,
95
+ value: 'a',
96
+ },
97
+ {
98
+ offset: 1,
99
+ type: 13,
100
+ value: ' ',
101
+ },
102
+ {
103
+ offset: 2,
104
+ type: 1,
105
+ value: ',cde',
106
+ },
107
+ {
108
+ offset: 6,
109
+ type: 13,
110
+ value: ' ',
111
+ },
112
+ {
113
+ offset: 7,
114
+ type: 1,
115
+ value: ',',
116
+ },
117
+ {
118
+ offset: 8,
119
+ type: 13,
120
+ value: ' ',
121
+ },
122
+ {
123
+ offset: 9,
124
+ type: 1,
125
+ value: 'f',
126
+ },
127
+ ]);
126
128
  });
127
129
  test('getConsecutiveToken', () => {
128
- var _a;
129
- expect(new token_collection_1.TokenCollection('a,b,c', { separator: 'comma' }).getConsecutiveToken(_1.Token.Comma)).toBeFalsy();
130
- expect(new token_collection_1.TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(_1.Token.Comma)).toBeTruthy();
131
- expect((_a = new token_collection_1.TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(_1.Token.Comma)) === null || _a === void 0 ? void 0 : _a.offset).toBe(2);
130
+ let _a;
131
+ expect(
132
+ new token_collection_1.TokenCollection('a,b,c', { separator: 'comma' }).getConsecutiveToken(_1.Token.Comma),
133
+ ).toBeFalsy();
134
+ expect(
135
+ new token_collection_1.TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(_1.Token.Comma),
136
+ ).toBeTruthy();
137
+ expect(
138
+ (_a = new token_collection_1.TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(
139
+ _1.Token.Comma,
140
+ )) === null || _a === void 0
141
+ ? void 0
142
+ : _a.offset,
143
+ ).toBe(2);
132
144
  });
133
145
  test('fromPatterns', () => {
134
- const patterns = [/\+|-/, /[0-9]{2}/, /:?/, /[0-9]{2}/];
135
- expect(token_collection_1.TokenCollection.fromPatterns('+00:00', patterns).map(t => t.value)).toStrictEqual(['+', '00', ':', '00']);
136
- expect(token_collection_1.TokenCollection.fromPatterns('+0000', patterns).map(t => t.value)).toStrictEqual(['+', '00', '', '00']);
137
- expect(token_collection_1.TokenCollection.fromPatterns('+00/00', patterns).map(t => t.value)).toStrictEqual([
138
- '+',
139
- '00',
140
- '',
141
- '',
142
- '/00',
143
- ]);
146
+ const patterns = [/\+|-/, /[0-9]{2}/, /:?/, /[0-9]{2}/];
147
+ expect(token_collection_1.TokenCollection.fromPatterns('+00:00', patterns).map(t => t.value)).toStrictEqual([
148
+ '+',
149
+ '00',
150
+ ':',
151
+ '00',
152
+ ]);
153
+ expect(token_collection_1.TokenCollection.fromPatterns('+0000', patterns).map(t => t.value)).toStrictEqual([
154
+ '+',
155
+ '00',
156
+ '',
157
+ '00',
158
+ ]);
159
+ expect(token_collection_1.TokenCollection.fromPatterns('+00/00', patterns).map(t => t.value)).toStrictEqual([
160
+ '+',
161
+ '00',
162
+ '',
163
+ '',
164
+ '/00',
165
+ ]);
144
166
  });
@@ -1,55 +1,61 @@
1
+ import type { TokenValue } from './types';
1
2
  import type { UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from '../types';
2
3
  export declare class Token {
3
- #private;
4
- /**
5
- * @see https://github.com/csstree/csstree/blob/master/lib/tokenizer/types.js
6
- */
7
- static readonly Comma = 18;
8
- static readonly Ident = 1;
9
- static readonly WhiteSpace = 13;
10
- /**
11
- * ASCII whitespace is
12
- * - U+0009 TAB
13
- * - U+000A LF
14
- * - U+000C FF
15
- * - U+000D CR
16
- * - U+0020 SPACE.
17
- *
18
- * @see https://infra.spec.whatwg.org/#ascii-whitespace
19
- */
20
- static readonly whitespace: ReadonlyArray<string>;
21
- static getCol(value: string, offset: number): number;
22
- static getLine(value: string, offset: number): number;
23
- static getType(value: string, separators?: string[]): 1 | 13 | 18;
24
- static shiftLocation(token: Token, offset: number): {
25
- offset: number;
26
- line: number;
27
- column: number;
28
- };
29
- readonly offset: number;
30
- readonly type: number;
31
- readonly value: string;
32
- constructor(value: string, offset: number, originalValue: string, separators?: string[]);
33
- get length(): number;
34
- get origin(): string;
35
- /**
36
- *
37
- * @param value The token value or the token type or its list
38
- */
39
- includes(value: string | RegExp | number | (string | RegExp | number)[], caseInsensitive?: boolean): boolean;
40
- /**
41
- *
42
- * @param value The token value or the token type or its list
43
- */
44
- match(value: string | RegExp | number | (string | RegExp | number)[], caseInsensitive?: boolean): boolean;
45
- toJSON(): {
46
- type: number;
47
- value: string;
48
- offset: number;
49
- };
50
- toNumber(): number;
51
- unmatched(options?: UnmatchedResultOptions & {
52
- ref?: string;
53
- reason?: UnmatchedResultReason;
54
- }): UnmatchedResult;
4
+ /**
5
+ * @see https://github.com/csstree/csstree/blob/master/lib/tokenizer/types.js
6
+ */
7
+ static readonly Comma = 18;
8
+ static readonly Ident = 1;
9
+ static readonly WhiteSpace = 13;
10
+ /**
11
+ * ASCII whitespace is
12
+ * - U+0009 TAB
13
+ * - U+000A LF
14
+ * - U+000C FF
15
+ * - U+000D CR
16
+ * - U+0020 SPACE.
17
+ *
18
+ * @see https://infra.spec.whatwg.org/#ascii-whitespace
19
+ */
20
+ static readonly whitespace: ReadonlyArray<string>;
21
+ static getCol(value: string, offset: number): number;
22
+ static getLine(value: string, offset: number): number;
23
+ static getType(value: string, separators?: readonly string[]): 1 | 13 | 18;
24
+ static shiftLocation(
25
+ token: Readonly<Token>,
26
+ offset: number,
27
+ ): {
28
+ offset: number;
29
+ line: number;
30
+ column: number;
31
+ };
32
+ readonly offset: number;
33
+ readonly originalValue: string;
34
+ readonly type: number;
35
+ readonly value: string;
36
+ constructor(value: string, offset: number, originalValue: string, separators?: readonly string[]);
37
+ get length(): number;
38
+ clone(): Token;
39
+ /**
40
+ *
41
+ * @param value The token value or the token type or its list
42
+ */
43
+ includes(value: TokenValue, caseInsensitive?: boolean): boolean;
44
+ /**
45
+ *
46
+ * @param value The token value or the token type or its list
47
+ */
48
+ match(value: TokenValue, caseInsensitive?: boolean): boolean;
49
+ toJSON(): {
50
+ type: number;
51
+ value: string;
52
+ offset: number;
53
+ };
54
+ toNumber(): number;
55
+ unmatched(
56
+ options?: UnmatchedResultOptions & {
57
+ readonly ref?: string;
58
+ readonly reason?: UnmatchedResultReason;
59
+ },
60
+ ): UnmatchedResult;
55
61
  }