0.2.3 • Published 2 years ago
defaults-deep-ts v0.2.3
defaults-deep-ts
Similar to _.defaultsDeep but with some differences:
- Intelligent TypeScript typings
- Doesn't try to merge arrays
- Doesn't allow multiple sources
- Treats
null
as an empty value
Install
npm install defaults-deep-ts
Usage
// let's say you have some object where some fields are optional:
type SomeData = {
order?: {
id?: string
};
}
const data: SomeData = {};
// You have to check for for undefined fields using `!` or `?`:
const id: string = data.order!.id!;
// Let's provide some defaults:
import defaultsDeep from 'defaults-deep-ts'
const dataWithDefaults = defaultsDeep(data, {order: {id: ''}});
// Now `order` and `id` are not optional bacause you provided defaults for them:
const id: string = dataWithDefaults.order.id;
0.2.3
2 years ago
0.2.2
3 years ago
0.2.1
3 years ago
0.2.0
4 years ago
0.1.14
4 years ago
0.1.13
4 years ago
0.1.12
4 years ago
0.1.11
4 years ago
0.1.10
4 years ago
0.1.9
4 years ago
0.1.8
4 years ago
0.1.7
4 years ago
0.1.6
4 years ago
0.1.5
4 years ago
0.1.4
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago
0.0.1
4 years ago