Skip to main content

Introduction

The @zayne-labs/toolkit-core package provides a collection of utility functions, state management solutions, and composable helpers designed for building robust web applications. It offers zero-dependency utilities (except for type helpers) optimized for performance and developer experience.

Installation

npm install @zayne-labs/toolkit-core

Package Features

The core package is organized into several categories:

Async Utilities

Debouncing, throttling, promises, and timing utilities

State Management

Lightweight stores for app state, localStorage, and location management

DOM Utilities

Browser APIs, event handling, scroll management, and more

General Utilities

Object manipulation, JSON parsing, and helper functions

Quick Start

Here’s a simple example using some of the core utilities:
import { debounce, createStore, copyToClipboard } from '@zayne-labs/toolkit-core';

// Debounce a search function
const debouncedSearch = debounce((query: string) => {
  console.log('Searching for:', query);
}, 300);

// Create a simple store
const counterStore = createStore(() => ({ count: 0 }));

counterStore.subscribe((state) => {
  console.log('Count updated:', state.count);
});

counterStore.setState({ count: 1 });

// Copy text to clipboard
await copyToClipboard('Hello, World!');

TypeScript Support

All utilities are written in TypeScript with comprehensive type definitions. The package provides excellent type inference and safety:
import { pickKeys, omitKeys } from '@zayne-labs/toolkit-core';

const user = { id: 1, name: 'John', email: '[email protected]', password: 'secret' };

// TypeScript knows the result type
const publicUser = omitKeys(user, ['password']); // { id: number; name: string; email: string }
const credentials = pickKeys(user, ['email', 'password']); // { email: string; password: string }
The toolkit-core package requires Node.js 18.x or higher and is optimized for modern JavaScript environments.

Bundle Size

The entire package is designed to be lightweight with a size limit of ~6.5kb. Individual utilities are tree-shakeable, so you only bundle what you use.

Browser Compatibility

Most utilities work in modern browsers that support ES2020+. DOM-specific utilities require a browser environment and include runtime checks for SSR compatibility.

Next Steps

Explore Utilities

Learn about object manipulation and helper functions

State Management

Build reactive applications with stores

Async Utilities

Master debouncing, throttling, and promises

DOM Utilities

Work with browser APIs and DOM manipulation

Build docs developers (and LLMs) love