@nirs4all/io-wasm 0.1.0 → 0.1.1
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 +29 -1
- package/nirs4all_io_wasm_bg.wasm +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -86,9 +86,37 @@ const browserPlan = wasm.inferDataset(
|
|
|
86
86
|
console.log(wasm.version());
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
## TypeScript types
|
|
90
|
+
|
|
91
|
+
wasm-bindgen types every `JsValue` parameter/return as `any`. Hand-written types
|
|
92
|
+
in [`types/nirs4all-io.d.ts`](types/nirs4all-io.d.ts) give the real shapes
|
|
93
|
+
(`NamedFile`, `RecordSet`, `InferOptions`, `ProposeOptions`, `DatasetPlan`,
|
|
94
|
+
`DatasetSpec`, `Proposal`, `ProposeResult`, `AssembledDataset`) and typed views
|
|
95
|
+
of every export, so call sites are checked by `tsc`.
|
|
96
|
+
|
|
97
|
+
## Idiomatic ESM wrapper
|
|
98
|
+
|
|
99
|
+
[`idiomatic.mjs`](idiomatic.mjs) (typed by [`idiomatic.d.ts`](idiomatic.d.ts)) is
|
|
100
|
+
a thin, dependency-free wrapper over the wasm-pack module. The object-returning
|
|
101
|
+
entry points (`inferFiles` / `inferRecords` / `inferDataset` / `proposeDataset` /
|
|
102
|
+
`assembleDataset`) are re-exported with default options; the string-JSON surface
|
|
103
|
+
gains native-JS conveniences `toSpec` (object → canonical spec **object**) and
|
|
104
|
+
`validateSpec` (object in; throws when invalid). `assembleDataset` also accepts a
|
|
105
|
+
spec **object** directly. The raw `to_spec` / `validate` string functions stay
|
|
106
|
+
reachable for the cross-binding JSON contract.
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import * as nio from "./idiomatic.mjs";
|
|
110
|
+
const spec = nio.toSpec({ name: "run", sources: [{ id: "x", role: "features", input: "x.csv" }] });
|
|
111
|
+
nio.validateSpec(spec); // throws on an invalid spec
|
|
112
|
+
const plan = nio.inferFiles(files); // options default to {}
|
|
113
|
+
const ds = nio.assembleDataset([], recordSets, plan.resolved_spec); // object spec OK
|
|
114
|
+
```
|
|
115
|
+
|
|
89
116
|
## Test
|
|
90
117
|
|
|
91
118
|
```bash
|
|
92
119
|
wasm-pack build bindings/wasm --target nodejs --out-dir pkg
|
|
93
|
-
node bindings/wasm/tests/node_smoke.cjs
|
|
120
|
+
node bindings/wasm/tests/node_smoke.cjs # raw exports
|
|
121
|
+
node bindings/wasm/tests/idiomatic_smoke.mjs # idiomatic.mjs wrapper
|
|
94
122
|
```
|
package/nirs4all_io_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"Gregory Beurier <gregory.beurier@cirad.fr>"
|
|
5
5
|
],
|
|
6
6
|
"description": "wasm-bindgen binding for nirs4all-io: the fs-free JSON surface (to_spec / validate over a spec dict). Excluded from the cargo workspace; built with wasm-pack.",
|
|
7
|
-
"version": "0.1.
|
|
8
|
-
"license": "
|
|
7
|
+
"version": "0.1.1",
|
|
8
|
+
"license": "CECILL-2.1 OR AGPL-3.0-or-later",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/GBeurier/nirs4all-io.git",
|