@extable/sequence 0.1.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/LICENSE +202 -0
- package/README.md +105 -0
- package/dist/builtins.d.ts +4 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +768 -0
- package/dist/index.js.map +1 -0
- package/dist/infer.d.ts +11 -0
- package/dist/registry.d.ts +53 -0
- package/dist/sequence.d.ts +10 -0
- package/dist/types.d.ts +6 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @extable/sequence
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@extable/sequence)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](../LICENSE)
|
|
6
|
+
[](https://github.com/shibukawa/extable/actions/workflows/test.yml)
|
|
7
|
+
[](https://bundlephobia.com/package/@extable/sequence)
|
|
8
|
+
|
|
9
|
+
Sequence inference engine for Extable auto-fill.
|
|
10
|
+
|
|
11
|
+
This package provides a small, composable sequence engine that can detect list patterns,
|
|
12
|
+
arithmetic/geometric progressions, and structured string patterns (embedded numbers, roman numerals,
|
|
13
|
+
English ordinals) and then generate subsequent values.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @extable/sequence
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { inferSequence, createBuiltInRegistry } from "@extable/sequence";
|
|
25
|
+
|
|
26
|
+
const registry = createBuiltInRegistry(["ja", "en"]);
|
|
27
|
+
const seq = inferSequence(["Jan", "Feb"], { registry });
|
|
28
|
+
|
|
29
|
+
// The iterator yields values *after* the seed.
|
|
30
|
+
seq.next().value; // "March"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
### inferSequence
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
inferSequence(seed: readonly number[], options?: { registry?: SequenceRegistry }): Sequence<number>
|
|
39
|
+
inferSequence(seed: readonly Date[], options?: { registry?: SequenceRegistry }): Sequence<Date>
|
|
40
|
+
inferSequence(seed: readonly string[], options?: { registry?: SequenceRegistry }): Sequence<string>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Inference priority:
|
|
44
|
+
1. Single-item seed -> copy
|
|
45
|
+
2. Built-in/custom list match
|
|
46
|
+
3. Arithmetic progression
|
|
47
|
+
4. Geometric progression (numbers only)
|
|
48
|
+
5. Seed repeat
|
|
49
|
+
|
|
50
|
+
### SequenceRegistry
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const registry = new SequenceRegistry({ langs: ["ja", "en"] });
|
|
54
|
+
registry.register(list);
|
|
55
|
+
registry.registerMatch(matcher);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- `langs` controls language preference (no `navigator` dependency).
|
|
59
|
+
- `en` is appended if missing.
|
|
60
|
+
|
|
61
|
+
## Built-in Lists
|
|
62
|
+
|
|
63
|
+
Cycle lists (wrap-around):
|
|
64
|
+
- Weekdays (en/ja)
|
|
65
|
+
- Months (en/ja, traditional Japanese month names)
|
|
66
|
+
- Quarters (en/ja)
|
|
67
|
+
- Zodiac animals (十二支)
|
|
68
|
+
- Zodiac signs (en/ja)
|
|
69
|
+
- Directions (16-wind, en/ja)
|
|
70
|
+
- AM/PM (en/ja)
|
|
71
|
+
- Seasons (en/ja)
|
|
72
|
+
- Solfege (en/ja)
|
|
73
|
+
- Rokuyo (六曜)
|
|
74
|
+
- Greek letters (en/ja/symbols)
|
|
75
|
+
|
|
76
|
+
Finite lists (stop at end):
|
|
77
|
+
- Ten Heavenly Stems (十干)
|
|
78
|
+
- Planets (en/ja, 8 planets)
|
|
79
|
+
- Kuji-in (九字)
|
|
80
|
+
- Eight virtues (八徳)
|
|
81
|
+
|
|
82
|
+
## Custom Matchers
|
|
83
|
+
|
|
84
|
+
You can register custom matchers with a score to override built-ins:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
registry.registerMatch({
|
|
88
|
+
id: "custom",
|
|
89
|
+
match(seed) {
|
|
90
|
+
if (seed[0] === "A" && seed[1] === "B") return { score: 100 };
|
|
91
|
+
return null;
|
|
92
|
+
},
|
|
93
|
+
createIterator() {
|
|
94
|
+
return {
|
|
95
|
+
next() {
|
|
96
|
+
return { value: "Z", done: false };
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
Apache-2.0
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SequenceRegistry } from './registry';
|
|
2
|
+
export declare const registerBuiltInLists: (registry: SequenceRegistry) => void;
|
|
3
|
+
export declare const registerBuiltInMatchers: (registry: SequenceRegistry) => void;
|
|
4
|
+
export declare const createBuiltInRegistry: (langs?: readonly string[]) => SequenceRegistry;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
const m = (e) => e.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "), j = (e) => {
|
|
2
|
+
const t = [];
|
|
3
|
+
if (e)
|
|
4
|
+
for (const n of e) {
|
|
5
|
+
const r = n.trim();
|
|
6
|
+
!r || t.includes(r) || t.push(r);
|
|
7
|
+
}
|
|
8
|
+
return t.length === 0 ? t.push("en") : t.includes("en") || t.push("en"), t;
|
|
9
|
+
}, T = (e, t) => {
|
|
10
|
+
const n = e.items.indexOf(t);
|
|
11
|
+
if (n !== -1)
|
|
12
|
+
return n;
|
|
13
|
+
if (!e.aliases)
|
|
14
|
+
return null;
|
|
15
|
+
const r = e.aliases[t];
|
|
16
|
+
if (!r)
|
|
17
|
+
return null;
|
|
18
|
+
const s = e.items.indexOf(r);
|
|
19
|
+
return s === -1 ? null : s;
|
|
20
|
+
}, M = (e, t) => {
|
|
21
|
+
const n = m(t);
|
|
22
|
+
if (m(e.id).includes(n))
|
|
23
|
+
return !0;
|
|
24
|
+
for (const r of e.items)
|
|
25
|
+
if (m(r).includes(n))
|
|
26
|
+
return !0;
|
|
27
|
+
return e.aliases ? Object.keys(e.aliases).some(
|
|
28
|
+
(r) => m(r).includes(n)
|
|
29
|
+
) : !1;
|
|
30
|
+
}, w = (e, t) => {
|
|
31
|
+
if (e.langs.length === 0)
|
|
32
|
+
return 0;
|
|
33
|
+
let n = Number.POSITIVE_INFINITY;
|
|
34
|
+
for (const r of e.langs) {
|
|
35
|
+
const s = t.indexOf(r);
|
|
36
|
+
s !== -1 && s < n && (n = s);
|
|
37
|
+
}
|
|
38
|
+
return n;
|
|
39
|
+
}, E = (e, t) => !e.langs || e.langs.length === 0 ? !0 : e.langs.some((n) => t.includes(n));
|
|
40
|
+
class J {
|
|
41
|
+
constructor(t) {
|
|
42
|
+
this.lists = [], this.matchers = [], this.langs = j(t?.langs);
|
|
43
|
+
}
|
|
44
|
+
register(t) {
|
|
45
|
+
const n = this.lists.findIndex((r) => r.id === t.id);
|
|
46
|
+
n === -1 ? this.lists.push(t) : this.lists[n] = t;
|
|
47
|
+
}
|
|
48
|
+
registerMatch(t) {
|
|
49
|
+
const n = this.matchers.findIndex((r) => r.id === t.id);
|
|
50
|
+
n === -1 ? this.matchers.push(t) : this.matchers[n] = t;
|
|
51
|
+
}
|
|
52
|
+
unregister(t) {
|
|
53
|
+
this.lists = this.lists.filter((n) => n.id !== t), this.matchers = this.matchers.filter((n) => n.id !== t);
|
|
54
|
+
}
|
|
55
|
+
list(t) {
|
|
56
|
+
let n = [...this.lists];
|
|
57
|
+
if (t?.enabledIds && t.enabledIds.length > 0) {
|
|
58
|
+
const s = new Set(t.enabledIds);
|
|
59
|
+
n = n.filter((i) => s.has(i.id));
|
|
60
|
+
}
|
|
61
|
+
const r = t?.queryText;
|
|
62
|
+
return r && (n = n.filter((s) => M(s, r))), n;
|
|
63
|
+
}
|
|
64
|
+
match(t, n) {
|
|
65
|
+
if (t.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
let r = null, s = Number.NEGATIVE_INFINITY;
|
|
68
|
+
const i = n?.enabledIds ? new Set(n.enabledIds) : null;
|
|
69
|
+
for (const o of this.matchers) {
|
|
70
|
+
if (i && !i.has(o.id) || !E(o, this.langs))
|
|
71
|
+
continue;
|
|
72
|
+
const l = o.match(t);
|
|
73
|
+
if (!l)
|
|
74
|
+
continue;
|
|
75
|
+
const u = l.score;
|
|
76
|
+
Number.isFinite(u) && u > s && (s = u, r = {
|
|
77
|
+
kind: "matcher",
|
|
78
|
+
matcher: o,
|
|
79
|
+
step: l.step ?? 1,
|
|
80
|
+
state: l.state
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const a = this.list(n).map((o) => ({ list: o, rank: w(o, this.langs) })).filter((o) => Number.isFinite(o.rank)).sort((o, l) => o.rank - l.rank);
|
|
84
|
+
for (const { list: o, rank: l } of a) {
|
|
85
|
+
const u = [];
|
|
86
|
+
let f = !1;
|
|
87
|
+
for (const N of t) {
|
|
88
|
+
const p = T(o, N);
|
|
89
|
+
if (p === null) {
|
|
90
|
+
f = !0;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
u.push(p);
|
|
94
|
+
}
|
|
95
|
+
if (f)
|
|
96
|
+
continue;
|
|
97
|
+
const h = this.inferStep(o, u);
|
|
98
|
+
if (h === null)
|
|
99
|
+
continue;
|
|
100
|
+
const g = 10 - l;
|
|
101
|
+
g > s && (s = g, r = {
|
|
102
|
+
kind: "list",
|
|
103
|
+
list: o,
|
|
104
|
+
startIndex: u[u.length - 1] ?? 0,
|
|
105
|
+
step: h
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return r;
|
|
109
|
+
}
|
|
110
|
+
inferStep(t, n) {
|
|
111
|
+
if (n.length < 2)
|
|
112
|
+
return 1;
|
|
113
|
+
const r = t.items.length, s = this.stepBetween(t.mode, r, n[0], n[1]);
|
|
114
|
+
if (s === null)
|
|
115
|
+
return null;
|
|
116
|
+
for (let i = 2; i < n.length; i += 1) {
|
|
117
|
+
const a = this.nextIndex(t.mode, r, n[i - 1], s);
|
|
118
|
+
if (a === null || a !== n[i])
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return s;
|
|
122
|
+
}
|
|
123
|
+
stepBetween(t, n, r, s) {
|
|
124
|
+
if (t === "cycle")
|
|
125
|
+
return (s - r + n) % n;
|
|
126
|
+
const i = s - r;
|
|
127
|
+
return i < 0 ? null : i;
|
|
128
|
+
}
|
|
129
|
+
nextIndex(t, n, r, s) {
|
|
130
|
+
if (t === "cycle")
|
|
131
|
+
return (r + s) % n;
|
|
132
|
+
const i = r + s;
|
|
133
|
+
return i >= n ? null : i;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const A = {
|
|
137
|
+
id: "weekdays-en",
|
|
138
|
+
mode: "cycle",
|
|
139
|
+
langs: ["en"],
|
|
140
|
+
items: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
|
141
|
+
aliases: {
|
|
142
|
+
Mon: "Monday",
|
|
143
|
+
Tue: "Tuesday",
|
|
144
|
+
Tues: "Tuesday",
|
|
145
|
+
Wed: "Wednesday",
|
|
146
|
+
Thu: "Thursday",
|
|
147
|
+
Thur: "Thursday",
|
|
148
|
+
Thurs: "Thursday",
|
|
149
|
+
Fri: "Friday",
|
|
150
|
+
Sat: "Saturday",
|
|
151
|
+
Sun: "Sunday"
|
|
152
|
+
}
|
|
153
|
+
}, L = {
|
|
154
|
+
id: "weekdays-ja",
|
|
155
|
+
mode: "cycle",
|
|
156
|
+
langs: ["ja"],
|
|
157
|
+
items: ["月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"],
|
|
158
|
+
aliases: {
|
|
159
|
+
月曜: "月曜日",
|
|
160
|
+
月: "月曜日",
|
|
161
|
+
火曜: "火曜日",
|
|
162
|
+
火: "火曜日",
|
|
163
|
+
水曜: "水曜日",
|
|
164
|
+
水: "水曜日",
|
|
165
|
+
木曜: "木曜日",
|
|
166
|
+
木: "木曜日",
|
|
167
|
+
金曜: "金曜日",
|
|
168
|
+
金: "金曜日",
|
|
169
|
+
土曜: "土曜日",
|
|
170
|
+
土: "土曜日",
|
|
171
|
+
日曜: "日曜日",
|
|
172
|
+
日: "日曜日"
|
|
173
|
+
}
|
|
174
|
+
}, F = {
|
|
175
|
+
id: "months-en",
|
|
176
|
+
mode: "cycle",
|
|
177
|
+
langs: ["en"],
|
|
178
|
+
items: [
|
|
179
|
+
"January",
|
|
180
|
+
"February",
|
|
181
|
+
"March",
|
|
182
|
+
"April",
|
|
183
|
+
"May",
|
|
184
|
+
"June",
|
|
185
|
+
"July",
|
|
186
|
+
"August",
|
|
187
|
+
"September",
|
|
188
|
+
"October",
|
|
189
|
+
"November",
|
|
190
|
+
"December"
|
|
191
|
+
],
|
|
192
|
+
aliases: {
|
|
193
|
+
Jan: "January",
|
|
194
|
+
Feb: "February",
|
|
195
|
+
Mar: "March",
|
|
196
|
+
Apr: "April",
|
|
197
|
+
Jun: "June",
|
|
198
|
+
Jul: "July",
|
|
199
|
+
Aug: "August",
|
|
200
|
+
Sep: "September",
|
|
201
|
+
Sept: "September",
|
|
202
|
+
Oct: "October",
|
|
203
|
+
Nov: "November",
|
|
204
|
+
Dec: "December"
|
|
205
|
+
}
|
|
206
|
+
}, v = {
|
|
207
|
+
id: "months-ja",
|
|
208
|
+
mode: "cycle",
|
|
209
|
+
langs: ["ja"],
|
|
210
|
+
items: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
|
|
211
|
+
}, z = {
|
|
212
|
+
id: "months-ja-traditional",
|
|
213
|
+
mode: "cycle",
|
|
214
|
+
langs: ["ja"],
|
|
215
|
+
items: ["睦月", "如月", "弥生", "卯月", "皐月", "水無月", "文月", "葉月", "長月", "神無月", "霜月", "師走"]
|
|
216
|
+
}, O = {
|
|
217
|
+
id: "quarters-en",
|
|
218
|
+
mode: "cycle",
|
|
219
|
+
langs: ["en"],
|
|
220
|
+
items: ["Q1", "Q2", "Q3", "Q4"]
|
|
221
|
+
}, P = {
|
|
222
|
+
id: "quarters-ja",
|
|
223
|
+
mode: "cycle",
|
|
224
|
+
langs: ["ja"],
|
|
225
|
+
items: ["第1四半期", "第2四半期", "第3四半期", "第4四半期"]
|
|
226
|
+
}, R = {
|
|
227
|
+
id: "zodiac-animals-ja",
|
|
228
|
+
mode: "cycle",
|
|
229
|
+
langs: ["ja"],
|
|
230
|
+
items: ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
|
|
231
|
+
}, C = {
|
|
232
|
+
id: "zodiac-signs-en",
|
|
233
|
+
mode: "cycle",
|
|
234
|
+
langs: ["en"],
|
|
235
|
+
items: [
|
|
236
|
+
"Aries",
|
|
237
|
+
"Taurus",
|
|
238
|
+
"Gemini",
|
|
239
|
+
"Cancer",
|
|
240
|
+
"Leo",
|
|
241
|
+
"Virgo",
|
|
242
|
+
"Libra",
|
|
243
|
+
"Scorpio",
|
|
244
|
+
"Sagittarius",
|
|
245
|
+
"Capricorn",
|
|
246
|
+
"Aquarius",
|
|
247
|
+
"Pisces"
|
|
248
|
+
]
|
|
249
|
+
}, D = {
|
|
250
|
+
id: "zodiac-signs-ja",
|
|
251
|
+
mode: "cycle",
|
|
252
|
+
langs: ["ja"],
|
|
253
|
+
items: ["牡羊座", "牡牛座", "双子座", "蟹座", "獅子座", "乙女座", "天秤座", "蠍座", "射手座", "山羊座", "水瓶座", "魚座"],
|
|
254
|
+
aliases: {
|
|
255
|
+
さそり座: "蠍座"
|
|
256
|
+
}
|
|
257
|
+
}, $ = {
|
|
258
|
+
id: "directions-16-en",
|
|
259
|
+
mode: "cycle",
|
|
260
|
+
langs: ["en"],
|
|
261
|
+
items: [
|
|
262
|
+
"North",
|
|
263
|
+
"North-Northeast",
|
|
264
|
+
"Northeast",
|
|
265
|
+
"East-Northeast",
|
|
266
|
+
"East",
|
|
267
|
+
"East-Southeast",
|
|
268
|
+
"Southeast",
|
|
269
|
+
"South-Southeast",
|
|
270
|
+
"South",
|
|
271
|
+
"South-Southwest",
|
|
272
|
+
"Southwest",
|
|
273
|
+
"West-Southwest",
|
|
274
|
+
"West",
|
|
275
|
+
"West-Northwest",
|
|
276
|
+
"Northwest",
|
|
277
|
+
"North-Northwest"
|
|
278
|
+
]
|
|
279
|
+
}, V = {
|
|
280
|
+
id: "directions-16-ja",
|
|
281
|
+
mode: "cycle",
|
|
282
|
+
langs: ["ja"],
|
|
283
|
+
items: [
|
|
284
|
+
"北",
|
|
285
|
+
"北北東",
|
|
286
|
+
"北東",
|
|
287
|
+
"東北東",
|
|
288
|
+
"東",
|
|
289
|
+
"東南東",
|
|
290
|
+
"南東",
|
|
291
|
+
"南南東",
|
|
292
|
+
"南",
|
|
293
|
+
"南南西",
|
|
294
|
+
"南西",
|
|
295
|
+
"西南西",
|
|
296
|
+
"西",
|
|
297
|
+
"西北西",
|
|
298
|
+
"北西",
|
|
299
|
+
"北北西"
|
|
300
|
+
]
|
|
301
|
+
}, W = {
|
|
302
|
+
id: "ampm-en",
|
|
303
|
+
mode: "cycle",
|
|
304
|
+
langs: ["en"],
|
|
305
|
+
items: ["AM", "PM"],
|
|
306
|
+
aliases: {
|
|
307
|
+
"A.M.": "AM",
|
|
308
|
+
"P.M.": "PM"
|
|
309
|
+
}
|
|
310
|
+
}, B = {
|
|
311
|
+
id: "ampm-ja",
|
|
312
|
+
mode: "cycle",
|
|
313
|
+
langs: ["ja"],
|
|
314
|
+
items: ["午前", "午後"]
|
|
315
|
+
}, Q = {
|
|
316
|
+
id: "seasons-en",
|
|
317
|
+
mode: "cycle",
|
|
318
|
+
langs: ["en"],
|
|
319
|
+
items: ["Spring", "Summer", "Autumn", "Winter"],
|
|
320
|
+
aliases: {
|
|
321
|
+
Fall: "Autumn"
|
|
322
|
+
}
|
|
323
|
+
}, q = {
|
|
324
|
+
id: "seasons-ja",
|
|
325
|
+
mode: "cycle",
|
|
326
|
+
langs: ["ja"],
|
|
327
|
+
items: ["春", "夏", "秋", "冬"]
|
|
328
|
+
}, G = {
|
|
329
|
+
id: "solfege-ja",
|
|
330
|
+
mode: "cycle",
|
|
331
|
+
langs: ["ja"],
|
|
332
|
+
items: ["ド", "レ", "ミ", "ファ", "ソ", "ラ", "シ"]
|
|
333
|
+
}, X = {
|
|
334
|
+
id: "solfege-en",
|
|
335
|
+
mode: "cycle",
|
|
336
|
+
langs: ["en"],
|
|
337
|
+
items: ["Do", "Re", "Mi", "Fa", "Sol", "La", "Ti"],
|
|
338
|
+
aliases: {
|
|
339
|
+
So: "Sol",
|
|
340
|
+
Si: "Ti"
|
|
341
|
+
}
|
|
342
|
+
}, U = {
|
|
343
|
+
id: "greek-letters-en",
|
|
344
|
+
mode: "cycle",
|
|
345
|
+
langs: ["en"],
|
|
346
|
+
items: [
|
|
347
|
+
"Alpha",
|
|
348
|
+
"Beta",
|
|
349
|
+
"Gamma",
|
|
350
|
+
"Delta",
|
|
351
|
+
"Epsilon",
|
|
352
|
+
"Zeta",
|
|
353
|
+
"Eta",
|
|
354
|
+
"Theta",
|
|
355
|
+
"Iota",
|
|
356
|
+
"Kappa",
|
|
357
|
+
"Lambda",
|
|
358
|
+
"Mu",
|
|
359
|
+
"Nu",
|
|
360
|
+
"Xi",
|
|
361
|
+
"Omicron",
|
|
362
|
+
"Pi",
|
|
363
|
+
"Rho",
|
|
364
|
+
"Sigma",
|
|
365
|
+
"Tau",
|
|
366
|
+
"Upsilon",
|
|
367
|
+
"Phi",
|
|
368
|
+
"Chi",
|
|
369
|
+
"Psi",
|
|
370
|
+
"Omega"
|
|
371
|
+
]
|
|
372
|
+
}, K = {
|
|
373
|
+
id: "greek-letters-ja",
|
|
374
|
+
mode: "cycle",
|
|
375
|
+
langs: ["ja"],
|
|
376
|
+
items: [
|
|
377
|
+
"アルファ",
|
|
378
|
+
"ベータ",
|
|
379
|
+
"ガンマ",
|
|
380
|
+
"デルタ",
|
|
381
|
+
"イプシロン",
|
|
382
|
+
"ゼータ",
|
|
383
|
+
"イータ",
|
|
384
|
+
"シータ",
|
|
385
|
+
"イオタ",
|
|
386
|
+
"カッパ",
|
|
387
|
+
"ラムダ",
|
|
388
|
+
"ミュー",
|
|
389
|
+
"ニュー",
|
|
390
|
+
"クサイ",
|
|
391
|
+
"オミクロン",
|
|
392
|
+
"パイ",
|
|
393
|
+
"ロー",
|
|
394
|
+
"シグマ",
|
|
395
|
+
"タウ",
|
|
396
|
+
"ウプシロン",
|
|
397
|
+
"ファイ",
|
|
398
|
+
"カイ",
|
|
399
|
+
"プサイ",
|
|
400
|
+
"オメガ"
|
|
401
|
+
]
|
|
402
|
+
}, Y = {
|
|
403
|
+
id: "greek-letters-symbols",
|
|
404
|
+
mode: "cycle",
|
|
405
|
+
langs: ["en", "ja"],
|
|
406
|
+
items: [
|
|
407
|
+
"α",
|
|
408
|
+
"β",
|
|
409
|
+
"γ",
|
|
410
|
+
"δ",
|
|
411
|
+
"ε",
|
|
412
|
+
"ζ",
|
|
413
|
+
"η",
|
|
414
|
+
"θ",
|
|
415
|
+
"ι",
|
|
416
|
+
"κ",
|
|
417
|
+
"λ",
|
|
418
|
+
"μ",
|
|
419
|
+
"ν",
|
|
420
|
+
"ξ",
|
|
421
|
+
"ο",
|
|
422
|
+
"π",
|
|
423
|
+
"ρ",
|
|
424
|
+
"σ",
|
|
425
|
+
"τ",
|
|
426
|
+
"υ",
|
|
427
|
+
"φ",
|
|
428
|
+
"χ",
|
|
429
|
+
"ψ",
|
|
430
|
+
"ω"
|
|
431
|
+
],
|
|
432
|
+
aliases: {
|
|
433
|
+
ς: "σ"
|
|
434
|
+
}
|
|
435
|
+
}, H = {
|
|
436
|
+
id: "rokuyo-ja",
|
|
437
|
+
mode: "cycle",
|
|
438
|
+
langs: ["ja"],
|
|
439
|
+
items: ["先勝", "友引", "先負", "仏滅", "大安", "赤口"]
|
|
440
|
+
}, Z = {
|
|
441
|
+
id: "heavenly-stems-ja",
|
|
442
|
+
mode: "finite",
|
|
443
|
+
langs: ["ja"],
|
|
444
|
+
items: ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
|
|
445
|
+
}, _ = {
|
|
446
|
+
id: "planets-en",
|
|
447
|
+
mode: "finite",
|
|
448
|
+
langs: ["en"],
|
|
449
|
+
items: ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
|
|
450
|
+
}, ee = {
|
|
451
|
+
id: "planets-ja",
|
|
452
|
+
mode: "finite",
|
|
453
|
+
langs: ["ja"],
|
|
454
|
+
items: ["水星", "金星", "地球", "火星", "木星", "土星", "天王星", "海王星"]
|
|
455
|
+
}, te = {
|
|
456
|
+
id: "kuji-in-ja",
|
|
457
|
+
mode: "finite",
|
|
458
|
+
langs: ["ja"],
|
|
459
|
+
items: ["臨", "兵", "闘", "者", "皆", "陣", "烈", "在", "前"]
|
|
460
|
+
}, ne = {
|
|
461
|
+
id: "eight-virtues-ja",
|
|
462
|
+
mode: "finite",
|
|
463
|
+
langs: ["ja"],
|
|
464
|
+
items: ["仁", "義", "礼", "智", "忠", "信", "孝", "悌"]
|
|
465
|
+
}, re = [
|
|
466
|
+
A,
|
|
467
|
+
L,
|
|
468
|
+
F,
|
|
469
|
+
v,
|
|
470
|
+
z,
|
|
471
|
+
O,
|
|
472
|
+
P,
|
|
473
|
+
R,
|
|
474
|
+
C,
|
|
475
|
+
D,
|
|
476
|
+
$,
|
|
477
|
+
V,
|
|
478
|
+
W,
|
|
479
|
+
B,
|
|
480
|
+
Q,
|
|
481
|
+
q,
|
|
482
|
+
G,
|
|
483
|
+
X,
|
|
484
|
+
U,
|
|
485
|
+
K,
|
|
486
|
+
Y,
|
|
487
|
+
H,
|
|
488
|
+
Z,
|
|
489
|
+
_,
|
|
490
|
+
ee,
|
|
491
|
+
te,
|
|
492
|
+
ne
|
|
493
|
+
], b = (e) => {
|
|
494
|
+
const t = e % 100;
|
|
495
|
+
if (t >= 11 && t <= 13) return "th";
|
|
496
|
+
const n = e % 10;
|
|
497
|
+
return n === 1 ? "st" : n === 2 ? "nd" : n === 3 ? "rd" : "th";
|
|
498
|
+
}, y = (e) => {
|
|
499
|
+
const t = /^(\d+)(st|nd|rd|th)$/.exec(e);
|
|
500
|
+
if (!t) return null;
|
|
501
|
+
const n = Number(t[1]);
|
|
502
|
+
if (!Number.isFinite(n) || n <= 0) return null;
|
|
503
|
+
const r = t[2];
|
|
504
|
+
return b(n) !== r ? null : n;
|
|
505
|
+
}, se = {
|
|
506
|
+
id: "ordinal-en",
|
|
507
|
+
langs: ["en"],
|
|
508
|
+
match(e) {
|
|
509
|
+
if (e.length < 2) return null;
|
|
510
|
+
const t = e.map((s) => y(s));
|
|
511
|
+
if (t.some((s) => s === null)) return null;
|
|
512
|
+
const n = t, r = n[1] - n[0];
|
|
513
|
+
for (let s = 2; s < n.length; s += 1)
|
|
514
|
+
if (n[s] - n[s - 1] !== r) return null;
|
|
515
|
+
return { score: 80, step: r };
|
|
516
|
+
},
|
|
517
|
+
createIterator(e, t) {
|
|
518
|
+
let r = y(e[e.length - 1] ?? "") ?? 0;
|
|
519
|
+
return {
|
|
520
|
+
next() {
|
|
521
|
+
return r += t.step, r <= 0 || !Number.isFinite(r) ? { value: void 0, done: !0 } : { value: `${r}${b(r)}`, done: !1 };
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
}, ie = (e) => {
|
|
526
|
+
for (const t of re)
|
|
527
|
+
e.register(t);
|
|
528
|
+
}, ae = (e) => {
|
|
529
|
+
e.registerMatch(se);
|
|
530
|
+
}, oe = (e) => {
|
|
531
|
+
const t = new J({ langs: e });
|
|
532
|
+
return ie(t), ae(t), t;
|
|
533
|
+
}, le = (e) => {
|
|
534
|
+
let t = 0;
|
|
535
|
+
return {
|
|
536
|
+
next() {
|
|
537
|
+
if (e.length === 0)
|
|
538
|
+
return { value: void 0, done: !0 };
|
|
539
|
+
const n = e[t % e.length];
|
|
540
|
+
return t += 1, { value: n, done: !1 };
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
class c {
|
|
545
|
+
constructor(...t) {
|
|
546
|
+
const n = t;
|
|
547
|
+
this.seed = n, this.kind = n.length === 1 ? "copy" : "seed-repeat", this.iterator = le(n);
|
|
548
|
+
}
|
|
549
|
+
static fromSeed(t, n, r) {
|
|
550
|
+
const s = new c(...t);
|
|
551
|
+
return s.kind = n, s.iterator = r, s;
|
|
552
|
+
}
|
|
553
|
+
next() {
|
|
554
|
+
return this.iterator.next();
|
|
555
|
+
}
|
|
556
|
+
[Symbol.iterator]() {
|
|
557
|
+
return this;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
const x = 1e-9, ce = 100, ue = (e) => ({
|
|
561
|
+
next() {
|
|
562
|
+
return { value: e, done: !1 };
|
|
563
|
+
}
|
|
564
|
+
}), S = (e) => {
|
|
565
|
+
let t = 0;
|
|
566
|
+
return {
|
|
567
|
+
next() {
|
|
568
|
+
if (e.length === 0)
|
|
569
|
+
return { value: void 0, done: !0 };
|
|
570
|
+
const n = e[t % e.length];
|
|
571
|
+
return t += 1, { value: n, done: !1 };
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
}, me = (e, t) => {
|
|
575
|
+
let n = 0;
|
|
576
|
+
return {
|
|
577
|
+
next() {
|
|
578
|
+
return n += 1, { value: e + t * n, done: !1 };
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}, de = (e, t) => {
|
|
582
|
+
let n = 0;
|
|
583
|
+
return {
|
|
584
|
+
next() {
|
|
585
|
+
return n += 1, { value: new Date(e.getTime() + t * n), done: !1 };
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
}, fe = (e, t) => {
|
|
589
|
+
let n = 0;
|
|
590
|
+
return {
|
|
591
|
+
next() {
|
|
592
|
+
return n += 1, { value: e * t ** n, done: !1 };
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
}, he = (e, t) => {
|
|
596
|
+
if (e.kind === "matcher")
|
|
597
|
+
return e.matcher.createIterator(t, { step: e.step, state: e.state });
|
|
598
|
+
const { list: n, startIndex: r, step: s } = e, i = n.items.length;
|
|
599
|
+
let a = r;
|
|
600
|
+
return {
|
|
601
|
+
next() {
|
|
602
|
+
if (n.mode === "finite") {
|
|
603
|
+
const o = a + s;
|
|
604
|
+
return o >= i ? { value: void 0, done: !0 } : (a = o, { value: n.items[a], done: !1 });
|
|
605
|
+
}
|
|
606
|
+
return a = (a + s) % i, { value: n.items[a], done: !1 };
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
}, ge = (e) => e.every((t) => typeof t == "number" && Number.isFinite(t)), pe = (e) => e.every((t) => t instanceof Date && !Number.isNaN(t.getTime())), ye = (e) => e.every((t) => typeof t == "string"), Se = (e) => {
|
|
610
|
+
const t = /^(.*?)(-?\d+)([^0-9]*)$/.exec(e);
|
|
611
|
+
if (!t)
|
|
612
|
+
return null;
|
|
613
|
+
const n = t[1] ?? "", r = t[2] ?? "", s = t[3] ?? "", i = Number(r);
|
|
614
|
+
if (!Number.isFinite(i))
|
|
615
|
+
return null;
|
|
616
|
+
const a = r.replace("-", "").length;
|
|
617
|
+
return { prefix: n, num: i, width: a, suffix: s };
|
|
618
|
+
}, be = (e, t, n) => {
|
|
619
|
+
let r = 0;
|
|
620
|
+
return {
|
|
621
|
+
next() {
|
|
622
|
+
r += 1;
|
|
623
|
+
const s = t + n * r, i = s < 0 ? "-" : "", a = Math.abs(s).toString().padStart(e.width, "0");
|
|
624
|
+
return { value: `${e.prefix}${i}${a}${e.suffix}`, done: !1 };
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}, I = [
|
|
628
|
+
["C", 100],
|
|
629
|
+
["XC", 90],
|
|
630
|
+
["L", 50],
|
|
631
|
+
["XL", 40],
|
|
632
|
+
["X", 10],
|
|
633
|
+
["IX", 9],
|
|
634
|
+
["V", 5],
|
|
635
|
+
["IV", 4],
|
|
636
|
+
["I", 1]
|
|
637
|
+
], k = (e) => {
|
|
638
|
+
if (e < 1 || e > ce)
|
|
639
|
+
return null;
|
|
640
|
+
let t = e, n = "";
|
|
641
|
+
for (const [r, s] of I)
|
|
642
|
+
for (; t >= s; )
|
|
643
|
+
n += r, t -= s;
|
|
644
|
+
return n;
|
|
645
|
+
}, xe = (e) => {
|
|
646
|
+
if (e.length === 0 || e !== e.toUpperCase())
|
|
647
|
+
return null;
|
|
648
|
+
let t = e, n = 0;
|
|
649
|
+
for (const [s, i] of I)
|
|
650
|
+
for (; t.startsWith(s); )
|
|
651
|
+
n += i, t = t.slice(s.length);
|
|
652
|
+
if (t.length > 0)
|
|
653
|
+
return null;
|
|
654
|
+
const r = k(n);
|
|
655
|
+
return !r || r !== e ? null : n;
|
|
656
|
+
}, Ie = (e, t) => {
|
|
657
|
+
let n = 0;
|
|
658
|
+
return {
|
|
659
|
+
next() {
|
|
660
|
+
n += 1;
|
|
661
|
+
const r = e + t * n, s = k(r);
|
|
662
|
+
return s ? { value: s, done: !1 } : { value: void 0, done: !0 };
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}, d = (e) => {
|
|
666
|
+
if (e.length < 2)
|
|
667
|
+
return null;
|
|
668
|
+
const t = e[1] - e[0];
|
|
669
|
+
for (let n = 2; n < e.length; n += 1)
|
|
670
|
+
if (Math.abs(e[n] - e[n - 1] - t) > x)
|
|
671
|
+
return null;
|
|
672
|
+
return t;
|
|
673
|
+
}, ke = (e) => {
|
|
674
|
+
if (e.length < 2 || e[0] === 0)
|
|
675
|
+
return null;
|
|
676
|
+
const t = e[1] / e[0];
|
|
677
|
+
for (let n = 2; n < e.length; n += 1)
|
|
678
|
+
if (e[n - 1] === 0 || Math.abs(e[n] / e[n - 1] - t) > x)
|
|
679
|
+
return null;
|
|
680
|
+
return t;
|
|
681
|
+
}, Ne = (e) => {
|
|
682
|
+
const t = e.map((r) => Se(r));
|
|
683
|
+
if (t.every(Boolean)) {
|
|
684
|
+
const r = t[0], s = t[t.length - 1];
|
|
685
|
+
if (t.every(
|
|
686
|
+
(a) => a?.prefix === r.prefix && a?.suffix === r.suffix
|
|
687
|
+
)) {
|
|
688
|
+
const a = t.map((l) => l?.num ?? 0), o = d(a);
|
|
689
|
+
if (o !== null)
|
|
690
|
+
return {
|
|
691
|
+
kind: "arithmetic",
|
|
692
|
+
iterator: be(
|
|
693
|
+
{ prefix: s.prefix, suffix: s.suffix, width: s.width },
|
|
694
|
+
s.num,
|
|
695
|
+
o
|
|
696
|
+
)
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const n = e.map((r) => xe(r));
|
|
701
|
+
if (n.every((r) => r !== null)) {
|
|
702
|
+
const r = n, s = d(r);
|
|
703
|
+
if (s !== null) {
|
|
704
|
+
const i = r[r.length - 1];
|
|
705
|
+
return {
|
|
706
|
+
kind: "arithmetic",
|
|
707
|
+
iterator: Ie(i, s)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}, je = (e, t) => {
|
|
713
|
+
const n = t.match(e);
|
|
714
|
+
return n ? {
|
|
715
|
+
kind: "list",
|
|
716
|
+
iterator: he(n, e)
|
|
717
|
+
} : null;
|
|
718
|
+
};
|
|
719
|
+
function Te(e, t) {
|
|
720
|
+
const n = t?.registry ?? oe();
|
|
721
|
+
if (e.length === 0)
|
|
722
|
+
return c.fromSeed(e, "seed-repeat", S(e));
|
|
723
|
+
if (e.length === 1)
|
|
724
|
+
return c.fromSeed(e, "copy", ue(e[0]));
|
|
725
|
+
if (ye(e)) {
|
|
726
|
+
const r = je(e, n);
|
|
727
|
+
if (r)
|
|
728
|
+
return c.fromSeed(e, r.kind, r.iterator);
|
|
729
|
+
const s = Ne(e);
|
|
730
|
+
if (s)
|
|
731
|
+
return c.fromSeed(e, s.kind, s.iterator);
|
|
732
|
+
}
|
|
733
|
+
if (ge(e)) {
|
|
734
|
+
const r = d(e);
|
|
735
|
+
if (r !== null)
|
|
736
|
+
return c.fromSeed(
|
|
737
|
+
e,
|
|
738
|
+
"arithmetic",
|
|
739
|
+
me(e[e.length - 1], r)
|
|
740
|
+
);
|
|
741
|
+
const s = ke(e);
|
|
742
|
+
if (s !== null)
|
|
743
|
+
return c.fromSeed(
|
|
744
|
+
e,
|
|
745
|
+
"geometric",
|
|
746
|
+
fe(e[e.length - 1], s)
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
if (pe(e)) {
|
|
750
|
+
const r = e.map((i) => i.getTime()), s = d(r);
|
|
751
|
+
if (s !== null)
|
|
752
|
+
return c.fromSeed(
|
|
753
|
+
e,
|
|
754
|
+
"arithmetic",
|
|
755
|
+
de(e[e.length - 1], s)
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
return c.fromSeed(e, "seed-repeat", S(e));
|
|
759
|
+
}
|
|
760
|
+
export {
|
|
761
|
+
c as Sequence,
|
|
762
|
+
J as SequenceRegistry,
|
|
763
|
+
oe as createBuiltInRegistry,
|
|
764
|
+
Te as inferSequence,
|
|
765
|
+
ie as registerBuiltInLists,
|
|
766
|
+
ae as registerBuiltInMatchers
|
|
767
|
+
};
|
|
768
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/registry.ts","../src/builtins.ts","../src/sequence.ts","../src/infer.ts"],"sourcesContent":["export type SequenceListMode = 'cycle' | 'finite';\n\nexport type SequenceList = {\n id: string;\n mode: SequenceListMode;\n langs: readonly string[];\n items: readonly string[];\n aliases?: Record<string, string>;\n};\n\nexport type SequenceMatch = {\n id: string;\n langs?: readonly string[];\n match(seed: readonly string[]):\n | { score: number; startIndex?: number; step?: number; state?: unknown }\n | null;\n createIterator(\n seed: readonly string[],\n ctx: { step: number; state?: unknown }\n ): Iterator<string>;\n};\n\nexport type RegistryQuery = {\n enabledIds?: readonly string[];\n queryText?: string;\n};\n\nexport type SequenceMatchResult =\n | {\n kind: 'list';\n list: SequenceList;\n startIndex: number;\n step: number;\n }\n | {\n kind: 'matcher';\n matcher: SequenceMatch;\n step: number;\n state?: unknown;\n };\n\nconst fallbackLang = 'en';\n\nconst normalizeQueryToken = (value: string): string => {\n return value.trim().normalize('NFKC').toLowerCase().replace(/\\s+/g, ' ');\n};\n\nconst normalizeLangs = (langs?: readonly string[]): readonly string[] => {\n const result: string[] = [];\n if (langs) {\n for (const lang of langs) {\n const normalized = lang.trim();\n if (!normalized || result.includes(normalized)) {\n continue;\n }\n result.push(normalized);\n }\n }\n if (result.length === 0) {\n result.push(fallbackLang);\n } else if (!result.includes(fallbackLang)) {\n result.push(fallbackLang);\n }\n return result;\n};\n\nconst resolveIndex = (list: SequenceList, token: string): number | null => {\n const directIndex = list.items.indexOf(token);\n if (directIndex !== -1) {\n return directIndex;\n }\n if (!list.aliases) {\n return null;\n }\n const canonical = list.aliases[token];\n if (!canonical) {\n return null;\n }\n const canonicalIndex = list.items.indexOf(canonical);\n return canonicalIndex === -1 ? null : canonicalIndex;\n};\n\nconst hasQueryHit = (list: SequenceList, queryText: string): boolean => {\n const normalizedQuery = normalizeQueryToken(queryText);\n if (normalizeQueryToken(list.id).includes(normalizedQuery)) {\n return true;\n }\n for (const item of list.items) {\n if (normalizeQueryToken(item).includes(normalizedQuery)) {\n return true;\n }\n }\n if (!list.aliases) {\n return false;\n }\n return Object.keys(list.aliases).some((alias) =>\n normalizeQueryToken(alias).includes(normalizedQuery)\n );\n};\n\nconst langsRank = (list: SequenceList, langs: readonly string[]): number => {\n if (list.langs.length === 0) {\n return 0;\n }\n let best = Number.POSITIVE_INFINITY;\n for (const lang of list.langs) {\n const index = langs.indexOf(lang);\n if (index !== -1 && index < best) {\n best = index;\n }\n }\n return best;\n};\n\nconst matcherLangsAllowed = (matcher: SequenceMatch, langs: readonly string[]): boolean => {\n if (!matcher.langs || matcher.langs.length === 0) {\n return true;\n }\n return matcher.langs.some((lang) => langs.includes(lang));\n};\n\nexport class SequenceRegistry {\n readonly langs: readonly string[];\n\n private lists: SequenceList[] = [];\n private matchers: SequenceMatch[] = [];\n\n constructor(opts?: { langs?: readonly string[] }) {\n this.langs = normalizeLangs(opts?.langs);\n }\n\n register(list: SequenceList): void {\n const index = this.lists.findIndex((item) => item.id === list.id);\n if (index === -1) {\n this.lists.push(list);\n } else {\n this.lists[index] = list;\n }\n }\n\n registerMatch(matcher: SequenceMatch): void {\n const index = this.matchers.findIndex((item) => item.id === matcher.id);\n if (index === -1) {\n this.matchers.push(matcher);\n } else {\n this.matchers[index] = matcher;\n }\n }\n\n unregister(id: string): void {\n this.lists = this.lists.filter((item) => item.id !== id);\n this.matchers = this.matchers.filter((item) => item.id !== id);\n }\n\n list(query?: RegistryQuery): SequenceList[] {\n let lists = [...this.lists];\n if (query?.enabledIds && query.enabledIds.length > 0) {\n const enabled = new Set(query.enabledIds);\n lists = lists.filter((list) => enabled.has(list.id));\n }\n const queryText = query?.queryText;\n if (queryText) {\n lists = lists.filter((list) => hasQueryHit(list, queryText));\n }\n return lists;\n }\n\n match(seed: readonly string[], query?: RegistryQuery): SequenceMatchResult | null {\n if (seed.length === 0) {\n return null;\n }\n let bestMatch: SequenceMatchResult | null = null;\n let bestScore = Number.NEGATIVE_INFINITY;\n\n const enabledIds = query?.enabledIds ? new Set(query.enabledIds) : null;\n for (const matcher of this.matchers) {\n if (enabledIds && !enabledIds.has(matcher.id)) {\n continue;\n }\n if (!matcherLangsAllowed(matcher, this.langs)) {\n continue;\n }\n const matched = matcher.match(seed);\n if (!matched) {\n continue;\n }\n const score = matched.score;\n if (!Number.isFinite(score)) {\n continue;\n }\n if (score > bestScore) {\n bestScore = score;\n bestMatch = {\n kind: 'matcher',\n matcher,\n step: matched.step ?? 1,\n state: matched.state\n };\n }\n }\n\n const candidates = this.list(query)\n .map((list) => ({ list, rank: langsRank(list, this.langs) }))\n .filter((candidate) => Number.isFinite(candidate.rank))\n .sort((a, b) => a.rank - b.rank);\n\n for (const { list, rank } of candidates) {\n const indices: number[] = [];\n let matchFailed = false;\n for (const token of seed) {\n const index = resolveIndex(list, token);\n if (index === null) {\n matchFailed = true;\n break;\n }\n indices.push(index);\n }\n if (matchFailed) {\n continue;\n }\n const step = this.inferStep(list, indices);\n if (step === null) {\n continue;\n }\n const listScore = 10 - rank;\n if (listScore > bestScore) {\n bestScore = listScore;\n bestMatch = {\n kind: 'list',\n list,\n startIndex: indices[indices.length - 1] ?? 0,\n step\n };\n }\n }\n\n return bestMatch;\n }\n\n private inferStep(list: SequenceList, indices: number[]): number | null {\n if (indices.length < 2) {\n return 1;\n }\n const length = list.items.length;\n const baseStep = this.stepBetween(list.mode, length, indices[0]!, indices[1]!);\n if (baseStep === null) {\n return null;\n }\n for (let i = 2; i < indices.length; i += 1) {\n const expected = this.nextIndex(list.mode, length, indices[i - 1]!, baseStep);\n if (expected === null || expected !== indices[i]) {\n return null;\n }\n }\n return baseStep;\n }\n\n private stepBetween(\n mode: SequenceListMode,\n length: number,\n from: number,\n to: number\n ): number | null {\n if (mode === 'cycle') {\n const step = (to - from + length) % length;\n return step;\n }\n const step = to - from;\n if (step < 0) {\n return null;\n }\n return step;\n }\n\n private nextIndex(\n mode: SequenceListMode,\n length: number,\n from: number,\n step: number\n ): number | null {\n if (mode === 'cycle') {\n return (from + step) % length;\n }\n const next = from + step;\n if (next >= length) {\n return null;\n }\n return next;\n }\n}\n","import type { SequenceList, SequenceMatch } from './registry';\nimport { SequenceRegistry } from './registry';\n\nconst weekdaysEn: SequenceList = {\n id: 'weekdays-en',\n mode: 'cycle',\n langs: ['en'],\n items: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],\n aliases: {\n Mon: 'Monday',\n Tue: 'Tuesday',\n Tues: 'Tuesday',\n Wed: 'Wednesday',\n Thu: 'Thursday',\n Thur: 'Thursday',\n Thurs: 'Thursday',\n Fri: 'Friday',\n Sat: 'Saturday',\n Sun: 'Sunday'\n }\n};\n\nconst weekdaysJa: SequenceList = {\n id: 'weekdays-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日', '日曜日'],\n aliases: {\n 月曜: '月曜日',\n 月: '月曜日',\n 火曜: '火曜日',\n 火: '火曜日',\n 水曜: '水曜日',\n 水: '水曜日',\n 木曜: '木曜日',\n 木: '木曜日',\n 金曜: '金曜日',\n 金: '金曜日',\n 土曜: '土曜日',\n 土: '土曜日',\n 日曜: '日曜日',\n 日: '日曜日'\n }\n};\n\nconst monthsEn: SequenceList = {\n id: 'months-en',\n mode: 'cycle',\n langs: ['en'],\n items: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December'\n ],\n aliases: {\n Jan: 'January',\n Feb: 'February',\n Mar: 'March',\n Apr: 'April',\n Jun: 'June',\n Jul: 'July',\n Aug: 'August',\n Sep: 'September',\n Sept: 'September',\n Oct: 'October',\n Nov: 'November',\n Dec: 'December'\n }\n};\n\nconst monthsJa: SequenceList = {\n id: 'months-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']\n};\n\nconst monthsJaTraditional: SequenceList = {\n id: 'months-ja-traditional',\n mode: 'cycle',\n langs: ['ja'],\n items: ['睦月', '如月', '弥生', '卯月', '皐月', '水無月', '文月', '葉月', '長月', '神無月', '霜月', '師走']\n};\n\nconst quartersEn: SequenceList = {\n id: 'quarters-en',\n mode: 'cycle',\n langs: ['en'],\n items: ['Q1', 'Q2', 'Q3', 'Q4']\n};\n\nconst quartersJa: SequenceList = {\n id: 'quarters-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['第1四半期', '第2四半期', '第3四半期', '第4四半期']\n};\n\nconst zodiacAnimals: SequenceList = {\n id: 'zodiac-animals-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥']\n};\n\nconst zodiacSignsEn: SequenceList = {\n id: 'zodiac-signs-en',\n mode: 'cycle',\n langs: ['en'],\n items: [\n 'Aries',\n 'Taurus',\n 'Gemini',\n 'Cancer',\n 'Leo',\n 'Virgo',\n 'Libra',\n 'Scorpio',\n 'Sagittarius',\n 'Capricorn',\n 'Aquarius',\n 'Pisces'\n ]\n};\n\nconst zodiacSignsJa: SequenceList = {\n id: 'zodiac-signs-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['牡羊座', '牡牛座', '双子座', '蟹座', '獅子座', '乙女座', '天秤座', '蠍座', '射手座', '山羊座', '水瓶座', '魚座'],\n aliases: {\n さそり座: '蠍座'\n }\n};\n\nconst directions16En: SequenceList = {\n id: 'directions-16-en',\n mode: 'cycle',\n langs: ['en'],\n items: [\n 'North',\n 'North-Northeast',\n 'Northeast',\n 'East-Northeast',\n 'East',\n 'East-Southeast',\n 'Southeast',\n 'South-Southeast',\n 'South',\n 'South-Southwest',\n 'Southwest',\n 'West-Southwest',\n 'West',\n 'West-Northwest',\n 'Northwest',\n 'North-Northwest'\n ]\n};\n\nconst directions16Ja: SequenceList = {\n id: 'directions-16-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: [\n '北',\n '北北東',\n '北東',\n '東北東',\n '東',\n '東南東',\n '南東',\n '南南東',\n '南',\n '南南西',\n '南西',\n '西南西',\n '西',\n '西北西',\n '北西',\n '北北西'\n ]\n};\n\nconst ampmEn: SequenceList = {\n id: 'ampm-en',\n mode: 'cycle',\n langs: ['en'],\n items: ['AM', 'PM'],\n aliases: {\n 'A.M.': 'AM',\n 'P.M.': 'PM'\n }\n};\n\nconst ampmJa: SequenceList = {\n id: 'ampm-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['午前', '午後']\n};\n\nconst seasonsEn: SequenceList = {\n id: 'seasons-en',\n mode: 'cycle',\n langs: ['en'],\n items: ['Spring', 'Summer', 'Autumn', 'Winter'],\n aliases: {\n Fall: 'Autumn'\n }\n};\n\nconst seasonsJa: SequenceList = {\n id: 'seasons-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['春', '夏', '秋', '冬']\n};\n\nconst solfegeJa: SequenceList = {\n id: 'solfege-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['ド', 'レ', 'ミ', 'ファ', 'ソ', 'ラ', 'シ']\n};\n\nconst solfegeEn: SequenceList = {\n id: 'solfege-en',\n mode: 'cycle',\n langs: ['en'],\n items: ['Do', 'Re', 'Mi', 'Fa', 'Sol', 'La', 'Ti'],\n aliases: {\n So: 'Sol',\n Si: 'Ti'\n }\n};\n\nconst greekLettersEn: SequenceList = {\n id: 'greek-letters-en',\n mode: 'cycle',\n langs: ['en'],\n items: [\n 'Alpha',\n 'Beta',\n 'Gamma',\n 'Delta',\n 'Epsilon',\n 'Zeta',\n 'Eta',\n 'Theta',\n 'Iota',\n 'Kappa',\n 'Lambda',\n 'Mu',\n 'Nu',\n 'Xi',\n 'Omicron',\n 'Pi',\n 'Rho',\n 'Sigma',\n 'Tau',\n 'Upsilon',\n 'Phi',\n 'Chi',\n 'Psi',\n 'Omega'\n ]\n};\n\nconst greekLettersJa: SequenceList = {\n id: 'greek-letters-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: [\n 'アルファ',\n 'ベータ',\n 'ガンマ',\n 'デルタ',\n 'イプシロン',\n 'ゼータ',\n 'イータ',\n 'シータ',\n 'イオタ',\n 'カッパ',\n 'ラムダ',\n 'ミュー',\n 'ニュー',\n 'クサイ',\n 'オミクロン',\n 'パイ',\n 'ロー',\n 'シグマ',\n 'タウ',\n 'ウプシロン',\n 'ファイ',\n 'カイ',\n 'プサイ',\n 'オメガ'\n ]\n};\n\nconst greekLettersSymbols: SequenceList = {\n id: 'greek-letters-symbols',\n mode: 'cycle',\n langs: ['en', 'ja'],\n items: [\n 'α',\n 'β',\n 'γ',\n 'δ',\n 'ε',\n 'ζ',\n 'η',\n 'θ',\n 'ι',\n 'κ',\n 'λ',\n 'μ',\n 'ν',\n 'ξ',\n 'ο',\n 'π',\n 'ρ',\n 'σ',\n 'τ',\n 'υ',\n 'φ',\n 'χ',\n 'ψ',\n 'ω'\n ],\n aliases: {\n 'ς': 'σ'\n }\n};\n\nconst rokuyo: SequenceList = {\n id: 'rokuyo-ja',\n mode: 'cycle',\n langs: ['ja'],\n items: ['先勝', '友引', '先負', '仏滅', '大安', '赤口']\n};\n\nconst heavenlyStems: SequenceList = {\n id: 'heavenly-stems-ja',\n mode: 'finite',\n langs: ['ja'],\n items: ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']\n};\n\nconst planetsEn: SequenceList = {\n id: 'planets-en',\n mode: 'finite',\n langs: ['en'],\n items: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']\n};\n\nconst planetsJa: SequenceList = {\n id: 'planets-ja',\n mode: 'finite',\n langs: ['ja'],\n items: ['水星', '金星', '地球', '火星', '木星', '土星', '天王星', '海王星']\n};\n\nconst kujiIn: SequenceList = {\n id: 'kuji-in-ja',\n mode: 'finite',\n langs: ['ja'],\n items: ['臨', '兵', '闘', '者', '皆', '陣', '烈', '在', '前']\n};\n\nconst eightVirtues: SequenceList = {\n id: 'eight-virtues-ja',\n mode: 'finite',\n langs: ['ja'],\n items: ['仁', '義', '礼', '智', '忠', '信', '孝', '悌']\n};\n\nconst builtInLists: SequenceList[] = [\n weekdaysEn,\n weekdaysJa,\n monthsEn,\n monthsJa,\n monthsJaTraditional,\n quartersEn,\n quartersJa,\n zodiacAnimals,\n zodiacSignsEn,\n zodiacSignsJa,\n directions16En,\n directions16Ja,\n ampmEn,\n ampmJa,\n seasonsEn,\n seasonsJa,\n solfegeJa,\n solfegeEn,\n greekLettersEn,\n greekLettersJa,\n greekLettersSymbols,\n rokuyo,\n heavenlyStems,\n planetsEn,\n planetsJa,\n kujiIn,\n eightVirtues\n];\n\nconst ordinalSuffix = (value: number): string => {\n const mod100 = value % 100;\n if (mod100 >= 11 && mod100 <= 13) return 'th';\n const mod10 = value % 10;\n if (mod10 === 1) return 'st';\n if (mod10 === 2) return 'nd';\n if (mod10 === 3) return 'rd';\n return 'th';\n};\n\nconst parseOrdinal = (value: string): number | null => {\n const match = /^(\\d+)(st|nd|rd|th)$/.exec(value);\n if (!match) return null;\n const num = Number(match[1]);\n if (!Number.isFinite(num) || num <= 0) return null;\n const suffix = match[2];\n if (ordinalSuffix(num) !== suffix) return null;\n return num;\n};\n\nconst ordinalMatcher: SequenceMatch = {\n id: 'ordinal-en',\n langs: ['en'],\n match(seed) {\n if (seed.length < 2) return null;\n const values = seed.map((value) => parseOrdinal(value));\n if (values.some((value) => value === null)) return null;\n const nums = values as number[];\n const step = nums[1]! - nums[0]!;\n for (let i = 2; i < nums.length; i += 1) {\n if (nums[i]! - nums[i - 1]! !== step) return null;\n }\n return { score: 80, step };\n },\n createIterator(seed, ctx) {\n const last = parseOrdinal(seed[seed.length - 1] ?? '');\n let current = last ?? 0;\n return {\n next() {\n current += ctx.step;\n if (current <= 0 || !Number.isFinite(current)) {\n return { value: undefined, done: true } as IteratorResult<string>;\n }\n return { value: `${current}${ordinalSuffix(current)}`, done: false };\n }\n };\n }\n};\n\nexport const registerBuiltInLists = (registry: SequenceRegistry): void => {\n for (const list of builtInLists) {\n registry.register(list);\n }\n};\n\nexport const registerBuiltInMatchers = (registry: SequenceRegistry): void => {\n registry.registerMatch(ordinalMatcher);\n};\n\nexport const createBuiltInRegistry = (langs?: readonly string[]): SequenceRegistry => {\n const registry = new SequenceRegistry({ langs });\n registerBuiltInLists(registry);\n registerBuiltInMatchers(registry);\n return registry;\n};\n","import type { SequenceKind, SequenceValue } from './types';\n\nconst createSeedRepeatIterator = <T>(seed: readonly T[]): Iterator<T> => {\n let index = 0;\n return {\n next() {\n if (seed.length === 0) {\n return { value: undefined, done: true } as IteratorResult<T>;\n }\n const value = seed[index % seed.length] as T;\n index += 1;\n return { value, done: false };\n }\n };\n};\n\nexport class Sequence<T extends SequenceValue> implements Iterable<T>, Iterator<T> {\n readonly seed: readonly T[];\n kind: SequenceKind;\n private iterator: Iterator<T>;\n\n constructor(...seed: T[]);\n constructor(...args: unknown[]) {\n const seed = args as T[];\n this.seed = seed;\n this.kind = seed.length === 1 ? 'copy' : 'seed-repeat';\n this.iterator = createSeedRepeatIterator(seed);\n }\n\n static fromSeed<T extends SequenceValue>(\n seed: readonly T[],\n kind: SequenceKind,\n iterator: Iterator<T>\n ): Sequence<T> {\n const instance = new Sequence<T>(...seed);\n instance.kind = kind;\n instance.iterator = iterator;\n return instance;\n }\n\n next(): IteratorResult<T> {\n return this.iterator.next();\n }\n\n [Symbol.iterator](): Iterator<T> {\n return this;\n }\n}\n","import { createBuiltInRegistry } from './builtins';\nimport { Sequence } from './sequence';\nimport type { SequenceKind, SequenceValue } from './types';\nimport type { SequenceMatchResult, SequenceRegistry } from './registry';\n\nconst numberEpsilon = 1e-9;\nconst romanMax = 100;\n\nconst createCopyIterator = <T>(value: T): Iterator<T> => {\n return {\n next() {\n return { value, done: false };\n }\n };\n};\n\nconst createSeedRepeatIterator = <T>(seed: readonly T[]): Iterator<T> => {\n let index = 0;\n return {\n next() {\n if (seed.length === 0) {\n return { value: undefined, done: true } as IteratorResult<T>;\n }\n const value = seed[index % seed.length] as T;\n index += 1;\n return { value, done: false };\n }\n };\n};\n\nconst createArithmeticNumberIterator = (last: number, step: number): Iterator<number> => {\n let offset = 0;\n return {\n next() {\n offset += 1;\n const value = last + step * offset;\n return { value, done: false };\n }\n };\n};\n\nconst createArithmeticDateIterator = (last: Date, stepMs: number): Iterator<Date> => {\n let offset = 0;\n return {\n next() {\n offset += 1;\n const value = new Date(last.getTime() + stepMs * offset);\n return { value, done: false };\n }\n };\n};\n\nconst createGeometricIterator = (last: number, ratio: number): Iterator<number> => {\n let offset = 0;\n return {\n next() {\n offset += 1;\n const value = last * ratio ** offset;\n return { value, done: false };\n }\n };\n};\n\nconst createListIterator = (\n match: SequenceMatchResult,\n seed: readonly string[]\n): Iterator<string> => {\n if (match.kind === 'matcher') {\n return match.matcher.createIterator(seed, { step: match.step, state: match.state });\n }\n const { list, startIndex, step } = match;\n const length = list.items.length;\n let currentIndex = startIndex;\n return {\n next() {\n if (list.mode === 'finite') {\n const nextIndex = currentIndex + step;\n if (nextIndex >= length) {\n return { value: undefined, done: true } as IteratorResult<string>;\n }\n currentIndex = nextIndex;\n return { value: list.items[currentIndex] as string, done: false };\n }\n currentIndex = (currentIndex + step) % length;\n return { value: list.items[currentIndex] as string, done: false };\n }\n };\n};\n\nconst isNumberSeed = (seed: readonly SequenceValue[]): seed is readonly number[] => {\n return seed.every((value) => typeof value === 'number' && Number.isFinite(value));\n};\n\nconst isDateSeed = (seed: readonly SequenceValue[]): seed is readonly Date[] => {\n return seed.every((value) => value instanceof Date && !Number.isNaN(value.getTime()));\n};\n\nconst isStringSeed = (seed: readonly SequenceValue[]): seed is readonly string[] => {\n return seed.every((value) => typeof value === 'string');\n};\n\nconst parseEmbeddedNumber = (value: string): { prefix: string; num: number; width: number; suffix: string } | null => {\n const match = /^(.*?)(-?\\d+)([^0-9]*)$/.exec(value);\n if (!match) {\n return null;\n }\n const prefix = match[1] ?? '';\n const digits = match[2] ?? '';\n const suffix = match[3] ?? '';\n const num = Number(digits);\n if (!Number.isFinite(num)) {\n return null;\n }\n const width = digits.replace('-', '').length;\n return { prefix, num, width, suffix };\n};\n\nconst createEmbeddedNumberIterator = (\n template: { prefix: string; suffix: string; width: number },\n last: number,\n step: number\n): Iterator<string> => {\n let offset = 0;\n return {\n next() {\n offset += 1;\n const next = last + step * offset;\n const sign = next < 0 ? '-' : '';\n const digits = Math.abs(next).toString().padStart(template.width, '0');\n return { value: `${template.prefix}${sign}${digits}${template.suffix}`, done: false };\n }\n };\n};\n\nconst romanMap: Array<[string, number]> = [\n ['C', 100],\n ['XC', 90],\n ['L', 50],\n ['XL', 40],\n ['X', 10],\n ['IX', 9],\n ['V', 5],\n ['IV', 4],\n ['I', 1]\n];\n\nconst toRoman = (value: number): string | null => {\n if (value < 1 || value > romanMax) {\n return null;\n }\n let remaining = value;\n let output = '';\n for (const [symbol, amount] of romanMap) {\n while (remaining >= amount) {\n output += symbol;\n remaining -= amount;\n }\n }\n return output;\n};\n\nconst parseRoman = (value: string): number | null => {\n if (value.length === 0) {\n return null;\n }\n if (value !== value.toUpperCase()) {\n return null;\n }\n let remaining = value;\n let total = 0;\n for (const [symbol, amount] of romanMap) {\n while (remaining.startsWith(symbol)) {\n total += amount;\n remaining = remaining.slice(symbol.length);\n }\n }\n if (remaining.length > 0) {\n return null;\n }\n const canonical = toRoman(total);\n if (!canonical || canonical !== value) {\n return null;\n }\n return total;\n};\n\nconst createRomanIterator = (last: number, step: number): Iterator<string> => {\n let offset = 0;\n return {\n next() {\n offset += 1;\n const next = last + step * offset;\n const roman = toRoman(next);\n if (!roman) {\n return { value: undefined, done: true } as IteratorResult<string>;\n }\n return { value: roman, done: false };\n }\n };\n};\n\nconst matchArithmetic = (values: readonly number[]): number | null => {\n if (values.length < 2) {\n return null;\n }\n const step = values[1]! - values[0]!;\n for (let i = 2; i < values.length; i += 1) {\n if (Math.abs(values[i]! - values[i - 1]! - step) > numberEpsilon) {\n return null;\n }\n }\n return step;\n};\n\nconst matchGeometric = (values: readonly number[]): number | null => {\n if (values.length < 2) {\n return null;\n }\n if (values[0] === 0) {\n return null;\n }\n const ratio = values[1]! / values[0]!;\n for (let i = 2; i < values.length; i += 1) {\n if (values[i - 1] === 0) {\n return null;\n }\n if (Math.abs(values[i]! / values[i - 1]! - ratio) > numberEpsilon) {\n return null;\n }\n }\n return ratio;\n};\n\nconst inferStringSequence = (\n seed: readonly string[]\n): { kind: SequenceKind; iterator: Iterator<string> } | null => {\n const embedded = seed.map((value) => parseEmbeddedNumber(value));\n if (embedded.every(Boolean)) {\n const first = embedded[0]!;\n const last = embedded[embedded.length - 1]!;\n const samePattern = embedded.every(\n (entry) => entry?.prefix === first.prefix && entry?.suffix === first.suffix\n );\n if (samePattern) {\n const values = embedded.map((entry) => entry?.num ?? 0);\n const step = matchArithmetic(values);\n if (step !== null) {\n return {\n kind: 'arithmetic',\n iterator: createEmbeddedNumberIterator(\n { prefix: last.prefix, suffix: last.suffix, width: last.width },\n last.num,\n step\n )\n };\n }\n }\n }\n\n const romanValues = seed.map((value) => parseRoman(value));\n if (romanValues.every((value) => value !== null)) {\n const numeric = romanValues as number[];\n const step = matchArithmetic(numeric);\n if (step !== null) {\n const last = numeric[numeric.length - 1]!;\n return {\n kind: 'arithmetic',\n iterator: createRomanIterator(last, step)\n };\n }\n }\n\n return null;\n};\n\nconst inferFromList = (\n seed: readonly string[],\n registry: SequenceRegistry\n): { kind: SequenceKind; iterator: Iterator<string> } | null => {\n const match = registry.match(seed);\n if (!match) {\n return null;\n }\n return {\n kind: 'list',\n iterator: createListIterator(match, seed)\n };\n};\n\nexport function inferSequence(seed: readonly number[], options?: { registry?: SequenceRegistry }): Sequence<number>;\nexport function inferSequence(seed: readonly Date[], options?: { registry?: SequenceRegistry }): Sequence<Date>;\nexport function inferSequence(seed: readonly string[], options?: { registry?: SequenceRegistry }): Sequence<string>;\nexport function inferSequence(\n seed: readonly SequenceValue[],\n options?: { registry?: SequenceRegistry }\n): Sequence<SequenceValue> {\n const registry = options?.registry ?? createBuiltInRegistry();\n if (seed.length === 0) {\n return Sequence.fromSeed(seed, 'seed-repeat', createSeedRepeatIterator(seed));\n }\n if (seed.length === 1) {\n return Sequence.fromSeed(seed, 'copy', createCopyIterator(seed[0]!));\n }\n\n if (isStringSeed(seed)) {\n const listSequence = inferFromList(seed, registry);\n if (listSequence) {\n return Sequence.fromSeed(seed, listSequence.kind, listSequence.iterator);\n }\n const structured = inferStringSequence(seed);\n if (structured) {\n return Sequence.fromSeed(seed, structured.kind, structured.iterator);\n }\n }\n\n if (isNumberSeed(seed)) {\n const step = matchArithmetic(seed);\n if (step !== null) {\n return Sequence.fromSeed(\n seed,\n 'arithmetic',\n createArithmeticNumberIterator(seed[seed.length - 1]!, step)\n );\n }\n const ratio = matchGeometric(seed);\n if (ratio !== null) {\n return Sequence.fromSeed(\n seed,\n 'geometric',\n createGeometricIterator(seed[seed.length - 1]!, ratio)\n );\n }\n }\n\n if (isDateSeed(seed)) {\n const times = seed.map((value) => value.getTime());\n const step = matchArithmetic(times);\n if (step !== null) {\n return Sequence.fromSeed(\n seed,\n 'arithmetic',\n createArithmeticDateIterator(seed[seed.length - 1]!, step)\n );\n }\n }\n\n return Sequence.fromSeed(seed, 'seed-repeat', createSeedRepeatIterator(seed));\n}\n"],"names":["normalizeQueryToken","value","normalizeLangs","langs","result","lang","normalized","resolveIndex","list","token","directIndex","canonical","canonicalIndex","hasQueryHit","queryText","normalizedQuery","item","alias","langsRank","best","index","matcherLangsAllowed","matcher","SequenceRegistry","opts","id","query","lists","enabled","seed","bestMatch","bestScore","enabledIds","matched","score","candidates","candidate","a","b","rank","indices","matchFailed","step","listScore","length","baseStep","expected","mode","from","to","next","weekdaysEn","weekdaysJa","monthsEn","monthsJa","monthsJaTraditional","quartersEn","quartersJa","zodiacAnimals","zodiacSignsEn","zodiacSignsJa","directions16En","directions16Ja","ampmEn","ampmJa","seasonsEn","seasonsJa","solfegeJa","solfegeEn","greekLettersEn","greekLettersJa","greekLettersSymbols","rokuyo","heavenlyStems","planetsEn","planetsJa","kujiIn","eightVirtues","builtInLists","ordinalSuffix","mod100","mod10","parseOrdinal","match","num","suffix","ordinalMatcher","values","nums","i","ctx","current","registerBuiltInLists","registry","registerBuiltInMatchers","createBuiltInRegistry","createSeedRepeatIterator","Sequence","args","kind","iterator","instance","numberEpsilon","romanMax","createCopyIterator","createArithmeticNumberIterator","last","offset","createArithmeticDateIterator","stepMs","createGeometricIterator","ratio","createListIterator","startIndex","currentIndex","nextIndex","isNumberSeed","isDateSeed","isStringSeed","parseEmbeddedNumber","prefix","digits","width","createEmbeddedNumberIterator","template","sign","romanMap","toRoman","remaining","output","symbol","amount","parseRoman","total","createRomanIterator","roman","matchArithmetic","matchGeometric","inferStringSequence","embedded","first","entry","romanValues","numeric","inferFromList","inferSequence","options","listSequence","structured","times"],"mappings":"AA2CA,MAAMA,IAAsB,CAACC,MACpBA,EAAM,KAAA,EAAO,UAAU,MAAM,EAAE,cAAc,QAAQ,QAAQ,GAAG,GAGnEC,IAAiB,CAACC,MAAiD;AACvE,QAAMC,IAAmB,CAAA;AACzB,MAAID;AACF,eAAWE,KAAQF,GAAO;AACxB,YAAMG,IAAaD,EAAK,KAAA;AACxB,MAAI,CAACC,KAAcF,EAAO,SAASE,CAAU,KAG7CF,EAAO,KAAKE,CAAU;AAAA,IACxB;AAEF,SAAIF,EAAO,WAAW,IACpBA,EAAO,KAAK,IAAY,IACdA,EAAO,SAAS,IAAY,KACtCA,EAAO,KAAK,IAAY,GAEnBA;AACT,GAEMG,IAAe,CAACC,GAAoBC,MAAiC;AACzE,QAAMC,IAAcF,EAAK,MAAM,QAAQC,CAAK;AAC5C,MAAIC,MAAgB;AAClB,WAAOA;AAET,MAAI,CAACF,EAAK;AACR,WAAO;AAET,QAAMG,IAAYH,EAAK,QAAQC,CAAK;AACpC,MAAI,CAACE;AACH,WAAO;AAET,QAAMC,IAAiBJ,EAAK,MAAM,QAAQG,CAAS;AACnD,SAAOC,MAAmB,KAAK,OAAOA;AACxC,GAEMC,IAAc,CAACL,GAAoBM,MAA+B;AAC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qE,IAAQ0B,GAAe5G,CAAI;AACjC,QAAIkF,MAAU;AACZ,aAAOd,EAAS;AAAA,QACdpE;AAAA,QACA;AAAA,QACAiF,GAAwBjF,EAAKA,EAAK,SAAS,CAAC,GAAIkF,CAAK;AAAA,MAAA;AAAA,EAG3D;AAEA,MAAIM,GAAWxF,CAAI,GAAG;AACpB,UAAMwH,IAAQxH,EAAK,IAAI,CAAC5B,MAAUA,EAAM,SAAS,GAC3CyC,IAAO8F,EAAgBa,CAAK;AAClC,QAAI3G,MAAS;AACX,aAAOuD,EAAS;AAAA,QACdpE;AAAA,QACA;AAAA,QACA+E,GAA6B/E,EAAKA,EAAK,SAAS,CAAC,GAAIa,CAAI;AAAA,MAAA;AAAA,EAG/D;AAEA,SAAOuD,EAAS,SAASpE,GAAM,eAAemE,EAAyBnE,CAAI,CAAC;AAC9E;"}
|
package/dist/infer.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Sequence } from './sequence';
|
|
2
|
+
import type { SequenceRegistry } from './registry';
|
|
3
|
+
export declare function inferSequence(seed: readonly number[], options?: {
|
|
4
|
+
registry?: SequenceRegistry;
|
|
5
|
+
}): Sequence<number>;
|
|
6
|
+
export declare function inferSequence(seed: readonly Date[], options?: {
|
|
7
|
+
registry?: SequenceRegistry;
|
|
8
|
+
}): Sequence<Date>;
|
|
9
|
+
export declare function inferSequence(seed: readonly string[], options?: {
|
|
10
|
+
registry?: SequenceRegistry;
|
|
11
|
+
}): Sequence<string>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type SequenceListMode = 'cycle' | 'finite';
|
|
2
|
+
export type SequenceList = {
|
|
3
|
+
id: string;
|
|
4
|
+
mode: SequenceListMode;
|
|
5
|
+
langs: readonly string[];
|
|
6
|
+
items: readonly string[];
|
|
7
|
+
aliases?: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export type SequenceMatch = {
|
|
10
|
+
id: string;
|
|
11
|
+
langs?: readonly string[];
|
|
12
|
+
match(seed: readonly string[]): {
|
|
13
|
+
score: number;
|
|
14
|
+
startIndex?: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
state?: unknown;
|
|
17
|
+
} | null;
|
|
18
|
+
createIterator(seed: readonly string[], ctx: {
|
|
19
|
+
step: number;
|
|
20
|
+
state?: unknown;
|
|
21
|
+
}): Iterator<string>;
|
|
22
|
+
};
|
|
23
|
+
export type RegistryQuery = {
|
|
24
|
+
enabledIds?: readonly string[];
|
|
25
|
+
queryText?: string;
|
|
26
|
+
};
|
|
27
|
+
export type SequenceMatchResult = {
|
|
28
|
+
kind: 'list';
|
|
29
|
+
list: SequenceList;
|
|
30
|
+
startIndex: number;
|
|
31
|
+
step: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'matcher';
|
|
34
|
+
matcher: SequenceMatch;
|
|
35
|
+
step: number;
|
|
36
|
+
state?: unknown;
|
|
37
|
+
};
|
|
38
|
+
export declare class SequenceRegistry {
|
|
39
|
+
readonly langs: readonly string[];
|
|
40
|
+
private lists;
|
|
41
|
+
private matchers;
|
|
42
|
+
constructor(opts?: {
|
|
43
|
+
langs?: readonly string[];
|
|
44
|
+
});
|
|
45
|
+
register(list: SequenceList): void;
|
|
46
|
+
registerMatch(matcher: SequenceMatch): void;
|
|
47
|
+
unregister(id: string): void;
|
|
48
|
+
list(query?: RegistryQuery): SequenceList[];
|
|
49
|
+
match(seed: readonly string[], query?: RegistryQuery): SequenceMatchResult | null;
|
|
50
|
+
private inferStep;
|
|
51
|
+
private stepBetween;
|
|
52
|
+
private nextIndex;
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SequenceKind, SequenceValue } from './types';
|
|
2
|
+
export declare class Sequence<T extends SequenceValue> implements Iterable<T>, Iterator<T> {
|
|
3
|
+
readonly seed: readonly T[];
|
|
4
|
+
kind: SequenceKind;
|
|
5
|
+
private iterator;
|
|
6
|
+
constructor(...seed: T[]);
|
|
7
|
+
static fromSeed<T extends SequenceValue>(seed: readonly T[], kind: SequenceKind, iterator: Iterator<T>): Sequence<T>;
|
|
8
|
+
next(): IteratorResult<T>;
|
|
9
|
+
[Symbol.iterator](): Iterator<T>;
|
|
10
|
+
}
|
package/dist/types.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@extable/sequence",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.build.json --emitDeclarationOnly && vite build",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"lint": "biome lint .",
|
|
24
|
+
"format": "biome format --write ."
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.6.3"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=22"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/shibukawa/extable.git"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://shibukawa.github.io/extable/",
|
|
37
|
+
"author": "Yoshiki Shibukawa",
|
|
38
|
+
"license": "Apache-2.0",
|
|
39
|
+
"peerDependencies": {}
|
|
40
|
+
}
|