weida 0.0.0-stage → 0.1.0-alpha.14
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/lib/errors.js +32 -0
- package/lib/index.d.ts +1211 -0
- package/lib/index.js +3354 -0
- package/lib/native.js +18 -0
- package/lib/wait.js +82 -0
- package/package.json +30 -4
- package/prebuilds/darwin-arm64/libweida.dylib +0 -0
- package/prebuilds/darwin-arm64/weida.node +0 -0
- package/prebuilds/linux-arm64/libweida.so +0 -0
- package/prebuilds/linux-arm64/weida.node +0 -0
- package/prebuilds/linux-x64/libweida.so +0 -0
- package/prebuilds/linux-x64/weida.node +0 -0
- package/prebuilds/win32-x64/weida.dll +0 -0
- package/prebuilds/win32-x64/weida.node +0 -0
- package/README.md +0 -3
package/lib/errors.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The one error class every failure of libweida throws (docs/c/README.md
|
|
2
|
+
// R9). The addon creates it with the message and sets the other fields from
|
|
3
|
+
// the thread-local record of the call that failed.
|
|
4
|
+
import native from "./native.js";
|
|
5
|
+
|
|
6
|
+
export class WeidaError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "WeidaError";
|
|
10
|
+
/** The R9 constant name, e.g. "WEIDA_EUNTRUSTED". */
|
|
11
|
+
this.code = null;
|
|
12
|
+
/** The positive status code. */
|
|
13
|
+
this.errno = null;
|
|
14
|
+
/** "WEIDA_LOSS_*" for WEIDA_ECONNECTION_LOST, otherwise null. */
|
|
15
|
+
this.lossCause = null;
|
|
16
|
+
/** The peer's fingerprint for WEIDA_EUNTRUSTED, otherwise null. */
|
|
17
|
+
this.fingerprint = null;
|
|
18
|
+
/** The connection's largest payload for WEIDA_ETOO_LARGE, otherwise null. */
|
|
19
|
+
this.max = null;
|
|
20
|
+
/** The raw OS error of WEIDA_EIO, when it carried one, otherwise null. */
|
|
21
|
+
this.osCode = null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
native.setErrorClass(WeidaError);
|
|
26
|
+
|
|
27
|
+
const ECLOSED = 103;
|
|
28
|
+
|
|
29
|
+
/** The error a dropped, spent or consumed object fails with. */
|
|
30
|
+
export function closed() {
|
|
31
|
+
return native.error(ECLOSED);
|
|
32
|
+
}
|