@markuplint/types 3.0.0-alpha.6 → 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 (107) hide show
  1. package/README.md +12 -8
  2. package/lib/check-multi-types.d.ts +1 -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 +1 -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 +3 -3
  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 +1 -1
  22. package/lib/primitive/split-unit.js +2 -2
  23. package/lib/rfc/is-bcp-47.spec.js +9 -8
  24. package/lib/token/token-collection.d.ts +20 -14
  25. package/lib/token/token-collection.js +30 -23
  26. package/lib/token/token-collection.spec.js +156 -134
  27. package/lib/token/token.d.ts +10 -9
  28. package/lib/token/token.js +19 -20
  29. package/lib/token/types.d.ts +3 -0
  30. package/lib/token/types.js +2 -0
  31. package/lib/types.d.ts +44 -44
  32. package/lib/types.schema.d.ts +369 -318
  33. package/lib/w3c/check-serialized-permissions-policy.spec.js +30 -28
  34. package/lib/whatwg/check-autocomplete.js +6 -6
  35. package/lib/whatwg/check-autocomplete.spec.js +361 -360
  36. package/lib/whatwg/check-datetime/datetime-tokens.js +9 -6
  37. package/lib/whatwg/check-datetime/duration-string.js +12 -2
  38. package/lib/whatwg/check-datetime/index.spec.js +277 -276
  39. package/lib/whatwg/check-datetime/local-date-and-time-string.js +6 -2
  40. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +1 -1
  41. package/lib/whatwg/check-datetime/time-zone-offset-string.js +3 -2
  42. package/lib/whatwg/check-mime-type.js +1 -1
  43. package/lib/whatwg/check-mime-type.spec.js +53 -52
  44. package/lib/whatwg/is-abs-url.spec.js +6 -5
  45. package/lib/whatwg/is-itemprop-name.js +1 -1
  46. package/package.json +13 -11
  47. package/{src/check.spec.ts → test/check.spec.js} +7 -1
  48. package/{src/css-syntax.spec.ts → test/css-syntax.spec.js} +10 -12
  49. package/{src/list.spec.ts → test/list.spec.js} +7 -7
  50. package/{src/primitive/index.spec.ts → test/primitive/index.spec.js} +1 -1
  51. package/{src/rfc/is-bcp-47.spec.ts → test/rfc/is-bcp-47.spec.js} +1 -1
  52. package/{src/token/token-collection.spec.ts → test/token/token-collection.spec.js} +2 -3
  53. package/{src/w3c/check-serialized-permissions-policy.spec.ts → test/w3c/check-serialized-permissions-policy.spec.js} +1 -3
  54. package/{src/whatwg/check-autocomplete.spec.ts → test/whatwg/check-autocomplete.spec.js} +1 -1
  55. package/{src/whatwg/check-datetime/index.spec.ts → test/whatwg/check-datetime/index.spec.js} +18 -15
  56. package/{src/whatwg/check-mime-type.spec.ts → test/whatwg/check-mime-type.spec.js} +1 -1
  57. package/{src/whatwg/is-abs-url.spec.ts → test/whatwg/is-abs-url.spec.js} +1 -1
  58. package/types.schema.json +369 -318
  59. package/gen/specific-schema.json +0 -98
  60. package/gen/types.ts +0 -66
  61. package/src/check-multi-types.ts +0 -35
  62. package/src/check.ts +0 -48
  63. package/src/css-syntax.ts +0 -188
  64. package/src/debug.ts +0 -3
  65. package/src/defs.ts +0 -811
  66. package/src/enum.ts +0 -25
  67. package/src/get-candidate.ts +0 -24
  68. package/src/index.ts +0 -3
  69. package/src/keyword-type.ts +0 -64
  70. package/src/list.ts +0 -34
  71. package/src/match-result.ts +0 -49
  72. package/src/number.ts +0 -46
  73. package/src/primitive/index.ts +0 -7
  74. package/src/primitive/is-float.ts +0 -8
  75. package/src/primitive/is-int.ts +0 -8
  76. package/src/primitive/is-non-zero-uint.ts +0 -8
  77. package/src/primitive/is-quantity.ts +0 -38
  78. package/src/primitive/is-uint.ts +0 -15
  79. package/src/primitive/range.ts +0 -14
  80. package/src/primitive/split-unit.ts +0 -20
  81. package/src/rfc/is-bcp-47.ts +0 -13
  82. package/src/token/index.ts +0 -2
  83. package/src/token/token-collection.ts +0 -444
  84. package/src/token/token.ts +0 -144
  85. package/src/types.schema.ts +0 -1062
  86. package/src/types.ts +0 -118
  87. package/src/w3c/check-serialized-permissions-policy.ts +0 -303
  88. package/src/whatwg/check-autocomplete.ts +0 -380
  89. package/src/whatwg/check-datetime/date-string.ts +0 -44
  90. package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
  91. package/src/whatwg/check-datetime/duration-string.ts +0 -399
  92. package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
  93. package/src/whatwg/check-datetime/index.ts +0 -36
  94. package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
  95. package/src/whatwg/check-datetime/month-string.ts +0 -31
  96. package/src/whatwg/check-datetime/time-string.ts +0 -49
  97. package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
  98. package/src/whatwg/check-datetime/week-string.ts +0 -41
  99. package/src/whatwg/check-datetime/year-string.ts +0 -26
  100. package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
  101. package/src/whatwg/check-mime-type.ts +0 -46
  102. package/src/whatwg/is-abs-url.ts +0 -31
  103. package/src/whatwg/is-browser-context-name.ts +0 -16
  104. package/src/whatwg/is-custom-element-name.ts +0 -76
  105. package/src/whatwg/is-itemprop-name.ts +0 -17
  106. package/tsconfig.test.json +0 -3
  107. package/tsconfig.tsbuildinfo +0 -1
