dot-path-value icon indicating copy to clipboard operation
dot-path-value copied to clipboard

hasByPath()

Open ozum opened this issue 1 year ago • 2 comments

Hi,

Thanks for the library. It would be great if it provided an hasByPath() method to check the path's availability.

Thanks,

ozum avatar Apr 28 '23 10:04 ozum

@ozum hi, thanks for feedback :) Maybe I misunderstood, but why can't you use like this? const hasValue = getByPath(obj, 'a.b.c') !== undefined

g-makarov avatar May 03 '23 09:05 g-makarov

Hi @g-makarov,

Below is an example for a use case:

const a = {
	name: "Jane"
	surname: undefined
}

const hasValue = getByPath(a, 'surname') !== undefined; // false
const hasValue = hasByPath(a, 'surname'); // true

ozum avatar May 03 '23 10:05 ozum