@ayonli/jsext

中文文档
1.9.0发布于 2025/10/04MITTypeScriptESM + CJS近 30 天下载 2.8万

A JavaScript extension package for building strong and modern applications.

原始使用文档
文档目录7 节
  1. Outstanding Features
  2. Import
  3. Note for Cloudflare Workers and Fastly Compute
  4. Note for TypeScript Project
  5. Language-enhancing Functions
  6. Subcategories
  7. Augmentation

JsExt

A JavaScript extension package for building strong and modern applications.

This package is built on top of modern web standards and provides unified high-level APIs that can work across different runtime environments, whether it's Node.js, Deno, Bun, Cloudflare Workers, browsers, Windows, macOS or Linux.

Outstanding Features

  • Various useful functions for built-in data types that are not built-in.
  • Various utility functions to extend the ability of flow control.
  • Multi-threaded JavaScript with parallel threads.
  • File system APIs for both server and browser environments.
  • Open dialogs in both CLI and web applications.
  • Serve HTTP requests, SSE and WebSockets for all server runtimes.
  • Manipulate file system paths and URLs in the same fashion.
  • Process byte arrays and readable streams effortlessly.
  • Create, extract and preview archives in all runtimes.
  • And many more...

Import

The recommended way is to only import the ones that are needed:

// Universal
import _try from "@ayonli/jsext/try";
import func from "@ayonli/jsext/func";
// ...

// Deno (URL)
import _try from "https://lib.deno.dev/x/ayonli_jsext@latest/try.ts";
import func from "https://lib.deno.dev/x/ayonli_jsext@latest/func.ts";
// ...

// Browsers (URL)
import _try from "https://ayonli.github.io/jsext/esm/try.js";
import func from "https://ayonli.github.io/jsext/esm/func.js";
// ...

There is also a bundled version that can be loaded via a <script> tag in the browser.

<script src="https://ayonli.github.io/jsext/bundle/jsext.js">
    // this will also include the sub-modules and augmentations
</script>

Note for Cloudflare Workers and Fastly Compute

For applications run in Cloudflare Workers and Fastly Compute, install the NPM version of this package instead of the JSR version.

Note for TypeScript Project

In tsconfig.json, the following compilerOptions must be set as such:

  • moduleResolution: Bundler or NodeNext
  • skipLibCheck: true

Language-enhancing Functions

  • _try Calls a function safely and return errors when captured.
  • func Declares a function along with a defer keyword, inspired by Golang.
  • once Creates a function that performs lazy initialization on the first call.
  • wrap Wraps a function for decorator pattern but keep its signature.
  • mixin Declares a class that combines all methods from the base classes.
  • throttle Throttles function calls for frequent access.
  • debounce Debounces function calls for frequent access.
  • queue Handles tasks sequentially and prevent concurrency conflicts.
  • lock Provides mutual exclusion for concurrent operations.
  • chan Creates a channel that transfers data across routines, even across multiple threads, inspired by Golang.
  • parallel Runs functions in parallel threads and take advantage of multi-core CPUs, inspired by Golang.
  • run Runs a script in a worker thread and invokes its default function to collect the result.
  • deprecate Marks a function as deprecated and emit warnings when it is called.
  • pipe Performs pipe operations through a series of functions upon a value.

Subcategories

Each of these modules includes specific functions and classes for their target categories:

  • archive Collecting files into an archive file, or extracting files from a archive file.
  • array Functions for dealing with arrays.
  • async Functions for async/promise context handling.
  • bytes Functions for dealing with byte arrays (Uint8Array).
  • class Functions for dealing with classes.
    • decorators Decorators to validate input/output data and guarantee type safety at runtime.
  • cli (Experimental) Useful utility functions for interacting with the terminal.
  • collections Additional collection data types.
  • dialog (Experimental) Asynchronous dialog functions for both browsers and terminals.
  • encoding Utilities for encoding and decoding binary representations like hex and base64 strings.
  • error Functions for converting errors to/from other types of objects.
  • event Functions for working with events.
  • filetype Functions to get file types in different fashions.
  • fs Universal file system APIs for both server and browser applications.
  • hash Simplified hash functions for various data types.
  • http Functions for handling HTTP related tasks, such as parsing headers and serving HTTP requests.
  • iterator Functions for dealing with iterator objects.
  • json Functions for parsing JSONs to specific structures.
  • math Functions for mathematical calculations.
  • module Functions for working with JavaScript modules.
  • net Functions for working with the network.
  • number Functions for dealing with numbers.
  • object Functions for dealing with objects.
  • path Platform-independent utility functions for dealing with file system paths and URLs.
  • reader Utility functions for reading data from various types of source into various forms.
  • result (Experimental) Introduces the Result pattern into JavaScript, inspired by Rust.
  • runtime Utility functions to retrieve runtime information or configure runtime behaviors.
  • sse Tools for processing Server-sent Events requests and handling message events.
  • string Functions for dealing with strings.
  • types The missing builtin classes of JavaScript and utility types for TypeScript.
  • ws (Experimental) A unified WebSocket server interface for Node.js, Deno, Bun and Cloudflare Workers.

Augmentation

This package supports augmenting some functions to the corresponding built-in types/namespaces, but they should only be used for application development, don't use them when developing libraries.

NOTE: this feature is only available by the NPM package, they don't work by the JSR package.

For more details, please check this document.

版本与发布记录

@ayonli/jsext 共发布 171 个版本,首次发布于 2023/09/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.9.0latest2025/10/041.1 年前
1.8.02025/06/301.4 年前
1.7.42025/06/251.4 年前
1.7.32025/05/101.5 年前
1.7.22025/05/091.5 年前
1.7.12025/05/081.5 年前

关于 @ayonli/jsext 的常见问题

@ayonli/jsext 是什么?

A JavaScript extension package for building strong and modern applications.

如何安装 @ayonli/jsext?

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

@ayonli/jsext 支持 TypeScript 吗?

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

@ayonli/jsext 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ayonli/jsext 需要什么版本的 Node.js?

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

@ayonli/jsext 可以商用吗?

@ayonli/jsext 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ayonli/jsext 的下载量有多少?

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

@ayonli/jsext 还在维护吗?

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