DEV Community

Cover image for check-toolkit: a lightweight, tree-shakable TypeScript utility library
Volodymyr Cherevchuk
Volodymyr Cherevchuk

Posted on

check-toolkit: a lightweight, tree-shakable TypeScript utility library

I built a small utility library called check-toolkit — first for my own projects, then decided to open-source it. It's a set of typed helpers and type guards for TypeScript/JavaScript, with zero runtime dependencies.

Why another utility library?

We all know lodash and friends. They're battle-tested, but:

  • they often pull more into your bundle than you actually use;
  • many were designed before tree-shaking was a thing;
  • typing is frequently bolted on rather than built in. I wanted something simpler: import exactly the one function I need, no heavy dependencies, and proper type guards out of the box. That's how check-toolkit came to be.

What's inside

  • Lightweight — small implementations, no heavy lodash-style machinery.
  • Tree-shakeable — every function is a separate export; only what you use ends up in your bundle.
  • Zero runtime dependencies — nothing extra shipped to your users.
  • Typed — guards like isNotNil, isPlainObject, isString actually narrow types in TypeScript. It already covers a decent surface: type checks (isString, isPlainObject, isEmpty, isEqual, isMatch…), object helpers (pick, omit, pickBy, omitBy), arrays (uniq, groupBy, partition, sortBy, difference…), strings (camelCase, kebabCase, snakeCase, escape…), cloning (clone, cloneDeep), function helpers (debounce, throttle, once), plus clamp and delay. Everything is covered by tests (vitest).

Example

// npm install check-toolkit
import { isString, isPlainObject, pick } from "check-toolkit";
isString("test");          // true
isPlainObject({ a: 1 });   // true
const payload = pick({ a: 1, b: 2, c: 3 }, ["a", "c"]);
// { a: 1, c: 3 }
Enter fullscreen mode Exit fullscreen mode

The part I like most is type narrowing — guards work as proper TypeScript predicates:

import { isNotNil } from "check-toolkit";
const values = [1, null, 2, undefined, 3];
const clean = values.filter(isNotNil);
// clean: number[] — TypeScript narrows the type, no `as` needed
Enter fullscreen mode Exit fullscreen mode

Status

The library is working and covered by tests, though the API may still get polished (it's at 0.1.0). Feedback, ideas and pull requests are very welcome. MIT licensed — use it freely.

Top comments (0)