Playground
Experience JavaScript Utils functions online without installation.
🚀 Quick Start
Click the button below to open the online demo environment with real-time editing and execution:
💻 Local Demo
You can also run the demo locally:
bash
# Clone the project
git clone https://github.com/toFrankie/utils.git
cd utils
# Install dependencies
pnpm install
# Run local demos
pnpm dev:array # Array utilities demo
pnpm dev:object # Object utilities demo
pnpm dev:string # String utilities demo
pnpm dev:validation # Validation utilities demo📚 Function Categories
Choose the functions you want to experience:
Function Utils
- Debounce - Delay function execution until after specified time
- Throttle - Limit function execution frequency
- Delay - Delay function execution
Array Utils
- Array Check (isArray) - Check if value is an array
- Array Chunk (chunk) - Split array into chunks of specified size
- Array Unique (unique) - Remove duplicates from array
Object Utils
- Deep Copy (deepCopy) - Deep clone objects
- Pick Properties (pick) - Pick specified properties from object
- Omit Properties (omit) - Omit specified properties from object
String Utils
- Pinyin Conversion (convert2pinyin) - Convert Chinese characters to pinyin
- Capitalize (capitalize) - Capitalize first letter of string
- Camel Case (camelCase) - Convert string to camelCase
Validation Utils
- ID Number Validation (checkIdNumber) - Validate Chinese ID number
- Email Validation (isEmail) - Validate email address
- Phone Validation (isPhone) - Validate phone number
Online Editor
🎮 Interactive Playground
📚 Version Information
- Latest: Contains all the latest features and fixes
- Stable: Well-tested stable version
- Beta: Preview version with experimental features
Local Development
You can also run examples locally:
bash
# Run ESM examples
pnpm dev:examples
# Or run directly
node examples/esm-demo.mjs
node examples/node-demo.cjsExample Code
Debounce Example
javascript
import { debounce } from '@tofrankie/utils'
const debouncedFn = debounce(() => {
console.log('Debounced execution')
}, 300)
// Multiple rapid calls, only the last one executes after 300ms
debouncedFn()
debouncedFn()
debouncedFn() // Only this one will executeThrottle Example
javascript
import { throttle } from '@tofrankie/utils'
const throttledFn = throttle(() => {
console.log('Throttled execution')
}, 300)
// Multiple calls within 300ms, only one executes
throttledFn()
throttledFn() // Ignored
throttledFn() // IgnoredDelay Example
javascript
import { delay } from '@tofrankie/utils'
const delayedFn = delay(() => {
console.log('Delayed execution')
}, 1000)
// Executes after 1 second
delayedFn()