aboutsummaryrefslogtreecommitdiff
path: root/docs/api/ffi.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/api/ffi.md')
-rw-r--r--docs/api/ffi.md21
1 files changed, 12 insertions, 9 deletions
diff --git a/docs/api/ffi.md b/docs/api/ffi.md
index d6ed23f47..0beae1744 100644
--- a/docs/api/ffi.md
+++ b/docs/api/ffi.md
@@ -229,7 +229,11 @@ const lib = linkSymbols({
},
});
-const [major, minor, patch] = [lib.symbols.getMajor(), lib.symbols.getMinor(), lib.symbols.getPatch()];
+const [major, minor, patch] = [
+ lib.symbols.getMajor(),
+ lib.symbols.getMinor(),
+ lib.symbols.getPatch(),
+];
```
## Callbacks
@@ -249,10 +253,13 @@ const {
},
});
-const searchIterator = new JSCallback((ptr, length) => /hello/.test(new CString(ptr, length)), {
- returns: "bool",
- args: ["ptr", "usize"],
-});
+const searchIterator = new JSCallback(
+ (ptr, length) => /hello/.test(new CString(ptr, length)),
+ {
+ returns: "bool",
+ args: ["ptr", "usize"],
+ },
+);
const str = Buffer.from("wwutwutwutwutwutwutwutwutwutwutut\0", "utf8");
if (search(ptr(str), searchIterator)) {
@@ -376,10 +383,6 @@ If you want to track when a `TypedArray` is no longer in use from JavaScript, yo
#### From C, Rust, Zig, etc
-{% callout %}
-**Note** — Available in Bun v0.1.8 and later.
-{% /callout %}
-
If you want to track when a `TypedArray` is no longer in use from C or FFI, you can pass a callback and an optional context pointer to `toArrayBuffer` or `toBuffer`. This function is called at some point later, once the garbage collector frees the underlying `ArrayBuffer` JavaScript object.
The expected signature is the same as in [JavaScriptCore's C API](https://developer.apple.com/documentation/javascriptcore/jstypedarraybytesdeallocator?language=objc):