Nestify anything ๐ง
November 14, 2022 ยท View on GitHub
npm i nestify-anything
Recreates an object from any nested.props. A simple and small integration.
Can be used in combination with flatten-anything ๐, which does the exact opposite of this one! ๐
Meet the family (more tiny utils with TS support)
- is-what ๐
- is-where ๐
- merge-anything ๐ฅก
- check-anything ๐
- remove-anything โ๏ธ
- getorset-anything ๐
- map-anything ๐บ
- filter-anything โ๏ธ
- copy-anything ๐ญ
- case-anything ๐ซ
- flatten-anything ๐
- nestify-anything ๐ง
Usage
import { nestifyObject } from 'nestify-anything'
const target = {
'name': 'Ho-oh',
'types.fire': true,
'types.flying': true,
}
nestifyObject(target)
// returns {
// name: 'Ho-oh',
// types: { fire: true, flying: true }
// }
Currently the library only works with the dot character '.' as separator. If you need other characters like slash '/', let me know in an issue!