Skip to content

Iterable.hasIn()? #247

Closed
Closed
@dashed

Description

@dashed

This may be a dumb question, but afaik, I don't think there's an API for this. It'd be great if there is Iterable.hasIn() can take in an array to check if a key path exists.

Iterable.has() can't be patched since an array is a valid key.

At the moment, I'm doing something like this:

function pathExists(iterable, path) {

  if(iterable.getIn(path)) {
    return true;
  }
  var notSetValue = true;
  return !(iterable.getIn(path, notSetValue) === notSetValue);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions