{"dist":{"shasum":"d3b6eb3da89a896463088385ecd7e53b9bbce5ac","tarball":"https://registry.npmjs.org/traverser/-/traverser-0.0.4.tgz","integrity":"sha512-DODiieNEQgFbO1Xqj/+A9c5rYfccBPTvaUt0pRv+h09U0l6YZTvCOlvCIU43W+rLG4+6WOU7NzS4OcqlErmMxg==","signatures":[{"sig":"MEUCIQChUKo6MBHaCHxef/qRhdX/eCvUH85Aur57zubZfa6NwQIgcMvXcUNA9fjAKT7hsPkSgcnSy7C25BE1ZDuORX13i2s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./traverser.sync","name":"traverser","author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com"},"readme":"\n#Traverser#\n\nsearch through a complex object (nearly) as easily as forEach\n\nall the nitty-gritty stuff is taken care of.\n\nincluding:\n  # checking for repeats.\n  # checking for cycles.\n  # getting the path the the current object. etc!\n\n#simple example#\ncollect all branches in a tree.\n\n    var traverser = require('traverser')\n      , branches = []\n\n    function branch(props){\n      if(!props.reference) //since we check for references with will work in cyclic graphs, without stackoverflows.\n        branches.push(props.value)\n\n      props.each()//continue working through the children of this object.\n    }\n\n    traverser([1,2,{},3,[\"x\"]],{branch: branch})\n    \n    console.log(branches)\n\n#simple example2#\ncollect all leaves in a tree. (only functions and primitives)\n\n    var traverser = require('traverser')\n\n    exports.leaves = leaves\n\n    function leaves (obj){\n        var leaves = []\n\n        function leaf(props){\n          leaves.push(props.value)\n        }\n\n        traverser(obj,{leaf: leaf})\n        return leaves\n    }\n\n    traverser([1,2,{},3,[\"x\"]],{leaf: leaves})\n\n    console.log(leaves([1,2,{},3,[\"x\"]]))\n    //[1,2,3,'x']\n    \n#complex example#\neven quite complex things like a topological sort are now achivable in ~30 lines.\nsee `traverser/examples/topo-sort`\n\n\n#API#\n\n  `traverser (obj, options)`\n  \n  obj: graph/tree to traverse\n  \n    options: (each of the following is optional)\n    {\n      branch: function to call on a branch of the tree (by default, where typeof == 'object'\n    , leaf: function to call on primitives and functions\n    , isBranch: return true if current value should be treated as a branch\n    }\n    \neach function is passed one arg, a properties object which describes the state of the traverse.\n  \n    {\n      value: this object\n    , parent: object which this item is a property of. (null if your on the root object)\n    , key: key of this item on parent. (null if your on the root object)\n    , path: [list of keys from root object to current item]\n    , reference: true if this object is a repeat\n    , circular: true if this object is in the ancestors list.\n    , seen: list of objects seen so far\n    , ancestors: list of objects between value and root object.\n\n    //when your in the branch function, you need to call one of the following to iterate over the children.\n    //none of these require an argument.\n\n    , each: iterate over each property\n    , find: iterate untill the first truthy return, returns the item.\n    , map: collects return values into an Array\n    , copy: copies objects, preserving whether it's a {} or a []\n    , max: iterate over all properties and return max return value\n    , min: iterate over all properties and return min return value\n    }\n\n###feel free to ask me questions if you need help!###\n\n###see https://github.com/dominictarr/trees for more examples.###\n\n##License\n\nMit/Apache2\n","engines":{"node":"*"},"_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"homepage":"https://github.com/dominictarr/traverser","repository":{"url":"git://github.com/dominictarr/traverser.git","type":"git"},"_npmVersion":"1.1.23","description":"lib for traversing trees and graphs","directories":{"lib":".","example":"examples"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"_nodeVersion":"v0.6.18","dependencies":{"curry":"0.0.x"},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":true,"optionalDependencies":{},"_id":"traverser@0.0.4","version":"0.0.4"}