Function getPaths

  • Iterates 'paths' for all the fields on o

    const d = {
    accel: { x: 1, y: 2, z: 3 },
    gyro: { x: 4, y: 5, z: 6 }
    };
    const paths = [...getFieldPaths(d)];
    // Yields [ `accel`, `gyro`, `accel.x`, `accel.y`,`accel.z`,`gyro.x`,`gyro.y`,`gyro.z` ]

    Use getField to fetch data based on a path

    If object is null or undefined, no results are returned.

    If onlyLeaves is true (default: false), only 'leaf' nodes are included. Leaf nodes are those that contain a primitive value.

    const paths = getFieldPaths(d, true);
    // Yields [ `accel.x`, `accel.y`,`accel.z`,`gyro.x`,`gyro.y`,`gyro.z` ]

    Parameters

    • object: null | object

      Object to get paths for.

    • onlyLeaves: boolean = false

      If true, only paths with a primitive value are returned.

    Returns Generator<string>