JSPM

  • Created
  • Published
  • Downloads 54730
  • Score
    100M100P100Q159767F
  • License MIT

Extended utils for React.Children opaque data structure

Package Exports

  • react-children-utilities

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-children-utilities) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Children Utilities

npm version npm downloads Build Status peerDependency Status devDependency Status Coverage Status

Extended utils for React.Children opaque data structure.

Install

This is a peer dependency so react must be present

npm install --save react-children-utilities react

Usage

Instead of requiring Children from React, require this one, it will extend existing capabilities from Children in your current React version.

var Children = require('react-children-utilities');

With ES6 modules

import Children from 'react-children-utilities';

Api documentation

Children.filter

Creates a new children array with all elements that pass the test implemented by the provided function.

Children.filter(children, callback)

Children.groupByType

Returns an object with keys that map each tag name to an array of children of that type, and a key that maps the rest of children.

Children.groupByType(children, tagNames[, restKey])

Children.deepMap

Creates a new children array with the results of calling a provided function on every element (and its children) in the provided children.

Children.deepMap(children, callback)

Children.deepForEach

Executes a provided function on every element (and its children) in the provided children.

Children.deepForEach(children, callback)

Children.deepFind

Returns the first element in the children (and its children) that satisfies the provided testing function.

Children.deepFind(children, callback)

Children.onlyText

Strips all html and returns only text nodes

Children.onlyText(children)

License

MIT (c) 2018 Fernando Pasik