Skip to content

Getting Started

Terminal window
npm install 1o1-utils
import { chunk, pick, slugify, retry } from "1o1-utils";

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.

  • Node.js >= 20
  • ESM only — this package uses "type": "module"
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 }]]
CategoryUtilities
ArraysarrayToHash, chunk, groupBy, sortBy, unique
ObjectsdeepMerge, isEmpty, omit, pick
Stringscapitalize, slugify, transformCase, truncate
Asyncdebounce, retry, sleep, throttle