npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tt23xrstudio/senri_ffi

v0.3.2

Published

Unified FFI library for [KossJS Runtime](github.com/KossJS), Node.js Runtime, and Bun Runtime

Downloads

36

Readme

senri_ffi / SenRi FFI / 千里 FFI / せんり FFI

统一 FFI(外部函数接口)库,适用于 KossJS Runtime、Node.js、Bun 和 Deno — 一套 API 到处调用原生 C 库。

特性

  • 一次编写,到处运行 — 同一套 FFI 代码可在 KossJS、Node.js、Bun 和 Deno 上运行
  • 自动检测 — 运行时自动选择正确的原生 FFI 后端
  • 零原生依赖 — 在 KossJS、Bun 和 Deno 上使用内置 FFI;Node.js 上可选安装 koffi
  • 完整类型系统 — 统一的 C 类型名称(int32、float64、cstring 等),各运行时自动映射
  • 结构体支持 — 定义 C 结构体,自动处理布局、对齐和紧凑排列
  • 指针 API — 从原始内存中读写基本类型、指针和 C 字符串
  • 回调函数 — 将 JavaScript 函数封装为 C 函数指针
  • 内存管理 — alloc、free、addressOf、errno、strerror
  • 异步调用 — Deno 和 KossJS 原生非阻塞、Node worker 线程、Bun Promise 包装

安装

npm install @tt23xrstudio/senri_ffi

在 Node.js 上还需要安装 koffi:

npm install koffi

快速开始

import { Library, types } from '@tt23xrstudio/senri_ffi';

// 加载原生库
const lib = Library.load(
  process.platform === 'win32' ? 'user32.dll' : 'libm.so.6'
);

// 调用 C 函数
const abs = lib.func('abs', types.int32, [types.int32]);
console.log(abs(-42)); // 42

// 别忘了关闭
lib.close();

文档

文档请参阅 SenRi FFI 文档

运行要求

| 运行时 | 版本 | 说明 | |---------|---------|-------| | KossJS | >=0.1.0-dev.6 | 内置 FFI,通过 _senri_ffi | | Bun | >= 1.0 | 内置 FFI,通过 Bun.FFI。注意cstring 类型存在已知崩溃问题;自动降级为 ptr(字符串参数转为 buffer,返回值返回原始指针地址)。 | | Node.js | >= 20 | 需要单独安装 koffi | | Deno | >= 2.8 | 内置 FFI,通过 Deno.dlopen |

许可证

Apache-2.0