Skip to content

undefined key throws #35

Open
Open

Description

@mikesherov

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';

Activity

  1. developit commented on Jul 29, 2019

    @developit
    Owner

    Likely broken by the inclusion of Array support. TBH I'm not sure if there's a better behaviour here - undefined could only really be stringified, which is super unintuitive. I'd kinda rather have it throw.

  2. mikesherov commented on Jul 29, 2019

    @mikesherov
    Author

    I agree. So should the docs be updated?

  3. lfre commented on Feb 18, 2021

    @lfre

    I ran across this recently in styled-system, and looked familiar. https://github.com/styled-system/styled-system/blob/6e00a16e0c53d865955c03df2d8d6ade8948bb2f/packages/core/src/index.js#L35

    key = key && key.split ? key.split('.') : [key] seems to do the trick. thoughts @developit ?

  4. Aaronphy commented on Mar 25, 2021

    @Aaronphy

    delve(undefined || {}, 'a.b.c') === undefined

    I think adding a default obj will be ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions