Small, predictable, and reusable utilities for JavaScript and TypeScript.
CyrefJS is a modern, lightweight utility library designed to provide practical helpers for everyday JavaScript and TypeScript development.
It focuses on simple APIs, strong TypeScript support, zero runtime dependencies, and predictable behavior.
- Small and focused utilities
- ESM-first package
- Full TypeScript declarations
- Predictable and consistent APIs
- Category-based subpath imports
- Thoroughly tested with Vitest
- Zero runtime dependencies
- Lightweight and tree-shaking friendly
- Built with modern TypeScript
npm install @cyref/jsOr with other package managers:
pnpm add @cyref/jsyarn add @cyref/jsbun add @cyref/jsYou can import utilities directly from the main package:
import { chunk, capitalize, clamp } from "@cyref/js";
const items = [1, 2, 3, 4, 5, 6];
chunk(items, 2);
// [[1, 2], [3, 4], [5, 6]]
capitalize("hello world");
// "Hello world"
clamp(150, 0, 100);
// 100CyrefJS also supports category-based imports.
import { chunk, shuffle } from "@cyref/js/array";
import { debounce, throttle } from "@cyref/js/function";
import { clamp, lerp } from "@cyref/js/number";This allows you to keep imports explicit and organized.
CyrefJS utilities are organized into focused categories.
Utilities for working with arrays and collections.
import {
chunk,
compact,
difference,
flatten,
groupBy,
shuffle,
unique,
} from "@cyref/js/array";Includes utilities for:
- Chunking
- Flattening
- Filtering
- Grouping
- Taking and dropping items
- Uniqueness
- Set-like operations
- Sampling
- Shuffling
- Zipping and unzipping
Small helpers for common date operations.
import {
addDays,
differenceInDays,
startOfDay,
endOfDay,
} from "@cyref/js/date";Includes:
- Date arithmetic
- Date comparison
- Day boundaries
- Date validation
- Difference calculations
Utilities for composing and controlling functions.
import {
compose,
debounce,
memoize,
once,
pipe,
throttle,
} from "@cyref/js/function";Includes:
- Composition
- Piping
- Currying
- Memoization
- Debouncing
- Throttling
- Partial application
- Function helpers
Utilities for working with numbers.
import { clamp, lerp, randomInt, roundTo } from "@cyref/js/number";Includes:
- Clamping
- Rounding
- Interpolation
- Random integers
- Percentages
- Floor and ceiling helpers
Utilities for working with objects.
import { get, has, merge, omit, pick, set } from "@cyref/js/object";Includes:
- Object access
- Deep cloning
- Merging
- Picking and omitting properties
- Mapping keys and values
- Nested property operations
Utilities for formatting and transforming strings.
import {
camelCase,
kebabCase,
pascalCase,
snakeCase,
slugify,
} from "@cyref/js/string";Includes:
- Case conversion
- Slug generation
- Capitalization
- Whitespace normalization
- Padding
- Truncation
- String transformations
Small runtime type-checking utilities.
import {
isArray,
isBoolean,
isDate,
isFunction,
isNumber,
isString,
} from "@cyref/js/type";Includes checks for:
- Arrays
- Booleans
- Dates
- Functions
- Numbers
- Strings
- Objects
- Regular expressions
nullundefined
Utilities for working with URLs and query parameters.
import {
buildQuery,
getQueryParam,
parseQuery,
setQueryParam,
} from "@cyref/js/url";Includes:
- Query string creation
- Query parsing
- Reading parameters
- Setting parameters
- Removing parameters
Small validation helpers for common use cases.
import {
isEmail,
isInteger,
isPositive,
isStrongPassword,
isURL,
} from "@cyref/js/validation";Includes:
- Email validation
- URL validation
- Integer validation
- Positive number validation
- Password strength validation
CyrefJS is written in TypeScript and ships with complete type declarations.
import { chunk } from "@cyref/js";
const result = chunk([1, 2, 3, 4], 2);Type information is included automatically, so no additional @types package is required.
CyrefJS provides category-based subpath exports:
@cyref/js
@cyref/js/array
@cyref/js/date
@cyref/js/function
@cyref/js/number
@cyref/js/object
@cyref/js/string
@cyref/js/type
@cyref/js/url
@cyref/js/validation
For example:
import { clamp } from "@cyref/js/number";Instead of:
import { clamp } from "@cyref/js";Both approaches are supported.
CyrefJS is designed with modern ESM tooling in mind.
Because utilities are exported as individual functions and the package has no runtime dependencies, modern bundlers can efficiently remove unused code from production builds.
import { clamp } from "@cyref/js/number";Use only what you need.
CyrefJS uses Vitest for testing.
Run the test suite:
npm testRun tests once:
npm run test:runRun tests in watch mode:
npm run test:watchClone the repository:
git clone https://github.com/VibelessYoung/CyrefJS.git
cd CyrefJSInstall dependencies:
npm installRun type checking:
npm run typecheckBuild the package:
npm run buildRun the complete release check:
npm run release:checkCyrefJS/
βββ src/
β βββ array/
β βββ date/
β βββ function/
β βββ number/
β βββ object/
β βββ string/
β βββ type/
β βββ url/
β βββ validation/
β βββ index.ts
β
βββ tests/
β βββ array/
β βββ date/
β βββ function/
β βββ number/
β βββ object/
β βββ string/
β βββ type/
β βββ url/
β βββ validation/
β
βββ CHANGELOG.md
βββ CONTRIBUTING.md
βββ LICENSE
βββ README.md
βββ SECURITY.md
βββ package.json
βββ tsconfig.json
Documentation and examples are planned to live alongside the project and will provide detailed information for each utility.
Until then, the TypeScript declarations and source code provide a reliable reference for the available APIs.
Contributions are welcome.
If you'd like to improve CyrefJS:
- Fork the repository.
- Create a new branch.
- Make your changes.
- Add or update tests.
- Run the type checker and test suite.
- Open a pull request.
Please read CONTRIBUTING.md before contributing.
If you discover a security issue, please follow the instructions in SECURITY.md.
Please avoid opening public issues for undisclosed security vulnerabilities.
CyrefJS is open source software licensed under the MIT License.
- Repository: https://github.com/VibelessYoung/CyrefJS
- Issues: https://github.com/VibelessYoung/CyrefJS/issues
- npm: https://www.npmjs.com/package/@cyref/js