1.0.0 • Published 5 years ago

hitcher v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

🔗 Hitcher

Optional object chaining, but now

Install

yarn add hitcher

Usage

import hitch from '$hitcher'

const myObj = {
	person: {
		name: {
			first: 'Harry',
			last: 'Fitz'
		},
		github: '@hjfitz'
	}
}

const first = hitch(myObj, 'person', 'name', 'first')

API

chain(obj: object, ...keys: string|number)

Follows ...keys in obj, looking for the value of obj[key[0]][key[1]]...[key[n-1]][key[n]]

Inspiration

Optional object chaining - a new feature to land in ES!

1.0.0

5 years ago