Function getPathsAndData

  • Returns a representation of the object as a set of paths and data.

    const o = { name: `hello`, size: 20, colour: { r:200, g:100, b:40 } }
    const pd = [...getPathsAndData(o)];
    // Yields:
    // [
    // { path: `name`, value: `hello` },
    // { path: `size`, value: `20` },
    // { path: `colour.r`, value: `200` },
    // { path: `colour.g`, value: `100` },
    // { path: `colour.b`, value: `40` }
    //]

    Parameters

    • o: object

      Object to get paths and data for

    • onlyLeaves: boolean = false
    • maxDepth: number = Number.MAX_SAFE_INTEGER

      Set maximum recursion depth. By default unlimited.

    • prefix: string = ...

      Manually set a path prefix if it's necessary

    Returns Generator<PathData<any>>