@markuplint/types 3.5.1 → 3.6.0

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/lib/list.spec.js CHANGED
@@ -1,130 +1,130 @@
1
- "use strict";
1
+ 'use strict';
2
2
  // @ts-nocheck
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const list_1 = require("./list");
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ const list_1 = require('./list');
5
5
  test('Zero space', () => {
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);
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);
21
21
  });
22
22
  test('Zero comma', () => {
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);
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);
34
34
  });
35
35
  test('Zero comma (disallowToSurroundBySpaces)', () => {
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);
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);
48
48
  });
49
49
  test('Location of the token', () => {
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
- });
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
+ });
90
90
  });
91
91
  test('Expected comma', () => {
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
- });
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
+ });
115
115
  });
116
116
  test('Missing comma', () => {
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
- });
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
+ });
130
130
  });
@@ -1,9 +1,22 @@
1
- import type { FormattedPrimitiveTypeCheck, MatchedResult, UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from './types';
2
- export declare function matches(checker: FormattedPrimitiveTypeCheck, options?: UnmatchedResultOptions & {
3
- readonly ref?: string;
4
- readonly reason?: UnmatchedResultReason;
5
- }): (value: string) => UnmatchedResult | MatchedResult;
1
+ import type {
2
+ FormattedPrimitiveTypeCheck,
3
+ MatchedResult,
4
+ UnmatchedResult,
5
+ UnmatchedResultOptions,
6
+ UnmatchedResultReason,
7
+ } from './types';
8
+ export declare function matches(
9
+ checker: FormattedPrimitiveTypeCheck,
10
+ options?: UnmatchedResultOptions & {
11
+ readonly ref?: string;
12
+ readonly reason?: UnmatchedResultReason;
13
+ },
14
+ ): (value: string) => MatchedResult | UnmatchedResult;
6
15
  export declare function matched(): MatchedResult;
7
- export declare function unmatched(value: string, reason?: UnmatchedResultReason, options?: UnmatchedResultOptions & {
8
- readonly ref?: string;
9
- }): UnmatchedResult;
16
+ export declare function unmatched(
17
+ value: string,
18
+ reason?: UnmatchedResultReason,
19
+ options?: UnmatchedResultOptions & {
20
+ readonly ref?: string;
21
+ },
22
+ ): UnmatchedResult;
@@ -1,63 +1,63 @@
1
- "use strict";
1
+ 'use strict';
2
2
  // @ts-nocheck
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const _1 = require(".");
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ const _1 = require('.');
5
5
  test('int', () => {
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);
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);
16
16
  });
17
17
  test('uint', () => {
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);
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);
28
28
  });
29
29
  test('float', () => {
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);
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);
40
40
  });
41
41
  test('nonZeroUint', () => {
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);
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);
52
52
  });
53
53
  test('quantity', () => {
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);
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);
63
63
  });
@@ -1,20 +1,20 @@
1
- "use strict";
1
+ 'use strict';
2
2
  // @ts-nocheck
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const is_bcp_47_1 = require("./is-bcp-47");
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ const is_bcp_47_1 = require('./is-bcp-47');
5
5
  const is = (0, is_bcp_47_1.isBCP47)();
6
6
  test('en-us', () => {
7
- expect(is('en-us')).toBe(true);
7
+ expect(is('en-us')).toBe(true);
8
8
  });
9
9
  test('ja-JP', () => {
10
- expect(is('ja-JP')).toBe(true);
10
+ expect(is('ja-JP')).toBe(true);
11
11
  });
12
12
  test('Empty', () => {
13
- expect(is('')).toBe(false);
13
+ expect(is('')).toBe(false);
14
14
  });
15
15
  test('Invalid', () => {
16
- expect(is(':::')).toBe(false);
16
+ expect(is(':::')).toBe(false);
17
17
  });
18
18
  test('Surrounded by spaces', () => {
19
- expect(is(' en ')).toBe(false);
19
+ expect(is(' en ')).toBe(false);
20
20
  });
@@ -3,62 +3,75 @@ import type { UnmatchedResult } from '..';
3
3
  import type { Expect, Result, List } from '../types';
4
4
  import type { ReadonlyDeep } from 'type-fest';
5
5
  import { Token } from './token';
6
- type TokenCollectionOptions = Partial<Omit<List, 'token'> & {
7
- specificSeparator: string | string[];
8
- }>;
6
+ type TokenCollectionOptions = Partial<
7
+ Omit<List, 'token'> & {
8
+ specificSeparator: string | string[];
9
+ }
10
+ >;
9
11
  export type TokenEachCheck = (head: Readonly<Token> | null, tail: ReadonlyDeep<TokenCollection>) => Result | void;
