@peple/utils
v0.1.3
Published
Shared utilities for People HR micro-frontends
Downloads
9
Maintainers
Readme
@peple/utils
Shared utilities for People HR micro-frontends.
Installation
npm install @peple/utilsUsage
import { formatDate, formatCurrency, EventBus } from '@peple/utils'
// Format a date
const formattedDate = formatDate(new Date())
// Format currency
const price = formatCurrency(1234.56)
// Use EventBus for cross-MFE communication
const eventBus = EventBus.getInstance()
eventBus.emit('user:updated', { id: 123, name: 'John' })Available Utilities
Date Formatting
formatDate(date: Date, format?: string): stringFormats a date to a readable string.
Currency Formatting
formatCurrency(amount: number, currency?: string): stringFormats a number as currency with proper locale formatting.
EventBus
A singleton event bus for cross-micro-frontend communication.
const eventBus = EventBus.getInstance()
// Subscribe to events
eventBus.on('event:name', (data) => {
console.log('Event received:', data)
})
// Emit events
eventBus.emit('event:name', { foo: 'bar' })
// Unsubscribe
eventBus.off('event:name', handler)TypeScript Support
This package includes TypeScript definitions. No additional type packages are required.
License
MIT
