Skip to main content

Duck Libs

Shared utilities for the gentleduck ecosystem. cn(), filteredObject, groupArray, parseDate. Each helper lives on its own subpath.

Zero deps

The utility layer behind every gentleduck package

Use it standalone whenever you reach for `cn()`, a date parser, or a grouping helper. Every other `@gentleduck` package depends on it.

cn()

Class-name merger built on clsx and tailwind-merge. Deduplicates conflicting Tailwind utilities so the last class wins.

filteredObject

Pick or omit keys from an object with a typed result. A typed replacement for `lodash.pick` and `omit`.

groupArray

Group a list by key or by function. Returns a record keyed by the group, values are the matching items.

groupDataByNumbers

Bucket numeric data into explicit ranges. Handy for histograms, charts, and ad-hoc analytics on arrays of numbers.

parseDate

Parse strings, numbers, or `Date` inputs into a real `Date`. Returns `null` for invalid input so you can early-return.

Subpath imports

Every helper ships under its own entry point. `@gentleduck/libs/cn`, `/parse-date`, and so on. No framework deps.

Install

Import any helper from its subpath.

# Install
bun add @gentleduck/libs

# Use the most popular helper
import { cn } from '@gentleduck/libs/cn'

Free & open source

gentleduck is MIT licensed and will always be free and open source. Every package ships with full source access — fork it, modify it, own it.

Become a Sponsor