check-toolkit
v0.1.0
Published
A lightweight TypeScript utility library focused on type guards and small, tree-shakeable helpers. Zero runtime dependencies — import only what you need.
Readme
check-toolkit
A lightweight TypeScript utility library focused on type guards and small, tree-shakeable helpers. Zero runtime dependencies — import only what you need.
Why check-toolkit?
- Lightweight — small implementations without heavy lodash-style utilities
- Tree-shakeable — each function is imported separately
- Zero runtime dependencies — nothing extra in your bundle
- Typed — type guards like
isNotNilandisPlainObjectnarrow types in TypeScript
Installation
npm install check-toolkitUsage
import { isString, isPlainObject, pick } from "check-toolkit";
console.log(isString("test")); // true
console.log(isPlainObject({ a: 1 })); // true
const payload = pick({ a: 1, b: 2, c: 3 }, ["a", "c"]);
// { a: 1, c: 3 }Available Functions
Type Checking
isSymbol- Check if value is a symbolisArray- Check if value is an arrayisArrayLike- Check if value is array-likeisNan- Check if value is NaNisObject- Check if value is an objectisNull- Check if value is nullisFunction- Check if value is a functionisNumber- Check if value is a numberisString- Check if value is a stringisBoolean- Check if value is a booleanisPlainObject- Check if value is a plain objectisUndefined- Check if value is undefinedisNotUndefined- Check if value is not undefinedisNil- Check if value is null or undefinedisNotNil- Check if value is not null and not undefinedisNotNaN- Check if value is not NaNisEmpty- Check if value is emptyisEqual- Check if two values are equalisMatch- Check if object matches source
Object Operations
pick- Creates a new object with only the specified keysomit- Creates a new object without the specified keyspickBy- Creates a new object with entries that satisfy a predicateomitBy- Creates a new object without entries that satisfy a predicate
Array Operations
compact- Removes falsy values from an arraycountBy- Counts elements grouped by iteratee resultuniq- Creates an array with unique valuesuniqBy- Like uniq but accepts an iterateegroupBy- Groups array elements by iteratee resultpartition- Splits an array into two groups by predicatesortBy- Creates a sorted copy by iteratee resultdifference- Create an array of unique values not included in other arraysdifferenceBy- Like difference but accepts iterateedifferenceWith- Like difference but accepts comparatorkeyBy- Creates an object composed of keys generated from array
String Operations
capitalize- Uppercases the first character only (not title case; usestoUpperCase)camelCase- Converts a string to camel casekebabCase- Converts a string to kebab casesnakeCase- Converts a string to snake casestartCase- Converts each word to start case (title-style)escape- Escapes HTML special charactersunescape- Unescapes HTML special charactersescapeRegExp- Escapes RegExp special characters
Clone Operations
clone- Creates a shallow clone of a valuecloneDeep- Creates a deep clone of a valuecloneWith- Creates a shallow clone with a customizercloneDeepWith- Creates a deep clone with a customizer
Function Utilities
debounce- Creates a debounced functionthrottle- Creates a throttled functionnoop- No-op default callbackidentity- Returns the first argument unchangedonce- Invokes a function at most once
Math
clamp- Clamps a number between min and max
Promise
delay- Resolves after the specified milliseconds
Testing
To run the test suite:
npm run testTo build the project:
npm run buildTo start development server:
npm run devContributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License
Originally created by Volodymyr Cherevchuk
