@soundblue/core
このコンテンツはまだ日本語訳がありません。
Layer 0
Terminal window
Overview
The core package provides foundational utilities used across all apps. It has no React dependency and contains only pure functions.
Installation
pnpm add @soundblue/coreExports
Validation
import { LIMITS, validateId, isValidLanguage, sanitizeInput} from '@soundblue/core/validation';
// Validate entry IDconst isValid = validateId('hello-world'); // trueconst isInvalid = validateId(''); // false
// Check language codeisValidLanguage('ko'); // trueisValidLanguage('xx'); // false
// Sanitize user inputconst safe = sanitizeInput('<script>alert(1)</script>');Utilities
import { chunkArray, debounce, throttle, cn} from '@soundblue/core/utils';
// Chunk arrayconst chunks = chunkArray([1, 2, 3, 4, 5], 2);// [[1, 2], [3, 4], [5]]
// Debounce functionconst debouncedSearch = debounce(search, 300);
// Throttle functionconst throttledScroll = throttle(onScroll, 100);
// Class names utility (like clsx)const className = cn('base', isActive && 'active', { 'dark': isDark });Types
import type { Language, Theme, DeepPartial, Nullable} from '@soundblue/core/types';
const lang: Language = 'ko'; // 'en' | 'ko' | 'ja'const theme: Theme = 'dark'; // 'light' | 'dark' | 'system'