Skip to content

Commit c7e0d03

Browse files
authored
Merge branch 'main' into main
2 parents 2796aef + 0bb101d commit c7e0d03

18 files changed

+2524
-1215
lines changed

.eslintignore

-1
This file was deleted.

.eslintrc.js

-89
This file was deleted.

.github/workflows/ci.yml

+12-8
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,26 @@ jobs:
1313
strategy:
1414
matrix:
1515
node-version:
16-
- '16'
1716
- '18'
1817
- '20'
18+
- '22'
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
- name: Setup Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v2
23+
uses: actions/setup-node@v4
2424
with:
2525
cache: npm
2626
node-version: ${{ matrix.node-version }}
2727

28-
- run: npm install -g nyc codecov
28+
- run: npm install -g nyc
2929
- run: npm ci
3030
- run: npm run test:cover
31-
- run: codecov -f coverage/*.json
31+
32+
- uses: codecov/codecov-action@v5
33+
with:
34+
files: coverage/coverage-final.json
35+
token: ${{ secrets.CODECOV_TOKEN }}
3236

3337
browser:
3438
runs-on: ubuntu-latest
@@ -37,12 +41,12 @@ jobs:
3741
browser: [ChromeHeadless, FirefoxHeadless]
3842

3943
steps:
40-
- uses: actions/checkout@v3
44+
- uses: actions/checkout@v4
4145
- name: Setup Node.js
42-
uses: actions/setup-node@v2
46+
uses: actions/setup-node@v4
4347
with:
4448
cache: npm
45-
node-version: '18'
49+
node-version: '22'
4650
- run: npm install -g npm
4751
- run: npm ci
4852
- run: npm run test:browser -- --browsers ${{ matrix.browser }}

.github/workflows/fuzz.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
node-version: "18"
2323

2424
# npm@9 may fail with https://github.com/npm/cli/issues/6723
25+
# npm@10 may fail with "GitFetcher requires an Arborist constructor to pack a tarball"
2526
- run: npm install -g npm@8
2627
- run: npm ci
2728
- run: npm run test:fuzz

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files.eol": "\n",
44
"editor.tabSize": 2,
55
"editor.codeActionsOnSave": {
6-
"source.fixAll.eslint": true
6+
"source.fixAll.eslint": "explicit"
77
},
88
"cSpell.words": [
99
"instanceof",

README.md

+15-11
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,15 @@ Name|Type|Default
148148
extensionCodec | ExtensionCodec | `ExtensionCodec.defaultCodec`
149149
context | user-defined | -
150150
useBigInt64 | boolean | false
151+
rawStrings | boolean | false
151152
maxStrLength | number | `4_294_967_295` (UINT32_MAX)
152153
maxBinLength | number | `4_294_967_295` (UINT32_MAX)
153154
maxArrayLength | number | `4_294_967_295` (UINT32_MAX)
154155
maxMapLength | number | `4_294_967_295` (UINT32_MAX)
155156
maxExtLength | number | `4_294_967_295` (UINT32_MAX)
156157

158+
To skip UTF-8 decoding of strings, `rawStrings` can be set to `true`. In this case, strings are decoded into `Uint8Array`.
159+
157160
You can use `max${Type}Length` to limit the length of each type decoded.
158161

159162
### `decodeMulti(buffer: ArrayLike<number> | BufferSource, options?: DecoderOptions): Generator<unknown, void, unknown>`
@@ -498,18 +501,19 @@ null, undefined|nil|null (*1)
498501
boolean (true, false)|bool family|boolean (true, false)
499502
number (53-bit int)|int family|number
500503
number (64-bit float)|float family|number
501-
string|str family|string
502-
ArrayBufferView |bin family|Uint8Array (*2)
504+
string|str family|string (*2)
505+
ArrayBufferView |bin family|Uint8Array (*3)
503506
Array|array family|Array
504-
Object|map family|Object (*3)
505-
Date|timestamp ext family|Date (*4)
506-
bigint|N/A|N/A (*5)
507+
Object|map family|Object (*4)
508+
Date|timestamp ext family|Date (*5)
509+
bigint|N/A|N/A (*6)
507510

508511
* *1 Both `null` and `undefined` are mapped to `nil` (`0xC0`) type, and are decoded into `null`
509-
* *2 Any `ArrayBufferView`s including NodeJS's `Buffer` are mapped to `bin` family, and are decoded into `Uint8Array`
510-
* *3 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
511-
* *4 MessagePack timestamps may have nanoseconds, which will lost when it is decoded into JavaScript `Date`. This behavior can be overridden by registering `-1` for the extension codec.
512-
* *5 bigint is not supported in `useBigInt64: false` mode, but you can define an extension codec for it.
512+
* *2 If you'd like to skip UTF-8 decoding of strings, set `rawStrings: true`. In this case, strings are decoded into `Uint8Array`.
513+
* *3 Any `ArrayBufferView`s including NodeJS's `Buffer` are mapped to `bin` family, and are decoded into `Uint8Array`
514+
* *4 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
515+
* *5 MessagePack timestamps may have nanoseconds, which will lost when it is decoded into JavaScript `Date`. This behavior can be overridden by registering `-1` for the extension codec.
516+
* *6 bigint is not supported in `useBigInt64: false` mode, but you can define an extension codec for it.
513517

514518
If you set `useBigInt64: true`, the following mapping is used:
515519

@@ -519,15 +523,15 @@ null, undefined|nil|null
519523
boolean (true, false)|bool family|boolean (true, false)
520524
**number (32-bit int)**|int family|number
521525
**number (except for the above)**|float family|number
522-
**bigint**|int64 / uint64|bigint (*6)
526+
**bigint**|int64 / uint64|bigint (*7)
523527
string|str family|string
524528
ArrayBufferView |bin family|Uint8Array
525529
Array|array family|Array
526530
Object|map family|Object
527531
Date|timestamp ext family|Date
528532

529533

530-
* *6 If the bigint is larger than the max value of uint64 or smaller than the min value of int64, then the behavior is undefined.
534+
* *7 If the bigint is larger than the max value of uint64 or smaller than the min value of int64, then the behavior is undefined.
531535

532536
## Prerequisites
533537

eslint.config.mjs

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import path from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
4+
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
5+
import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin";
6+
import tsdoc from "eslint-plugin-tsdoc";
7+
import tsParser from "@typescript-eslint/parser";
8+
import js from "@eslint/js";
9+
import { FlatCompat } from "@eslint/eslintrc";
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all
17+
});
18+
19+
export default [{
20+
ignores: ["**/*.js"],
21+
}, ...fixupConfigRules(compat.extends(
22+
"eslint:recommended",
23+
"plugin:@typescript-eslint/recommended",
24+
"plugin:import/recommended",
25+
"plugin:import/typescript",
26+
"prettier",
27+
)), {
28+
plugins: {
29+
"@typescript-eslint": fixupPluginRules(typescriptEslintEslintPlugin),
30+
tsdoc,
31+
},
32+
33+
languageOptions: {
34+
parser: tsParser,
35+
ecmaVersion: 5,
36+
sourceType: "script",
37+
38+
parserOptions: {
39+
project: "./tsconfig.json",
40+
},
41+
},
42+
43+
settings: {},
44+
45+
rules: {
46+
"no-constant-condition": ["warn", {
47+
checkLoops: false,
48+
}],
49+
50+
"no-useless-escape": "warn",
51+
"no-console": "warn",
52+
"no-var": "warn",
53+
"no-return-await": "warn",
54+
"prefer-const": "warn",
55+
"guard-for-in": "warn",
56+
curly: "warn",
57+
"no-param-reassign": "warn",
58+
"prefer-spread": "warn",
59+
"import/no-unresolved": "off",
60+
"import/no-cycle": "error",
61+
"import/no-default-export": "warn",
62+
"tsdoc/syntax": "warn",
63+
"@typescript-eslint/await-thenable": "warn",
64+
65+
"@typescript-eslint/array-type": ["warn", {
66+
default: "generic",
67+
}],
68+
69+
"@typescript-eslint/naming-convention": ["warn", {
70+
selector: "default",
71+
format: ["camelCase", "UPPER_CASE", "PascalCase"],
72+
leadingUnderscore: "allow",
73+
}, {
74+
selector: "typeLike",
75+
format: ["PascalCase"],
76+
leadingUnderscore: "allow",
77+
}],
78+
79+
"@typescript-eslint/restrict-plus-operands": "warn",
80+
//"@typescript-eslint/no-throw-literal": "warn",
81+
"@typescript-eslint/unbound-method": "warn",
82+
"@typescript-eslint/explicit-module-boundary-types": "warn",
83+
//"@typescript-eslint/no-extra-semi": "warn",
84+
"@typescript-eslint/no-extra-non-null-assertion": "warn",
85+
86+
"@typescript-eslint/no-unused-vars": ["warn", {
87+
argsIgnorePattern: "^_",
88+
}],
89+
90+
"@typescript-eslint/no-use-before-define": "warn",
91+
"@typescript-eslint/no-for-in-array": "warn",
92+
"@typescript-eslint/no-unsafe-argument": "warn",
93+
"@typescript-eslint/no-unsafe-call": "warn",
94+
95+
"@typescript-eslint/no-unnecessary-condition": ["warn", {
96+
allowConstantLoopConditions: true,
97+
}],
98+
99+
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
100+
"@typescript-eslint/no-implied-eval": "warn",
101+
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
102+
"@typescript-eslint/no-invalid-void-type": "warn",
103+
"@typescript-eslint/no-loss-of-precision": "warn",
104+
"@typescript-eslint/no-confusing-void-expression": "warn",
105+
"@typescript-eslint/no-redundant-type-constituents": "warn",
106+
"@typescript-eslint/prefer-for-of": "warn",
107+
"@typescript-eslint/prefer-includes": "warn",
108+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
109+
"@typescript-eslint/prefer-readonly": "warn",
110+
"@typescript-eslint/prefer-regexp-exec": "warn",
111+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
112+
"@typescript-eslint/prefer-optional-chain": "warn",
113+
"@typescript-eslint/prefer-ts-expect-error": "warn",
114+
"@typescript-eslint/indent": "off",
115+
"@typescript-eslint/no-explicit-any": "off",
116+
"@typescript-eslint/no-empty-interface": "off",
117+
"@typescript-eslint/no-empty-function": "off",
118+
"@typescript-eslint/no-var-requires": "off",
119+
"@typescript-eslint/no-non-null-assertion": "off",
120+
"@typescript-eslint/ban-ts-comment": "off",
121+
},
122+
}];

0 commit comments

Comments
 (0)