# @ayonli/jsext

> A JavaScript extension package for building strong and modern applications.

Latest version **1.9.0** (published 2025-10-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ayonli/jsext
pnpm add @ayonli/jsext
yarn add @ayonli/jsext
bun add @ayonli/jsext
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.9.0 |
| Published | 2025-10-04 |
| First published | 2023-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=14.18 |
| Dependencies | 4 |
| Unpacked size | 6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | A-yon Lee |
| Maintainers | ayonli |
| Keywords | wrap, mixin, try, defer, throttle, debounce, queue, channel, worker, parallel, parallelism, multithreading, goroutine, asyncIterator, compare, capitalize, hyphenate, chunk, truncate, trim, byteLength, random, isFloat, isNumeric, range, count, equals, split, uniq, shuffle, orderBy, groupBy, patch, pick, omit, hasOwn, hasOwnMethod, as, isValid, isPlainObject, sanitize, sortKeys, flatKeys, sum, avg, product, round, sleep, until, promise, json, error, uint8array, path, dirname, basename, extname, resolve, join, contains, startsWith, endsWith, alert, confirm, prompt, async, interop, importScript, BiMap, CiMap, tarball, tar, untar, fs, readDir, readFile, writeFile, rename, link, readLink, createReadableStream, createWritableStream, stream, sse, bytes, ByteArray, pipe, cli, run, powershell, which, sudo, parseArgs, stringWidth, hash, md5, sha1, sha256, sha512 |

## Links

- npm: https://www.npmjs.com/package/@ayonli/jsext
- Repository: https://github.com/ayonli/jsext
- Homepage: https://github.com/ayonli/jsext#readme
- Issues: https://github.com/ayonli/jsext/issues
- npm.io page: https://npm.io/package/@ayonli/jsext

## Dependencies (4)

- [ws](https://npm.io/package/ws.md) ^8.17.0
- [zod](https://npm.io/package/zod.md) ^3.23.8
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.6.3
- [sudo-prompt](https://npm.io/package/sudo-prompt.md) ^9.2.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.9.0 (latest) — 2025-10-04
- 1.8.0 — 2025-06-29
- 1.7.4 — 2025-06-25
- 1.7.3 — 2025-05-09
- 1.7.2 — 2025-05-08
- 1.7.1 — 2025-05-08
- 1.7.0 — 2025-05-07
- 1.6.0 — 2025-03-18
- 1.5.1 — 2025-03-03
- 1.5.0 — 2025-03-02
- 1.4.7 — 2025-02-07
- 1.4.6 — 2025-02-07
- 1.4.5 — 2025-02-07
- 1.4.4 — 2025-02-04
- 1.4.3 — 2025-02-04
- … 156 more at https://npm.io/package/@ayonli/jsext/versions

## README

# 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

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

## Import

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

```js
// 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.

```html
<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](https://jsr.io/@ayonli/jsext/doc/try/~/_try) Calls a function safely and
  return errors when captured.
- [func](https://jsr.io/@ayonli/jsext/doc/func/~/func) Declares a function along with
  a `defer` keyword, inspired by
  Golang.
- [once](https://jsr.io/@ayonli/jsext/doc/once/~/once) Creates a function that performs
  lazy initialization on the first call.
- [wrap](https://jsr.io/@ayonli/jsext/doc/wrap/~/wrap) Wraps a function for decorator
  pattern but keep its signature.
- [mixin](https://jsr.io/@ayonli/jsext/doc/mixin/~/mixin) Declares a class that
  combines all methods from the base classes.
- [throttle](https://jsr.io/@ayonli/jsext/doc/throttle/~/throttle) Throttles function
  calls for frequent access.
- [debounce](https://jsr.io/@ayonli/jsext/doc/debounce/~/debounce) Debounces function
  calls for frequent access.
- [queue](https://jsr.io/@ayonli/jsext/doc/queue/~/queue) Handles tasks sequentially
  and prevent concurrency conflicts.
- [lock](https://jsr.io/@ayonli/jsext/doc/lock/~/lock) Provides mutual exclusion for
  concurrent operations.
- [chan](https://jsr.io/@ayonli/jsext/doc/chan/~/chan) Creates a channel that
  transfers data across routines, even across multiple threads, inspired by
  Golang.
- [parallel](https://jsr.io/@ayonli/jsext/doc/parallel/~/default) Runs functions in
  parallel threads and take advantage of multi-core CPUs, inspired by Golang.
- [run](https://jsr.io/@ayonli/jsext/doc/run/~/default) Runs a script in a worker
  thread and invokes its `default` function to collect the result.
- [deprecate](https://jsr.io/@ayonli/jsext/doc/deprecate/~/deprecate) Marks a function as
  deprecated and emit warnings when it is called.
- [pipe](https://jsr.io/@ayonli/jsext/doc/pipe/~/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](https://jsr.io/@ayonli/jsext/doc/archive/~) Collecting files into an
  archive file, or extracting files from a archive file.
- [array](https://jsr.io/@ayonli/jsext/doc/array/~) Functions for dealing with
  arrays.
- [async](https://jsr.io/@ayonli/jsext/doc/async/~) Functions for async/promise
  context handling.
- [bytes](https://jsr.io/@ayonli/jsext/doc/bytes/~) Functions for dealing with
  byte arrays (`Uint8Array`).
- [class](https://jsr.io/@ayonli/jsext/doc/class/~) Functions for dealing with
  classes.
  - [decorators](https://jsr.io/@ayonli/jsext/doc/class/decorators/~) Decorators
    to validate input/output data and guarantee type safety at runtime.
- [cli](https://jsr.io/@ayonli/jsext/doc/cli/~) (Experimental) Useful utility
  functions for interacting with the terminal.
- [collections](https://jsr.io/@ayonli/jsext/doc/collections/~) Additional
  collection data types.
- [dialog](https://jsr.io/@ayonli/jsext/doc/dialog/~) (Experimental)
  Asynchronous dialog functions for both browsers and terminals.
- [encoding](https://jsr.io/@ayonli/jsext/doc/encoding/~) Utilities for encoding
  and decoding binary representations like hex and base64 strings.
- [error](https://jsr.io/@ayonli/jsext/doc/error/~) Functions for converting
  errors to/from other types of objects.
- [event](https://jsr.io/@ayonli/jsext/doc/event/~) Functions for working with
  events.
- [filetype](https://jsr.io/@ayonli/jsext/doc/filetype/~) Functions to get file
  types in different fashions.
- [fs](https://jsr.io/@ayonli/jsext/doc/fs/~) Universal file system APIs for
  both server and browser applications.
- [hash](https://jsr.io/@ayonli/jsext/doc/hash/~) Simplified hash functions for
  various data types.
- [http](https://jsr.io/@ayonli/jsext/doc/http/~) Functions for handling HTTP
  related tasks, such as parsing headers and serving HTTP requests.
- [iterator](https://jsr.io/@ayonli/jsext/doc/iterator/~) Functions for dealing
  with iterator objects.
- [json](https://jsr.io/@ayonli/jsext/doc/json/~) Functions for parsing JSONs to
  specific structures.
- [math](https://jsr.io/@ayonli/jsext/doc/math/~) Functions for mathematical
  calculations.
- [module](https://jsr.io/@ayonli/jsext/doc/module/~) Functions for working with
  JavaScript modules.
- [net](https://jsr.io/@ayonli/jsext/doc/net/~) Functions for working with the
  network.
- [number](https://jsr.io/@ayonli/jsext/doc/number/~) Functions for dealing with
  numbers.
- [object](https://jsr.io/@ayonli/jsext/doc/object/~) Functions for dealing with
  objects.
- [path](https://jsr.io/@ayonli/jsext/doc/path/~) Platform-independent utility
  functions for dealing with file system paths and URLs.
- [reader](https://jsr.io/@ayonli/jsext/doc/reader/~) Utility functions for
  reading data from various types of source into various forms.
- [result](https://jsr.io/@ayonli/jsext/doc/result/~) (Experimental)
  Introduces the `Result` pattern into JavaScript, inspired by Rust.
- [runtime](https://jsr.io/@ayonli/jsext/doc/runtime/~) Utility functions to
  retrieve runtime information or configure runtime behaviors.
- [sse](https://jsr.io/@ayonli/jsext/doc/sse/~) Tools for processing Server-sent
  Events requests and handling message events.
- [string](https://jsr.io/@ayonli/jsext/doc/string/~) Functions for dealing with
  strings.
- [types](https://jsr.io/@ayonli/jsext/doc/types/~) The missing builtin classes
  of JavaScript and utility types for TypeScript.
- [ws](https://jsr.io/@ayonli/jsext/doc/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](https://github.com/ayonli/jsext/blob/main/augment/README.md).

---
_Source: https://npm.io/package/@ayonli/jsext · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
