ofl
Convertion between nested object and flat one with delimited keys. Yet another flatten/unflatten module with few differences:
- no undefined values allowed
- only primitives in arrays (no nested arrays and so on)
- only plain objects
- empty objects are ignored when flatten
- only own and enumerable fields counts when flatten
- no key conflicts allowed in flat object
- no delimiter string in any key in nested object
It is intended to be useful for work with well-serializable config data.
Install
npm install ofl
Usage
const flatten //convert nested object to flat unflatten //convert flat object to nested patch //cange some fields in flat object validKeys //test if array of keys are valid for flat object validValues //test if array of values are valid for flat object} = ; flatObj = ;nestedObj = ;//throw error if inappropriate object sent//delimiter is optional, defaults to '.' patchedFlatObj = ;//throw error if diffFlatObj keys is not subset of flatObj keys ;;//throw error if inappropriate key or value
License
MIT