jonschlinkert/get-value

Open to PR with `get(...default='default')`?

rmharrison opened this issue · 2 comments

Same behavior as get(), but returns the default value instead of undefined?

For example...

> var obj = {a: {b: 'c'}}

> get(obj, 'a.b')
'c'

> get(obj, 'a.b.c.d.e')
undefined

> get(obj, 'a.b.c.d.e', default='default')
'default'

Hi @rmharrison, I think it would be better to use another library for this, so we can keep each function focused on a single responsibility. for example:

> var koalas = require('koalas')
> var get = require('get-value')
> var obj = {a: {b: 'c'}}
> koalas(get(obj, 'a.b.c.d.e'), 'default')
'default'

Thanks for the prompt feedback.

Used npm:object-path, which is a heavier-weight alternative to the get-value suite.