-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.ts
More file actions
28 lines (26 loc) · 829 Bytes
/
Copy pathinit.ts
File metadata and controls
28 lines (26 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as xlsx from "../index";
{
xlsx.registerType("items", (value) => {
try {
type ItemArray = [number, number][];
const items = xlsx.convertValue(value, "table") as ItemArray;
if (Array.isArray(items)) {
return items.map((v) => ({ id: v[0], count: v[1] }));
}
return null;
} catch {
return null;
}
});
xlsx.registerType("item", (value) => {
try {
type Item = [number, number];
const item = xlsx.convertValue(value, "json") as Item;
return { id: item[0], count: item[1] };
} catch {
return null;
}
});
}
xlsx.registerChecker("TaskArgsChecker", () => () => true);
xlsx.registerChecker("ItemArrayChecker", () => () => true);