Skip to content
This repository was archived by the owner on May 8, 2021. It is now read-only.

Commit 735dcde

Browse files
committed
- Removal of not needed undefined check 🚧
- Readme updates 🚧
1 parent be93d86 commit 735dcde

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# ts-get
2-
[![codecov](https://codecov.io/gh/RIP21/ts-get/branch/master/graph/badge.svg)](https://codecov.io/gh/RIP21/ts-get)
2+
[![npm version](https://badge.fury.io/js/ts-get.svg)](https://badge.fury.io/js/ts-get)
33
[![Build Status](https://travis-ci.org/RIP21/ts-get.svg?branch=master)](https://travis-ci.org/RIP21/ts-get)
4+
[![codecov](https://codecov.io/gh/RIP21/ts-get/branch/master/graph/badge.svg)](https://codecov.io/gh/RIP21/ts-get)
5+
6+
Alternative to `lodash.get` that makes it typed and cool as if optional chaining proposal is there.
47

5-
Alternative to `lodash.get` that makes it typed and cool as if optional chaining proposal is there.
8+
Means you're not only safely navigate object, but you're also getting 100% autocomplete and type-safeness 🎉
69

7-
## Usage and features
10+
## Usage and examples
811

912
```typescript
1013
import get from 'ts-get'
@@ -16,8 +19,8 @@ import get from 'ts-get'
1619
}
1720
} | undefined | null
1821

19-
const input = {}
20-
const input2 = {
22+
const input: SomeType = {}
23+
const input2: SomeType = {
2124
optionalField: "value",
2225
}
2326

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function get<T, R>(
6060
const result = accessorFn((object as unknown) as RequiredRecursively<T>)
6161
return result === undefined || result === null ? defaultValue : result
6262
} catch (e) {
63-
return defaultValue === undefined ? undefined : defaultValue
63+
return defaultValue
6464
}
6565
}
6666

0 commit comments

Comments
 (0)