Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

document function and boolean path elements

  • Loading branch information...
commit b8cfc39afdbb1a125ee38f71f2fa86995a3461b7 1 parent e792079
@substack authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 README.markdown
View
17 README.markdown
@@ -1,7 +1,7 @@
pathway
=======
-Trace key-paths through nested objects.
+Follow key-paths through nested objects.
[![build status](https://secure.travis-ci.org/substack/node-pathway.png)](http://travis-ci.org/substack/node-pathway)
@@ -41,10 +41,17 @@ 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.
+Key paths determine how to proceed deeper into the object for each element.
+Key paths may contain these kinds of elements:
+
+* string, number - used as raw keys
+* RegExp - match keys
+* boolean - match all or no keys
+* function - match keys with `f(key, value)`, return truthiness
+
+Some types may select multiple matching results at a given node, in which case
+all the matching nodes at that level will be followed forward into the result
+until a later condition isn't satisfied.
This behavior is heavily inspired by how
[JSONStream](https://github.com/dominictarr/JSONStream)'s `.parse()` function
Please sign in to comment.
Something went wrong with that request. Please try again.