Skip to content

A modern and modular JavaScript utility toolkit offering essential functions for strings, arrays, objects, numbers, dates, types, and more.

License

Notifications You must be signed in to change notification settings

teneplaysofficial/js-utils-kit

Js Utils Kit

Modular JavaScript utilities with type support for strings, objects, arrays and more

Build Test codecov npm version JSR JSR Score License GitHub stars Issues PRs Last Commit Downloads Type Support Sponsor Follow @teneplays on X

Overview

JS Utils Kit is a compact and reliable library of essential JavaScript utility functions. It includes helpers for arrays, objects, numbers, promises, type checking, and more. Designed for performance and modularity, it integrates easily into JavaScript and TypeScript projects with minimal impact on bundle size.

Streamline your code with battle-tested, tree-shakable utilities.

This package includes utilities designed for both browser and Node.js environments, clearly organized and optimized for cross-platform compatibility.

Features

  • Organized by category (e.g., number, string, file, etc.)
  • Fully typed in TypeScript
  • Thoroughly tested with Jest
  • Tree‑shakeable and supports both ESM and CJS
  • CLI-ready tools for file and system operations

Installation

# via npm
npm install js-utils-kit

# via yarn
yarn add js-utils-kit

# via pnpm
pnpm add js-utils-kit

# via bun
bun add js-utils-kit

# via Deno (using npm)
deno add npm:js-utils-kit

# via Deno (using JSR)
deno add jsr:@tene/js-utils-kit

# via JSR
npx jsr add @tene/js-utils-kit

Usage

js-utils-kit offers a modular structure for utilities across different categories like number, string, array, object, env, and more. You can use full or scoped imports depending on your preference and project setup.

Recommended Import

Import only what you need by utility category:

import number from 'js-utils-kit/number';
import string from 'js-utils-kit/string';
import array from 'js-utils-kit/array';
import object from 'js-utils-kit/object';
import env from 'js-utils-kit/env';

console.log(number.clamp(150, 0, 100)); // 100
console.log(string.capitalize('hello world')); // 'Hello World'
console.log(array.unique([1, 2, 2, 3])); // [1, 2, 3]
console.log(object.isEmpty({})); // true
console.log(env.isBrowser()); // true/false

Full Import (All utils in one namespace)

import * as kit from 'js-utils-kit';

console.log(kit.number.clamp(150, 0, 100)); // 100
console.log(kit.string.capitalize('hello')); // 'Hello'
console.log(kit.array.unique([1, 1, 2])); // [1, 2]
console.log(kit.object.isEmpty({})); // true
console.log(kit.env.isNode()); // true/false

Named Imports

import { number, string, env } from 'js-utils-kit';

console.log(number.clamp(42, 0, 100)); // 42
console.log(string.capitalize('js-utils-kit')); // 'Js-utils-kit'
console.log(env.isDev()); // true/false

Using JSR or Deno

import { number, string, env } from '@tene/js-utils-kit';
// or
import { number, string, env } from 'jsr:@tene/js-utils-kit';
// or
import number from '@tene/js-utils-kit/number';
import string from '@tene/js-utils-kit/string';
import array from '@tene/js-utils-kit/array';
import object from '@tene/js-utils-kit/object';
import env from '@tene/js-utils-kit/env';

CommonJS Usage

const { number, string, array, object, env } = require('js-utils-kit');

console.log(number.clamp(150, 0, 100)); // 100
console.log(string.capitalize('hello world')); // 'Hello World'
console.log(array.unique([1, 2, 2, 3])); // [1, 2, 3]
console.log(object.isEmpty({})); // true
console.log(env.isBrowser()); // true/false

Documentation

Full documentation available at GitHub Pages

Requirements

  • Node.js: Version 18.0.0 or higher
  • Yarn (or npm as an alternative)
  • TypeScript (optional, for TypeScript projects or development)
  • Browsers: Modern browsers for browser-based usage

Contributing

We welcome contributions whether it's fixing bugs, adding utilities, improving docs, or writing tests. See CONTRIBUTING.md for guidelines and join our GitHub Discussions to share ideas or propose features.

FAQ

Does it work in browsers?

Yes, JS Utils Kit is compatible with modern browsers and Node.js.

Do I need TypeScript?

No, the library works in plain JavaScript, but TypeScript users benefit from full type definitions and editor support.

How do I report a bug?

Open an issue on GitHub or join the Discussions to ask questions or share feedback.

How can I optimize bundle size?

Import only what you need:

import { clamp } from 'js-utils-kit/number';

This enables tree-shaking for smaller, optimized bundles.

License

Released under the MIT License

About

A modern and modular JavaScript utility toolkit offering essential functions for strings, arrays, objects, numbers, dates, types, and more.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 5