package/lib/list.spec.js CHANGED
@@ -1,129 +1,130 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const list_1 = require("./list");
1
+ 'use strict';
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ const list_1 = require('./list');
4
5
  test('Zero space', () => {
5
- const type = { token: 'Zero', separator: 'space' };
6
- expect((0, list_1.checkList)('0', type).matched).toBe(true);
7
- expect((0, list_1.checkList)(' 0 ', type).matched).toBe(true);
8
- expect((0, list_1.checkList)(' 0 0', type).matched).toBe(true);
9
- expect((0, list_1.checkList)(' 0 0 ', type).matched).toBe(true);
10
- expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(true);
11
- expect((0, list_1.checkList)('0 0 0 0', type).matched).toBe(true);
12
- expect((0, list_1.checkList)('0 0 0 0', type).matched).toBe(true);
13
- expect((0, list_1.checkList)('1', type).matched).toBe(false);
14
- expect((0, list_1.checkList)(' 1 ', type).matched).toBe(false);
15
- expect((0, list_1.checkList)(' 1 0', type).matched).toBe(false);
16
- expect((0, list_1.checkList)(' 1 0 ', type).matched).toBe(false);
17
- expect((0, list_1.checkList)('0 1 0 ', type).matched).toBe(false);
18
- expect((0, list_1.checkList)('0 1 0 0', type).matched).toBe(false);
19
- expect((0, list_1.checkList)('0 1 0 0', type).matched).toBe(false);
6
+ const type = { token: 'Zero', separator: 'space' };
7
+ expect((0, list_1.checkList)('0', type).matched).toBe(true);
8
+ expect((0, list_1.checkList)(' 0 ', type).matched).toBe(true);
9
+ expect((0, list_1.checkList)(' 0 0', type).matched).toBe(true);
10
+ expect((0, list_1.checkList)(' 0 0 ', type).matched).toBe(true);
11
+ expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(true);
12
+ expect((0, list_1.checkList)('0 0 0 0', type).matched).toBe(true);
13
+ expect((0, list_1.checkList)('0 0 0 0', type).matched).toBe(true);
14
+ expect((0, list_1.checkList)('1', type).matched).toBe(false);
15
+ expect((0, list_1.checkList)(' 1 ', type).matched).toBe(false);
16
+ expect((0, list_1.checkList)(' 1 0', type).matched).toBe(false);
17
+ expect((0, list_1.checkList)(' 1 0 ', type).matched).toBe(false);
18
+ expect((0, list_1.checkList)('0 1 0 ', type).matched).toBe(false);
19
+ expect((0, list_1.checkList)('0 1 0 0', type).matched).toBe(false);
20
+ expect((0, list_1.checkList)('0 1 0 0', type).matched).toBe(false);
20
21
  });
