diff --git a/benchmark/benchmark-from-msgpack-lite.ts b/benchmark/benchmark-from-msgpack-lite.ts index c03cd0a..40ac6f9 100644 --- a/benchmark/benchmark-from-msgpack-lite.ts +++ b/benchmark/benchmark-from-msgpack-lite.ts @@ -1,7 +1,7 @@ /* eslint-disable */ // original: https://raw.githubusercontent.com/kawanet/msgpack-lite/master/lib/benchmark.js -var msgpack_msgpack = require("../src"); +var msgpack_msgpack = require("../src/index.ts"); var msgpack_node = try_require("msgpack"); var msgpack_lite = try_require("msgpack-lite"); diff --git a/benchmark/decode-string.ts b/benchmark/decode-string.ts index a6ea146..3e6bfbb 100644 --- a/benchmark/decode-string.ts +++ b/benchmark/decode-string.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { utf8EncodeJs, utf8Count, utf8DecodeJs, utf8DecodeTD } from "../src/utils/utf8"; +import { utf8EncodeJs, utf8Count, utf8DecodeJs, utf8DecodeTD } from "../src/utils/utf8.ts"; // @ts-ignore import Benchmark from "benchmark"; diff --git a/benchmark/encode-string.ts b/benchmark/encode-string.ts index 3f6aac6..df1b283 100644 --- a/benchmark/encode-string.ts +++ b/benchmark/encode-string.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { utf8EncodeJs, utf8Count, utf8EncodeTE } from "../src/utils/utf8"; +import { utf8EncodeJs, utf8Count, utf8EncodeTE } from "../src/utils/utf8.ts"; // @ts-ignore import Benchmark from "benchmark"; diff --git a/benchmark/key-decoder.ts b/benchmark/key-decoder.ts index 594bbab..dec38f3 100644 --- a/benchmark/key-decoder.ts +++ b/benchmark/key-decoder.ts @@ -1,9 +1,11 @@ /* eslint-disable no-console */ -import { utf8EncodeJs, utf8Count, utf8DecodeJs } from "../src/utils/utf8"; +import { utf8EncodeJs, utf8Count, utf8DecodeJs } from "../src/utils/utf8.ts"; +import { CachedKeyDecoder } from "../src/CachedKeyDecoder.ts"; + +import data from "./benchmark-from-msgpack-lite-data.json" with { type: "json" }; // @ts-ignore import Benchmark from "benchmark"; -import { CachedKeyDecoder } from "../src/CachedKeyDecoder"; type InputType = { bytes: Uint8Array; @@ -11,7 +13,7 @@ type InputType = { str: string; }; -const keys: Array = Object.keys(require("./benchmark-from-msgpack-lite-data.json")).map((str) => { +const keys: Array = Object.keys(data).map((str) => { const byteLength = utf8Count(str); const bytes = new Uint8Array(new ArrayBuffer(byteLength)); utf8EncodeJs(str, bytes, 0); diff --git a/benchmark/package.json b/benchmark/package.json index 161581b..ddc30b8 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -2,6 +2,7 @@ "name": "@msgpack/msgpack-benchmark", "private": true, "version": "0.0.0", + "type": "module", "scripts": { "update-dependencies": "npx rimraf node_modules/ package-lock.json ; npm install ; npm audit fix --force ; git restore package.json ; npm install" }, diff --git a/benchmark/profile-decode.ts b/benchmark/profile-decode.ts index 081ddab..512d87e 100644 --- a/benchmark/profile-decode.ts +++ b/benchmark/profile-decode.ts @@ -1,4 +1,4 @@ -import { encode, decode, decodeAsync } from "../src"; +import { encode, decode, decodeAsync } from "../src/index.ts"; // @ts-ignore import _ from "lodash"; const data = require("./benchmark-from-msgpack-lite-data.json"); diff --git a/benchmark/profile-encode.ts b/benchmark/profile-encode.ts index 6efcf01..245e71b 100644 --- a/benchmark/profile-encode.ts +++ b/benchmark/profile-encode.ts @@ -1,4 +1,4 @@ -import { encode } from "../src"; +import { encode } from "../src/index.ts"; // @ts-ignore import _ from "lodash"; diff --git a/benchmark/string.ts b/benchmark/string.ts index b801394..4f11f30 100644 --- a/benchmark/string.ts +++ b/benchmark/string.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { encode, decode } from "../src"; +import { encode, decode } from "../src/index.ts"; const ascii = "A".repeat(40000); const emoji = "🌏".repeat(20000); diff --git a/benchmark/sync-vs-async.ts b/benchmark/sync-vs-async.ts index 6981932..620438e 100644 --- a/benchmark/sync-vs-async.ts +++ b/benchmark/sync-vs-async.ts @@ -1,12 +1,14 @@ -#!ts-node +#!/usr/bin/env node /* eslint-disable no-console */ -import { encode, decode, decodeAsync, decodeArrayStream } from "../src"; -import { writeFileSync, unlinkSync, readFileSync, createReadStream } from "fs"; -import { deepStrictEqual } from "assert"; +import { encode, decode, decodeAsync, decodeArrayStream } from "../src/index.ts"; +import { writeFileSync, unlinkSync, readFileSync, createReadStream } from "node:fs"; +import { deepStrictEqual } from "node:assert"; + +type Data = { id: number; score: number; title: string; content: string; createdAt: Date }; (async () => { - const data = []; + const data: Data[] = []; for (let i = 0; i < 1000; i++) { const id = i + 1; data.push({ diff --git a/benchmark/timestamp-ext.ts b/benchmark/timestamp-ext.ts index ba96a22..318b445 100644 --- a/benchmark/timestamp-ext.ts +++ b/benchmark/timestamp-ext.ts @@ -1,4 +1,4 @@ -import { encode, decode } from "../src"; +import { encode, decode } from "../src/index.ts"; const data = new Array(100).fill(new Date());