deep-trails - v3.0.0-beta.3
    Preparing search index...

    Function toPathString

    • Converts a path into a readable string with bracket or mixed notation.

      Type Parameters

      • T = unknown

      Parameters

      • path: string | readonly T[]

        Path as array or string.

      • Optionaloptions: { extraKey?: unknown; notation?: "mixed" | "bracket" }

        Options for more precision.

        • OptionalextraKey?: unknown

          Optional extra key to append to the path string.

        • Optionalnotation?: "mixed" | "bracket"

          The notation in which the path and/or the extra key string will be created.

      Returns string

      String representation of the path.

      • Uses toSimpleString for stringify keys.
      • If the path is a string, it is returned as is or the extra key is added.

      TypeError if some argument is invalid.

      const path = [ "a", "b", "c", 0 ];
      toPathString(path, { notation: "mixed" }) // "a.b.c[0]"
      toPathString(path, { notation: "bracket" }) // '["a"]["b"]["c"][0]'
      toPathString(path, { extraKey: "d" }) // "a.b.c[0].d"
      toPathString("a.b", { notation: "bracket" }) // "a.b"

      3.0.0-beta.3

    Index

    Properties

    Properties

    notation: "mixed" | "bracket"

    The notation in which the path and/or the extra key string will be created.

    3.0.0-beta.3