Skip to content

Latest commit

 

History

81 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

简体中文 | English

Fast.Utils Logo

Fast.Utils

npm version npm downloads License

A TypeScript utility SDK for modern browsers, WebViews, Vue 3 and uni-app.

Documentation · Official website

Highlights

  • Typed, side-effect-free utilities with one named-export entry for effective Tree Shaking.
  • Browser, WebView, Vue 3, and uni-app contracts without import-time platform access.
  • Explicit security boundaries for storage, identity, encoding, random generation, and cryptography.
  • TypeScript 6 strict checks, ESLint, runtime tests, consumer type tests, package validation, and Publint.

Install

pnpm add @fast-china/utils

CDN

The jsDelivr entry uses the minified dist/index.global.min.js browser file, which exposes the FastUtils global.

Resource jsDelivr unpkg
vue@3.5.11/dist/vue.global.prod.js jsDelivr unpkg
@fast-china/utils/dist/index.global.min.js jsDelivr unpkg

Quick start

The default namespace is fast__; store and retrieve business data with an optional TTL:

import { Local } from "@fast-china/utils";

Local.set("profile", { name: "Fast" }, { ttlMs: 30 * 60 * 1000 });
const profile = Local.get<{ name: string }>("profile");
console.log(profile?.name);

Without a TTL, entries do not expire. Configure a custom namespace or codec before the first storage operation. The legacy crypto option is Base64 obfuscation, not encryption. uni-app supports Local, not Session.

Common usage

Import utilities by name from the package root:

import { encodeBase64, formatBytes, sleep } from "@fast-china/utils";

const encoded = encodeBase64("Fast");
const size = formatBytes(1536);
await sleep(100);
console.log(encoded, size);

Parameter validation or a pre-aborted signal may throw synchronously; cancellation during the wait rejects the returned Promise.

Modules

@fast-china/utils is the only public entry and exposes every API as a named export. Source modules remain separate in dist/ so modern bundlers can remove unused exports; those internal files are not public package subpaths.

The object module includes dependency-free deep cloning and equality plus predicate-based property selection. Array utilities include a SameValueZero symmetric difference, while once preserves the first return value, Promise identity, or synchronous error.

Runtime contract

  • The package-manager entry is pure ESM; the CDN entry is a separately minified IIFE.
  • ES2022 modern browsers and WebViews.
  • Vue 3.5.11 or newer through a required peer dependency.
  • uni-app through call-time detection of runtime-injected uni and App-Plus plus, with global-property fallbacks.
  • No import-time access to window, Storage, or uni; unsupported calls fail explicitly.
  • Web Crypto, URL, Intl, TextEncoder, and related platform capabilities are not polyfilled.

Documentation

Development

Development requires Node.js ^22.18.0 || ^24.18.0 and pnpm ^11.0.0.

pnpm install --frozen-lockfile
pnpm check

Use pnpm dev for a long-running tsdown watch build while editing source files.

Copyright, license and use

Copyright © 2018-Now 小方. This project uses Apache License 2.0. Use, modification, distribution and commercial use are permitted subject to its terms.

When redistributing, provide the license, mark modified files and preserve applicable copyright, attribution and supplied NOTICE information as required. This summary does not replace the license or impose additional UI attribution.

Users are responsible for the legal compliance and authorization of their own modifications, deployment, data processing and operations. This reminder is not an additional license condition.

Except as required by applicable law or agreed in writing, the software is provided on an "AS IS" basis. Sections 7 and 8 govern warranty disclaimers and liability limits. Providing the project does not endorse downstream activities or assume users' contractual commitments. This statement does not exclude liability that cannot lawfully be excluded.

About

TypeScript utilities for browsers, WebViews, Vue 3 and uni-app, including storage, async and data helpers.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages