@bare-ts/lib 0.3.0 → 0.4.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/LICENSE +21 -201
- package/dist/codec/data.d.ts +1 -1
- package/dist/codec/data.js +10 -12
- package/dist/codec/float-array.d.ts +9 -9
- package/dist/codec/float-array.js +51 -43
- package/dist/codec/i16-array.d.ts +5 -5
- package/dist/codec/i16-array.js +34 -26
- package/dist/codec/i32-array.d.ts +5 -5
- package/dist/codec/i32-array.js +34 -26
- package/dist/codec/i64-array.d.ts +5 -5
- package/dist/codec/i64-array.js +34 -26
- package/dist/codec/i8-array.d.ts +1 -1
- package/dist/codec/i8-array.js +12 -14
- package/dist/codec/primitive.d.ts +3 -1
- package/dist/codec/primitive.js +225 -147
- package/dist/codec/string.d.ts +1 -1
- package/dist/codec/string.js +45 -31
- package/dist/codec/u16-array.d.ts +5 -5
- package/dist/codec/u16-array.js +34 -26
- package/dist/codec/u32-array.d.ts +5 -5
- package/dist/codec/u32-array.js +34 -26
- package/dist/codec/u64-array.d.ts +5 -5
- package/dist/codec/u64-array.js +34 -26
- package/dist/codec/u8-array.d.ts +7 -1
- package/dist/codec/u8-array.js +22 -17
- package/dist/codec/u8-clamped-array.d.ts +1 -1
- package/dist/codec/u8-clamped-array.js +13 -15
- package/dist/core/bare-error.d.ts +4 -1
- package/dist/core/bare-error.js +4 -8
- package/dist/core/byte-cursor.d.ts +22 -28
- package/dist/core/byte-cursor.js +33 -29
- package/dist/core/config.d.ts +3 -7
- package/dist/core/config.js +14 -20
- package/dist/env/dev.d.ts +1 -0
- package/dist/env/dev.development.d.ts +1 -0
- package/dist/env/dev.development.js +2 -0
- package/dist/env/dev.js +2 -0
- package/dist/env/dev.node.d.ts +1 -0
- package/dist/env/dev.node.js +2 -0
- package/dist/index.cjs +504 -286
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +17 -4
- package/dist/util/assert.d.ts +6 -8
- package/dist/util/assert.js +10 -13
- package/dist/util/constants.d.ts +4 -7
- package/dist/util/constants.js +11 -30
- package/dist/util/validator.d.ts +1 -1
- package/dist/util/validator.js +12 -24
- package/package.json +31 -24
- package/dist/codec/index.d.ts +0 -13
- package/dist/codec/index.js +0 -15
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.js +0 -5
- package/dist/util/util.d.ts +0 -1
- package/dist/util/util.js +0 -6
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./codec/data.js";
|
|
2
|
+
export * from "./codec/float-array.js";
|
|
3
|
+
export * from "./codec/i16-array.js";
|
|
4
|
+
export * from "./codec/i32-array.js";
|
|
5
|
+
export * from "./codec/i64-array.js";
|
|
6
|
+
export * from "./codec/i8-array.js";
|
|
7
|
+
export * from "./codec/primitive.js";
|
|
8
|
+
export * from "./codec/string.js";
|
|
9
|
+
export * from "./codec/u16-array.js";
|
|
10
|
+
export * from "./codec/u32-array.js";
|
|
11
|
+
export * from "./codec/u64-array.js";
|
|
12
|
+
export * from "./codec/u8-array.js";
|
|
13
|
+
export * from "./codec/u8-clamped-array.js";
|
|
14
|
+
export * from "./core/bare-error.js";
|
|
15
|
+
export * from "./core/byte-cursor.js";
|
|
16
|
+
export * from "./core/config.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
export * from "./codec/
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./codec/data.js";
|
|
2
|
+
export * from "./codec/float-array.js";
|
|
3
|
+
export * from "./codec/i16-array.js";
|
|
4
|
+
export * from "./codec/i32-array.js";
|
|
5
|
+
export * from "./codec/i64-array.js";
|
|
6
|
+
export * from "./codec/i8-array.js";
|
|
7
|
+
export * from "./codec/primitive.js";
|
|
8
|
+
export * from "./codec/string.js";
|
|
9
|
+
export * from "./codec/u16-array.js";
|
|
10
|
+
export * from "./codec/u32-array.js";
|
|
11
|
+
export * from "./codec/u64-array.js";
|
|
12
|
+
export * from "./codec/u8-array.js";
|
|
13
|
+
export * from "./codec/u8-clamped-array.js";
|
|
14
|
+
export * from "./core/bare-error.js";
|
|
15
|
+
export * from "./core/byte-cursor.js";
|
|
16
|
+
export * from "./core/config.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
export * from "./codec/
|
|
3
|
-
export * from "./
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
export * from "./codec/data.js";
|
|
3
|
+
export * from "./codec/float-array.js";
|
|
4
|
+
export * from "./codec/i16-array.js";
|
|
5
|
+
export * from "./codec/i32-array.js";
|
|
6
|
+
export * from "./codec/i64-array.js";
|
|
7
|
+
export * from "./codec/i8-array.js";
|
|
8
|
+
export * from "./codec/primitive.js";
|
|
9
|
+
export * from "./codec/string.js";
|
|
10
|
+
export * from "./codec/u16-array.js";
|
|
11
|
+
export * from "./codec/u32-array.js";
|
|
12
|
+
export * from "./codec/u64-array.js";
|
|
13
|
+
export * from "./codec/u8-array.js";
|
|
14
|
+
export * from "./codec/u8-clamped-array.js";
|
|
15
|
+
export * from "./core/bare-error.js";
|
|
16
|
+
export * from "./core/byte-cursor.js";
|
|
17
|
+
export * from "./core/config.js";
|
package/dist/util/assert.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
export { DEV } from "#dev";
|
|
2
|
+
/**
|
|
3
|
+
* @sealed
|
|
4
|
+
*/
|
|
1
5
|
export declare class AssertionError extends Error {
|
|
2
|
-
|
|
3
|
-
constructor(message: string);
|
|
6
|
+
name: string;
|
|
4
7
|
}
|
|
5
|
-
export declare function assert(test: boolean, message
|
|
6
|
-
declare const Error: V8ErrorConstructor;
|
|
7
|
-
interface V8ErrorConstructor extends ErrorConstructor {
|
|
8
|
-
readonly captureStackTrace?: (e: Error, f: unknown) => void;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
8
|
+
export declare function assert(test: boolean, message?: string): asserts test;
|
package/dist/util/assert.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
export { DEV } from "#dev";
|
|
3
|
+
export class AssertionError extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
5
6
|
this.name = "AssertionError";
|
|
6
7
|
}
|
|
7
|
-
}
|
|
8
|
-
|
|
8
|
+
}
|
|
9
|
+
const V8Error = Error;
|
|
10
|
+
export function assert(test, message = "") {
|
|
9
11
|
if (!test) {
|
|
10
12
|
const e = new AssertionError(message);
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
+
if (V8Error.captureStackTrace) {
|
|
14
|
+
V8Error.captureStackTrace(e, assert);
|
|
13
15
|
}
|
|
14
16
|
throw e;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
export {
|
|
18
|
-
AssertionError,
|
|
19
|
-
assert
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=assert.js.map
|
package/dist/util/constants.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const I64_BYTE_COUNT = 8;
|
|
4
|
-
export declare const U16_BYTE_COUNT = 2;
|
|
5
|
-
export declare const U32_BYTE_COUNT = 4;
|
|
6
|
-
export declare const U64_BYTE_COUNT = 8;
|
|
1
|
+
export declare const TEXT_DECODER_THRESHOLD = 256;
|
|
2
|
+
export declare const TEXT_ENCODER_THRESHOLD = 256;
|
|
7
3
|
export declare const INT_SAFE_MAX_BYTE_COUNT = 8;
|
|
8
4
|
export declare const UINT_MAX_BYTE_COUNT = 10;
|
|
9
|
-
export declare const
|
|
5
|
+
export declare const UINT_SAFE32_MAX_BYTE_COUNT = 5;
|
|
10
6
|
export declare const INVALID_UTF8_STRING = "invalid UTF-8 string";
|
|
11
7
|
export declare const NON_CANONICAL_REPRESENTATION = "must be canonical";
|
|
12
8
|
export declare const TOO_LARGE_BUFFER = "too large buffer";
|
|
13
9
|
export declare const TOO_LARGE_NUMBER = "too large number";
|
|
10
|
+
export declare const IS_LITTLE_ENDIAN_PLATFORM: boolean;
|
package/dist/util/constants.js
CHANGED
|
@@ -1,30 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var NON_CANONICAL_REPRESENTATION = "must be canonical";
|
|
13
|
-
var TOO_LARGE_BUFFER = "too large buffer";
|
|
14
|
-
var TOO_LARGE_NUMBER = "too large number";
|
|
15
|
-
export {
|
|
16
|
-
I16_BYTE_COUNT,
|
|
17
|
-
I32_BYTE_COUNT,
|
|
18
|
-
I64_BYTE_COUNT,
|
|
19
|
-
INT_SAFE_MAX_BYTE_COUNT,
|
|
20
|
-
INVALID_UTF8_STRING,
|
|
21
|
-
NON_CANONICAL_REPRESENTATION,
|
|
22
|
-
TOO_LARGE_BUFFER,
|
|
23
|
-
TOO_LARGE_NUMBER,
|
|
24
|
-
U16_BYTE_COUNT,
|
|
25
|
-
U32_BYTE_COUNT,
|
|
26
|
-
U64_BYTE_COUNT,
|
|
27
|
-
UINT_MAX_BYTE_COUNT,
|
|
28
|
-
UINT_SAFE_MAX_BYTE_COUNT
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=constants.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
export const TEXT_DECODER_THRESHOLD = 256;
|
|
3
|
+
export const TEXT_ENCODER_THRESHOLD = 256;
|
|
4
|
+
export const INT_SAFE_MAX_BYTE_COUNT = 8;
|
|
5
|
+
export const UINT_MAX_BYTE_COUNT = 10;
|
|
6
|
+
export const UINT_SAFE32_MAX_BYTE_COUNT = 5;
|
|
7
|
+
export const INVALID_UTF8_STRING = "invalid UTF-8 string";
|
|
8
|
+
export const NON_CANONICAL_REPRESENTATION = "must be canonical";
|
|
9
|
+
export const TOO_LARGE_BUFFER = "too large buffer";
|
|
10
|
+
export const TOO_LARGE_NUMBER = "too large number";
|
|
11
|
+
export const IS_LITTLE_ENDIAN_PLATFORM = /* @__PURE__ */ new DataView(Uint16Array.of(1).buffer).getUint8(0) === 1;
|
package/dist/util/validator.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export declare function isI8(val: number): boolean;
|
|
|
2
2
|
export declare function isI16(val: number): boolean;
|
|
3
3
|
export declare function isI32(val: number): boolean;
|
|
4
4
|
export declare function isI64(val: bigint): boolean;
|
|
5
|
-
export declare function isSafeU64(val: number): boolean;
|
|
6
5
|
export declare function isU8(val: number): boolean;
|
|
7
6
|
export declare function isU16(val: number): boolean;
|
|
8
7
|
export declare function isU32(val: number): boolean;
|
|
9
8
|
export declare function isU64(val: bigint): boolean;
|
|
9
|
+
export declare function isU64Safe(val: number): boolean;
|
package/dist/util/validator.js
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
function isI8(val) {
|
|
1
|
+
"use strict";
|
|
2
|
+
export function isI8(val) {
|
|
3
3
|
return val === val << 24 >> 24;
|
|
4
4
|
}
|
|
5
|
-
function isI16(val) {
|
|
5
|
+
export function isI16(val) {
|
|
6
6
|
return val === val << 16 >> 16;
|
|
7
7
|
}
|
|
8
|
-
function isI32(val) {
|
|
8
|
+
export function isI32(val) {
|
|
9
9
|
return val === (val | 0);
|
|
10
10
|
}
|
|
11
|
-
function isI64(val) {
|
|
11
|
+
export function isI64(val) {
|
|
12
12
|
return val === BigInt.asIntN(64, val);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return Number.isSafeInteger(val) && val >= 0;
|
|
16
|
-
}
|
|
17
|
-
function isU8(val) {
|
|
14
|
+
export function isU8(val) {
|
|
18
15
|
return val === (val & 255);
|
|
19
16
|
}
|
|
20
|
-
function isU16(val) {
|
|
17
|
+
export function isU16(val) {
|
|
21
18
|
return val === (val & 65535);
|
|
22
19
|
}
|
|
23
|
-
function isU32(val) {
|
|
20
|
+
export function isU32(val) {
|
|
24
21
|
return val === val >>> 0;
|
|
25
22
|
}
|
|
26
|
-
function isU64(val) {
|
|
23
|
+
export function isU64(val) {
|
|
27
24
|
return val === BigInt.asUintN(64, val);
|
|
28
25
|
}
|
|
29
|
-
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
isI64,
|
|
33
|
-
isI8,
|
|
34
|
-
isSafeU64,
|
|
35
|
-
isU16,
|
|
36
|
-
isU32,
|
|
37
|
-
isU64,
|
|
38
|
-
isU8
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=validator.js.map
|
|
26
|
+
export function isU64Safe(val) {
|
|
27
|
+
return Number.isSafeInteger(val) && val >= 0;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bare-ts/lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "TypeScript library for BARE, a compact and simple binary-serialization format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bare",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"schema"
|
|
12
12
|
],
|
|
13
13
|
"author": "Victorien Elvinger (victorien.elvinger.fr)",
|
|
14
|
-
"license": "
|
|
14
|
+
"license": "MIT",
|
|
15
15
|
"homepage": "https://baremessages.org",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -21,23 +21,34 @@
|
|
|
21
21
|
"url": "https://github.com/bare-ts/lib/issues"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": "^14.18.0 || >=16.0.0"
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
27
|
-
"main": "./dist/index.cjs",
|
|
28
27
|
"module": "./dist/index.js",
|
|
29
|
-
"
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
28
|
+
"main": "./dist/index.cjs",
|
|
31
29
|
"exports": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
30
|
+
"./package.json": "./package.json",
|
|
31
|
+
".": {
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"default": "./dist/index.cjs"
|
|
35
|
+
},
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"module": "./dist/index.js",
|
|
38
|
+
"default": "./dist/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"imports": {
|
|
42
|
+
"#dev": {
|
|
43
|
+
"development": "./dist/env/dev.development.js",
|
|
44
|
+
"node": "./dist/env/dev.node.js",
|
|
45
|
+
"default": "./dist/env/dev.js"
|
|
46
|
+
}
|
|
34
47
|
},
|
|
35
48
|
"sideEffects": false,
|
|
36
49
|
"files": [
|
|
37
|
-
"dist/*.cjs",
|
|
38
|
-
"dist/*.d.ts",
|
|
39
|
-
"dist/*.js",
|
|
40
50
|
"dist/**/*.cjs",
|
|
51
|
+
"dist/**/*.d.cts",
|
|
41
52
|
"dist/**/*.d.ts",
|
|
42
53
|
"dist/**/*.js"
|
|
43
54
|
],
|
|
@@ -47,22 +58,18 @@
|
|
|
47
58
|
"scripts": {
|
|
48
59
|
"build": "sh ./scripts/build.sh",
|
|
49
60
|
"clean": "rm -rf dist coverage",
|
|
61
|
+
"coverage": "c8 --reporter=lcovonly npm test",
|
|
62
|
+
"format": "rome format --write .",
|
|
50
63
|
"prepare": "validate-commit-msg",
|
|
51
64
|
"prepublishOnly": "npm run clean && npm test",
|
|
52
|
-
"test": "
|
|
53
|
-
"
|
|
65
|
+
"test": "sh ./scripts/test.sh",
|
|
66
|
+
"version": "sh ./scripts/version.sh"
|
|
54
67
|
},
|
|
55
|
-
"size-limit": [
|
|
56
|
-
{
|
|
57
|
-
"path": "./dist/index.js",
|
|
58
|
-
"limit": "10 kB"
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
68
|
"devDependencies": {
|
|
62
|
-
"esbuild": "
|
|
63
|
-
"oletus": "
|
|
64
|
-
"
|
|
65
|
-
"typescript": "
|
|
66
|
-
"validate-commit-message": "
|
|
69
|
+
"esbuild": "0.18.4",
|
|
70
|
+
"oletus": "4.0.0",
|
|
71
|
+
"rome": "12.1.3",
|
|
72
|
+
"typescript": "5.1.3",
|
|
73
|
+
"validate-commit-message": "3.2.0"
|
|
67
74
|
}
|
|
68
75
|
}
|
package/dist/codec/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./data.js";
|
|
2
|
-
export * from "./float-array.js";
|
|
3
|
-
export * from "./i16-array.js";
|
|
4
|
-
export * from "./i32-array.js";
|
|
5
|
-
export * from "./i64-array.js";
|
|
6
|
-
export * from "./i8-array.js";
|
|
7
|
-
export * from "./primitive.js";
|
|
8
|
-
export * from "./string.js";
|
|
9
|
-
export * from "./u16-array.js";
|
|
10
|
-
export * from "./u32-array.js";
|
|
11
|
-
export * from "./u64-array.js";
|
|
12
|
-
export * from "./u8-array.js";
|
|
13
|
-
export * from "./u8-clamped-array.js";
|
package/dist/codec/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/codec/index.ts
|
|
2
|
-
export * from "./data.js";
|
|
3
|
-
export * from "./float-array.js";
|
|
4
|
-
export * from "./i16-array.js";
|
|
5
|
-
export * from "./i32-array.js";
|
|
6
|
-
export * from "./i64-array.js";
|
|
7
|
-
export * from "./i8-array.js";
|
|
8
|
-
export * from "./primitive.js";
|
|
9
|
-
export * from "./string.js";
|
|
10
|
-
export * from "./u16-array.js";
|
|
11
|
-
export * from "./u32-array.js";
|
|
12
|
-
export * from "./u64-array.js";
|
|
13
|
-
export * from "./u8-array.js";
|
|
14
|
-
export * from "./u8-clamped-array.js";
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/dist/core/index.d.ts
DELETED
package/dist/core/index.js
DELETED
package/dist/util/util.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const IS_LITTLE_ENDIAN_PLATFORM: boolean;
|