-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cameron Campbell
authored and
Cameron Campbell
committed
Aug 5, 2024
1 parent
0578fec
commit dfef6d7
Showing
8 changed files
with
51 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
type SupportedCryptoAlgorithms = | ||
| "blake2b256" | ||
| "blake2b512" | ||
| "md4" | ||
| "md5" | ||
| "ripemd160" | ||
| "sha1" | ||
| "sha224" | ||
| "sha256" | ||
| "sha384" | ||
| "sha512" | ||
| "sha512-224" | ||
| "sha512-256" | ||
| "sha3-224" | ||
| "sha3-256" | ||
| "sha3-384" | ||
| "sha3-512" | ||
| "shake128" | ||
| "shake256"; | ||
|
||
type BlobOrStringOrBuffer = | ||
| string | ||
| NodeJS.TypedArray | ||
| ArrayBufferLike | ||
| Blob | ||
|
||
type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary"; | ||
type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1"; | ||
type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2"; | ||
type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding; | ||
|
||
export declare const Bun: { | ||
file: (path: string | URL, options?: BlobPropertyBag) => { | ||
arrayBuffer: () => Promise<Buffer> | ||
}, | ||
|
||
CryptoHasher: { | ||
new(algorithm: SupportedCryptoAlgorithms): { | ||
update: (input: BlobOrStringOrBuffer, inputEncoding?: Encoding) => { | ||
digest: (encoding: "base64" | "hex") => string | ||
} | ||
} | ||
} | ||
} |
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 +1,3 @@ | ||
import { Bun } from "../bun" | ||
|
||
export const md5Checksum = (content: string) => new Bun.CryptoHasher("md5").update(content).digest("base64") |
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,3 +1,5 @@ | ||
import { Bun } from "../bun" | ||
|
||
export const readFile = async (path: string) => { | ||
return Buffer.from(await Bun.file(path).arrayBuffer()) | ||
} |
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