@zl-asica/react/utils
This module contains utility functions for arrays, dates, DOM, math, objects, and strings. Compatible with SSR (Server-Side Rendering).
Use @zl-asica/react/utils
for utilities functions in SSR (Server-Side Rendering). If you do not need SSR, use @zl-asica/react
will also works.
Example
ts
import { assignUUID } from '@zl-asica/react/utils'
const data = [
{ id: '1', name: 'John' },
{ id: '2', name: 'Jane' },
]
const dataWithUUID = assignUUID(data)
// → [ { id: '1', name: 'John' }, { id: '2', name: 'Jane' } ]
Functions
- chunkArray
- uniqueArray
- isAllZeroArray
- assignUUID
- formatDate
- isSameDay
- getDayOfWeek
- getRelativeDay
- getScrollPosition
- copyToClipboard
- pasteFromClipboard
- backToTop
- randomInt
- randomFloat
- clamp
- lerp
- mapRange
- deepClone
- isObject
- mergeObjects
- pick
- omit
- isEmpty
- capitalize
- camelCaseToKebabCase
- truncate
- toSnakeCase
- reverseString
- removeSpecialCharacters
- generateUniqueId
- truncateToNearestWord