Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
trace key-paths through nested objects
JavaScript
Tree: 8de058128a

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
test
.travis.yml
README.markdown
index.js
package.json

README.markdown

pathway

Trace key-paths through nested objects.

build status

example

var pathway = require('pathway');
var xs = [
    { x : { y : { z : 555 } } },
    { beep : 'boop' },
    { x : { y : { z : 444 } }, w : 4 },
    { x : { y : 'zzz' } },
    { x : { y : { z : 333 } } },
    { X : { y : { z : 222 } } }
];
var ys = pathway(xs, [ /./, /x/i, 'y', 'z' ]);
console.dir(ys);

[ 555, 444, 333, 222 ]

methods

var pathway = require('pathway')

pathway(obj, path)

Return an array of all the matching paths through the nested object obj that match the key path route path.

Key path routes may contain string or regexp elements. Keys along the element path go deeper into obj. If there are multiple matching results from a regexp key element, both will be traced forward to the result unless a subsequent value doesn't match.

This behavior is heavily inspired by how JSONStream's .parse() function works.

install

With npm do:

npm install pathway

notes

This module was written high up in a tree at Mosswood Park.

Something went wrong with that request. Please try again.