@krakstack/utils
v0.0.10
Published
Javascript and React utility library
Maintainers
Readme
@krakstack/utils
A utility package that can be used in various environments
Features
Commons:
isEmpty- Utility function to check for empty arrays, objects, or stringsisNil- Utility function to check for null or undefinedomit- Utility function to remove specific key-value pairs from an objectpick- Utility function to extract specific key-value pairs from an objectsum- Utility function that returns the sum of given numbersobjectKeys- Extended Object.keys function with accurate return type inferencegetIsClient- Utility function to check client environmentgetIsServer- Utility function to check server environmentwithComma- Formatting utility function to add thousand separators to numbersdateUtils- Date manipulation and formatting utilities based on dayjs
React:
ErrorBoundary- Error Boundary component for React error handlinguseErrorBoundary- Hook containing functionality to explicitly expose or reset Error BoundarycombineRef- Function that assigns all received refs to an elementcreateRequiredContext- Utility function to create Context that enforces Provider usagesafeForwardRef- Utility function to prevent props type errors in forwardRefuseDebounceState- useState Hook with debounce functionalityuseDebounceEffect- Effect Hook with debounce functionalityuseIsomorphicLayoutEffect- Layout Effect Hook that works on both client and serveruseOnViewport- Hook that returns whether a specific element exists within the viewport
TODOS
To-do list
- [x] Configure ESLint, Typescript
- [x] Configure bundling with rollup
- [x] Deploy npm package
- [ ] Develop documentation
Usage
Installation
- Requires minimum version 18 of packages such as
react,react-dom,@types/react
pnpm add @krakstack/utilsUsage
import { isClient } from '@krakstack/utils/commons';
if (isClient()) {
// Client code
}