-
Notifications
You must be signed in to change notification settings - Fork 1
/
extend_wasm_pkg.sh
executable file
·97 lines (92 loc) · 2.7 KB
/
extend_wasm_pkg.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
API="
// CUSTOM API FROM extend_wasm_pkg.sh
// ------------------------------------------------------
export function matchValue(value, matcher) {
if (
matcher.string &&
matcher.boolean &&
matcher.dateTime &&
matcher.number &&
matcher.duration &&
matcher.raw
) {
switch (value._type) {
case 'string':
case 'langString':
return matcher.string(value)
case 'raw':
return matcher.raw(value)
case 'dateTime':
return matcher.dateTime(value)
case 'number':
return matcher.number(value)
case 'boolean':
return matcher.boolean(value)
case 'duration':
return matcher.duration(value)
}
} else if (matcher.default) {
switch (value._type) {
case 'string':
case 'langString':
return matcher.string !== undefined
? matcher.string(value)
: matcher.default(value)
case 'raw':
return matcher.raw !== undefined
? matcher.raw(value)
: matcher.default(value)
case 'dateTime':
return matcher.dateTime !== undefined
? matcher.dateTime(value)
: matcher.default(value)
case 'number':
return matcher.number !== undefined
? matcher.number(value)
: matcher.default(value)
case 'boolean':
return matcher.boolean !== undefined
? matcher.boolean(value)
: matcher.default(value)
case 'duration':
return matcher.duration !== undefined
? matcher.duration(value)
: matcher.default(value)
default:
return matcher.default(value)
}
} else {
throw new Error('Non exhaustive value match!')
}
}
export function matchAxiom(axiom, matcher) {
for (const key in axiom) {
if (matcher[key]) {
return matcher[key](axiom[key])
break
}
}
}
export function matchDeclaration(declaration, matcher) {
for (const key in declaration) {
if (matcher[key]) {
return matcher[key](declaration[key])
break
}
}
}
export function matchClassConst(axiom, matcher) {
for (const key in axiom) {
if (matcher[key]) {
return matcher[key](axiom[key])
break
}
}
}
export class IRI {
_type
string
}
"
echo "$API" >> ./pkg/owlish.js