From d29dcf36803bd645e7a225de2a73d93aba00a951 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 4 May 2022 07:03:38 -0700 Subject: [PATCH] Document `FFIType.i64_fast` --- packages/bun-types/types.d.ts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/bun-types/types.d.ts b/packages/bun-types/types.d.ts index 87db8a016f..bcc0fd0d0f 100644 --- a/packages/bun-types/types.d.ts +++ b/packages/bun-types/types.d.ts @@ -1365,6 +1365,30 @@ declare module "bun:ffi" { * */ cstring = 14, + + /** + * Attempt to coerce `BigInt` into a `Number` if it fits. This improves performance + * but means you might get a `BigInt` or you might get a `number`. + * + * In C, this always becomes `int64_t` + * + * In JavaScript, this could be number or it could be BigInt, depending on what + * value is passed in. + * + */ + i64_fast = 15, + + /** + * Attempt to coerce `BigInt` into a `Number` if it fits. This improves performance + * but means you might get a `BigInt` or you might get a `number`. + * + * In C, this always becomes `uint64_t` + * + * In JavaScript, this could be number or it could be BigInt, depending on what + * value is passed in. + * + */ + u64_fast = 16, } export type FFITypeOrString = | FFIType @@ -1481,7 +1505,7 @@ declare module "bun:ffi" { close(): void; } - export function dlopen(libraryName: string, symbols: Symbols): Library; + export function dlopen(libraryName: string, symbols: Symbols): Library; /** * Read a pointer as a {@link Buffer} @@ -1607,7 +1631,7 @@ declare module "bun:ffi" { * reading beyond the bounds of the pointer will crash the program or cause * undefined behavior. Use with care! */ - constructor(ptr: number, byteOffset?: number, byteLength?: number): string; + constructor(ptr: number, byteOffset?: number, byteLength?: number); /** * The ptr to the C string