@dimvexa/wasm 0.1.2 → 0.2.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/README.md +0 -1
- package/dimvexa.d.ts +0 -10
- package/dimvexa.js +0 -42
- package/dimvexa_bg.wasm +0 -0
- package/dimvexa_bg.wasm.d.ts +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,6 @@ const d = require('@dimvexa/wasm'); // after `npm install @dimvexa/wasm`; loca
|
|
|
13
13
|
d.convert(212, 'degF', 'degC'); // 100 (fast path, f64)
|
|
14
14
|
d.convertExact('98.6', 'degF', 'degC'); // 37 (exact rational, rounded once)
|
|
15
15
|
d.convertQuantity('5 ft', 'm'); // "1.524 m"
|
|
16
|
-
d.addQuantities('20 degC', '5 delta_K'); // "25 degC"
|
|
17
16
|
|
|
18
17
|
const c = new d.DimvexaConversion('m/s', 'km/h'); // parse and compose once
|
|
19
18
|
c.apply(10); // 36
|
package/dimvexa.d.ts
CHANGED
|
@@ -47,16 +47,6 @@ export class DimvexaConversion {
|
|
|
47
47
|
constructor(from: string, to: string);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* Adds two quantity texts exactly (`"20 degC"` + `"5 delta_K"`) and returns the result as text.
|
|
52
|
-
* A temperature point plus a temperature point is refused with code `kind_mismatch`.
|
|
53
|
-
*
|
|
54
|
-
* # Errors
|
|
55
|
-
*
|
|
56
|
-
* Throws a `DimvexaError` with a stable `code`.
|
|
57
|
-
*/
|
|
58
|
-
export function addQuantities(a: string, b: string): string;
|
|
59
|
-
|
|
60
50
|
/**
|
|
61
51
|
* One-shot fast-path conversion: `convert(1, "km", "m")`.
|
|
62
52
|
*
|
package/dimvexa.js
CHANGED
|
@@ -115,48 +115,6 @@ class DimvexaConversion {
|
|
|
115
115
|
if (Symbol.dispose) DimvexaConversion.prototype[Symbol.dispose] = DimvexaConversion.prototype.free;
|
|
116
116
|
exports.DimvexaConversion = DimvexaConversion;
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Adds two quantity texts exactly (`"20 degC"` + `"5 delta_K"`) and returns the result as text.
|
|
120
|
-
* A temperature point plus a temperature point is refused with code `kind_mismatch`.
|
|
121
|
-
*
|
|
122
|
-
* # Errors
|
|
123
|
-
*
|
|
124
|
-
* Throws a `DimvexaError` with a stable `code`.
|
|
125
|
-
* @param {string} a
|
|
126
|
-
* @param {string} b
|
|
127
|
-
* @returns {string}
|
|
128
|
-
*/
|
|
129
|
-
function addQuantities(a, b) {
|
|
130
|
-
let deferred4_0;
|
|
131
|
-
let deferred4_1;
|
|
132
|
-
try {
|
|
133
|
-
let ptr0, len0, ptr1, len1;
|
|
134
|
-
try {
|
|
135
|
-
ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
136
|
-
len0 = WASM_VECTOR_LEN;
|
|
137
|
-
ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
-
len1 = WASM_VECTOR_LEN;
|
|
139
|
-
} catch (e) {
|
|
140
|
-
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
141
|
-
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
142
|
-
throw e;
|
|
143
|
-
}
|
|
144
|
-
const ret = wasm.addQuantities(ptr0, len0, ptr1, len1);
|
|
145
|
-
var ptr3 = ret[0];
|
|
146
|
-
var len3 = ret[1];
|
|
147
|
-
if (ret[3]) {
|
|
148
|
-
ptr3 = 0; len3 = 0;
|
|
149
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
150
|
-
}
|
|
151
|
-
deferred4_0 = ptr3;
|
|
152
|
-
deferred4_1 = len3;
|
|
153
|
-
return getStringFromWasm0(ptr3, len3);
|
|
154
|
-
} finally {
|
|
155
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.addQuantities = addQuantities;
|
|
159
|
-
|
|
160
118
|
/**
|
|
161
119
|
* One-shot fast-path conversion: `convert(1, "km", "m")`.
|
|
162
120
|
*
|
package/dimvexa_bg.wasm
CHANGED
|
Binary file
|
package/dimvexa_bg.wasm.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_dimvexaconversion_free: (a: number, b: number) => void;
|
|
5
|
-
export const addQuantities: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
6
5
|
export const convert: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
7
6
|
export const convertExact: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
8
7
|
export const convertQuantity: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimvexa/wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Unit conversion with exact factors and loud failures (WebAssembly build of the Rust library)",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": { "type": "git", "url": "git+https://github.com/welworx/dimvexa.git", "directory": "bindings/wasm" },
|