@hpcc-js/wasm 1.17.1 → 1.19.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.
Files changed (66) hide show
  1. package/README.md +392 -87
  2. package/bin/{cli.js → dot-wasm.mjs} +72 -74
  3. package/bin/dot-wasm.mjs.map +1 -0
  4. package/bin/sfx-wasm.mjs +44 -0
  5. package/bin/sfx-wasm.mjs.map +1 -0
  6. package/dist/base91lib.wasm +0 -0
  7. package/dist/expat.es6.js +7 -4
  8. package/dist/expat.es6.js.map +1 -1
  9. package/dist/expat.js +7 -4
  10. package/dist/expat.js.map +1 -1
  11. package/dist/expatlib.wasm +0 -0
  12. package/dist/extract.es6.js +680 -0
  13. package/dist/extract.es6.js.map +1 -0
  14. package/dist/extract.js +690 -0
  15. package/dist/extract.js.map +1 -0
  16. package/dist/graphviz.es6.js +21 -9
  17. package/dist/graphviz.es6.js.map +1 -1
  18. package/dist/graphviz.js +21 -9
  19. package/dist/graphviz.js.map +1 -1
  20. package/dist/graphvizlib.wasm +0 -0
  21. package/dist/index.es6.js +887 -25
  22. package/dist/index.es6.js.map +1 -1
  23. package/dist/index.js +889 -24
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.min.js +1 -1
  26. package/dist/index.min.js.map +1 -1
  27. package/dist/index.node.es6.mjs +891 -17
  28. package/dist/index.node.es6.mjs.map +1 -1
  29. package/dist/index.node.js +893 -16
  30. package/dist/index.node.js.map +1 -1
  31. package/dist/zstd.es6.js +166 -0
  32. package/dist/zstd.es6.js.map +1 -0
  33. package/dist/zstd.js +176 -0
  34. package/dist/zstd.js.map +1 -0
  35. package/dist/zstdlib.wasm +0 -0
  36. package/package.json +32 -12
  37. package/types/__bin__/dot-wasm.d.mts +2 -0
  38. package/types/__bin__/dot-wasm.d.mts.map +1 -0
  39. package/types/__bin__/sfx-wasm.d.mts +2 -0
  40. package/types/__bin__/sfx-wasm.d.mts.map +1 -0
  41. package/types/__tests__/base91.d.ts +2 -0
  42. package/types/__tests__/base91.d.ts.map +1 -0
  43. package/types/__tests__/index.d.ts +2 -0
  44. package/types/__tests__/index.d.ts.map +1 -1
  45. package/types/__tests__/zstd.d.ts +2 -0
  46. package/types/__tests__/zstd.d.ts.map +1 -0
  47. package/types/base91.d.ts +9 -0
  48. package/types/base91.d.ts.map +1 -0
  49. package/types/extract.d.ts +2 -0
  50. package/types/extract.d.ts.map +1 -0
  51. package/types/fetch-browser.d.ts +0 -1
  52. package/types/fetch-browser.d.ts.map +1 -1
  53. package/types/fetch-node.d.ts.map +1 -1
  54. package/types/graphviz.d.ts.map +1 -1
  55. package/types/index-common.d.ts +7 -0
  56. package/types/index-common.d.ts.map +1 -0
  57. package/types/index-node.d.ts +1 -3
  58. package/types/index-node.d.ts.map +1 -1
  59. package/types/index.d.ts +1 -3
  60. package/types/index.d.ts.map +1 -1
  61. package/types/util.d.ts +0 -1
  62. package/types/util.d.ts.map +1 -1
  63. package/types/wasm-library.d.ts +22 -0
  64. package/types/wasm-library.d.ts.map +1 -0
  65. package/types/zstd.d.ts +12 -0
  66. package/types/zstd.d.ts.map +1 -0