21
22
  test('Zero comma', () => {
22
- const type = { token: 'Zero', separator: 'comma' };
23
- expect((0, list_1.checkList)('0', type).matched).toBe(true);
24
- expect((0, list_1.checkList)(' 0 ', type).matched).toBe(true);
25
- expect((0, list_1.checkList)(' 0 0', type).matched).toBe(false);
26
- expect((0, list_1.checkList)(' 0,0', type).matched).toBe(true);
27
- expect((0, list_1.checkList)(' 0,,0 ', type).matched).toBe(false);
28
- expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(false);
29
- expect((0, list_1.checkList)(' 0,0,0,0 ', type).matched).toBe(true);
30
- expect((0, list_1.checkList)('0, 0, 0 , 0', type).matched).toBe(true);
31
- expect((0, list_1.checkList)('0,0,0,0,', type).matched).toBe(false);
32
- expect((0, list_1.checkList)(',0,0,0,0', type).matched).toBe(false);
23
+ const type = { token: 'Zero', separator: 'comma' };
24
+ expect((0, list_1.checkList)('0', type).matched).toBe(true);
25
+ expect((0, list_1.checkList)(' 0 ', type).matched).toBe(true);
26
+ expect((0, list_1.checkList)(' 0 0', type).matched).toBe(false);
27
+ expect((0, list_1.checkList)(' 0,0', type).matched).toBe(true);
28
+ expect((0, list_1.checkList)(' 0,,0 ', type).matched).toBe(false);
29
+ expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(false);
30
+ expect((0, list_1.checkList)(' 0,0,0,0 ', type).matched).toBe(true);
31
+ expect((0, list_1.checkList)('0, 0, 0 , 0', type).matched).toBe(true);
32
+ expect((0, list_1.checkList)('0,0,0,0,', type).matched).toBe(false);
33
+ expect((0, list_1.checkList)(',0,0,0,0', type).matched).toBe(false);
33
34
  });
34
35
  test('Zero comma (disallowToSurroundBySpaces)', () => {
35
- const type = { token: 'Zero', separator: 'comma', disallowToSurroundBySpaces: true };
36
- expect((0, list_1.checkList)('0', type).matched).toBe(true);
37
- expect((0, list_1.checkList)(' 0 ', type).matched).toBe(false);
38
- expect((0, list_1.checkList)(' 0 0', type).matched).toBe(false);
39
- expect((0, list_1.checkList)(' 0,0', type).matched).toBe(false);
40
- expect((0, list_1.checkList)(' 0,,0 ', type).matched).toBe(false);
41
- expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(false);
42
- expect((0, list_1.checkList)(' 0,0,0,0 ', type).matched).toBe(false);
43
- expect((0, list_1.checkList)('0, 0, 0 , 0', type).matched).toBe(false);
44
- expect((0, list_1.checkList)('0,0,0,0', type).matched).toBe(true);
45
- expect((0, list_1.checkList)('0,0,0,0,', type).matched).toBe(false);
46
- expect((0, list_1.checkList)(',0,0,0,0', type).matched).toBe(false);
36
+ const type = { token: 'Zero', separator: 'comma', disallowToSurroundBySpaces: true };
37
+ expect((0, list_1.checkList)('0', type).matched).toBe(true);
38
+ expect((0, list_1.checkList)(' 0 ', type).matched).toBe(false);
39
+ expect((0, list_1.checkList)(' 0 0', type).matched).toBe(false);
40
+ expect((0, list_1.checkList)(' 0,0', type).matched).toBe(false);
41
+ expect((0, list_1.checkList)(' 0,,0 ', type).matched).toBe(false);
42
+ expect((0, list_1.checkList)('0 0 0 ', type).matched).toBe(false);
43
+ expect((0, list_1.checkList)(' 0,0,0,0 ', type).matched).toBe(false);
44
+ expect((0, list_1.checkList)('0, 0, 0 , 0', type).matched).toBe(false);
45
+ expect((0, list_1.checkList)('0,0,0,0', type).matched).toBe(true);
46
+ expect((0, list_1.checkList)('0,0,0,0,', type).matched).toBe(false);
47
+ expect((0, list_1.checkList)(',0,0,0,0', type).matched).toBe(false);
47
48
  });
