Recursively reduce an object to match a given map.
Table of Contents generated with DocToc
- Reduce a given object to match the structure and leaf data types of a given map
- Delete non-matching input nodes
- Optionally throw an error for non-matching nodes with throwErrorOnAlien
- Provide options:
- keepKeys: Retain mismatched keys as null opposed to deleting them
- throwErrorOnAlien: Throw error on alien found
- allowNullishKeys: Preserve null or undefined keys in the output
In version 1 a bug was discovered that permitted alien keys of null value into the output. This has now been resolved however may cause any tools using this helper tool to break, hence the major version bump.
An example use case of this package can be found in the TypeScript openapi-nodegen templates as an output transformer: openapi-nodegen-typescript-server
The most up to date examples can always be found in the tests