- v1.1.1Latest
- v1.1.0
- v1.0.0
- v0.9.80
- 0.9.80
- v0.9.72
- v0.9.71
- v0.9.70
- v0.9.68
- v0.9.67
- v0.9.66
- v0.9.65
- v0.9.64
- v0.9.63
- v0.9.62
- v0.9.61
- v0.9.60
- v0.9.58
- v0.9.57
- v0.9.56
- v0.9.55
- v0.9.54
- v0.9.53
- v0.9.52
- v0.9.51
- v0.9.50
- v0.9.42
- v0.9.41
- v0.9.40
- v0.9.35
- v0.9.34
- v0.9.33
- v0.9.32
- v0.9.30
- v0.9.20
- v0.9.19
- v0.9.18
- v0.9.17
- v0.9.16
- v0.9.15
- v0.9.14
- v0.9.13
- v0.9.12
- v0.9.11
- v0.9.10
- v0.9.8
- v0.9.7
- v0.9.6
- v0.9.5
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.43
- v0.8.41
- v0.8.40
- v0.8.30
- v0.8.25
- v0.8.24
- v0.8.23
- v0.8.22
- v0.8.21
- v0.8.20
- v0.8.11
- v0.8.10
- v0.8.9
- v0.8.8
- v0.8.7
- v0.8.6
- v0.8.5
- v0.8.4
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.11
- v0.7.10
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.0
- v0.6.31
- v0.6.30
- v0.6.29
- v0.6.27
- v0.6.26
- v0.6.25
- v0.6.24
- v0.6.22
- v0.6.21
- v0.6.20
- v0.6.18
- v0.6.17
- v0.6.16
- v0.6.15
- v0.6.14
- v0.6.13
- v0.6.12
- v0.6.11
- v0.6.10
- v0.6.9
- v0.6.8
- v0.6.7
- v0.6.6
- v0.6.5
- v0.6.4
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.7
- v0.5.5
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.6
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
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
This package requires compilerOptions.moduleResolution
set to Bundler
or
NodeNext
in tsconfig.json
.
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. - 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 another thread and abort at any time.
- 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.
- json Functions for parsing JSONs to specific structures.
- math Functions for mathematical calculations.
- module Utility functions for working with JavaScript modules.
- 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.
- 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.