Installation
Adding js-utils to a project takes one command. It's a dual ESM + CommonJS package with bundled
TypeScript types, so there's nothing else to configure — no separate @types package, no build
step.
Requirements
js-utils has no runtime dependencies and works anywhere modern JavaScript runs:
- Node.js — a current LTS release (Node 18 or newer is recommended).
- Any bundler — Vite, webpack, esbuild, Rollup, or Parcel.
- TypeScript — optional. If you use it, types are picked up automatically.
Install
Install the package with your package manager of choice:
npm install @0x26e/utilspnpm add @0x26e/utilsyarn add @0x26e/utilsbun add @0x26e/utilsImporting
Every helper is a named export, so import only what you need. This keeps your bundle small — unused helpers are tree-shaken away.
import { get, set, clamp, pagination } from '@0x26e/utils'
const config = { server: { port: 3000 } }
get(config, 'server.port', 8080) // 3000You can import as many or as few helpers as you like in a single statement:
import {
crossJoin,
toCssClasses,
get,
set,
sleep,
usleep,
until,
blank,
clamp,
tap,
pagination,
Paginator,
} from '@0x26e/utils'ESM vs CommonJS
js-utils ships both module formats and selects the right one automatically based on how you load it.
import { clamp } from '@0x26e/utils'
clamp(15, 1, 10) // 10const { clamp } = require('@0x26e/utils')
clamp(15, 1, 10) // 10How the right build is chosen
The package declares an exports map: bundlers and ESM runtimes resolve to the import build,
while a require call resolves to the CommonJS build. You don't have to do anything — just import
or require as usual.
TypeScript support
Type definitions ship inside the package, so there is no @types/... package to install. Editors
get full autocomplete and inline documentation, and generics flow through the helpers that have
them:
import { get, tap } from '@0x26e/utils'
// `get<T>` lets you state the expected return type
const price = get<number>({ desk: { price: 100 } }, 'desk.price', 0)
// ^? number | undefined
// `tap<T>` infers its return type from the interceptor
const doubled = tap(5, (n) => n * 2)
// ^? numberVerify it works
A quick sanity check after installing:
import { pagination } from '@0x26e/utils'
const page = pagination(10, 100).setPage(2)
console.log(page.getFirstItemOnPage()) // 11
console.log(page.getLastItemOnPage()) // 20
console.log(page.getPageCount()) // 10If that prints 11, 20, and 10, you're ready to go.
Next steps
Explore the API reference, where every function is documented with its signature, parameters, and real examples:
- Arrays & Objects —
crossJoin,toCssClasses,get,set - Async Helpers —
sleep,usleep,until - Value Helpers —
blank,clamp,tap - Pagination —
paginationand thePaginatorclass