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

@bridge-rs/cool

v1.0.10

Published

Template project for writing node package with napi-rs

Downloads

50

Readme

@bridge-rs/cool

一个高性能的磁盘信息获取工具,使用 Rust 编写,通过 NAPI-RS 为 Node.js 提供原生绑定。

特性

  • 🚀 高性能:基于 Rust 实现,提供接近原生的性能
  • 🔧 跨平台支持:支持 Windows、macOS 和 Linux
  • 📦 Node.js 兼容:支持 Node.js 12 及以上版本
  • 🛡️ 类型安全:完整的 TypeScript 类型定义

安装

npm install @bridge-rs/cool

或使用 yarn:

yarn add @bridge-rs/cool

系统要求

Node.js 版本

  • 最低要求:Node.js 12.0.0
  • 推荐版本:Node.js 16.0.0 或更高

支持的操作系统

  • Windows (x64, ia32, arm64)
  • macOS (x64, arm64, universal)
  • Linux (x64, arm64, arm)

API

getMainDiskInfo(): PackageJson

获取主磁盘(Windows 为 C 盘,Unix 系统为根目录)的空间信息。

返回值:

interface PackageJson {
  totalBytes: number // 总空间(字节)
  availableBytes: number // 可用空间(字节)
}

使用示例

基本用法

const { getMainDiskInfo } = require('@bridge-rs/cool')

// 获取磁盘信息
const diskInfo = getMainDiskInfo()

console.log(`总空间: ${(diskInfo.totalBytes / 1024 / 1024 / 1024).toFixed(2)} GB`)
console.log(`可用空间: ${(diskInfo.availableBytes / 1024 / 1024 / 1024).toFixed(2)} GB`)
console.log(`已使用: ${((diskInfo.totalBytes - diskInfo.availableBytes) / 1024 / 1024 / 1024).toFixed(2)} GB`)

TypeScript 支持

import { getMainDiskInfo, PackageJson } from '@bridge-rs/cool'

const diskInfo: PackageJson = getMainDiskInfo()
console.log(
  `磁盘使用率: ${(((diskInfo.totalBytes - diskInfo.availableBytes) / diskInfo.totalBytes) * 100).toFixed(2)}%`,
)

错误处理

const { getMainDiskInfo } = require('@bridge-rs/cool')

try {
  const diskInfo = getMainDiskInfo()
  console.log('磁盘信息:', diskInfo)
} catch (error) {
  console.error('获取磁盘信息失败:', error.message)
}

平台特定说明

Windows

  • 自动检测系统架构(x64/ia32/arm64)
  • 支持 MSVC 和 GNU 工具链
  • 默认获取 C 盘信息

macOS

  • 支持 Intel 和 Apple Silicon
  • 提供 Universal 二进制文件
  • 获取根目录(/)的磁盘信息

Linux

  • 支持 glibc 和 musl
  • 自动检测 C 库类型
  • 获取根目录(/)的磁盘信息

开发

环境要求

  • Rust 1.70+
  • Node.js 12+
  • npm 或 yarn

构建命令

# 安装依赖
npm install

# 构建 Rust 原生模块
npm run build

# 运行测试
npm test

# 运行基准测试
npm run bench

# 格式化代码
npm run format

故障排除

常见问题

  1. Node.js 版本兼容性

    • 如果使用 Node.js 12,确保使用最新版本(12.22.12+)
    • 推荐升级到 Node.js 16+ 以获得更好的性能和稳定性
  2. 权限问题

    • 确保应用有读取磁盘信息的权限
    • 在某些 Linux 发行版上可能需要 root 权限

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v1.0.6

  • 添加 Node.js 12 支持
  • 改进跨平台兼容性
  • 优化性能和内存使用