@hpcc-js/wasm-base91 1.12.1 → 1.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/wasm-base91",
3
- "version": "1.12.1",
3
+ "version": "1.13.1",
4
4
  "description": "hpcc-js - WASM Base91",
5
5
  "type": "module",
6
6
  "exports": {
@@ -38,7 +38,7 @@
38
38
  "update-major": "npx -y npm-check-updates -u"
39
39
  },
40
40
  "devDependencies": {
41
- "@hpcc-js/esbuild-plugins": "1.8.1",
41
+ "@hpcc-js/esbuild-plugins": "1.8.3",
42
42
  "@hpcc-js/wasm-util": "1.0.0"
43
43
  },
44
44
  "keywords": [
@@ -56,5 +56,5 @@
56
56
  },
57
57
  "homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
58
58
  "license": "Apache-2.0",
59
- "gitHead": "9d18bfd8d74b23e6b79bb07a05115b2412e3a9c9"
59
+ "gitHead": "0199646cd7680d07e1619e593dc189c47bc25c1a"
60
60
  }
package/src/base91.ts CHANGED
@@ -21,13 +21,14 @@ let g_base91: Promise<Base91> | undefined;
21
21
  * const decoded_data = await base91.decode(encoded_data);
22
22
  * ```
23
23
  */
24
- export class Base91 extends MainModuleEx<MainModule> {
24
+ export class Base91 {
25
25
 
26
+ private _mainModule: MainModuleEx<MainModule>;
26
27
  private _base91: CBasE91;
27
28
 
28
29
  private constructor(_module: MainModule) {
29
- super(_module);
30
- this._base91 = new this._module.CBasE91();
30
+ this._mainModule = new MainModuleEx(_module);
31
+ this._base91 = new _module.CBasE91();
31
32
  }
32
33
 
33
34
  /**
@@ -80,16 +81,16 @@ export class Base91 extends MainModuleEx<MainModule> {
80
81
  encode(data: Uint8Array): string {
81
82
  this._base91.reset();
82
83
 
83
- const unencoded = this.dataToHeap(data);
84
- const encoded = this.malloc(unencoded.size + Math.ceil(unencoded.size / 4));
84
+ const unencoded = this._mainModule.dataToHeap(data);
85
+ const encoded = this._mainModule.malloc(unencoded.size + Math.ceil(unencoded.size / 4));
85
86
 
86
87
  encoded.size = this._base91.encode(unencoded.ptr, unencoded.size, encoded.ptr);
87
- let retVal = this.heapToString(encoded);
88
+ let retVal = this._mainModule.heapToString(encoded);
88
89
  encoded.size = this._base91.encode_end(encoded.ptr);
89
- retVal += this.heapToString(encoded);
90
+ retVal += this._mainModule.heapToString(encoded);
90
91
 
91
- this.free(encoded);
92
- this.free(unencoded);
92
+ this._mainModule.free(encoded);
93
+ this._mainModule.free(unencoded);
93
94
  return retVal;
94
95
  }
95
96
 
@@ -98,13 +99,13 @@ export class Base91 extends MainModuleEx<MainModule> {
98
99
  * @returns string containing the Base 91 encoded data
99
100
  */
100
101
  encodeChunk(data: Uint8Array): string {
101
- const unencoded = this.dataToHeap(data);
102
- const encoded = this.malloc(unencoded.size + Math.ceil(unencoded.size / 4));
102
+ const unencoded = this._mainModule.dataToHeap(data);
103
+ const encoded = this._mainModule.malloc(unencoded.size + Math.ceil(unencoded.size / 4));
103
104
 
104
105
  encoded.size = this._base91.encode(unencoded.ptr, unencoded.size, encoded.ptr);
105
- const retVal = this.heapToString(encoded);
106
- this.free(encoded);
107
- this.free(unencoded);
106
+ const retVal = this._mainModule.heapToString(encoded);
107
+ this._mainModule.free(encoded);
108
+ this._mainModule.free(unencoded);
108
109
  return retVal;
109
110
  }
110
111
 
@@ -114,12 +115,12 @@ export class Base91 extends MainModuleEx<MainModule> {
114
115
  * @returns string containing the Base 91 encoded data
115
116
  */
116
117
  encodeChunkEnd(): string {
117
- const encoded = this.malloc(2);
118
+ const encoded = this._mainModule.malloc(2);
118
119
 
119
120
  encoded.size = this._base91.encode_end(encoded.ptr);
120
- const retVal = this.heapToString(encoded);
121
+ const retVal = this._mainModule.heapToString(encoded);
121
122
 
122
- this.free(encoded);
123
+ this._mainModule.free(encoded);
123
124
  return retVal;
124
125
  }
125
126
 
@@ -130,16 +131,16 @@ export class Base91 extends MainModuleEx<MainModule> {
130
131
  decode(base91Str: string): Uint8Array {
131
132
  this._base91.reset();
132
133
 
133
- const encoded = this.stringToHeap(base91Str);
134
- const unencoded = this.malloc(encoded.size);
134
+ const encoded = this._mainModule.stringToHeap(base91Str);
135
+ const unencoded = this._mainModule.malloc(encoded.size);
135
136
 
136
137
  unencoded.size = this._base91.decode(encoded.ptr, encoded.size, unencoded.ptr);
137
- let retVal = this.heapView(unencoded);
138
+ let retVal = this._mainModule.heapView(unencoded);
138
139
  unencoded.size = this._base91.decode_end(unencoded.ptr);
139
- retVal = new Uint8Array([...retVal, ...this.heapView(unencoded)]);
140
+ retVal = new Uint8Array([...retVal, ...this._mainModule.heapView(unencoded)]);
140
141
 
141
- this.free(unencoded);
142
- this.free(encoded);
142
+ this._mainModule.free(unencoded);
143
+ this._mainModule.free(encoded);
143
144
  return retVal;
144
145
  }
145
146
 
@@ -149,14 +150,13 @@ export class Base91 extends MainModuleEx<MainModule> {
149
150
  * @returns decoded bytes for the chunk
150
151
  */
151
152
  decodeChunk(base91Str: string): Uint8Array {
152
- const encoded = this.stringToHeap(base91Str);
153
- const unencoded = this.malloc(encoded.size);
153
+ const encoded = this._mainModule.stringToHeap(base91Str);
154
+ const unencoded = this._mainModule.malloc(encoded.size);
154
155
 
155
156
  unencoded.size = this._base91.decode(encoded.ptr, encoded.size, unencoded.ptr);
156
- const retVal = this.heapToUint8Array(unencoded);
157
-
158
- this.free(unencoded);
159
- this.free(encoded);
157
+ const retVal = this._mainModule.heapToUint8Array(unencoded);
158
+ this._mainModule.free(unencoded);
159
+ this._mainModule.free(encoded);
160
160
  return retVal;
161
161
  }
162
162
 
@@ -165,12 +165,11 @@ export class Base91 extends MainModuleEx<MainModule> {
165
165
  * @returns remaining decoded bytes
166
166
  */
167
167
  decodeChunkEnd(): Uint8Array {
168
- const unencoded = this.malloc(1);
168
+ const unencoded = this._mainModule.malloc(1);
169
169
 
170
170
  unencoded.size = this._base91.decode_end(unencoded.ptr);
171
- const retVal = this.heapToUint8Array(unencoded);
172
-
173
- this.free(unencoded);
171
+ const retVal = this._mainModule.heapToUint8Array(unencoded);
172
+ this._mainModule.free(unencoded);
174
173
  return retVal;
175
174
  }
176
175
  }
package/types/base91.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import type { MainModule } from "../types/base91lib.js";
2
- import { MainModuleEx } from "@hpcc-js/wasm-util";
3
1
  /**
4
2
  * Base 91 WASM library, similar to Base 64 but uses more characters resulting in smaller strings.
5
3
  *
@@ -14,7 +12,8 @@ import { MainModuleEx } from "@hpcc-js/wasm-util";
14
12
  * const decoded_data = await base91.decode(encoded_data);
15
13
  * ```
16
14
  */
17
- export declare class Base91 extends MainModuleEx<MainModule> {
15
+ export declare class Base91 {
16
+ private _mainModule;
18
17
  private _base91;
19
18
  private constructor();
20
19
  /**