@markuplint/types 3.0.0-dev.24 → 3.0.0-dev.290

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 (173) hide show
  1. package/README.md +63 -61
  2. package/lib/check-multi-types.d.ts +2 -2
  3. package/lib/check-multi-types.js +9 -13
  4. package/lib/check.d.ts +7 -6
  5. package/lib/check.js +20 -30
  6. package/lib/css-syntax.d.ts +1 -1
  7. package/lib/css-syntax.js +60 -63
  8. package/lib/debug.js +2 -6
  9. package/lib/defs.d.ts +1 -1
  10. package/lib/defs.js +163 -91
  11. package/lib/enum.d.ts +4 -3
  12. package/lib/enum.js +7 -12
  13. package/lib/get-candidate.d.ts +1 -1
  14. package/lib/get-candidate.js +3 -8
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.js +3 -6
  17. package/lib/keyword-type.d.ts +2 -2
  18. package/lib/keyword-type.js +17 -21
  19. package/lib/list.d.ts +4 -3
  20. package/lib/list.js +9 -13
  21. package/lib/match-result.d.ts +4 -4
  22. package/lib/match-result.js +6 -12
  23. package/lib/number.d.ts +3 -3
  24. package/lib/number.js +11 -15
  25. package/lib/primitive/index.d.ts +7 -7
  26. package/lib/primitive/index.js +7 -17
  27. package/lib/primitive/is-float.js +1 -5
  28. package/lib/primitive/is-int.js +1 -5
  29. package/lib/primitive/is-non-zero-uint.js +1 -5
  30. package/lib/primitive/is-quantity.d.ts +1 -1
  31. package/lib/primitive/is-quantity.js +9 -13
  32. package/lib/primitive/is-uint.d.ts +1 -1
  33. package/lib/primitive/is-uint.js +1 -5
  34. package/lib/primitive/range.js +1 -5
  35. package/lib/primitive/split-unit.js +3 -7
  36. package/lib/rfc/is-bcp-47.d.ts +1 -1
  37. package/lib/rfc/is-bcp-47.js +3 -7
  38. package/lib/token/index.d.ts +2 -2
  39. package/lib/token/index.js +2 -7
  40. package/lib/token/token-collection.d.ts +13 -13
  41. package/lib/token/token-collection.js +55 -50
  42. package/lib/token/token.d.ts +11 -10
  43. package/lib/token/token.js +16 -24
  44. package/lib/token/types.d.ts +3 -0
  45. package/lib/types.d.ts +47 -46
  46. package/lib/types.js +1 -2
  47. package/lib/types.schema.d.ts +2 -2
  48. package/lib/types.schema.js +1 -3
  49. package/lib/w3c/check-serialized-permissions-policy.d.ts +1 -1
  50. package/lib/w3c/check-serialized-permissions-policy.js +16 -20
  51. package/lib/whatwg/check-autocomplete.d.ts +1 -1
  52. package/lib/whatwg/check-autocomplete.js +28 -32
  53. package/lib/whatwg/check-datetime/date-string.d.ts +1 -1
  54. package/lib/whatwg/check-datetime/date-string.js +9 -13
  55. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +1 -1
  56. package/lib/whatwg/check-datetime/datetime-tokens.js +43 -46
  57. package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
  58. package/lib/whatwg/check-datetime/duration-string.js +48 -44
  59. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +1 -1
  60. package/lib/whatwg/check-datetime/global-date-and-time-string.js +17 -21
  61. package/lib/whatwg/check-datetime/index.d.ts +1 -1
  62. package/lib/whatwg/check-datetime/index.js +25 -29
  63. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +1 -1
  64. package/lib/whatwg/check-datetime/local-date-and-time-string.js +25 -26
  65. package/lib/whatwg/check-datetime/month-string.d.ts +1 -1
  66. package/lib/whatwg/check-datetime/month-string.js +9 -13
  67. package/lib/whatwg/check-datetime/time-string.d.ts +1 -1
  68. package/lib/whatwg/check-datetime/time-string.js +9 -13
  69. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +3 -3
  70. package/lib/whatwg/check-datetime/time-zone-offset-string.js +16 -21
  71. package/lib/whatwg/check-datetime/week-string.d.ts +1 -1
  72. package/lib/whatwg/check-datetime/week-string.js +9 -13
  73. package/lib/whatwg/check-datetime/year-string.d.ts +1 -1
  74. package/lib/whatwg/check-datetime/year-string.js +9 -13
  75. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +1 -1
  76. package/lib/whatwg/check-datetime/yearless-date-string.js +9 -13
  77. package/lib/whatwg/check-mime-type.d.ts +1 -1
  78. package/lib/whatwg/check-mime-type.js +12 -18
  79. package/lib/whatwg/is-abs-url.d.ts +1 -1
  80. package/lib/whatwg/is-abs-url.js +1 -5
  81. package/lib/whatwg/is-browser-context-name.d.ts +3 -1
  82. package/lib/whatwg/is-browser-context-name.js +3 -5
  83. package/lib/whatwg/is-custom-element-name.d.ts +1 -1
  84. package/lib/whatwg/is-custom-element-name.js +1 -5
  85. package/lib/whatwg/is-itemprop-name.d.ts +1 -1
  86. package/lib/whatwg/is-itemprop-name.js +2 -6
  87. package/lib/whatwg/is-navigable-target-name.d.ts +11 -0
  88. package/lib/whatwg/is-navigable-target-name.js +20 -0
  89. package/package.json +19 -13
  90. package/types.schema.json +314 -311
  91. package/gen/specific-schema.json +0 -98
  92. package/gen/types.ts +0 -66
  93. package/lib/check.spec.js +0 -76
  94. package/lib/css-syntax.spec.d.ts +0 -1
  95. package/lib/css-syntax.spec.js +0 -157
  96. package/lib/list.spec.d.ts +0 -1
  97. package/lib/list.spec.js +0 -129
  98. package/lib/primitive/index.spec.d.ts +0 -1
  99. package/lib/primitive/index.spec.js +0 -62
  100. package/lib/rfc/is-bcp-47.spec.d.ts +0 -1
  101. package/lib/rfc/is-bcp-47.spec.js +0 -19
  102. package/lib/token/token-collection.spec.d.ts +0 -1
  103. package/lib/token/token-collection.spec.js +0 -144
  104. package/lib/w3c/check-serialized-permissions-policy.spec.d.ts +0 -1
  105. package/lib/w3c/check-serialized-permissions-policy.spec.js +0 -34
  106. package/lib/whatwg/check-autocomplete.spec.d.ts +0 -1
  107. package/lib/whatwg/check-autocomplete.spec.js +0 -379
  108. package/lib/whatwg/check-datetime/index.spec.d.ts +0 -1
  109. package/lib/whatwg/check-datetime/index.spec.js +0 -318
  110. package/lib/whatwg/check-mime-type.spec.d.ts +0 -1
  111. package/lib/whatwg/check-mime-type.spec.js +0 -58
  112. package/lib/whatwg/is-abs-url.spec.d.ts +0 -1
  113. package/lib/whatwg/is-abs-url.spec.js +0 -8
  114. package/patches/css-tree+2.3.1.patch +0 -23
  115. package/src/check-multi-types.ts +0 -35
  116. package/src/check.spec.ts +0 -83
  117. package/src/check.ts +0 -48
  118. package/src/css-syntax.spec.ts +0 -167
  119. package/src/css-syntax.ts +0 -188
  120. package/src/debug.ts +0 -3
  121. package/src/defs.ts +0 -811
  122. package/src/enum.ts +0 -25
  123. package/src/get-candidate.ts +0 -24
  124. package/src/index.ts +0 -3
  125. package/src/keyword-type.ts +0 -64
  126. package/src/list.spec.ts +0 -133
  127. package/src/list.ts +0 -34
  128. package/src/match-result.ts +0 -49
  129. package/src/number.ts +0 -46
  130. package/src/primitive/index.spec.ts +0 -65
  131. package/src/primitive/index.ts +0 -7
  132. package/src/primitive/is-float.ts +0 -8
  133. package/src/primitive/is-int.ts +0 -8
  134. package/src/primitive/is-non-zero-uint.ts +0 -8
  135. package/src/primitive/is-quantity.ts +0 -38
  136. package/src/primitive/is-uint.ts +0 -15
  137. package/src/primitive/range.ts +0 -14
  138. package/src/primitive/split-unit.ts +0 -20
  139. package/src/rfc/is-bcp-47.spec.ts +0 -23
  140. package/src/rfc/is-bcp-47.ts +0 -13
  141. package/src/token/index.ts +0 -2
  142. package/src/token/token-collection.spec.ts +0 -147
  143. package/src/token/token-collection.ts +0 -444
  144. package/src/token/token.ts +0 -144
  145. package/src/types.schema.ts +0 -1113
  146. package/src/types.ts +0 -118
  147. package/src/w3c/check-serialized-permissions-policy.spec.ts +0 -38
  148. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  149. package/src/whatwg/check-autocomplete.spec.ts +0 -387
  150. package/src/whatwg/check-autocomplete.ts +0 -380
  151. package/src/whatwg/check-datetime/date-string.ts +0 -44
  152. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  153. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  154. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  155. package/src/whatwg/check-datetime/index.spec.ts +0 -333
  156. package/src/whatwg/check-datetime/index.ts +0 -36
  157. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  158. package/src/whatwg/check-datetime/month-string.ts +0 -31
  159. package/src/whatwg/check-datetime/time-string.ts +0 -49
  160. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  161. package/src/whatwg/check-datetime/week-string.ts +0 -41
  162. package/src/whatwg/check-datetime/year-string.ts +0 -26
  163. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  164. package/src/whatwg/check-mime-type.spec.ts +0 -59
  165. package/src/whatwg/check-mime-type.ts +0 -46
  166. package/src/whatwg/is-abs-url.spec.ts +0 -8
  167. package/src/whatwg/is-abs-url.ts +0 -31
  168. package/src/whatwg/is-browser-context-name.ts +0 -16
  169. package/src/whatwg/is-custom-element-name.ts +0 -76
  170. package/src/whatwg/is-itemprop-name.ts +0 -17
  171. package/tsconfig.test.json +0 -3
  172. package/tsconfig.tsbuildinfo +0 -1
  173. /package/lib/{check.spec.d.ts → token/types.js} +0 -0
