Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Campbell authored and Cameron Campbell committed Aug 5, 2024
1 parent 0578fec commit dfef6d7
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 6 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"typeforge": "^0.0.19"
},
"devDependencies": {
"@types/bun": "^1.1.2",
"@types/lodash": "^4.17.0",
"@types/node": "^20.12.12",
"esbuild": "^0.21.5",
Expand Down
44 changes: 44 additions & 0 deletions src/bun.ts
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
}
}
}
}
2 changes: 2 additions & 0 deletions src/crypto/crypto.bun.ts
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")
2 changes: 2 additions & 0 deletions src/file/file.bun.ts
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())
}
1 change: 0 additions & 1 deletion src/http/httpHandler/httpHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// [ Modules ] ///////////////////////////////////////////////////////////////////
import { parseBEDEV1ErrorFromStringAndHeaders, parseBEDEV2ErrorFromStringAndHeaders } from "parse-roblox-errors"
import { HBAClient } from "roblox-bat"

import { HttpError, HttpResponse } from "../http.utils"
import { FetchAdapter } from "../httpAdapters/fetchHttpAdapter"
Expand Down
1 change: 1 addition & 0 deletions src/queries/cloud/usersQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type UnionKeepTypes<U, ToKeep> = U extends ToKeep ? U : never
type UnionRemoveTypes<U, ToKeep> = U extends ToKeep ? never : U


// @ts-ignore | ignored
type UserInfoField = ArrayToUnion<typeof userInfoFields>
type UserThumbnailField = "thumbnail" | `thumbnail/${UserThumbnailSize}` | `thumbnail/${UserThumbnailSize}/${"PNG" | "JPEG"}` | `thumbnail/${UserThumbnailSize}/${"PNG" | "JPEG"}/${"ROUND" | "SQUARE"}`
type UsersField = UnionPrettify<UserInfoField | UserThumbnailField>
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
Expand All @@ -13,7 +12,7 @@

"declaration": true,
"outDir": "dist", // Output directory
"rootDirs": ["src"], // Source directory
"rootDir": "src", // Source directory

/* Strictness */
"strict": true,
Expand All @@ -26,11 +25,10 @@
"moduleResolution": "Bundler",
"jsx": "preserve",

"types": [ "node", "bun" ],
"typeRoots": ["./node_modules/@types"]
},
"include": [
"./src"
],
"exclude": ["node_modules"],
"exclude": ["node_modules", "node_modules/@types"],
}

0 comments on commit dfef6d7

Please sign in to comment.