Skip to content

Commit

Permalink
upgrade dependencies && npm run lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Sep 8, 2023
1 parent b0e4662 commit 84418e9
Show file tree
Hide file tree
Showing 10 changed files with 977 additions and 632 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
{ "selector": "default", "format": ["camelCase", "UPPER_CASE", "PascalCase"], "leadingUnderscore": "allow" },
{ "selector": "typeLike", "format": ["PascalCase"], "leadingUnderscore": "allow" },
],
"@typescript-eslint/restrict-plus-operands": ["warn", { "checkCompoundAssignments": true }],
"@typescript-eslint/restrict-plus-operands": "warn",
"@typescript-eslint/no-throw-literal": "warn",
"@typescript-eslint/unbound-method": "warn",
"@typescript-eslint/explicit-module-boundary-types": "warn",
Expand Down
1,570 changes: 955 additions & 615 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/CachedKeyDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class CachedKeyDecoder implements KeyDecoder {
miss = 0;
private readonly caches: Array<Array<KeyCacheRecord>>;

constructor(readonly maxKeyLength = DEFAULT_MAX_KEY_LENGTH, readonly maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
constructor(
readonly maxKeyLength = DEFAULT_MAX_KEY_LENGTH,
readonly maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY,
) {
// avoid `new Array(N)`, which makes a sparse array,
// because a sparse array is typically slower than a non-sparse array.
this.caches = [];
Expand Down
10 changes: 5 additions & 5 deletions src/Decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export type DecoderOptions<ContextType = undefined> = Readonly<
> &
ContextOf<ContextType>;


const STATE_ARRAY = "array";
const STATE_MAP_KEY = "map_key";
const STATE_MAP_VALUE = "map_value";
Expand Down Expand Up @@ -120,7 +119,6 @@ class StackPool {
this.stackHeadPosition++;

if (this.stackHeadPosition === this.stack.length) {

const partialState: Partial<StackState> = {
type: undefined,
size: 0,
Expand All @@ -131,7 +129,7 @@ class StackPool {
key: null,
};

this.stack.push(partialState as StackState)
this.stack.push(partialState as StackState);
}

return this.stack[this.stackHeadPosition];
Expand Down Expand Up @@ -182,7 +180,9 @@ try {
EMPTY_VIEW.getInt8(0);
} catch (e) {
if (!(e instanceof RangeError)) {
throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
throw new Error(
"This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access",
);
}
}
export const DataViewIndexOutOfBoundsError = RangeError;
Expand Down Expand Up @@ -220,7 +220,7 @@ export class Decoder<ContextType = undefined> {
this.maxArrayLength = options?.maxArrayLength ?? UINT32_MAX;
this.maxMapLength = options?.maxMapLength ?? UINT32_MAX;
this.maxExtLength = options?.maxExtLength ?? UINT32_MAX;
this.keyDecoder = (options?.keyDecoder !== undefined) ? options.keyDecoder : sharedCachedKeyDecoder;
this.keyDecoder = options?.keyDecoder !== undefined ? options.keyDecoder : sharedCachedKeyDecoder;
}

private reinitializeState() {
Expand Down
4 changes: 2 additions & 2 deletions src/Encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ensureUint8Array } from "./utils/typedArrays";
import type { ExtData } from "./ExtData";
import type { ContextOf } from "./context";


export const DEFAULT_MAX_DEPTH = 100;
export const DEFAULT_INITIAL_BUFFER_SIZE = 2048;

Expand Down Expand Up @@ -69,7 +68,8 @@ export type EncoderOptions<ContextType = undefined> = Partial<
*/
forceIntegerToFloat: boolean;
}>
> & ContextOf<ContextType>;
> &
ContextOf<ContextType>;

export class Encoder<ContextType = undefined> {
private readonly extensionCodec: ExtensionCodecType<ContextType>;
Expand Down
5 changes: 4 additions & 1 deletion src/ExtData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
* ExtData is used to handle Extension Types that are not registered to ExtensionCodec.
*/
export class ExtData {
constructor(readonly type: number, readonly data: Uint8Array) {}
constructor(
readonly type: number,
readonly data: Uint8Array,
) {}
}
4 changes: 2 additions & 2 deletions src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const defaultDecodeOptions: never = undefined as never;
* It decodes a single MessagePack object in a buffer.
*
* This is a synchronous decoding function.
* See other variants for asynchronous decoding: {@link decodeAsync()}, {@link decodeStream()}, or {@link decodeArrayStream()}.
* See other variants for asynchronous decoding: {@link decodeAsync}, {@link decodeStream}, or {@link decodeArrayStream}.
*
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
* @throws {@link DecodeError} if the buffer contains invalid data.
Expand All @@ -31,7 +31,7 @@ export function decode<ContextType = undefined>(

/**
* It decodes multiple MessagePack objects in a buffer.
* This is corresponding to {@link decodeMultiStream()}.
* This is corresponding to {@link decodeMultiStream}.
*
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
* @throws {@link DecodeError} if the buffer contains invalid data.
Expand Down
6 changes: 3 additions & 3 deletions src/decodeAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { SplitUndefined } from "./context";
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
* @throws {@link DecodeError} if the buffer contains invalid data.
*/
export async function decodeAsync<ContextType = undefined>(
export async function decodeAsync<ContextType = undefined>(
streamLike: ReadableStreamLike<ArrayLike<number> | BufferSource>,
options?: DecoderOptions<SplitUndefined<ContextType>>,
): Promise<unknown> {
Expand All @@ -21,7 +21,7 @@ import type { SplitUndefined } from "./context";
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
* @throws {@link DecodeError} if the buffer contains invalid data.
*/
export function decodeArrayStream<ContextType>(
export function decodeArrayStream<ContextType>(
streamLike: ReadableStreamLike<ArrayLike<number> | BufferSource>,
options?: DecoderOptions<SplitUndefined<ContextType>>,
): AsyncGenerator<unknown, void, unknown> {
Expand All @@ -44,6 +44,6 @@ export function decodeMultiStream<ContextType>(
}

/**
* @deprecated Use {@link decodeMultiStream()} instead.
* @deprecated Use {@link decodeMultiStream} instead.
*/
export const decodeStream: never = undefined as never;
1 change: 0 additions & 1 deletion src/utils/utf8.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export function utf8Count(str: string): number {
const strLength = str.length;

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitOverride": true,
// "verbatimModuleSyntax": true, // TODO
"verbatimModuleSyntax": false,

/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
Expand Down

0 comments on commit 84418e9

Please sign in to comment.