@gesslar/toolkit

中文文档
6.0.3发布于 2026/10/260BSDTypeScriptES Module近 30 天下载 2594

A collection of utilities for Node.js and browser environments.

原始使用文档
文档目录10 节
  1. Included Classes
  2. Browser
  3. Node.js
  4. Installation
  5. Usage
  6. Browser-like
  7. Node.js
  8. Vendor Bundle
  9. Post Partum
  10. License

@gesslar/toolkit

CodeQL, Linting, Testing

A collection of utilities for Node.js and browser environments, including file and directory abstractions, terminal utilities, validation helpers, and data manipulation functions.

Included Classes

Browser

These classes exist and function within the browser, or browser-like environment, such as a Tauri app.

NameDescription
CollectionArray, Map, Set, and other collection manipulation methods
DataPrimitive manipulation and type identification
DisposerLifecycle management for disposable resources
HTMLHTML loading and sanitization utilities
NotifyEvent system wrapper for DOM events
PromisedPromise utilities for settling, filtering, and extracting values from promise results
SassCustom Error class with enhanced features
TantrumAggregateError implementation
TimeTiming operations and promise-based delays with cancellation support
TypeString-based type management (exported as TypeSpec in browser)
UtilGeneral utility functions
ValidValidation and assertion methods

Node.js

Includes all browser functionality plus Node.js-specific modules for file I/O, logging, and system operations.

NameDescription
CacheCache management for file I/O operations
DirectoryObjectDirectory metadata and operations including path resolution, existence checks, and traversal
FileObjectFile system wrapper for file operations
FileSystemBase class for file system operations with static utilities
GlogLogging framework
NotifyEvent system wrapper for Node.js events
SassCustom Error class with enhanced features
TantrumAggregateError implementation
TermTerminal formatting and output utilities
UtilGeneral utility functions (Node-enhanced version)
ValidValidation and assertion methods
WatcherFile and directory change watcher with debounce protection

Installation

npm i @gesslar/toolkit

Usage

Toolkit is environment aware and automatically detects whether it is being used in a web browser or in Node.js. You can optionally specify the node or browser variant explicitly.

Browser-like

TypeScript editors do not pick up types from jsDelivr. If you want inline types without installing from npm, use the esm.sh ?dts URL or install the package locally for development and use the CDN at runtime.

jsDelivr (runtime only)

https://cdn.jsdelivr.net/npm/@gesslar/toolkit

esm.sh (runtime, types)

https://esm.sh/@gesslar/toolkit
https://esm.sh/@gesslar/toolkit?dts` (serves `.d.ts` for editors)

Node.js

import * as TK from "@gesslar/toolkit"
import {Data, FileObject, Cache} from "@gesslar/toolkit"
import {Data, FileObject} from "@gesslar/toolkit/node"
import { Data, Collection, Util } from '@gesslar/toolkit/browser'

The browser version includes: Collection, Data, Disposer, HTML, Notify, Sass, Tantrum, Type (TypeSpec), Util, and Valid. Node-only modules (Cache, DirectoryObject, FileObject, FileSystem, Glog, Term) are not available in the browser version.

Vendor Bundle

Pre-built bundles are included for environments without a build pipeline, such as webviews (VS Code, Tauri, Electron) or plain HTML pages. No bundler required.

ES module

<script type="module">
  import {Data, Collection} from "./node_modules/@gesslar/toolkit/vendor/toolkit.esm.js"
</script>

Or import via the package export:

import {Data, Collection} from "@gesslar/toolkit/vendor"

UMD (global script)

<script src="./node_modules/@gesslar/toolkit/vendor/toolkit.umd.js"></script>
<script>
  const {Data, Collection} = Toolkit
</script>

The vendor bundles contain the same browser-compatible utilities listed above, fully self-contained with zero external dependencies.

Post Partum

If you made it this far, please understand that I have absolutely zero scruples when it comes to breaking changes. Primarily, the audience for this library is myself. Consequently, anything that relies on the contents of this library will dutifully crash and I'll have to refactor those things then. It's like playing nicky nicky nine doors. But with myself. And there's a lazy bomb waiting for me. That I planted. For me. And the bomb just explodes poop.

You're of course welcome to use my library! It's pretty robust. Uhhh, but maybe lock in the version until you see if something is gonna poop all over you. I make robots make my PR notifications and generally they're very good at firing off klaxons about my fetish for breaking changes, so you should be all right if you're paying attention. 🤷🏻

Sincerely, Senator Yabba of the Dabba (Doo)

License

@gesslar/toolkit is released under the 0BSD.

This package includes or depends on third-party components under their own licenses:

DependencyLicense
@gesslar/colours0BSD
ajvMIT
json5MIT
supports-colorMIT
yamlISC

版本与发布记录

@gesslar/toolkit 共发布 149 个版本,首次发布于 2025/09/21;过去 12 个月发布了 114 个版本。

版本发布日期距今
6.0.3latest2026/10/2621 天前
6.0.02026/10/2521 天前
5.9.12026/07/263 个月前
5.9.02026/07/263 个月前
5.8.02026/06/274 个月前
5.7.02026/06/274 个月前

关于 @gesslar/toolkit 的常见问题

@gesslar/toolkit 是什么?

A collection of utilities for Node.js and browser environments.

如何安装 @gesslar/toolkit?

在项目目录运行 npm install @gesslar/toolkit,或使用 pnpm add / yarn add / bun add。

@gesslar/toolkit 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gesslar/toolkit 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gesslar/toolkit 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@gesslar/toolkit 可以商用吗?

@gesslar/toolkit 使用 0BSD 许可。几乎没有限制:可自由使用、修改和分发,连保留版权声明也不要求。以上为概括,不构成法律意见,请以许可原文为准。

@gesslar/toolkit 的下载量有多少?

根据 npm 官方下载统计,@gesslar/toolkit 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,594 次,日均约 86 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gesslar/toolkit 还在维护吗?

最新版本 6.0.3 发布于 2026/10/26(21 天前);至今共发布 149 个版本,其中过去 12 个月发布了 114 个;首次发布于 2025/09/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。