path_to_target

1.0.0 • Public • Published

A simple function that traverses an object

Pass the object and the keys (as strings) and the function return the value or undefined if it doesn't exist.

const pathToTarget = require('path_to_target');
const anObject = {hello: {world: ' hello earth'}};
const result = pathToTarget(anObject, ['hello', 'world']);
console.log(result);
//'hello earth'

/path_to_target/

    Package Sidebar

    Install

    npm i path_to_target

    Weekly Downloads

    1

    Version

    1.0.0

    License

    GPL-3.0-or-later

    Unpacked Size

    1.53 kB

    Total Files

    3

    Last publish

    Collaborators

    • tomasmetcalfe