48
49
  test('Location of the token', () => {
49
- const type = { token: 'Accept', separator: 'comma' };
50
- expect((0, list_1.checkList)('x/y;a=b', type)).toStrictEqual({
51
- candidate: 'x/y',
52
- column: 4,
53
- expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
54
- length: 4,
55
- line: 1,
56
- matched: false,
57
- offset: 3,
58
- raw: ';a=b',
59
- reason: 'extra-token',
60
- partName: 'the content of the list',
61
- ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
62
- });
63
- expect((0, list_1.checkList)('x/y,x/y;a=b', type)).toStrictEqual({
64
- candidate: 'x/y',
65
- column: 8,
66
- expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
67
- length: 4,
68
- line: 1,
69
- matched: false,
70
- offset: 7,
71
- raw: ';a=b',
72
- reason: 'extra-token',
73
- partName: 'the content of the list',
74
- ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
75
- });
76
- expect((0, list_1.checkList)('x/y\n,\nx/y;a=b', type)).toStrictEqual({
77
- candidate: 'x/y',
78
- column: 4,
79
- expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
80
- length: 4,
81
- line: 3,
82
- matched: false,
83
- offset: 9,
84
- raw: ';a=b',
85
- reason: 'extra-token',
86
- partName: 'the content of the list',
87
- ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
88
- });
50
+ const type = { token: 'Accept', separator: 'comma' };
51
+ expect((0, list_1.checkList)('x/y;a=b', type)).toStrictEqual({
52
+ candidate: 'x/y',
53
+ column: 4,
54
+ expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
55
+ length: 4,
56
+ line: 1,
57
+ matched: false,
58
+ offset: 3,
59
+ raw: ';a=b',
60
+ reason: 'extra-token',
61
+ partName: 'the content of the list',
62
+ ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
63
+ });
64
+ expect((0, list_1.checkList)('x/y,x/y;a=b', type)).toStrictEqual({
65
+ candidate: 'x/y',
66
+ column: 8,
67
+ expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
68
+ length: 4,
69
+ line: 1,
70
+ matched: false,
71
+ offset: 7,
72
+ raw: ';a=b',
73
+ reason: 'extra-token',
74
+ partName: 'the content of the list',
75
+ ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
76
+ });
77
+ expect((0, list_1.checkList)('x/y\n,\nx/y;a=b', type)).toStrictEqual({
78
+ candidate: 'x/y',
79
+ column: 4,
80
+ expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
81
+ length: 4,
82
+ line: 3,
83
+ matched: false,
84
+ offset: 9,
85
+ raw: ';a=b',
86
+ reason: 'extra-token',
87
+ partName: 'the content of the list',
88
+ ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
89
+ });
89
90
  });
90
91
  test('Expected comma', () => {
91
- const type = { token: 'Accept', separator: 'comma' };
92
- expect((0, list_1.checkList)('x/y,', type)).toStrictEqual({
93
- column: 4,
94
- expects: undefined,
95
- length: 1,
96
- line: 1,
97
- matched: false,
98
- offset: 3,
99
- raw: ',',
100
- reason: 'extra-token',
101
- ref: null,
102
- });
103
- expect((0, list_1.checkList)('x/y,,x/y', type)).toStrictEqual({
104
- column: 5,
105
- expects: undefined,
106
- length: 1,
107
- line: 1,
108
- matched: false,
109
- offset: 4,
110
- raw: ',',
111
- reason: 'unexpected-comma',
112
- ref: null,
113
- });
92
+ const type = { token: 'Accept', separator: 'comma' };
93
+ expect((0, list_1.checkList)('x/y,', type)).toStrictEqual({
94
+ column: 4,
95
+ expects: undefined,
96
+ length: 1,
97
+ line: 1,
98
+ matched: false,
99
+ offset: 3,
100
+ raw: ',',
101
+ reason: 'extra-token',
102
+ ref: null,
103
+ });
104
+ expect((0, list_1.checkList)('x/y,,x/y', type)).toStrictEqual({
105
+ column: 5,
106
+ expects: undefined,
107
+ length: 1,
108
+ line: 1,
109
+ matched: false,
110
+ offset: 4,
111
+ raw: ',',
112
+ reason: 'unexpected-comma',
113
+ ref: null,
114
+ });
114
115
  });
