@c9up/atom 0.1.11 → 0.1.13
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/README.md +9 -1
- package/dist/Decimal.d.ts +8 -1
- package/dist/Decimal.d.ts.map +1 -1
- package/dist/Decimal.js +132 -96
- package/dist/Decimal.js.map +1 -1
- package/dist/Money.d.ts +15 -2
- package/dist/Money.d.ts.map +1 -1
- package/dist/Money.js +28 -3
- package/dist/Money.js.map +1 -1
- package/dist/atlas.d.ts +2 -5
- package/dist/atlas.d.ts.map +1 -1
- package/dist/atlas.js +2 -5
- package/dist/atlas.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -33
- package/dist/index.js.map +1 -1
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +8 -7
- package/scripts/build-napi-types.mjs +4 -3
- package/scripts/clean-wasm-pack-meta.mjs +32 -0
- package/scripts/copy-napi.mjs +11 -3
- package/scripts/generate-napi-types.mjs +9 -6
- package/scripts/verify-wasm.mjs +29 -1
- package/src/Decimal.ts +203 -134
- package/src/Money.ts +44 -5
- package/src/atlas.ts +2 -5
- package/src/index.ts +75 -36
- package/wasm/atom_engine_wasm.d.ts +60 -0
- package/wasm/atom_engine_wasm.js +416 -0
- package/wasm/atom_engine_wasm_bg.wasm +0 -0
- package/wasm/atom_engine_wasm_bg.wasm.d.ts +17 -0
package/src/index.ts
CHANGED
|
@@ -26,7 +26,11 @@ export type {
|
|
|
26
26
|
ToMinorUnitsOptions,
|
|
27
27
|
} from "./Decimal.js";
|
|
28
28
|
export { Decimal } from "./Decimal.js";
|
|
29
|
-
export type {
|
|
29
|
+
export type {
|
|
30
|
+
MoneyFormatOptions,
|
|
31
|
+
MoneyOptions,
|
|
32
|
+
MoneyRoundingOptions,
|
|
33
|
+
} from "./Money.js";
|
|
30
34
|
export { Money, money } from "./Money.js";
|
|
31
35
|
export { isNativeAvailable } from "./native.js";
|
|
32
36
|
|
|
@@ -46,13 +50,36 @@ function isDecimalIterable(value: unknown): value is Iterable<DecimalInput> {
|
|
|
46
50
|
);
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
/**
|
|
54
|
+
* What every aggregate accepts as one value.
|
|
55
|
+
*
|
|
56
|
+
* The variadic form used to be asserted back into shape — a claim about the
|
|
57
|
+
* caller's arguments made in the one place that can check them. Anything else
|
|
58
|
+
* reached `new Decimal(...)`, where an object failed as
|
|
59
|
+
* `input.trim is not a function`, naming neither the argument nor the call.
|
|
60
|
+
*/
|
|
61
|
+
function isDecimalValue(value: unknown): value is DecimalInput {
|
|
62
|
+
return (
|
|
63
|
+
Decimal.isDecimal(value) ||
|
|
64
|
+
typeof value === "string" ||
|
|
65
|
+
typeof value === "number" ||
|
|
66
|
+
typeof value === "bigint"
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function toDecimalValue(value: unknown): DecimalInput {
|
|
71
|
+
if (isDecimalValue(value)) return value;
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Atom aggregates take a string, number, bigint or Decimal, got ${
|
|
74
|
+
value === null ? "null" : typeof value
|
|
75
|
+
}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function resolveValues(args: readonly unknown[]): Iterable<DecimalInput> {
|
|
80
|
+
const head = args[0];
|
|
81
|
+
if (args.length === 1 && isDecimalIterable(head)) return head;
|
|
82
|
+
return args.map(toDecimalValue);
|
|
56
83
|
}
|
|
57
84
|
|
|
58
85
|
function sumImpl(values: Iterable<DecimalInput>): Decimal {
|
|
@@ -77,25 +104,25 @@ function avgImpl(values: Iterable<DecimalInput>): Decimal {
|
|
|
77
104
|
}
|
|
78
105
|
|
|
79
106
|
function minImpl(values: Iterable<DecimalInput>): Decimal {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
107
|
+
const [first, ...rest] = [...values].map((value) => new Decimal(value));
|
|
108
|
+
if (first === undefined) {
|
|
82
109
|
throw new Error("Atom.min requires at least one value");
|
|
83
110
|
}
|
|
84
|
-
let best =
|
|
85
|
-
for (
|
|
86
|
-
if (
|
|
111
|
+
let best = first;
|
|
112
|
+
for (const candidate of rest) {
|
|
113
|
+
if (candidate.lt(best)) best = candidate;
|
|
87
114
|
}
|
|
88
115
|
return best;
|
|
89
116
|
}
|
|
90
117
|
|
|
91
118
|
function maxImpl(values: Iterable<DecimalInput>): Decimal {
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
119
|
+
const [first, ...rest] = [...values].map((value) => new Decimal(value));
|
|
120
|
+
if (first === undefined) {
|
|
94
121
|
throw new Error("Atom.max requires at least one value");
|
|
95
122
|
}
|
|
96
|
-
let best =
|
|
97
|
-
for (
|
|
98
|
-
if (
|
|
123
|
+
let best = first;
|
|
124
|
+
for (const candidate of rest) {
|
|
125
|
+
if (candidate.gt(best)) best = candidate;
|
|
99
126
|
}
|
|
100
127
|
return best;
|
|
101
128
|
}
|
|
@@ -110,9 +137,14 @@ function medianImpl(
|
|
|
110
137
|
}
|
|
111
138
|
list.sort((a, b) => a.cmp(b));
|
|
112
139
|
const mid = Math.floor(list.length / 2);
|
|
113
|
-
|
|
140
|
+
// The empty case threw above, so both halves of the middle are present.
|
|
141
|
+
const upper = list[mid];
|
|
142
|
+
if (upper === undefined) throw new Error("Atom.median lost its middle value");
|
|
143
|
+
if (list.length % 2 === 1) return upper;
|
|
144
|
+
const lower = list[mid - 1];
|
|
145
|
+
if (lower === undefined) throw new Error("Atom.median lost its middle value");
|
|
114
146
|
const precision = options.precision ?? defaultPrecision();
|
|
115
|
-
return
|
|
147
|
+
return lower.plus(upper).div("2", { precision });
|
|
116
148
|
}
|
|
117
149
|
|
|
118
150
|
function modeImpl(values: Iterable<DecimalInput>): Decimal[] {
|
|
@@ -162,32 +194,39 @@ function stddevImpl(
|
|
|
162
194
|
return variance.sqrt({ precision, mode });
|
|
163
195
|
}
|
|
164
196
|
|
|
197
|
+
/**
|
|
198
|
+
* The trailing options object of `median(values, options)` / `stddev(values,
|
|
199
|
+
* options)`, or `{}`.
|
|
200
|
+
*
|
|
201
|
+
* A `Decimal` is an object too, so excluding it is what lets the compiler
|
|
202
|
+
* check the narrowing instead of being told the answer.
|
|
203
|
+
*/
|
|
204
|
+
function optionsFrom<T extends MedianOptions | StddevOptions>(
|
|
205
|
+
value: DecimalInput | T | undefined,
|
|
206
|
+
): T | Record<string, never> {
|
|
207
|
+
if (typeof value !== "object" || value === null) return {};
|
|
208
|
+
if (Decimal.isDecimal(value)) return {};
|
|
209
|
+
return value;
|
|
210
|
+
}
|
|
211
|
+
|
|
165
212
|
function parseMedianArgs(
|
|
166
213
|
args: [Iterable<DecimalInput>, MedianOptions?] | DecimalInput[],
|
|
167
214
|
): { values: Iterable<DecimalInput>; options: MedianOptions } {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
args.length > 1 && typeof args[1] === "object" && args[1] !== null
|
|
172
|
-
? (args[1] as MedianOptions)
|
|
173
|
-
: {};
|
|
174
|
-
return { values, options };
|
|
215
|
+
const head = args[0];
|
|
216
|
+
if (isDecimalIterable(head)) {
|
|
217
|
+
return { values: head, options: optionsFrom<MedianOptions>(args[1]) };
|
|
175
218
|
}
|
|
176
|
-
return { values: args
|
|
219
|
+
return { values: resolveValues(args), options: {} };
|
|
177
220
|
}
|
|
178
221
|
|
|
179
222
|
function parseStddevArgs(
|
|
180
223
|
args: [Iterable<DecimalInput>, StddevOptions?] | DecimalInput[],
|
|
181
224
|
): { values: Iterable<DecimalInput>; options: StddevOptions } {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
args.length > 1 && typeof args[1] === "object" && args[1] !== null
|
|
186
|
-
? (args[1] as StddevOptions)
|
|
187
|
-
: {};
|
|
188
|
-
return { values, options };
|
|
225
|
+
const head = args[0];
|
|
226
|
+
if (isDecimalIterable(head)) {
|
|
227
|
+
return { values: head, options: optionsFrom<StddevOptions>(args[1]) };
|
|
189
228
|
}
|
|
190
|
-
return { values: args
|
|
229
|
+
return { values: resolveValues(args), options: {} };
|
|
191
230
|
}
|
|
192
231
|
|
|
193
232
|
function sumFn(...args: [Iterable<DecimalInput>] | DecimalInput[]): Decimal {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function add(a: string, b: string): string;
|
|
5
|
+
|
|
6
|
+
export function cmp(a: string, b: string): number;
|
|
7
|
+
|
|
8
|
+
export function div(a: string, b: string, precision: number): string;
|
|
9
|
+
|
|
10
|
+
export function mul(a: string, b: string): string;
|
|
11
|
+
|
|
12
|
+
export function pow(a: string, exp: number, precision: number): string;
|
|
13
|
+
|
|
14
|
+
export function rem(a: string, b: string): string;
|
|
15
|
+
|
|
16
|
+
export function sqrt(a: string, precision: number): string;
|
|
17
|
+
|
|
18
|
+
export function sub(a: string, b: string): string;
|
|
19
|
+
|
|
20
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
21
|
+
|
|
22
|
+
export interface InitOutput {
|
|
23
|
+
readonly memory: WebAssembly.Memory;
|
|
24
|
+
readonly add: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
25
|
+
readonly cmp: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
26
|
+
readonly div: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
27
|
+
readonly mul: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
28
|
+
readonly pow: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
29
|
+
readonly rem: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
30
|
+
readonly sqrt: (a: number, b: number, c: number) => [number, number, number, number];
|
|
31
|
+
readonly sub: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
32
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
33
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
34
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
35
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
36
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
37
|
+
readonly __wbindgen_start: () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
44
|
+
* a precompiled `WebAssembly.Module`.
|
|
45
|
+
*
|
|
46
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
47
|
+
*
|
|
48
|
+
* @returns {InitOutput}
|
|
49
|
+
*/
|
|
50
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
54
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
55
|
+
*
|
|
56
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
57
|
+
*
|
|
58
|
+
* @returns {Promise<InitOutput>}
|
|
59
|
+
*/
|
|
60
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/* @ts-self-types="./atom_engine_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} a
|
|
5
|
+
* @param {string} b
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function add(a, b) {
|
|
9
|
+
let deferred4_0;
|
|
10
|
+
let deferred4_1;
|
|
11
|
+
try {
|
|
12
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
15
|
+
const len1 = WASM_VECTOR_LEN;
|
|
16
|
+
const ret = wasm.add(ptr0, len0, ptr1, len1);
|
|
17
|
+
var ptr3 = ret[0];
|
|
18
|
+
var len3 = ret[1];
|
|
19
|
+
if (ret[3]) {
|
|
20
|
+
ptr3 = 0; len3 = 0;
|
|
21
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
22
|
+
}
|
|
23
|
+
deferred4_0 = ptr3;
|
|
24
|
+
deferred4_1 = len3;
|
|
25
|
+
return getStringFromWasm0(ptr3, len3);
|
|
26
|
+
} finally {
|
|
27
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} a
|
|
33
|
+
* @param {string} b
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
export function cmp(a, b) {
|
|
37
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
40
|
+
const len1 = WASM_VECTOR_LEN;
|
|
41
|
+
const ret = wasm.cmp(ptr0, len0, ptr1, len1);
|
|
42
|
+
if (ret[2]) {
|
|
43
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
44
|
+
}
|
|
45
|
+
return ret[0];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {string} a
|
|
50
|
+
* @param {string} b
|
|
51
|
+
* @param {number} precision
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export function div(a, b, precision) {
|
|
55
|
+
let deferred4_0;
|
|
56
|
+
let deferred4_1;
|
|
57
|
+
try {
|
|
58
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
61
|
+
const len1 = WASM_VECTOR_LEN;
|
|
62
|
+
const ret = wasm.div(ptr0, len0, ptr1, len1, precision);
|
|
63
|
+
var ptr3 = ret[0];
|
|
64
|
+
var len3 = ret[1];
|
|
65
|
+
if (ret[3]) {
|
|
66
|
+
ptr3 = 0; len3 = 0;
|
|
67
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
68
|
+
}
|
|
69
|
+
deferred4_0 = ptr3;
|
|
70
|
+
deferred4_1 = len3;
|
|
71
|
+
return getStringFromWasm0(ptr3, len3);
|
|
72
|
+
} finally {
|
|
73
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {string} a
|
|
79
|
+
* @param {string} b
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
export function mul(a, b) {
|
|
83
|
+
let deferred4_0;
|
|
84
|
+
let deferred4_1;
|
|
85
|
+
try {
|
|
86
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
87
|
+
const len0 = WASM_VECTOR_LEN;
|
|
88
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
89
|
+
const len1 = WASM_VECTOR_LEN;
|
|
90
|
+
const ret = wasm.mul(ptr0, len0, ptr1, len1);
|
|
91
|
+
var ptr3 = ret[0];
|
|
92
|
+
var len3 = ret[1];
|
|
93
|
+
if (ret[3]) {
|
|
94
|
+
ptr3 = 0; len3 = 0;
|
|
95
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
96
|
+
}
|
|
97
|
+
deferred4_0 = ptr3;
|
|
98
|
+
deferred4_1 = len3;
|
|
99
|
+
return getStringFromWasm0(ptr3, len3);
|
|
100
|
+
} finally {
|
|
101
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} a
|
|
107
|
+
* @param {number} exp
|
|
108
|
+
* @param {number} precision
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
export function pow(a, exp, precision) {
|
|
112
|
+
let deferred3_0;
|
|
113
|
+
let deferred3_1;
|
|
114
|
+
try {
|
|
115
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
const ret = wasm.pow(ptr0, len0, exp, precision);
|
|
118
|
+
var ptr2 = ret[0];
|
|
119
|
+
var len2 = ret[1];
|
|
120
|
+
if (ret[3]) {
|
|
121
|
+
ptr2 = 0; len2 = 0;
|
|
122
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
123
|
+
}
|
|
124
|
+
deferred3_0 = ptr2;
|
|
125
|
+
deferred3_1 = len2;
|
|
126
|
+
return getStringFromWasm0(ptr2, len2);
|
|
127
|
+
} finally {
|
|
128
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {string} a
|
|
134
|
+
* @param {string} b
|
|
135
|
+
* @returns {string}
|
|
136
|
+
*/
|
|
137
|
+
export function rem(a, b) {
|
|
138
|
+
let deferred4_0;
|
|
139
|
+
let deferred4_1;
|
|
140
|
+
try {
|
|
141
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
const len0 = WASM_VECTOR_LEN;
|
|
143
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
144
|
+
const len1 = WASM_VECTOR_LEN;
|
|
145
|
+
const ret = wasm.rem(ptr0, len0, ptr1, len1);
|
|
146
|
+
var ptr3 = ret[0];
|
|
147
|
+
var len3 = ret[1];
|
|
148
|
+
if (ret[3]) {
|
|
149
|
+
ptr3 = 0; len3 = 0;
|
|
150
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
151
|
+
}
|
|
152
|
+
deferred4_0 = ptr3;
|
|
153
|
+
deferred4_1 = len3;
|
|
154
|
+
return getStringFromWasm0(ptr3, len3);
|
|
155
|
+
} finally {
|
|
156
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param {string} a
|
|
162
|
+
* @param {number} precision
|
|
163
|
+
* @returns {string}
|
|
164
|
+
*/
|
|
165
|
+
export function sqrt(a, precision) {
|
|
166
|
+
let deferred3_0;
|
|
167
|
+
let deferred3_1;
|
|
168
|
+
try {
|
|
169
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
|
+
const len0 = WASM_VECTOR_LEN;
|
|
171
|
+
const ret = wasm.sqrt(ptr0, len0, precision);
|
|
172
|
+
var ptr2 = ret[0];
|
|
173
|
+
var len2 = ret[1];
|
|
174
|
+
if (ret[3]) {
|
|
175
|
+
ptr2 = 0; len2 = 0;
|
|
176
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
177
|
+
}
|
|
178
|
+
deferred3_0 = ptr2;
|
|
179
|
+
deferred3_1 = len2;
|
|
180
|
+
return getStringFromWasm0(ptr2, len2);
|
|
181
|
+
} finally {
|
|
182
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @param {string} a
|
|
188
|
+
* @param {string} b
|
|
189
|
+
* @returns {string}
|
|
190
|
+
*/
|
|
191
|
+
export function sub(a, b) {
|
|
192
|
+
let deferred4_0;
|
|
193
|
+
let deferred4_1;
|
|
194
|
+
try {
|
|
195
|
+
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
196
|
+
const len0 = WASM_VECTOR_LEN;
|
|
197
|
+
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
198
|
+
const len1 = WASM_VECTOR_LEN;
|
|
199
|
+
const ret = wasm.sub(ptr0, len0, ptr1, len1);
|
|
200
|
+
var ptr3 = ret[0];
|
|
201
|
+
var len3 = ret[1];
|
|
202
|
+
if (ret[3]) {
|
|
203
|
+
ptr3 = 0; len3 = 0;
|
|
204
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
205
|
+
}
|
|
206
|
+
deferred4_0 = ptr3;
|
|
207
|
+
deferred4_1 = len3;
|
|
208
|
+
return getStringFromWasm0(ptr3, len3);
|
|
209
|
+
} finally {
|
|
210
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function __wbg_get_imports() {
|
|
214
|
+
const import0 = {
|
|
215
|
+
__proto__: null,
|
|
216
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
217
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
218
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
219
|
+
return ret;
|
|
220
|
+
},
|
|
221
|
+
__wbindgen_init_externref_table: function() {
|
|
222
|
+
const table = wasm.__wbindgen_externrefs;
|
|
223
|
+
const offset = table.grow(4);
|
|
224
|
+
table.set(0, undefined);
|
|
225
|
+
table.set(offset + 0, undefined);
|
|
226
|
+
table.set(offset + 1, null);
|
|
227
|
+
table.set(offset + 2, true);
|
|
228
|
+
table.set(offset + 3, false);
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
return {
|
|
232
|
+
__proto__: null,
|
|
233
|
+
"./atom_engine_wasm_bg.js": import0,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function getStringFromWasm0(ptr, len) {
|
|
238
|
+
return decodeText(ptr >>> 0, len);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
let cachedUint8ArrayMemory0 = null;
|
|
242
|
+
function getUint8ArrayMemory0() {
|
|
243
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
244
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
245
|
+
}
|
|
246
|
+
return cachedUint8ArrayMemory0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
250
|
+
if (realloc === undefined) {
|
|
251
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
252
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
253
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
254
|
+
WASM_VECTOR_LEN = buf.length;
|
|
255
|
+
return ptr;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let len = arg.length;
|
|
259
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
260
|
+
|
|
261
|
+
const mem = getUint8ArrayMemory0();
|
|
262
|
+
|
|
263
|
+
let offset = 0;
|
|
264
|
+
|
|
265
|
+
for (; offset < len; offset++) {
|
|
266
|
+
const code = arg.charCodeAt(offset);
|
|
267
|
+
if (code > 0x7F) break;
|
|
268
|
+
mem[ptr + offset] = code;
|
|
269
|
+
}
|
|
270
|
+
if (offset !== len) {
|
|
271
|
+
if (offset !== 0) {
|
|
272
|
+
arg = arg.slice(offset);
|
|
273
|
+
}
|
|
274
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
275
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
276
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
277
|
+
|
|
278
|
+
offset += ret.written;
|
|
279
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
WASM_VECTOR_LEN = offset;
|
|
283
|
+
return ptr;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function takeFromExternrefTable0(idx) {
|
|
287
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
288
|
+
wasm.__externref_table_dealloc(idx);
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
293
|
+
cachedTextDecoder.decode();
|
|
294
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
295
|
+
let numBytesDecoded = 0;
|
|
296
|
+
function decodeText(ptr, len) {
|
|
297
|
+
numBytesDecoded += len;
|
|
298
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
299
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
300
|
+
cachedTextDecoder.decode();
|
|
301
|
+
numBytesDecoded = len;
|
|
302
|
+
}
|
|
303
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const cachedTextEncoder = new TextEncoder();
|
|
307
|
+
|
|
308
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
309
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
310
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
311
|
+
view.set(buf);
|
|
312
|
+
return {
|
|
313
|
+
read: arg.length,
|
|
314
|
+
written: buf.length
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
let WASM_VECTOR_LEN = 0;
|
|
320
|
+
|
|
321
|
+
let wasmModule, wasmInstance, wasm;
|
|
322
|
+
function __wbg_finalize_init(instance, module) {
|
|
323
|
+
wasmInstance = instance;
|
|
324
|
+
wasm = instance.exports;
|
|
325
|
+
wasmModule = module;
|
|
326
|
+
cachedUint8ArrayMemory0 = null;
|
|
327
|
+
wasm.__wbindgen_start();
|
|
328
|
+
return wasm;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async function __wbg_load(module, imports) {
|
|
332
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
333
|
+
if (!module.ok) {
|
|
334
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
338
|
+
try {
|
|
339
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
340
|
+
} catch (e) {
|
|
341
|
+
const validResponse = expectedResponseType(module.type);
|
|
342
|
+
|
|
343
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
344
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
345
|
+
|
|
346
|
+
} else { throw e; }
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const bytes = await module.arrayBuffer();
|
|
351
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
352
|
+
} else {
|
|
353
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
354
|
+
|
|
355
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
356
|
+
return { instance, module };
|
|
357
|
+
} else {
|
|
358
|
+
return instance;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function expectedResponseType(type) {
|
|
363
|
+
switch (type) {
|
|
364
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function initSync(module) {
|
|
371
|
+
if (wasm !== undefined) return wasm;
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
if (module !== undefined) {
|
|
375
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
376
|
+
({module} = module)
|
|
377
|
+
} else {
|
|
378
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const imports = __wbg_get_imports();
|
|
383
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
384
|
+
module = new WebAssembly.Module(module);
|
|
385
|
+
}
|
|
386
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
387
|
+
return __wbg_finalize_init(instance, module);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
async function __wbg_init(module_or_path) {
|
|
391
|
+
if (wasm !== undefined) return wasm;
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
if (module_or_path !== undefined) {
|
|
395
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
396
|
+
({module_or_path} = module_or_path)
|
|
397
|
+
} else {
|
|
398
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (module_or_path === undefined) {
|
|
403
|
+
module_or_path = new URL('atom_engine_wasm_bg.wasm', import.meta.url);
|
|
404
|
+
}
|
|
405
|
+
const imports = __wbg_get_imports();
|
|
406
|
+
|
|
407
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
408
|
+
module_or_path = fetch(module_or_path);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
412
|
+
|
|
413
|
+
return __wbg_finalize_init(instance, module);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const add: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
5
|
+
export const cmp: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
6
|
+
export const div: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
7
|
+
export const mul: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
8
|
+
export const pow: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
|
+
export const rem: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
10
|
+
export const sqrt: (a: number, b: number, c: number) => [number, number, number, number];
|
|
11
|
+
export const sub: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
12
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
13
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
14
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
15
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
16
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const __wbindgen_start: () => void;
|