@bare-ts/lib 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/CHANGELOG.md +25 -0
- package/README.md +12 -2
- package/dist/codec/data.js +26 -0
- package/dist/codec/float-array.js +99 -0
- package/dist/codec/i16-array.js +50 -0
- package/dist/codec/i32-array.js +50 -0
- package/dist/codec/i64-array.js +50 -0
- package/dist/codec/i8-array.js +24 -0
- package/dist/codec/index.js +15 -0
- package/dist/codec/primitive.js +352 -0
- package/dist/codec/string.js +122 -0
- package/dist/codec/u16-array.js +50 -0
- package/dist/codec/u32-array.js +50 -0
- package/dist/codec/u64-array.js +50 -0
- package/dist/codec/u8-array.js +25 -0
- package/dist/codec/u8-clamped-array.js +24 -0
- package/dist/core/bare-error.js +14 -0
- package/dist/core/byte-cursor.js +52 -0
- package/dist/core/config.js +26 -0
- package/dist/core/index.js +5 -0
- package/dist/index.cjs +66 -74
- package/dist/index.js +3 -987
- package/dist/util/assert.cjs +55 -0
- package/dist/util/assert.d.ts +1 -0
- package/dist/util/assert.js +3 -1
- package/dist/util/util.js +6 -0
- package/dist/util/validator.js +40 -0
- package/package.json +13 -8
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
|
|
24
|
+
// src/util/assert.ts
|
|
25
|
+
var assert_exports = {};
|
|
26
|
+
__export(assert_exports, {
|
|
27
|
+
AssertionError: () => AssertionError,
|
|
28
|
+
default: () => assert,
|
|
29
|
+
ok: () => ok
|
|
30
|
+
});
|
|
31
|
+
var AssertionError = class extends Error {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = "AssertionError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function assert(test, message) {
|
|
38
|
+
if (!test) {
|
|
39
|
+
if (message instanceof Error) {
|
|
40
|
+
throw message;
|
|
41
|
+
}
|
|
42
|
+
const e = new AssertionError(message);
|
|
43
|
+
if (Error.captureStackTrace) {
|
|
44
|
+
Error.captureStackTrace(e, assert);
|
|
45
|
+
}
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
var ok = assert;
|
|
50
|
+
module.exports = __toCommonJS(assert_exports);
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
AssertionError,
|
|
54
|
+
ok
|
|
55
|
+
});
|
package/dist/util/assert.d.ts
CHANGED
package/dist/util/assert.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/util/validator.ts
|
|
2
|
+
function isI8(val) {
|
|
3
|
+
return val === val << 24 >> 24;
|
|
4
|
+
}
|
|
5
|
+
function isI16(val) {
|
|
6
|
+
return val === val << 16 >> 16;
|
|
7
|
+
}
|
|
8
|
+
function isI32(val) {
|
|
9
|
+
return val === (val | 0);
|
|
10
|
+
}
|
|
11
|
+
function isI64(val) {
|
|
12
|
+
return val === BigInt.asIntN(64, val);
|
|
13
|
+
}
|
|
14
|
+
function isSafeU64(val) {
|
|
15
|
+
return Number.isSafeInteger(val) && val >= 0;
|
|
16
|
+
}
|
|
17
|
+
function isU8(val) {
|
|
18
|
+
return val === (val & 255);
|
|
19
|
+
}
|
|
20
|
+
function isU16(val) {
|
|
21
|
+
return val === (val & 65535);
|
|
22
|
+
}
|
|
23
|
+
function isU32(val) {
|
|
24
|
+
return val === val >>> 0;
|
|
25
|
+
}
|
|
26
|
+
function isU64(val) {
|
|
27
|
+
return val === BigInt.asUintN(64, val);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
isI16,
|
|
31
|
+
isI32,
|
|
32
|
+
isI64,
|
|
33
|
+
isI8,
|
|
34
|
+
isSafeU64,
|
|
35
|
+
isU16,
|
|
36
|
+
isU32,
|
|
37
|
+
isU64,
|
|
38
|
+
isU8
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=validator.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bare-ts/lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "TypeScript library for BARE, a compact and simple binary-serialization format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bare",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"homepage": "https://baremessages.org",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/bare-ts/lib"
|
|
18
|
+
"url": "git+https://github.com/bare-ts/lib.git"
|
|
19
19
|
},
|
|
20
20
|
"bugs": {
|
|
21
21
|
"url": "https://github.com/bare-ts/lib/issues"
|
|
@@ -40,14 +40,19 @@
|
|
|
40
40
|
"dist/*.cjs",
|
|
41
41
|
"dist/*.d.ts",
|
|
42
42
|
"dist/*.js",
|
|
43
|
+
"dist/**/*.cjs",
|
|
43
44
|
"dist/**/*.d.ts",
|
|
44
45
|
"dist/**/*.js"
|
|
45
46
|
],
|
|
47
|
+
"directories": {
|
|
48
|
+
"test": "tests"
|
|
49
|
+
},
|
|
46
50
|
"scripts": {
|
|
47
|
-
"build": "
|
|
51
|
+
"build": "sh ./scripts/build.sh",
|
|
48
52
|
"clean": "rm -rf dist coverage",
|
|
49
|
-
"prepublishOnly": "npm run clean && npm
|
|
50
|
-
"test": "npm run build && tsc -b tests && oletus tests/**/*.test.js"
|
|
53
|
+
"prepublishOnly": "npm run clean && npm test",
|
|
54
|
+
"test": "npm run build && tsc -b tests && oletus tests/**/*.test.js",
|
|
55
|
+
"test:coverage": "c8 --reporter=lcovonly npm test"
|
|
51
56
|
},
|
|
52
57
|
"size-limit": [
|
|
53
58
|
{
|
|
@@ -57,10 +62,10 @@
|
|
|
57
62
|
],
|
|
58
63
|
"devDependencies": {
|
|
59
64
|
"@types/node": "^17.0.6",
|
|
60
|
-
"esbuild": "
|
|
65
|
+
"esbuild": "~0.14.10",
|
|
61
66
|
"oletus": "^3.2.0",
|
|
62
|
-
"prettier": "
|
|
63
|
-
"typescript": "
|
|
67
|
+
"prettier": "~2.5.1",
|
|
68
|
+
"typescript": "~4.5.4",
|
|
64
69
|
"validate-commit-message": "^3.2.0"
|
|
65
70
|
}
|
|
66
71
|
}
|