10
12
  export declare class TokenCollection extends Array<Token> {
11
- static fromPatterns(value: Readonly<Token> | string, patterns: readonly Readonly<RegExp>[], typeOptions?: ReadonlyDeep<Omit<TokenCollectionOptions, 'specificSeparator'> & {
12
- repeat?: boolean;
13
- }>): TokenCollection;
14
- static get [Symbol.species](): ArrayConstructor;
15
- readonly allowEmpty: NonNullable<List['allowEmpty']>;
16
- readonly caseInsensitive: NonNullable<List['caseInsensitive']>;
17
- readonly disallowToSurroundBySpaces: NonNullable<List['disallowToSurroundBySpaces']>;
18
- readonly number: List['number'];
19
- readonly ordered: NonNullable<List['ordered']>;
20
- readonly separator: NonNullable<List['separator']>;
21
- readonly unique: NonNullable<List['unique']>;
22
- constructor(value?: string, typeOptions?: ReadonlyDeep<TokenCollectionOptions>);
23
- constructor(value?: number);
24
- get value(): string;
25
- check(options?: {
26
- expects?: Expect[];
27
- ref?: string;
28
- cache?: boolean;
29
- }): UnmatchedResult | import("..").MatchedResult;
30
- chunk(split: number): TokenCollection[];
31
- compareTokens(callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void): Readonly<Token> | null | undefined;
32
- divide(position: number): readonly [TokenCollection, TokenCollection];
33
- eachCheck(...callbacks: readonly TokenEachCheck[]): Result;
34
- filter(callback: Parameters<Array<Token>['filter']>[0]): TokenCollection;
35
- getConsecutiveToken(tokenType: number): Readonly<Token> | null;
36
- getDuplicated(): Token | null;
37
- getIdentTokens(): TokenCollection;
38
- /**
39
- *
40
- * @param value The token value or the token type or its list
41
- */
42
- has(value: TokenValue): boolean;
43
- headAndTail(): {
44
- head: Token | null;
45
- tail: TokenCollection;
46
- };
47
- /**
48
- *
49
- * @param value The token value or the token type or its list
50
- */
51
- search(value: TokenValue): Token | null;
52
- takeTurns(tokenNumbers: ReadonlyArray<number>, lastTokenNumber?: number): {
53
- unexpectedLastToken: boolean;
54
- expectedTokenNumber: number | undefined;
55
- token: Token;
56
- } | null;
57
- toJSON(): {
58
- type: number;
59
- value: string;
60
- offset: number;
61
- }[];
62
- private static _new;
13
+ static fromPatterns(
14
+ value: Readonly<Token> | string,
15
+ patterns: readonly Readonly<RegExp>[],
16
+ typeOptions?: ReadonlyDeep<
17
+ Omit<TokenCollectionOptions, 'specificSeparator'> & {
18
+ repeat?: boolean;
19
+ }
20
+ >,
21
+ ): TokenCollection;
22
+ static get [Symbol.species](): ArrayConstructor;
23
+ readonly allowEmpty: NonNullable<List['allowEmpty']>;
24
+ readonly caseInsensitive: NonNullable<List['caseInsensitive']>;
25
+ readonly disallowToSurroundBySpaces: NonNullable<List['disallowToSurroundBySpaces']>;
26
+ readonly number: List['number'];
27
+ readonly ordered: NonNullable<List['ordered']>;
28
+ readonly separator: NonNullable<List['separator']>;
29
+ readonly unique: NonNullable<List['unique']>;
30
+ constructor(value?: string, typeOptions?: ReadonlyDeep<TokenCollectionOptions>);
31
+ constructor(value?: number);
32
+ get value(): string;
33
+ check(options?: {
34
+ expects?: Expect[];
35
+ ref?: string;
36
+ cache?: boolean;
37
+ }): import('..').MatchedResult | UnmatchedResult;
38
+ chunk(split: number): TokenCollection[];
39
+ compareTokens(
40
+ callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void,
41
+ ): Readonly<Token> | null | undefined;
42
+ divide(position: number): readonly [TokenCollection, TokenCollection];
43
+ eachCheck(...callbacks: readonly TokenEachCheck[]): Result;
44
+ filter(callback: Parameters<Array<Token>['filter']>[0]): TokenCollection;
45
+ getConsecutiveToken(tokenType: number): Readonly<Token> | null;
46
+ getDuplicated(): Token | null;
47
+ getIdentTokens(): TokenCollection;
48
+ /**
49
+ *
50
+ * @param value The token value or the token type or its list
51
+ */
52
+ has(value: TokenValue): boolean;
53
+ headAndTail(): {
54
+ head: Token | null;
55
+ tail: TokenCollection;
56
+ };
57
+ /**
58
+ *
59
+ * @param value The token value or the token type or its list
60
+ */
61
+ search(value: TokenValue): Token | null;
62
+ takeTurns(
63
+ tokenNumbers: ReadonlyArray<number>,
64
+ lastTokenNumber?: number,
65
+ ): {
66
+ unexpectedLastToken: boolean;
67
+ expectedTokenNumber: number | undefined;
68
+ token: Token;
69
+ } | null;
70
+ toJSON(): {
71
+ type: number;
72
+ value: string;
73
+ offset: number;
74
+ }[];
75
+ private static _new;
63
76
  }
64
77
  export {};