package/README.md CHANGED
@@ -3,79 +3,63 @@
3
3
  ![Test PR](https://github.com/hpcc-systems/hpcc-js-wasm/workflows/Test%20PR/badge.svg)
4
4
 
5
5
  This repository contains a collection of useful c++ libraries compiled to WASM for (re)use in Node JS, Web Browsers and JavaScript Libraries:
6
- * [graphviz](https://www.graphviz.org/) - v6.0.2
7
- * [expat](https://libexpat.github.io/) - v2.4.8
6
+ - [graphviz](https://www.graphviz.org/) - v7.0.0
7
+ - [expat](https://libexpat.github.io/) - v2.4.9
8
+ - [zstd](https://github.com/facebook/zstd) - v1.5.2
9
+ - ...more to follow...
8
10
 
9
11
  Built with:
10
- * [emsdk](https://github.com/emscripten-core/emsdk) - v3.1.24
12
+ - [emsdk](https://github.com/emscripten-core/emsdk) - v3.1.24
11
13
 
12
- ## Quick GraphViz Demos
13
- * https://raw.githack.com/hpcc-systems/hpcc-js-wasm/trunk/index.html
14
- * https://observablehq.com/@gordonsmith/graphviz
14
+ ---
15
15
 
16
- ## Installation
17
- The simplest way to include this project is via NPM:
18
- ```
19
- npm install --save @hpcc-js/wasm
20
- ```
16
+ ## Contents
21
17
 
22
- ## CLI
23
- To call `dot-wasm` without installing:
24
- ```
25
- npx -p @hpcc-js/wasm dot-wasm [file | 'dot']
26
- ```
18
+ - [Installation](#installation)
19
+ - [NPM](#npm)
20
+ - [Vanilla HTML](#vanilla-html)
21
+ - [GraphViz](#graphviz)
22
+ - [Online Demos](#online-demos)
23
+ - [Command Line Interface](#command-line-interface)
24
+ - [Hello World](#graphviz-hello-world)
25
+ - [API](#graphviz-api)
26
+ - [Expat](#expat)
27
+ - [Hello World](#expat-hello-world)
28
+ - [API](#expat-api)
29
+ - [Zstandard (zstd)](#zstandard)
30
+ - [Hello World](#zstandard-hello-world)
31
+ - [API](#zstandard-api)
32
+ - [Base91](#base91)
33
+ - [Hello World](#base91-hello-world)
34
+ - [API](#base91-api)
35
+ - [Utilities](#utility)
36
+ - [Building @hpcc-js/wasm](#building-hpcc-js-wasm)
27
37
 
28
- To install the global command `dot-wasm` via NPM:
29
- ```
30
- npm install --global @hpcc-js/wasm
31
- ```
38
+ ---
32
39
 
33
- ### Usage:
34
- ```
35
- Usage: dot-wasm [options] fileOrDot
40
+ ## Installation
36
41
 
37
- Options:
38
- --version Show version number [boolean]
39
- -K, --layout Set layout engine (circo | dot | fdp | sfdp | neato | osage
40
- | patchwork | twopi). By default, dot is used.
41
- -T, --format Set output language to one of the supported formats (svg,
42
- dot, json, dot_json, xdot_json, plain, plain-ext). By
43
- default, svg is produced.
44
- -n, --neato-no-op Sets no-op flag in neato.
45
- "-n 1" assumes neato nodes have already been positioned and
46
- all nodes have a pos attribute giving the positions. It
47
- then performs an optional adjustment to remove node-node
48
- overlap, depending on the value of the overlap attribute,
49
- computes the edge layouts, depending on the value of the
50
- splines attribute, and emits the graph in the appropriate
51
- format.
52
- "-n 2" Use node positions as specified, with no adjustment
53
- to remove node-node overlaps, and use any edge layouts
54
- already specified by the pos attribute. neato computes an
55
- edge layout for any edge that does not have a pos
56
- attribute. As usual, edge layout is guided by the splines
57
- attribute.
58
- -y, --invert-y By default, the coordinate system used in generic output
59
- formats, such as attributed dot, extended dot, plain and
60
- plain-ext, is the standard cartesian system with the origin
61
- in the lower left corner, and with increasing y coordinates
62
- as points move from bottom to top. If the -y flag is used,
63
- the coordinate system is inverted, so that increasing
64
- values of y correspond to movement from top to bottom.
65
- -h, --help Show help [boolean]
42
+ ### NPM
66
43
 
67
- Examples:
68
- dot-wasm -K neato -T xdot ./input.dot Execute NEATO layout and outputs XDOT
69
- format.
44
+ The simplest way to include this project is via NPM:
45
+ ```
46
+ npm install --save @hpcc-js/wasm
70
47
  ```
71
48
 
72
- ## Contents
73
- @hpcc-js/wasm includes the following files in its `dist` folder:
74
- * `index.js` / `index.min.js` files: Exposes _all_ the available APIs for all WASM files.
75
- * WASM Files:
76
- * `graphvizlib.wasm`
77
- * `expatlib.wasm`
78
- * ...more to follow...
49
+ The @hpcc-js/wasm package includes the following files in its `dist` folder:
50
+ - `index.js` / `index.min.js`: Browser UMD Package for all APIs.
51
+ - `index.es6.js`: Browser ESM Package for all APIs.
52
+ - `index.node.js`: Node CJS Package for all APIs.
53
+ - `index.node.es6.js`: Node ESM Package for all APIs.
54
+ - `graphviz.js`: Browser UMD Package for graphviz APIs.
55
+ - `graphviz.es6.js`: Browser ESM Package for graphviz APIs.
56
+ - `graphvizlib.wasm`: graphviz wasm file (loaded on demand).
57
+ - `expat.js`: Browser UMD Package for expat API.
58
+ - `expat.es6.js`: Browser ESM Package for expat API.
59
+ - `expatlib.wasm`: expat wasm file (loaded on demand).
60
+ - `expat.js`: Browser UMD Package for zstd API.
61
+ - `zstd.es6.js`: Browser ESM Package for zstd API.
62
+ - `zstdlib.wasm`: zstd wasm file (loaded on demand).
79
63
 
80
64
  **Important**: WASM files are dynamically loaded at runtime (this is a browser / emscripten requirement), which has a few implications for the consumer:
81
65
 
@@ -86,31 +70,92 @@ Examples:
86
70
  * Most browsers don't support `fetch` and loading pages via `file://` URN, so for testing / development work you will need to run a test web server.
87
71
  * Bundlers (RollupJS / WebPack) will ignore the WASM files, so you will need to manually ensure they are present in your final distribution (typically they are placed in the same folder as the bundled JS)
88
72
 
89
- ## API Reference
90
- * [Common](#common)
91
- * [GraphViz](#graphviz)
92
- * [Expat](#expat)
73
+ ### Vanilla HTML
93
74
 
94
- ### Common
95
- Utility functions relating to @hpcc-js/wasm as a package
75
+ Alternatively the @hpcc-js/wasm package can be imported directly within the html page, using a NPM CDN server like [unpkg](https://www.unpkg.com/), [jsdelivr](https://www.jsdelivr.com/). For modern browsers and `import`:
96
76
 
97
- <a name="wasmFolder" href="#wasmFolder">#</a> **wasmFolder**([_url_]) · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/util.ts "Source")
77
+ ```html
78
+ <script type="module">
79
+ import { graphvizSync } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.es6.js";
80
+
81
+ graphvizSync().then(graphviz => {
82
+ const div = document.getElementById("placeholder2");
83
+ div.innerHTML = graphviz.layout(dot, "svg", "dot");
84
+ });
85
+ </script>
86
+ ```
98
87
 
99
- If _url_ is specified, sets the default location for all WASM files. If _url_ is not specified it returns the current _url_ (defaults to `undefined`).
88
+ For legacy environments you can load the UMD packages:
89
+ ```html
90
+ <script src="https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.min.js"></script>
91
+ <script>
92
+ var hpccWasm = window["@hpcc-js/wasm"];
93
+
94
+ hpccWasm.graphvizSync().then(graphviz => {
95
+ var div = document.getElementById("placeholder2");
96
+ div.innerHTML = graphviz.layout(dot, "svg", "dot");
97
+ });
98
+ </script>
99
+ ```
100
100
 
101
- <a name="__hpcc_wasmFolder" href="#__hpcc_wasmFolder">#</a> **__hpcc_wasmFolder** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/util.ts "Source")
101
+ ## GraphViz
102
102
 
103
- Global variable for setting default WASM location, this is an alternative to [wasmFolder](#wasmFolder)
103
+ GraphViz WASM library, see [graphviz.org](https://www.graphviz.org/) for c++ details. While this package is similar to [Viz.js](https://github.com/mdaines/viz.js), it employs a completely different build methodology derived from [GraphControl](https://github.com/hpcc-systems/GraphControl).
104
104
 
105
- ---
106
- ### GraphViz (`graphvizlib.wasm`)
107
- GraphViz WASM library, see [graphviz.org](https://www.graphviz.org/) for c++ details. While this package is similar to [Viz.js](https://github.com/mdaines/viz.js), it employs a completely different build methodology taken from [GraphControl](https://github.com/hpcc-systems/GraphControl).
108
105
 
109
- The _GraphViz_ library comes in **two** flavours
110
- * An exported `graphviz` namespace, where each API function is **asynchrounous** and returns a `Promise<string>`.
111
- * A `graphvizSync` **asynchrounous** function which returns a `Promise<GraphvizSync>` which is a mirror instance of `graphviz`, where each API function is **synchrounous** and returns a `string`.
106
+ ### Online Demos
107
+ * https://raw.githack.com/hpcc-systems/hpcc-js-wasm/trunk/index.html
108
+ * https://observablehq.com/@gordonsmith/graphviz
109
+
110
+ ### Command Line Interface
111
+
112
+ To call `dot-wasm` without installing:
113
+ ```
114
+ npx -p @hpcc-js/wasm dot-wasm [options] fileOrDot
115
+ ```
116
+
117
+ To install the global command `dot-wasm` via NPM:
118
+ ```
119
+ npm install --global @hpcc-js/wasm
120
+ ```
121
+
122
+ Usage:
123
+ ```
124
+ Usage: dot-wasm [options] fileOrDot
125
+
126
+ Options:
127
+ --version Show version number [boolean]
128
+ -K, --layout Set layout engine (circo | dot | fdp | sfdp | neato | osage | patchwo
129
+ rk | twopi). By default, dot is used.
130
+ -T, --format Set output language to one of the supported formats (svg | dot | json
131
+ | dot_json | xdot_json | plain | plain-ext). By default, svg is prod
132
+ uced.
133
+ -n, --neato-no-op Sets no-op flag in neato.
134
+ "-n 1" assumes neato nodes have already bee
135
+ n positioned and all nodes have a pos attribute giving the positions.
136
+ It then performs an optional adjustment to remove node-node overlap,
137
+ depending on the value of the overlap attribute, computes the edge l
138
+ ayouts, depending on the value of the splines attribute, and emits th
139
+ e graph in the appropriate format.
140
+ "-n 2" Use node positions as speci
141
+ fied, with no adjustment to remove node-node overlaps, and use any ed
142
+ ge layouts already specified by the pos attribute. neato computes an
143
+ edge layout for any edge that does not have a pos attribute. As usual
144
+ , edge layout is guided by the splines attribute.
145
+ -y, --invert-y By default, the coordinate system used in generic output formats, suc
146
+ h as attributed dot, extended dot, plain and plain-ext, is the standa
147
+ rd cartesian system with the origin in the lower left corner, and wit
148
+ h increasing y coordinates as points move from bottom to top. If the
149
+ -y flag is used, the coordinate system is inverted, so that increasin
150
+ g values of y correspond to movement from top to bottom.
151
+ -v Echo GraphViz library version
152
+ -h, --help Show help [boolean]
153
+
154
+ Examples:
155
+ dot-wasm -K neato -T xdot ./input.dot Execute NEATO layout and outputs XDOT format.
156
+ ```
112
157
 
113
- #### Hello World
158
+ ### GraphViz Hello World
114
159
  ```html
115
160
  <!DOCTYPE html>
116
161
  <html>
@@ -125,7 +170,22 @@ The _GraphViz_ library comes in **two** flavours
125
170
  </head>
126
171
 
127
172
  <body>
128
- <div id="placeholder"></div>
173
+ <div id="placeholder0"></div>
174
+ <script>
175
+ const test = `\
176
+ digraph {
177
+ layout = neato
178
+ splines = true
179
+ edge [len = 2]
180
+ a -> b
181
+ b -> a
182
+ }`;
183
+ hpccWasm.graphviz.layout(test, "svg", "dot").then(svg => {
184
+ const div = document.getElementById("placeholder0");
185
+ div.innerHTML = svg;
186
+ });
187
+ </script>
188
+ <div id="placeholder1"></div>
129
189
  <div id="placeholder2"></div>
130
190
  <script>
131
191
  const dot = `
@@ -162,11 +222,15 @@ The _GraphViz_ library comes in **two** flavours
162
222
 
163
223
  // Asynchronous call to layout
164
224
  hpccWasm.graphviz.layout(dot, "svg", "dot").then(svg => {
165
- const div = document.getElementById("placeholder");
225
+ const div = document.getElementById("placeholder1");
166
226
  div.innerHTML = svg;
167
227
  });
228
+ </script>
168
229
 
169
- hpccWasm.graphvizSync().then(graphviz => {
230
+ <script type="module">
231
+ import { graphvizSync } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.es6.js";
232
+
233
+ graphvizSync().then(graphviz => {
170
234
  const div = document.getElementById("placeholder2");
171
235
  // Synchronous call to layout
172
236
  div.innerHTML = graphviz.layout(dot, "svg", "dot");
@@ -178,7 +242,11 @@ The _GraphViz_ library comes in **two** flavours
178
242
  </html>
179
243
  ```
180
244
 
181
- #### GraphViz API
245
+ ### GraphViz API
246
+
247
+ The _GraphViz_ library comes in **two** flavours
248
+ * An exported `graphviz` namespace, where each API function is **asynchrounous** and returns a `Promise<string>`.
249
+ * A `graphvizSync` **asynchrounous** function which returns a `Promise<GraphvizSync>` which is a mirror instance of `graphviz`, where each API function is **synchrounous** and returns a `string`.
182
250
 
183
251
  <a name="graphvizVersion" href="#graphvizVersion">#</a> **graphvizVersion**() · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/graphviz.ts "Source")
184
252
 
@@ -282,10 +350,11 @@ Returns a `Promise<GraphvizSync>`, once resolved provides a synchronous variant
282
350
 
283
351
  ---
284
352
 
285
- ### Expat (`expatlib.wasm`)
353
+ ## Expat
354
+
286
355
  Expat WASM library, provides a simplified wrapper around the Expat XML Parser library, see [libexpat.github.io](https://libexpat.github.io/) for c++ details.
287
356
 
288
- #### Hello World
357
+ ### Expat Hello World
289
358
  ```html
290
359
  <!DOCTYPE html>
291
360
  <html>
@@ -320,7 +389,7 @@ Expat WASM library, provides a simplified wrapper around the Expat XML Parser li
320
389
  </html>
321
390
  ```
322
391
 
323
- #### Expat API
392
+ ### Expat API
324
393
 
325
394
  <a name="expatVersion" href="#expatVersion">#</a> **expatVersion**() · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/expat.ts "Source")
326
395
 
@@ -340,13 +409,249 @@ Parses the XML with suitable callbacks.
340
409
 
341
410
  ---
342
411
 
412
+ ## Zstandard
413
+ _zstd for short_
414
+
415
+ Zstandard WASM library, provides a simplified wrapper around the Zstandard c++ library, see [Zstandard](https://facebook.github.io/zstd/) for more details.
416
+
417
+ ### Zstandard Hello World
418
+
419
+ ```html
420
+ <!DOCTYPE html>
421
+ <html>
422
+
423
+ <head>
424
+ <meta charset="UTF-8">
425
+ <title>Zstandard WASM</title>
426
+ </head>
427
+
428
+ <body>
429
+ <div id="placeholder"></div>
430
+ <script type="module">
431
+ import { Zstd } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.es6.js";
432
+
433
+ const zstd = await Zstd.load();
434
+ const data = new Uint8Array(Array.from({ length: 100000 }, (_, i) => i % 256));
435
+ const compressed_data = await zstd.compress(data);
436
+ const decompressed_data = await zstd.decompress(compressed_data);
437
+ document.getElementById("placeholder").innerHTML = `\
438
+ <ul>
439
+ <li>Default Compression Level: ${await zstd.defaultCLevel()}</li>
440
+ <li>Decompressed Size (bytes): ${decompressed_data.byteLength}</li>
441
+ <li>Data Size (bytes): ${data.byteLength}</li>
442
+ <li>Compressed Size (bytes): ${compressed_data.byteLength}</li>
443
+ <li>Decompressed Size (bytes): ${decompressed_data.byteLength}</li>
444
+ </ul>
445
+ `;
446
+ </script>
447
+
448
+ </body>
449
+
450
+ </html>
451
+ ```
452
+
453
+ ### Zstandard API
454
+
455
+ #### Interfaces
456
+
457
+ <a name="Options" href="#ZstandardOptions">#</a> **Options** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/zstd.ts "Source")
458
+
459
+ Options structure for advanced loading.
460
+
461
+ ```typescript
462
+ interface Options {
463
+ wasmFolder?: string;
464
+ wasmBinary?: ArrayBuffer;
465
+ }
466
+ ```
467
+
468
+ * _wasmFolder_: An optional `string` specifying the location of wasm file.
469
+ * _wasmBinary_: An optional "pre-fetched" copy of the wasm binary as returned from `XHR` or `fetch`.
470
+
471
+ <a name="Zstd" href="#Zstd">#</a> **Zstd** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/zstd.ts "Source")
472
+
473
+ Conceptual interface for TypeScript/JavaScript wrapper API
474
+
475
+ ```typescript
476
+ interface Zstd {
477
+ static load(options?: Options): Promise<Zstd>;
478
+ version(): string;
479
+
480
+ compress(data: Uint8Array, compressionLevel: number = this.defaultCLevel()): Uint8Array;
481
+ decompress(array: Uint8Array): Uint8Array;
482
+ defaultCLevel(): number;
483
+ }
484
+ ```
485
+
486
+ <a name="zstdLoad" href="#zstdLoad">#</a> **Zstd.load**(_options_?: **Options**): **Promise\<Zstd\>** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/zstd.ts "Source")
487
+
488
+ Loads and initializes the Zstandard wasm library, returns a Promise to `Zstd`:
489
+ ```typescript
490
+ const zstd = await Zstd.load();
491
+ ...dostuff...
492
+ ```
493
+ or
494
+ ```typescript
495
+ Zstd.load().then(zstd => {...dostuff...});
496
+ ```
497
+
498
+ <a name="zstdVersion" href="#zstdVersion">#</a> **zstd.version**(): **string** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/zstd.ts "Source")
499
+
500
+ * **_returns_**: The Zstandard library Version.
501
+
502
+ <a name="zstdCompress" href="#zstdCompress">#</a> **zstd.compress**(_data_: **Uint8Array**, _compressionLevel_?: **number**): **Uint8Array** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/zstd.ts "Source")
503
+
504
+ * **_data_**: Raw data to compress.
505
+ * **_compressionLevel_**: Compression v Speed tradeoff, when omitted it will default to `zstd.defaultCLevel()` which is currently 3.
506
+ * **_returns_**: Compressed data.
507
+
508
+ Compresses raw data.
509
+
510
+ A note on compressionLevel: The library supports regular compression levels from 1 up 22. Levels >= 20, should be used with caution, as they require more memory. The library also offers negative compression levels, which extend the range of speed vs. ratio preferences. The lower the level, the faster the speed (at the cost of compression).
511
+
512
+ <a name="zstdDefaultCLevel" href="#zstdDefaultCLevel">#</a> **zstd.defaultCLevel**(): **number** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/zstd.ts "Source")
513
+
514
+ * **_returns_**: Default compression level (see above).
515
+
516
+ ---
517
+
518
+ ## Base91
519
+ _Similar to Base 64, but uses more characters resulting in smaller strings._
520
+
521
+ Base 91 WASM library, similar to Base 64 but uses more characters resulting in smaller strings, see [Base91](https://base91.sourceforge.net/) for more details.
522
+
523
+ ### Base91 Hello World
524
+
525
+ ```html
526
+ <!DOCTYPE html>
527
+ <html>
528
+
529
+ <head>
530
+ <meta charset="UTF-8">
531
+ <title>Base91 WASM</title>
532
+ </head>
533
+
534
+ <body>
535
+ <div id="placeholder"></div>
536
+ <script type="module">
537
+ import { Base91 } from "./dist/index.es6.js";
538
+ //import { Base91 } from "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.es6.js";
539
+
540
+ const base91 = await Base91.load();
541
+ const data = new Uint8Array(Array.from({ length: 100 }, (_, i) => Math.random() * 100));
542
+ const encoded_data = await base91.encode(data);
543
+ const decoded_data = await base91.decode(encoded_data);
544
+ document.getElementById("placeholder").innerHTML = `\
545
+ <ul>
546
+ <li>Data Size (bytes): ${data.byteLength}</li>
547
+ <li>Endoded Size (bytes): ${encoded_data.length}</li>
548
+ <li>Decoded Size (bytes): ${decoded_data.byteLength}</li>
549
+ </ul>
550
+ <h4>Data: </h4>
551
+ <code>
552
+ ${data}
553
+ </code>
554
+ <h4>Base 91: </h4>
555
+ <code id="base91">
556
+ </code>
557
+ <h4>Decoded: </h4>
558
+ <code>
559
+ ${decoded_data}
560
+ </code>
561
+ `;
562
+ document.getElementById("base91").innerText = encoded_data;
563
+ </script>
564
+
565
+ </body>
566
+
567
+ </html>
568
+ ```
569
+
570
+ ### Base91 API
571
+
572
+ #### Interfaces
573
+
574
+ <a name="Options" href="#Base91Options">#</a> **Options** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/base91.ts "Source")
575
+
576
+ Options structure for advanced loading.
577
+
578
+ ```typescript
579
+ interface Options {
580
+ wasmFolder?: string;
581
+ wasmBinary?: ArrayBuffer;
582
+ }
583
+ ```
584
+
585
+ * _wasmFolder_: An optional `string` specifying the location of wasm file.
586
+ * _wasmBinary_: An optional "pre-fetched" copy of the wasm binary as returned from `XHR` or `fetch`.
587
+
588
+ <a name="Base91" href="#Base91">#</a> **Base91** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/base91.ts "Source")
589
+
590
+ Conceptual interface for TypeScript/JavaScript wrapper API
591
+
592
+ ```typescript
593
+ interface Base91 {
594
+ static load(options?: Options): Promise<Base91>;
595
+ version(): string;
596
+
597
+ encode(data: Uint8Array): string;
598
+ decode(array: string): Uint8Array;
599
+ }
600
+ ```
601
+
602
+ <a name="base91Load" href="#base91Load">#</a> **Base91.load**(_options_?: **Options**): **Promise\<Base91\>** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/base91.ts "Source")
603
+
604
+ Loads and initializes the Base91 wasm library, returns a Promise to `Base91`:
605
+ ```typescript
606
+ const base91 = await Base91.load();
607
+ ...dostuff...
608
+ ```
609
+ or
610
+ ```typescript
611
+ Base91.load().then(base91 => {...dostuff...});
612
+ ```
613
+
614
+ <a name="base91Version" href="#base91Version">#</a> **base91.version**(): **string** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/base91.ts "Source")
615
+
616
+ * **_returns_**: The Base91 library Version.
617
+
618
+ <a name="base91Encode" href="#base91Encode">#</a> **base91.encode**(_data_: **Uint8Array**): **string** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/base91.ts "Source")
619
+
620
+ * **_data_**: Raw data to encode.
621
+ * **_returns_**: Encoded string.
622
+
623
+ Encodes the raw data.
624
+
625
+ <a name="base91Decode" href="#base91Decode">#</a> **base91.decode**(_str_: **string**): **Uint8Array** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/base91.ts "Source")
626
+
627
+ * **_str_**: String to decode.
628
+ * **_returns_**: Decoded data.
629
+
630
+ Decodes the raw data.
631
+
632
+ ---
633
+
634
+ ## Utility
635
+
636
+ Utility functions unrelated to any specific wasm APIs
637
+
638
+ <a name="wasmFolder" href="#wasmFolder">#</a> **wasmFolder**([_url_]) · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/util.ts "Source")
639
+
640
+ If _url_ is specified, sets the default location for all WASM files. If _url_ is not specified it returns the current _url_ (defaults to `undefined`).
641
+
642
+ <a name="__hpcc_wasmFolder" href="#__hpcc_wasmFolder">#</a> **__hpcc_wasmFolder** · [<>](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/src/util.ts "Source")
643
+
644
+ Global variable for setting default WASM location, this is an alternative to [wasmFolder](#wasmFolder)
645
+
646
+ ---
647
+
343
648
  ## Building @hpcc-js/wasm
344
649
  _Building is supported on both Linux (tested with Ubuntu 20.04) and Windows with WSL enabled (Ubuntu-20.04). Building in other environments should work, but may be missing certain prerequisites._
345
650
 
346
651
  These are then known required OS dependencies (see [./docker/ubuntu-dev.dockerfile](./docker/ubuntu-dev.dockerfile) for test script):
347
652
  ```
348
653
  sudo apt-get install -y curl
349
- sudo curl --silent --location https://deb.nodesource.com/setup_14.x | sudo bash -
654
+ sudo curl --silent --location https://deb.nodesource.com/setup_16.x | sudo bash -
350
655
  sudo apt-get install -y nodejs
351
656
  sudo apt-get install -y build-essential
352
657