@feedzai/js-utilities

中文文档
2.4.0发布于 2025/09/30AGPL-3.0-onlyTypeScriptESM + CJS零依赖近 30 天下载 2429

A collection of common javascript utilities for web projects

原始使用文档
文档目录26 节
  1. Intro
  2. Table of Contents
  3. Installation
  4. Usage
  5. Functions
  6. DOM
  7. Random
  8. Arrays
  9. Browsers
  10. Curry
  11. Dates
  12. Events
  13. Internationalization
  14. Numbers
  15. Objects
  16. String
  17. Typed
  18. Utilities
  19. React Hooks
  20. Tests
  21. Other solutions available
  22. Issues
  23. 🐛 Bugs
  24. 💡 Feature Requests
  25. Contributors ✨
  26. LICENSE

@feedzai/js-utilities

A collection of common javascript utilities for web projects


Read The Docs


Build Status version downloads GNU AGPL License PRs Welcome

Intro

In this vast landscape of JavaScript and TypeScript development, having a reliable set of tools at your disposal when building web projects can make all the difference. @feedzai/js-utilities is a comprehensive collection of JavaScript helpers, functions and custom React hooks designed to streamline projects with ease and efficiency.

With this package, developers gain access to a treasure trove of utilities crafted to simplify common tasks encountered in JS/TS projects. From handy helpers to custom React hooks, this library empowers developers to write cleaner, more concise code without sacrificing functionality.

Each function and hook is tested to ensure functionality and effectiveness, whilst giving developers the confidence to integrate them seamlessly into their projects.

It also comes with comprehensive documentation, making it a breeze to navigate and utilize its features effectively.

The package is available in both CommonJS and ES Modules formats so, whether you're working in a traditional environment or embracing the latest ES Modules, we have you covered.

For JavaScript and TypeScript developers seeking a lightweight but robust toolkit that balances simplicity with utility, @feedzai/js-utilities might jus be the answer!

Table of Contents

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's dependencies or devDependencies:

## using npm
npm install @feedzai/js-utilities

## using yarn
yarn add @feedzai/js-utilities

## using pnpm
pnpm add @feedzai/js-utilities

Usage

This is a collection of functions, utilities and react hooks. You'll find all available code in src.

The bundle is available as:

  • ES Modules
  • Common JS

To import a piece of code into your javascript project just do:

// Just one function
import { isNil } from "@feedzai/js-utilities";

// Just a single module, with the full path to the file
import isNil from "@feedzai/js-utilities/dist/functions/typed/is-nil";

// Multiple functions
import { callIfExists, throwError, getLSItem } from "@feedzai/js-utilities";

// React Hooks
import { useMount, useConstant } from "@feedzai/js-utilities/hooks";

// Alias the whole object
import * as JS_UTILS from "@feedzai/js-utilities";

Functions

DOM

NameSource
classNamessource
cloneValidElementsource
queueMicrotasksource
toggleDataAttributesource
waitsource

Random

NameSource
drawsource
randomsource

Arrays

NameSource
arrayMovesource
chunksource
findIndexsource
findsource
flatMapsource
flattensource
groupBysource
inRangesource
includessource
mergesource
removeIndexsource
removeItemsource
uniqBysource
uniqsource

Browsers

NameSource
isBrowsersource
DEVsource

Curry

NameSource
debouncesource
memosource
throttlesource

Dates

NameSource
getBrowserTimezonesource

Events

NameSource
onsource
offsource
emitCustomEventsource
useCustomEventListenersource

Internationalization

NameSource
getBrowserLocalesource

Numbers

NameSource
formatNumbersource
roundsource
shortenNumbersource
toIntsource

Objects

NameSource
atsource
clonesource
getValuesource
getsource
hassource
isEqualsource
omitsource
picksource
setsource

String

NameSource
camelCasesource
capitalizesource
escapeRegExpsource
kebabCasesource
makeIdsource
pascalCasesource
readableStringListsource
stripUnitsource
templatesource
titleCasesource
trimsource

Typed

NameSource
boolOrBoolStringsource
isArraysource
isBlanksource
isBooleansource
isDatesource
isElementsource
isEmptysource
isFunctionsource
isNilsource
isNullsource
isNumbersource
isObjectsource
isPlainObjectsource
isPrimitivesource
isPromisesource
isStringsource
isUndefinedsource

Utilities

NameSource
callIfExistssource
emptyFunctionsource
makeCancelablesource
throwErrorsource
HTTP StatusCodessource
Keyboard Key Codessource

React Hooks

NameSource
useContainerQuerysource
useControlledStatesource
useNetworkStatesource
usePageVisibilitysource
usePermissionsource
useAutoIdsource
useClickOutsidesource
useConstantsource
useCopyToClipboardsource
useEffectOncesource
useLifecyclesource
useLiveRefsource
useMergeRefssource
useMountsource
useMountedStatesource
usePrevioussource
useSafeLayoutEffectsource
useScriptsource

Tests

All tests have been written using cypress.

To run tests locally:

# using npm
npm run test:open

# using npm (headless)
npm run test

# using yarn
yarn test:open

# using yarn (headless)
yarn test

Other solutions available

If you are aware of any, please make a pull request and add it here!

  • Lightdash - A small JavaScript utility library to complement lodash.
  • Radash - A drop-in replacement for lodash, also written in ES Modules.
  • You might not need lodash - It’s a great website, well crafted, battle tested and with a very skilled and active community contributing. The goal of that project is NOT to provide drop in replacements, but to show how to achieve similar functionalities in plain Javascript, to understand how things work behind the hood.

Issues

Looking to contribute? Look for the Good First Issue label. You also need to be a Feedzai-aproved contributor to contribute directly to the repo. Otherwise, you always fork the repo and open a merge-request.

See Issues

🐛 Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

See Bugs

💡 Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.

See Feature Requests

Contributors ✨


João Dias


💻

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

GNU Affero General Public License v3.0

版本与发布记录

@feedzai/js-utilities 共发布 15 个版本,首次发布于 2024/03/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.4.0latest2025/09/301.1 年前
2.3.12025/06/121.4 年前
2.3.02025/06/071.4 年前
2.2.02025/06/051.4 年前
2.1.02025/06/041.4 年前
2.0.02025/06/031.4 年前

关于 @feedzai/js-utilities 的常见问题

@feedzai/js-utilities 是什么?

A collection of common javascript utilities for web projects

如何安装 @feedzai/js-utilities?

在项目目录运行 npm install @feedzai/js-utilities,或使用 pnpm add / yarn add / bun add。

@feedzai/js-utilities 支持 TypeScript 吗?

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

@feedzai/js-utilities 支持 ESM 还是 CommonJS?

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

@feedzai/js-utilities 可以商用吗?

@feedzai/js-utilities 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@feedzai/js-utilities 的下载量有多少?

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

@feedzai/js-utilities 还在维护吗?

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