This repository was archived by the owner on May 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
1013import 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments