1.3.14-r • Published 12 months ago
@syyu/util v1.3.14-r
@syyu/util
Javascript/Typescript Utility Package for Practice
TS
import {...} from '@syyu/util'
isServer(), isClient()
objectKeys(), objectEntries()
- Object.keys and Object.Entries with type assertion
isEmpty()
- A utility function for checking if a value is empty or not
- empty values are:
'', [], {}, null, undefined, EMPTY[], EMPTY{} - e.g.
isEmpty({a: ''}) //true
noop(), asyncNoop()
- function that does nothing (
() => {})
getRandomNumber(), getRandomInt()
- function that helps to get random number easily
- e.g.
const num = getRandomNumber([3,6], 'int') //returns int between 3 <= N < 6
REACT
import {...} from '@syyu/util/react'
useModal
- A React hook for using Modal easily
- DOCS
useForceRender
- A React hook for forcibly rendering a component
- DOCS
useForm (beta)
- A React hook for using form easily
- During the beta period, the API may unexpectedly change or new features may be added
- supports textarea and inputs (text, number, checkbox)
- provides APIs,
createUseFormContextanduseFormContextfor integrating with Context API - DOCS
useBooleanState
- A useState hook for using boolean state conveniently
- example
const [display, show, hide, toggle] = useBooleanState(initialState) - If
initialStateis not provided as an argument, the default state value is set to false. - DOCS
useTextCopy
- A React hook for copying plain text to clipboard
- other types will be provided later
- example:
const [ copy, isCopied, restoreState ] = useTextCopy(duration, onError) - works only in localhost or https
- DOCS
useDebouncedEffect/useDebouncedState
- A React hook for debounced effect/state
- DOCS
useConditionalRender
- A React hook for using conditional render easily
- useful in triggering animation with (un)mounting component
- DOCS
useIsomorphicLayoutEffect
- In an SSR environment, useEffect should be used, while on the client side, useLayoutEffect should be utilized.
- helps prevent hydration errors
- DOCS
useRandomNumber
- React hook for using random number with range easily
- DOCS
1.3.13-c
12 months ago
1.3.13
12 months ago
1.3.14-r
12 months ago
1.3.10
1 year ago
1.3.11
1 year ago
1.3.12
1 year ago
1.3.9
1 year ago
1.3.7
1 year ago
1.3.8
1 year ago
1.3.6
1 year ago
1.3.5
1 year ago
1.3.4
1 year ago
1.3.3
1 year ago
1.3.0
2 years ago
1.2.0
2 years ago
1.1.0
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago