dist/ngTreeTools.js
function children(tree, query, options) {
      var compiledQuery = query ? _.matches(query) : null;

      var settings = _.defaults(options, {
        childNode: ['children']
      });

      settings.childNode = _.castArray(settings.childNode);
      var rootNode = query ? treeTools.find(tree, query) : tree;
      var seekStack = [];

      var seekDown = function seekDown(branch, level) {
        if (level > 0) seekStack.push(branch);
        settings.childNode.some(function (key) {
          if (branch[key] && _.isArray(branch[key])) {
            branch[key].forEach(function (branchChild) {
              seekDown(branchChild, level + 1);
            });
            return true;
          }
        });
      };

      seekDown(rootNode, 0);
      return seekStack;
    }
function children(tree, query, options) {
      var compiledQuery = query ? _.matches(query) : null;

      var settings = _.defaults(options, {
        childNode: ['children']
      });

      settings.childNode = _.castArray(settings.childNode);
      var rootNode = query ? treeTools.find(tree, query) : tree;
      var seekStack = [];

      var seekDown = function seekDown(branch, level) {
        if (level > 0) seekStack.push(branch);
        settings.childNode.some(function (key) {
          if (branch[key] && _.isArray(branch[key])) {
            branch[key].forEach(function (branchChild) {
              seekDown(branchChild, level + 1);
            });
            return true;
          }
        });
      };

      seekDown(rootNode, 0);
      return seekStack;
    }
function children ( tree , query , options ) { var compiledQuery = query ? _ . matches ( query ) : null ; var settings = _ . defaults ( options , { childNode : [ 'children' ] } ) ; settings . childNode = _ . castArray ( settings . childNode ) ; var rootNode = query ? treeTools . find ( tree , query ) : tree ; var seekStack = [ ] ; var seekDown = function seekDown ( branch , level ) { if ( level > 0 ) seekStack . push ( branch ) ; settings . childNode . some ( function ( key ) { if ( branch [ key ] && _ . isArray ( branch [ key ] ) ) { branch [ key ] . forEach ( function ( branchChild ) { seekDown ( branchChild , level + 1 ) ; } ) ; return true ; } } ) ; } ; seekDown ( rootNode , 0 ) ; return seekStack ; }
Utility function to deep search a tree structure for a matching query and find all children after the given query
If found this function will return an array of all child elements NOT including the query element
@param {Object|array} tree The tree structure to search (assumed to be a collection)
@param {Object|function|null} [query] A valid lodash query to run (anything valid via _.find()) or a callback function. If null the entire flattened tree is returned
@param {Object} [options] Optional options object
@param {array|string} [options.childNode="children"] Node or nodes to examine to discover the child elements
@return {array} An array of all child elements under that item
Utility function to deep search a tree structure for a matching query and find all children after the given query If found this function will return an array of all child elements NOT including the query element