nodeComponents/findAll/findAll.js

  1. // local dependencies
  2. import { findAll } from '../../rootComponents/rootComponents';
  3. export default (node) =>
  4. /**
  5. * Find all nodes with the given validator. By default, the first argument accepts a string
  6. * that is used to find the first node with the matching `name` value. For more advanced
  7. * queries, you can provide a function to validate any property to find the desired node.
  8. *
  9. * @module findAll
  10. * @param {string|function} name - Either a `string` or `function` that is used to find the
  11. * matching node.
  12. * @returns {node[]} - An array of matching nodes.
  13. *
  14. * @example
  15. * // returns an array of child nodes under `Cube_1` with the `name` being `Cube_1`
  16. * $$$
  17. * .find('Cube_1')
  18. * .findAll('Cube_1');
  19. *
  20. * // returns an array of child nodes under `Cube_1` with the `name` containing the word `Cube`
  21. * $$$
  22. * .find('Cube_1')
  23. * .findAll(node => ~node.name.indexOf('Cube'));
  24. */
  25. (name) => findAll(name, node);