0.2.3 • Published 3 years ago

defaults-deep-ts v0.2.3

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

defaults-deep-ts

Build Status

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

3 years ago

0.2.2

4 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago