コンテンツにスキップ

@soundblue/core

このコンテンツはまだ日本語訳がありません。

Layer 0

Overview

The core package provides foundational utilities used across all apps. It has no React dependency and contains only pure functions.

Installation

Terminal window
pnpm add @soundblue/core

Exports

Validation

import {
LIMITS,
validateId,
isValidLanguage,
sanitizeInput
} from '@soundblue/core/validation';
// Validate entry ID
const isValid = validateId('hello-world'); // true
const isInvalid = validateId(''); // false
// Check language code
isValidLanguage('ko'); // true
isValidLanguage('xx'); // false
// Sanitize user input
const safe = sanitizeInput('<script>alert(1)</script>');

Utilities

import {
chunkArray,
debounce,
throttle,
cn
} from '@soundblue/core/utils';
// Chunk array
const chunks = chunkArray([1, 2, 3, 4, 5], 2);
// [[1, 2], [3, 4], [5]]
// Debounce function
const debouncedSearch = debounce(search, 300);
// Throttle function
const 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'

Source

packages/core/