Skip to content

unctionjs/cascadingKeyChain

Repository files navigation

@unction/cascadingKeyChain

Tests Stability Dependencies

Array => KeyedEnumerableType => ValueType

Cascades through multiple keychains in order to arrive at a value. Null keys are replaced with the previous keychain's value.

cascadingKeyChain(
  [
    ["ephemeral", "current", "session"],
    ["resources", "sessions", null, "relationships", "account", "data", "id"],
    ["resources", "accounts", null, "attributes", "name"]
  ]
)(
  {
    ephemeral: {current: {session: "1"}},
    resources: {
      sessions: {
        1: {
          id: "1",
          relationships: {account: {data: {id: "2"}}},
        },
      },
      accounts: {
        2: {
          id: "2",
          attributes: {name: "Kurtis Rainbolt-Greene"},
        },
      },
    },
  }
)

returns

"Kurtis Rainbolt-Greene"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published