bun-ffi-extra
v1.0.21
Published
Extra features for Bun's FFI module.
Readme
bun-ffi-extra
🚧 This package is currently under active development. APIs may change and some features may be incomplete.
The use of Bun FFI's read namespace is currently avoided since it is not faster than the built-in DataView.getFloat64 method despite what the documentation says.
Development
bun lint # lint and fix with biomejs
bun test # run testsTODO
- [ ] Test and benchmark memory footprint
- [ ] Easy access for struct address. Idea: add a readonly
$field that is dynamically gotten fromptr(foo.$raw). - [x] Use
import source from "./file.c" with {type: "file"};to import C source in tests - [x] Rewrite
Ptras{ [index: number]: T }for better DX and C arrays ar the same time - [ ] Rewrite
PRIMITIVE_READERSandPRIMITIVE_WRITERSfor better type safety - [ ] Function Pointers
- [x] Implement
- [x] use
JSCallBack.ptrto write - [x] use
CFunctionto read - [x] Create a
FunPtrtype with specified return and arg type (mimic C function pointer)
- [x] use
- [x] Test
- [ ] Document
- [x] Implement
- [ ] Make Field type translation correspond to the maps defined in
ffi.d.ts - [ ] C unions: Stack Overflow
- [x] Implement
- [x] Test
- [ ] Document
- [ ] C Structs
- [x] Implement
- [x] Test
- [ ] Document
- [x] Optimizations
- [x] decide read and write case methods when defining properties, avoid switch statement traversal on every access
