@mycuppa/core
v0.0.0
Published
Core utilities and types for Cuppa framework
Maintainers
Readme
@mycuppa/core
Essential utilities, types, and helpers that form the foundation of the Cuppa framework.
Installation
npm install @mycuppa/core
# or
pnpm add @mycuppa/core
# or
yarn add @mycuppa/coreFeatures
- 🎯 Type Utilities - Advanced TypeScript helpers for better type safety
- 🛠️ Utility Functions - Common functions for everyday tasks
- ⚡ Performance Utilities - Debounce and throttle functions
- 📝 Logger - Structured logging with configurable levels
- 🔑 ID Generation - Generate unique identifiers with prefixes
Quick Start
import {
isDefined,
deepMerge,
debounce,
createLogger,
generateId,
} from '@mycuppa/core'
// Type-safe null checks
const value: string | null = getValue()
if (isDefined(value)) {
console.log(value.toUpperCase())
}
// Deep merge objects
const config = deepMerge(defaults, custom)
// Debounce function calls
const search = debounce((query: string) => {
console.log('Searching...', query)
}, 300)
// Create logger
const logger = createLogger({
level: 'info',
prefix: 'App',
})
logger.info('Application started')
// Generate unique IDs
const userId = generateId('user') // 'user-k2j9f8x1-a3b4c5d6'API Reference
Type Checking
isDefined<T>(value)- Type-safe check for non-null/undefined valuesisPlainObject(value)- Check if value is a plain object
Object Manipulation
deepMerge(target, source)- Deep merge two objects
Performance
debounce(fn, delay)- Create debounced functionthrottle(fn, limit)- Create throttled functionsleep(ms)- Async sleep utility
Utilities
generateId(prefix?)- Generate unique IDs
Logger
const logger = createLogger({
level: 'info', // 'debug' | 'info' | 'warn' | 'error'
prefix: 'App',
timestamp: true,
})
logger.debug('Debug message')
logger.info('Info message')
logger.warn('Warning message')
logger.error('Error message')TypeScript Support
Full TypeScript support with type definitions included:
import type { DeepPartial, LogLevel, CuppaConfig } from '@mycuppa/core'Documentation
For detailed documentation, visit:
License
MIT
