-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance and bundled size (#6)
* test the file contents * use base64 instead of an integer array * single to double-quoted strings * consistent semicolons * make isomorphic * simple version, but vitest doesn't start * resolve base64 decode with native module * decode with `atob` if exists on `self` * update doc * fix test --------- Co-authored-by: Tachibana Shin <[email protected]>
- Loading branch information
1 parent
d694cca
commit 32ba3bd
Showing
5 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
import arrayBuffer from "./typescript.svg?arraybuffer"; | ||
import uint8array from "./typescript.svg?uint8array"; | ||
import arrayBufferB64 from "./typescript.svg?arraybuffer&base64"; | ||
import uint8arrayB64 from "./typescript.svg?uint8array&base64"; | ||
import crypto from "node:crypto"; | ||
|
||
import { describe, expect, test } from "vitest"; | ||
|
||
const hash = (buffer: ArrayBuffer) => crypto.createHash("md5").update(Buffer.from(buffer)).digest("hex"); | ||
|
||
describe("test plugin", () => { | ||
test("?arraybuffer", () => { | ||
expect(arrayBuffer[Symbol.toStringTag]).toBe("ArrayBuffer"); | ||
expect(arrayBuffer instanceof ArrayBuffer).toBe(true); | ||
expect(hash(arrayBuffer)).toEqual("7167f7caac27a336c58b0c16cc5003d7"); | ||
}); | ||
test("?uint8array", () => { | ||
expect(uint8array[Symbol.toStringTag]).toBe("Uint8Array"); | ||
expect(uint8array instanceof Uint8Array).toBe(true); | ||
expect(hash(uint8array.buffer)).toEqual("7167f7caac27a336c58b0c16cc5003d7"); | ||
}); | ||
test("?arraybuffer&base64", () => { | ||
expect(arrayBufferB64[Symbol.toStringTag]).toBe("ArrayBuffer"); | ||
expect(arrayBufferB64 instanceof ArrayBuffer).toBe(true); | ||
expect(hash(arrayBufferB64)).toEqual("7167f7caac27a336c58b0c16cc5003d7"); | ||
}); | ||
test("?uint8array&base64", () => { | ||
expect(uint8arrayB64[Symbol.toStringTag]).toBe("Uint8Array"); | ||
expect(uint8arrayB64 instanceof Uint8Array).toBe(true); | ||
expect(hash(uint8arrayB64.buffer)).toEqual("7167f7caac27a336c58b0c16cc5003d7"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters