@antropia/snip
v1.0.1
Published
Utility library for TS by Antropia Studio
Readme
Snip
Snip is a TypeScript utility library with the stuff you actually need. Small footprint, full type safety, works everywhere.
Overview
A collection of well-tested utilities for arrays, objects, strings, math, and async operations. Everything you find yourself rewriting across projects, packaged up with proper types and security in mind.
Installation
npm install @antropia/snipyarn add @antropia/snippnpm add @antropia/snipUsage
import { range, oneOf, groupBy, exponentialBackoffDelay } from '@antropia/snip';
// Generate sequences
const numbers = range(5); // [0, 1, 2, 3, 4]
// Random selection
const greeting = oneOf(['Hey', 'Hi', 'Hello', 'Howdy']);
// Group data
const users = [
{ id: 1, role: 'admin' },
{ id: 2, role: 'user' },
{ id: 3, role: 'admin' },
];
const byRole = groupBy(users, user => user.role);
// { admin: [...], user: [...] }
// Exponential backoff for retries
await exponentialBackoffDelay(2);Design Principles
- Simplicity over cleverness — Code should be obvious
- Safety first — Runtime checks where needed, strict TypeScript everywhere
- Practical, not exhaustive — What you actually use, not every possible variation
- Good defaults — Sensible behavior out of the box
Development
# Run tests
npm test
# Lint and type-check
npm run lint
# Build
npm run prepare
# Release
npm run releaseContributing
Found a bug or have a useful utility to add? Open an issue or PR on GitHub.
Note: We're picky. New utilities should be genuinely useful, well-tested, and fit the library's philosophy.
License
MIT © Antropia Studio
