UnFFI

Examples

Runnable scripts for native system libraries.

The repository includes examples under examples/. Build first, then run the script for your OS:

bun run build
bun examples/macos/security-random.ts

Each OS-specific script exits early on the wrong platform.

macOS

ExampleWhat it shows
examples/macos/libsystem-process.tsProcess IDs and native C string helpers from libSystem.
examples/macos/corefoundation-clock.tsCoreFoundation absolute time and type IDs.
examples/macos/security-random.tsCryptographic bytes from Security.framework.
examples/macos/systemconfiguration-metadata.tsSafe metadata for pointer-returning SystemConfiguration APIs.

Linux

ExampleWhat it shows
examples/linux/libc-process.tsProcess IDs and native C string helpers from libc.
examples/linux/libm-native-math.tsNative libm trigonometry and floating-point helpers.
examples/linux/pthread-self.tsNative pthread identity for the current JS thread.
examples/linux/unistd-access.tsPOSIX user/group IDs and access checks.
examples/linux/libdl-metadata.tsDynamic-loader metadata without forcing a failing loader call.

Windows

ExampleWhat it shows
examples/windows/kernel32-process.tsProcess/thread IDs, uptime, and ANSI string length.
examples/windows/advapi32-username.tsNative username lookup with Win32 output buffers.
examples/windows/user32-system-metrics.tsDesktop metrics and double-click timing from user32.

These examples are intentionally small. They teach the typed FFI boundary, not broad OS wrapper design.

On this page