dlv icon indicating copy to clipboard operation
dlv copied to clipboard

Safe deep property access in 120 bytes. x = dlv(obj, 'a.b.x')

Results 10 dlv issues
Sort by recently updated
recently updated
newest added

> Smallest possible implementation: only 120 bytes. There's possibly smaller version: ```js export dlv = (obj, key) => (key.split ? key.split('.') : key).reduce((a,b)=>b?a?.[b]:a,obj) ```

From the readme: ``` //undefined obj or key returns undefined, unless a default is supplied delve(undefined, 'a.b.c') === undefined; delve(undefined, 'a.b.c', 'foo') === 'foo'; delve(obj, undefined, 'foo') === 'foo'; ```

question

*** 🚨 **Reminder!** Less than one month left to migrate your repositories over to Snyk before Greenkeeper says goodbye on June 3rd! 💜 🚚💨 💚 [Find out how to migrate...

greenkeeper

Before: ``` 122 B: dlv.js.gz 91 B: dlv.js.br 121 B: dlv.es.js.gz 97 B: dlv.es.js.br 198 B: dlv.umd.js.gz 160 B: dlv.umd.js.br ``` After: ``` 117 B: dlv.js.gz 82 B: dlv.js.br 116...

lodash.get allows for something like this: ```js get(obj, 'foo[0]') ``` which would correspond to: ```js obj = { foo: [ 'x' //

With this change, if you have and object like `{ foo: "bar" }` and you do `dlv(obj, 'foo.bar.foobar.0.whatever')` it will run twice instead of 5 times. I have objects that...

I realize that this was already attempted in #24, but with a little extra work I was able to support the edge cases mentioned in the thread. I tested these...

Hi there! By using an array reduce on the key, you'll can go even leaner with 124 bytes 💪

The project is licensed under MIT, but lacks a copyright notice.

```js const obj = { "a.b": { "c": 1 } } ``` There are cases when object keys already have a dot in the name. It would be nice to...