@@ -1,380 +0,0 @@
1
- import type { Expect } from '..';
2
- import type { CustomSyntaxChecker } from '../types';
3
-
4
- import { log } from '../debug';
5
- import { getCandidate } from '../get-candidate';
6
- import { matched } from '../match-result';
7
- import { TokenCollection } from '../token';
8
-
9
- const acLog = log.extend('autocomplete');
10
-
11
- /**
12
- * https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-section
13
- */
14
- const namedGroup = /^section-/i;
15
-
16
- /**
17
- * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-shipping
18
- */
19
- const partOfAddress = ['shipping', 'billing'];
20
-
21
- /**
22
- * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field
23
- */
24
- const autofillFieldNames = [
25
- 'name',
26
- 'honorific-prefix',
27
- 'given-name',
28
- 'additional-name',
29
- 'family-name',
30
- 'honorific-suffix',
31
- 'nickname',
32
- 'username',
33
- 'new-password',
34
- 'current-password',
35
- 'one-time-code',
36
- 'organization-title',
37
- 'organization',
38
- 'street-address',
39
- 'address-line1',
40
- 'address-line2',
41
- 'address-line3',
42
- 'address-level4',
43
- 'address-level3',
44
- 'address-level2',
45
- 'address-level1',
46
- 'country',
47
- 'country-name',
48
- 'postal-code',
49
- 'cc-name',
50
- 'cc-given-name',
51
- 'cc-additional-name',
52
- 'cc-family-name',
53
- 'cc-number',
54
- 'cc-exp',
55
- 'cc-exp-month',
56
- 'cc-exp-year',
57
- 'cc-csc',
58
- 'cc-type',
59
- 'transaction-currency',
60
- 'transaction-amount',
61
- 'language',
62
- 'bday',
63
- 'bday-day',
64
- 'bday-month',
65
- 'bday-year',
66
- 'sex',
67
- 'url',
68
- 'photo',
69
- ];
70
-
71
- /**
72
- * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-home
73
- */
74
- const contactingTokens = ['home', 'work', 'mobile', 'fax', 'pager'];
75
-
76
- /**
77
- * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:ascii-case-insensitive-7
78
- */
79
- const contactableFieldNames = [
80
- 'tel',
81
- 'tel-country-code',
82
- 'tel-national',
83
- 'tel-area-code',
84
- 'tel-local',
85
- 'tel-local-prefix',
86
- 'tel-local-suffix',
87
- 'tel-extension',
88
- 'email',
89
- 'impp',
90
- ];
91
-
92
- /**
93
- * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-webauthn
94
- */
95
- const webauthnFieldNames = ['webauthn'];
96
-
97
- const URL_AUTOCOMPLETE = 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete';
98
- const URL_ON_OFF =
99
- 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2';
100
- const URL_NAMED_GROUP =
101
- 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-section';
102
- const URL_PART_OF_ADDRESS =
103
- 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-shipping';
104
- const URL_AUTOFILL_FIELD = 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field';
105
- const URL_CONTACTABLE_FIELD =
106
- 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel';
107
-
108
- /**
109
- * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete
110
- */
111
- export const checkAutoComplete: CustomSyntaxChecker = () => value => {
112
- let hasNamedGroup = false;
113
- let hasPartOfAddress = false;
114
- let hasContactingToken = false;
115
-
116
- const tokens = new TokenCollection(value, {
117
- disallowToSurroundBySpaces: false,
118
- allowEmpty: false,
119
- ordered: true,
120
- unique: true,
121
- caseInsensitive: true,
122
- });
123
-
124
- const listingChecked = tokens.check({
125
- expects: [
126
- {
127
- type: 'format',
128
- value: 'autocomplete',
129
- },
130
- ],
131
- ref: URL_AUTOCOMPLETE,
132
- });
133
- if (!listingChecked.matched) {
134
- acLog('Unmatch: %s', listingChecked.reason);
135
- return listingChecked;
136
- }
137
-
138
- const identTokens = tokens.getIdentTokens();
139
- const headAndTail1 = identTokens.headAndTail();
140
- let { head, tail } = headAndTail1;
141
- if (!head) {
142
- // Never
143
- throw new Error('TokenCollection is empty');
144
- }
145
-
146
- // > When wearing the autofill anchor mantle, the autocomplete attribute,
147
- // > if specified, must have a value that is
148
- // > an ordered set of space-separated tokens consisting of
149
- // > just autofill detail tokens
150
- // > (i.e. the "on" and "off" keywords are not allowed).
151
- if (head.match(['on', 'off'], true)) {
152
- if (tail.length) {
153
- acLog('[Unmatched ("%s")] Unexpected pair with "on" or "off": "%s"', value, tail.value);
154
- return tail[0].unmatched({
155
- reason: 'extra-token',
156
- expects: [
157
- {
158
- type: 'format',
159
- value: 'autocomplete',
160
- },
161
- ],
162
- ref: URL_ON_OFF,
163
- });
164
- }
165
-
166
- return matched();
167
- }
168
-
169
- // > Optionally, a token whose first eight characters are
170
- // > an ASCII case-insensitive match for the string "section-",
171
- // > meaning that the field belongs to the named group.
172
- if (head.match(namedGroup, true)) {
173
- hasNamedGroup = true;
174
- const sectionToken = tail.search(namedGroup);
175
- if (sectionToken) {
176
- acLog('[Unmatched ("%s")] Deprecated in autofill named group: "%s"', value, sectionToken.value);
177
- return sectionToken.unmatched({
178
- partName: 'autofill named group',
179
- reason: 'duplicated',
180
- ref: URL_NAMED_GROUP,
181
- });
182
- }
183
-
184
- const headAndTail2 = tail.headAndTail();
185
- head = headAndTail2.head;
186
- tail = headAndTail2.tail;
187
-
188
- if (!head) {
189
- // Missing autofill field name but it is valid
190
- return matched();
191
- }
192
- }
193
-
194
- // > Optionally, a token that is an ASCII case-insensitive match for
195
- // > one of the following strings:
196
- // > - "shipping", meaning the field is part of the shipping address or contact information
197
- // > - "billing", meaning the field is part of the billing address or contact information
198
- if (head.match(partOfAddress, true)) {
199
- hasPartOfAddress = true;
200
- const partToken = tail.search(partOfAddress);
201
- if (partToken) {
202
- acLog('[Unmatched ("%s")] Duplicated values: "%s"', value, partToken.value);
203
- return partToken.unmatched({
204
- reason: 'duplicated',
205
- expects: [
206
- {
207
- type: 'format',
208
- value: 'autocomplete',
209
- },
210
- ],
211
- ref: URL_PART_OF_ADDRESS,
212
- });
213
- }
214
-
215
- const headAndTail3 = tail.headAndTail();
216
- head = headAndTail3.head;
217
- tail = headAndTail3.tail;
218
-
219
- if (!head) {
220
- // Missing autofill field name but it is valid
221
- return matched();
222
- }
223
- }
224
-
225
- if (head.match(contactingTokens, true)) {
226
- hasContactingToken = true;
227
- const contactableFiledToken = tail[0];
228
- if (!contactableFiledToken) {
229
- // Missing autofill field name but it is valid
230
- return matched();
231
- }
232
-
233
- if (!contactableFiledToken.match(contactableFieldNames, true)) {
234
- const candidate = getCandidate(contactableFiledToken.value, contactableFieldNames);
235
- acLog('[Unmatched ("%s")] Unexpected token: "%s"', value, contactableFiledToken.value);
236
- return contactableFiledToken.unmatched({
237
- reason: 'unexpected-token',
238
- expects: contactableFieldNames.slice().map(token => ({
239
- type: 'const' as const,
240
- value: token,
241
- })),
242
- candidate,
243
- ref: URL_CONTACTABLE_FIELD,
244
- });
245
- }
246
-
247
- if (tail[1]) {
248
- if (tail[1].match(webauthnFieldNames)) {
249
- return matched();
250
- }
251
-
252
- const candidate = getCandidate(tail[1].value, webauthnFieldNames);
253
-
254
- if (candidate) {
255
- acLog(
256
- '[Unmatched ("%s")] Unnecessarily token: "%s", Do you mean "%s"? ',
257
- value,
258
- tail[1].value,
259
- candidate,
260
- );
261
- } else {
262
- acLog('[Unmatched ("%s")] Unnecessarily token: "%s"', value, tail[1].value);
263
- }
264
-
265
- return tail[1].unmatched({
266
- reason: 'extra-token',
267
- expects: [
268
- {
269
- type: 'format',
270
- value: 'autocomplete',
271
- },
272
- ],
273
- ref: URL_AUTOFILL_FIELD,
274
- });
275
- }
276
-
277
- return matched();
278
- }
279
-
280
- if (head.match([...autofillFieldNames, ...contactableFieldNames], true)) {
281
- if (tail.length) {
282
- if (tail[0].match(webauthnFieldNames)) {
283
- return matched();
284
- }
285
-
286
- const candidate = getCandidate(tail[0].value, webauthnFieldNames);
287
-
288
- if (candidate) {
289
- acLog(
290
- '[Unmatched ("%s")] Unnecessarily token: "%s", Do you mean "%s"? ',
291
- value,
292
- tail[0].value,
293
- candidate,
294
- );
295
- } else {
296
- acLog('[Unmatched ("%s")] Unnecessarily token: "%s"', value, tail[0].value);
297
- }
298
-
299
- return tail[0].unmatched({
300
- reason: 'extra-token',
301
- expects: [
302
- {
303
- type: 'format',
304
- value: 'autocomplete',
305
- },
306
- ],
307
- ref: URL_AUTOFILL_FIELD,
308
- });
309
- }
310
-
311
- return matched();
312
- }
313
-
314
- if (head.match(webauthnFieldNames)) {
315
- return matched();
316
- }
317
-
318
- const expects: Expect[] = [
319
- {
320
- type: 'common',
321
- value: 'autofill field name',
322
- },
323
- ];
324
- let candidate: string | undefined;
325
-
326
- if (!hasNamedGroup) {
327
- expects.unshift({
328
- type: 'common',
329
- value: 'autofill named group',
330
- });
331
-
332
- // Potentially typo a named group
333
- const [prefix, namedGroupStr] = head.value.split('-');
334
- const candidatePrefix = getCandidate(prefix, 'section');
335
- if (candidatePrefix) {
336
- candidate = `${candidatePrefix}-${namedGroupStr || ''}`;
337
- }
338
- } else if (!hasPartOfAddress) {
339
- expects.unshift(
340
- ...partOfAddress
341
- .slice()
342
- .reverse()
343
- .map(token => ({
344
- type: 'const' as const,
345
- value: token,
346
- })),
347
- );
348
-
349
- candidate = getCandidate(
350
- head.value,
351
- partOfAddress,
352
- autofillFieldNames,
353
- contactingTokens,
354
- contactableFieldNames,
355
- );
356
- } else if (!hasContactingToken) {
357
- expects.push(
358
- ...contactingTokens.slice().map(token => ({
359
- type: 'const' as const,
360
- value: token,
361
- })),
362
- );
363
-
364
- candidate = getCandidate(head.value, autofillFieldNames, contactingTokens, contactableFieldNames);
365
- }
366
-
367
- candidate = candidate || getCandidate(head.value, autofillFieldNames);
368
-
369
- if (candidate) {
370
- acLog('[Unmatched ("%s")] Unexpected token: "%s", Do you mean "%s"? ', value, head.value, candidate);
371
- } else {
372
- acLog('[Unmatched ("%s")] Unexpected token: "%s"', value, head.value);
373
- }
374
- return head.unmatched({
375
- reason: 'unexpected-token',
376
- expects,
377
- candidate,
378
- ref: URL_AUTOFILL_FIELD,
379
- });
380
- };
@@ -1,44 +0,0 @@
1
- import type { CustomSyntaxChecker } from '../../types';
2
-
3
- import { log } from '../../debug';
4
- import { TokenCollection } from '../../token';
5
-
6
- import { datetimeTokenCheck } from './datetime-tokens';
7
-
8
- /**
9
- * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#dates
10
- */
11
- export const checkDateString: CustomSyntaxChecker = () =>
12
- function checkDateString(value) {
13
- log('CHECK: date-string');
14
-
15
- const tokens = TokenCollection.fromPatterns(value, [
16
- // YYYY
17
- /[^-]*/,
18
- // -
19
- /[^0-9]?/,
20
- // MM
21
- /[^-]*/,
22
- // -
23
- /[^0-9]/,
24
- // DD
25
- /.[0-9]*/,
26
- ]);
27
-
28
- log('Date: "%s" => %O', tokens.value, tokens);
29
-
30
- const res = tokens.eachCheck(
31
- datetimeTokenCheck.year,
32
- datetimeTokenCheck.hyphen,
33
- datetimeTokenCheck.month,
34
- datetimeTokenCheck.hyphen,
35
- datetimeTokenCheck.date,
36
- datetimeTokenCheck.extra,
37
- );
38
-
39
- if (!res.matched) {
40
- log('Failed: %O', res);
41
- }
42
-
43
- return res;
44
- };