JS Utils Kit - v0.5.1
    Preparing search index...

    JS Utils Kit - v0.5.1

    Js Utils Kit

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

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

    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.

    • 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
    # 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

    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.

    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
    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
    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
    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';
    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

    Full documentation available at GitHub Pages

    • 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

    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.

    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.

    Released under the MIT License