Getting Started
Installation
Section titled “Installation”npm install 1o1-utilspnpm add 1o1-utilsyarn add 1o1-utilsbun add 1o1-utilsImport
Section titled “Import”Full library
Section titled “Full library”import { chunk, pick, slugify, retry } from "1o1-utils";Individual modules
Section titled “Individual modules”For the smallest possible bundle, import only the utilities you need:
import { chunk } from "1o1-utils/chunk";import { pick } from "1o1-utils/pick";import { slugify } from "1o1-utils/slugify";import { retry } from "1o1-utils/retry";Each individual module is under 2 kB gzipped.
Requirements
Section titled “Requirements”- Node.js >= 20
- ESM only — this package uses
"type": "module"
Quick example
Section titled “Quick example”import { chunk, sortBy, unique } from "1o1-utils";
const users = [ { name: "Alice", age: 30 }, { name: "Bob", age: 25 }, { name: "Alice", age: 30 },];
const deduplicated = unique({ array: users, key: "name" });// => [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }]
const sorted = sortBy({ array: deduplicated, key: "age" });// => [{ name: "Bob", age: 25 }, { name: "Alice", age: 30 }]
const batches = chunk({ array: sorted, size: 1 });// => [[{ name: "Bob", age: 25 }], [{ name: "Alice", age: 30 }]]Available utilities
Section titled “Available utilities”| Category | Utilities |
|---|---|
| Arrays | arrayToHash, chunk, groupBy, sortBy, unique |
| Objects | deepMerge, isEmpty, omit, pick |
| Strings | capitalize, slugify, transformCase, truncate |
| Async | debounce, retry, sleep, throttle |