@extremejs/utils - v1.0.0-beta.23
    Preparing search index...

    Function property

    • Creates a function that returns the value at path of a given object.

      Type Parameters

      • Property extends PropertyKey
      • Fallback = undefined

      Parameters

      • path: Property

        The path of the property to get.

      • Optionalfallback: Fallback

        The fallback value in case of not finding the value of the desired property.

      Returns PropertyAccessorT<Property, Fallback>

      The new accessor function.

      1.0.0

      const fn = property("foo"); // => (value) => get(value, "foo");

      fn({ foo: "bar" }); // => "bar"
      const fn = property("foo.bar", 0); // => (value) => get(value, "foo.bar", 0);

      fn({ foo: "bar" }); // => 0