115
116
  test('Missing comma', () => {
116
- const type = { token: 'Accept', separator: 'comma' };
117
- expect((0, list_1.checkList)('a/b,x/y a/z', type)).toStrictEqual({
118
- column: 9,
119
- candidate: ',a/z',
120
- expects: undefined,
121
- length: 3,
122
- line: 1,
123
- matched: false,
124
- offset: 8,
125
- raw: 'a/z',
126
- reason: 'missing-comma',
127
- ref: null,
128
- });
117
+ const type = { token: 'Accept', separator: 'comma' };
118
+ expect((0, list_1.checkList)('a/b,x/y a/z', type)).toStrictEqual({
119
+ column: 9,
120
+ candidate: ',a/z',
121
+ expects: undefined,
122
+ length: 3,
123
+ line: 1,
124
+ matched: false,
125
+ offset: 8,
126
+ raw: 'a/z',
127
+ reason: 'missing-comma',
128
+ ref: null,
129
+ });
129
130
  });
@@ -8,8 +8,8 @@ import type {
8
8
  export declare function matches(
9
9
  checker: FormattedPrimitiveTypeCheck,
10
10
  options?: UnmatchedResultOptions & {
11
- ref?: string;
12
- reason?: UnmatchedResultReason;
11
+ readonly ref?: string;
12
+ readonly reason?: UnmatchedResultReason;
13
13
  },
14
14
  ): (value: string) => MatchedResult | UnmatchedResult;
15
15
  export declare function matched(): MatchedResult;
@@ -17,6 +17,6 @@ export declare function unmatched(
17
17
  value: string,
18
18
  reason?: UnmatchedResultReason,
19
19
  options?: UnmatchedResultOptions & {
20
- ref?: string;
20
+ readonly ref?: string;
21
21
  },
22
22
  ): UnmatchedResult;
@@ -18,10 +18,11 @@ function matched() {
18
18
  }
19
19
  exports.matched = matched;
20
20
  function unmatched(value, reason, options) {
21
+ var _a;
21
22
  return {
22
23
  ...options,
23
24
  matched: false,
24
- ref: (options === null || options === void 0 ? void 0 : options.ref) || null,
25
+ ref: (_a = options === null || options === void 0 ? void 0 : options.ref) !== null && _a !== void 0 ? _a : null,
25
26
  raw: value,
26
27
  offset: 0,
27
28
  length: value.length,
package/lib/number.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { Result } from './types';
2
2
  import type { Number } from './types.schema';
3
- export declare function checkNumber(value: string, type: Number, ref?: string): Result;
3
+ export declare function checkNumber(value: string, type: Readonly<Number>, ref?: string): Result;
@@ -1,62 +1,63 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const _1 = require(".");
1
+ 'use strict';
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ const _1 = require('.');
4
5
  test('int', () => {
5
- expect((0, _1.isInt)('0')).toBe(true);
6
- expect((0, _1.isInt)('1')).toBe(true);
7
- expect((0, _1.isInt)('-0')).toBe(true);
8
- expect((0, _1.isInt)('-1')).toBe(true);
9
- expect((0, _1.isInt)('10')).toBe(true);
10
- expect((0, _1.isInt)('100')).toBe(true);
11
- expect((0, _1.isInt)('1.00')).toBe(false);
12
- expect((0, _1.isInt)('.001')).toBe(false);
13
- expect((0, _1.isInt)(' 1 ')).toBe(false);
14
- expect((0, _1.isInt)('- 1')).toBe(false);
6
+ expect((0, _1.isInt)('0')).toBe(true);
7
+ expect((0, _1.isInt)('1')).toBe(true);
8
+ expect((0, _1.isInt)('-0')).toBe(true);
9
+ expect((0, _1.isInt)('-1')).toBe(true);
10
+ expect((0, _1.isInt)('10')).toBe(true);
11
+ expect((0, _1.isInt)('100')).toBe(true);
12
+ expect((0, _1.isInt)('1.00')).toBe(false);
13
+ expect((0, _1.isInt)('.001')).toBe(false);
14
+ expect((0, _1.isInt)(' 1 ')).toBe(false);
15
+ expect((0, _1.isInt)('- 1')).toBe(false);
15
16
  });
16
17
  test('uint', () => {
17
- expect((0, _1.isUint)('0')).toBe(true);
18
- expect((0, _1.isUint)('1')).toBe(true);
19
- expect((0, _1.isUint)('10')).toBe(true);
20
- expect((0, _1.isUint)('100')).toBe(true);
21
- expect((0, _1.isUint)('-0')).toBe(false);
22
- expect((0, _1.isUint)('-1')).toBe(false);
23
- expect((0, _1.isUint)('1.00')).toBe(false);
24
- expect((0, _1.isUint)('.001')).toBe(false);
25
- expect((0, _1.isUint)(' 1 ')).toBe(false);
26
- expect((0, _1.isUint)('- 1')).toBe(false);
18
+ expect((0, _1.isUint)('0')).toBe(true);
19
+ expect((0, _1.isUint)('1')).toBe(true);
20
+ expect((0, _1.isUint)('10')).toBe(true);
21
+ expect((0, _1.isUint)('100')).toBe(true);
22
+ expect((0, _1.isUint)('-0')).toBe(false);
23
+ expect((0, _1.isUint)('-1')).toBe(false);
24
+ expect((0, _1.isUint)('1.00')).toBe(false);
25
+ expect((0, _1.isUint)('.001')).toBe(false);
26
+ expect((0, _1.isUint)(' 1 ')).toBe(false);
27
+ expect((0, _1.isUint)('- 1')).toBe(false);
27
28
  });
28
29
  test('float', () => {
29
- expect((0, _1.isFloat)('0')).toBe(true);
30
- expect((0, _1.isFloat)('1')).toBe(true);
31
- expect((0, _1.isFloat)('10')).toBe(true);
32
- expect((0, _1.isFloat)('100')).toBe(true);
33
- expect((0, _1.isFloat)('-0')).toBe(true);
34
- expect((0, _1.isFloat)('-1')).toBe(true);
35
- expect((0, _1.isFloat)('1.00')).toBe(true);
36
- expect((0, _1.isFloat)('.001')).toBe(true);
37
- expect((0, _1.isFloat)(' 1 ')).toBe(false);
38
- expect((0, _1.isFloat)('- 1')).toBe(false);
30
+ expect((0, _1.isFloat)('0')).toBe(true);
31
+ expect((0, _1.isFloat)('1')).toBe(true);
32
+ expect((0, _1.isFloat)('10')).toBe(true);
33
+ expect((0, _1.isFloat)('100')).toBe(true);
34
+ expect((0, _1.isFloat)('-0')).toBe(true);
35
+ expect((0, _1.isFloat)('-1')).toBe(true);
36
+ expect((0, _1.isFloat)('1.00')).toBe(true);
37
+ expect((0, _1.isFloat)('.001')).toBe(true);
38
+ expect((0, _1.isFloat)(' 1 ')).toBe(false);
39
+ expect((0, _1.isFloat)('- 1')).toBe(false);
39
40
  });
40
41
  test('nonZeroUint', () => {
41
- expect((0, _1.isNonZeroUint)('0')).toBe(false);
42
- expect((0, _1.isNonZeroUint)('1')).toBe(true);
43
- expect((0, _1.isNonZeroUint)('10')).toBe(true);
44
- expect((0, _1.isNonZeroUint)('100')).toBe(true);
45
- expect((0, _1.isNonZeroUint)('-0')).toBe(false);
46
- expect((0, _1.isNonZeroUint)('-1')).toBe(false);
47
- expect((0, _1.isNonZeroUint)('1.00')).toBe(false);
48
- expect((0, _1.isNonZeroUint)('.001')).toBe(false);
49
- expect((0, _1.isNonZeroUint)(' 1 ')).toBe(false);
50
- expect((0, _1.isNonZeroUint)('- 1')).toBe(false);
42
+ expect((0, _1.isNonZeroUint)('0')).toBe(false);
43
+ expect((0, _1.isNonZeroUint)('1')).toBe(true);
44
+ expect((0, _1.isNonZeroUint)('10')).toBe(true);
45
+ expect((0, _1.isNonZeroUint)('100')).toBe(true);
46
+ expect((0, _1.isNonZeroUint)('-0')).toBe(false);
47
+ expect((0, _1.isNonZeroUint)('-1')).toBe(false);
48
+ expect((0, _1.isNonZeroUint)('1.00')).toBe(false);
49
+ expect((0, _1.isNonZeroUint)('.001')).toBe(false);
50
+ expect((0, _1.isNonZeroUint)(' 1 ')).toBe(false);
51
+ expect((0, _1.isNonZeroUint)('- 1')).toBe(false);
51
52
  });
52
53
  test('quantity', () => {
53
- expect((0, _1.isQuantity)('0px', ['px', 'em'])).toBe(true);
54
- expect((0, _1.isQuantity)('.5px', ['px', 'em'])).toBe(true);
55
- expect((0, _1.isQuantity)('1.5em', ['px', 'em'])).toBe(true);
56
- expect((0, _1.isQuantity)('1.5cm', ['px', 'em'])).toBe(false);
57
- expect((0, _1.isQuantity)('1.5px', ['px', 'em'], 'int')).toBe(false);
58
- expect((0, _1.isQuantity)('-5px', ['px', 'em'], 'int')).toBe(true);
59
- expect((0, _1.isQuantity)('-5px', ['px', 'em'], 'uint')).toBe(false);
60
- expect((0, _1.isQuantity)('1.12e+21px', ['px', 'em'], 'float')).toBe(true);
61
- expect((0, _1.isQuantity)('1.12e+21px', ['px', 'em'], 'int')).toBe(false);
54
+ expect((0, _1.isQuantity)('0px', ['px', 'em'])).toBe(true);
55
+ expect((0, _1.isQuantity)('.5px', ['px', 'em'])).toBe(true);
56
+ expect((0, _1.isQuantity)('1.5em', ['px', 'em'])).toBe(true);
57
+ expect((0, _1.isQuantity)('1.5cm', ['px', 'em'])).toBe(false);
58
+ expect((0, _1.isQuantity)('1.5px', ['px', 'em'], 'int')).toBe(false);
59
+ expect((0, _1.isQuantity)('-5px', ['px', 'em'], 'int')).toBe(true);
60
+ expect((0, _1.isQuantity)('-5px', ['px', 'em'], 'uint')).toBe(false);
61
+ expect((0, _1.isQuantity)('1.12e+21px', ['px', 'em'], 'float')).toBe(true);
62
+ expect((0, _1.isQuantity)('1.12e+21px', ['px', 'em'], 'int')).toBe(false);
62
63
  });
@@ -4,4 +4,8 @@
4
4
  * @param units
5
5
  * @param numberType
6
6
  */
7
- export declare function isQuantity(value: string, units: string[], numberType?: 'int' | 'uint' | 'float'): boolean;
7
+ export declare function isQuantity(
8
+ value: string,
9
+ units: readonly string[],
10
+ numberType?: 'int' | 'uint' | 'float',
11
+ ): boolean;
@@ -6,6 +6,6 @@
6
6
  export declare function isUint(
7
7
  value: string,
8
8
  options?: {
9
- gt?: number;
9
+ readonly gt?: number;
10
10
  },
11
11
  ): boolean;
@@ -17,8 +17,8 @@ function splitUnit(value) {
17
17
  }
18
18
  const [, num, unit] = matched;
19
19
  return {
20
- num,
21
- unit,
20
+ num: num !== null && num !== void 0 ? num : value,
21
+ unit: unit !== null && unit !== void 0 ? unit : '',
22
22
  };
23
23
  }
24
24
  exports.splitUnit = splitUnit;
@@ -1,19 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const is_bcp_47_1 = require("./is-bcp-47");
1
+ 'use strict';
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ const is_bcp_47_1 = require('./is-bcp-47');
4
5
  const is = (0, is_bcp_47_1.isBCP47)();
5
6
  test('en-us', () => {
6
- expect(is('en-us')).toBe(true);
7
+ expect(is('en-us')).toBe(true);
7
8
  });
8
9
  test('ja-JP', () => {
9
- expect(is('ja-JP')).toBe(true);
10
+ expect(is('ja-JP')).toBe(true);
10
11
  });
11
12
  test('Empty', () => {
12
- expect(is('')).toBe(false);
13
+ expect(is('')).toBe(false);
13
14
  });
14
15
  test('Invalid', () => {
15
- expect(is(':::')).toBe(false);
16
+ expect(is(':::')).toBe(false);
16
17
  });
17
18
  test('Surrounded by spaces', () => {
18
- expect(is(' en ')).toBe(false);
19
+ expect(is(' en ')).toBe(false);
19
20
  });
@@ -1,19 +1,23 @@
1
+ import type { TokenValue } from './types';
1
2
  import type { UnmatchedResult } from '..';
2
3
  import type { Expect, Result, List } from '../types';
4
+ import type { ReadonlyDeep } from 'type-fest';
3
5
  import { Token } from './token';
4
6
  type TokenCollectionOptions = Partial<
5
7
  Omit<List, 'token'> & {
6
8
  specificSeparator: string | string[];
7
9
  }
8
10
  >;
9
- export type TokenEachCheck = (head: Token | null, tail: TokenCollection) => Result | void;
11
+ export type TokenEachCheck = (head: Readonly<Token> | null, tail: ReadonlyDeep<TokenCollection>) => Result | void;
10
12
  export declare class TokenCollection extends Array<Token> {
11
13
  static fromPatterns(
12
- value: Token | string,
13
- patterns: RegExp[],
14
- typeOptions?: Omit<TokenCollectionOptions, 'specificSeparator'> & {
15
- repeat?: boolean;
16
- },
14
+ value: Readonly<Token> | string,
15
+ patterns: readonly Readonly<RegExp>[],
16
+ typeOptions?: ReadonlyDeep<
17
+ Omit<TokenCollectionOptions, 'specificSeparator'> & {
18
+ repeat?: boolean;
19
+ }
20
+ >,
17
21
  ): TokenCollection;
18
22
  static get [Symbol.species](): ArrayConstructor;
19
23
  readonly allowEmpty: NonNullable<List['allowEmpty']>;
@@ -23,7 +27,7 @@ export declare class TokenCollection extends Array<Token> {
23
27
  readonly ordered: NonNullable<List['ordered']>;
24
28
  readonly separator: NonNullable<List['separator']>;
25
29
  readonly unique: NonNullable<List['unique']>;
26
- constructor(value?: string, typeOptions?: TokenCollectionOptions);
30
+ constructor(value?: string, typeOptions?: ReadonlyDeep<TokenCollectionOptions>);
27
31
  constructor(value?: number);
28
32
  get value(): string;
29
33
  check(options?: {
@@ -32,18 +36,20 @@ export declare class TokenCollection extends Array<Token> {
32
36
  cache?: boolean;
33
37
  }): import('..').MatchedResult | UnmatchedResult;
34
38
  chunk(split: number): TokenCollection[];
35
- compareTokens(callback: (prev: Token, current: Token) => Token | null | void): Token | null | undefined;
39
+ compareTokens(
40
+ callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void,
41
+ ): Readonly<Token> | null | undefined;
36
42
  divide(position: number): readonly [TokenCollection, TokenCollection];
37
- eachCheck(...callbacks: TokenEachCheck[]): Result;
38
- filter(callback: (value: Token, index: number, array: Token[]) => boolean): TokenCollection;
39
- getConsecutiveToken(tokenType: number): Token | null;
43
+ eachCheck(...callbacks: readonly TokenEachCheck[]): Result;
44
+ filter(callback: Parameters<Array<Token>['filter']>[0]): TokenCollection;
45
+ getConsecutiveToken(tokenType: number): Readonly<Token> | null;
40
46
  getDuplicated(): Token | null;
41
47
  getIdentTokens(): TokenCollection;
42
48
  /**
43
49
  *
44
50
  * @param value The token value or the token type or its list
45
51
  */
46
- has(value: string | RegExp | number | (string | RegExp | number)[]): boolean;
52
+ has(value: TokenValue): boolean;
47
53
  headAndTail(): {
48
54
  head: Token | null;
49
55
  tail: TokenCollection;
@@ -52,13 +58,13 @@ export declare class TokenCollection extends Array<Token> {
52
58
  *
53
59
  * @param value The token value or the token type or its list
54
60
  */
55
- search(value: string | RegExp | number | (string | RegExp | number)[]): Token | null;
61
+ search(value: TokenValue): Token | null;
56
62
  takeTurns(
57
63
  tokenNumbers: ReadonlyArray<number>,
58
64
  lastTokenNumber?: number,
59
65
  ): {
60
66
  unexpectedLastToken: boolean;
61
- expectedTokenNumber: number;
67
+ expectedTokenNumber: number | undefined;
62
68
  token: Token;
63
69
  } | null;
64
70
  toJSON(): {