react-children-utilities
Advanced tools
Comparing version 2.0.8 to 2.0.9
import { ReactNode } from 'react'; | ||
export declare const childToString: (child?: string | number | boolean | {} | null | undefined) => string; | ||
declare const onlyText: (children: ReactNode) => string; | ||
export default onlyText; | ||
//# sourceMappingURL=onlyText.d.ts.map |
import { Children, isValidElement } from 'react'; | ||
import hasChildren from './hasChildren'; | ||
const childToString = (child) => { | ||
export const childToString = (child) => { | ||
if (typeof child === 'undefined' || child === null || typeof child === 'boolean') { | ||
return ''; | ||
} | ||
if (JSON.stringify(child) === '{}') { | ||
return ''; | ||
} | ||
return child.toString(); | ||
@@ -8,0 +11,0 @@ }; |
{ | ||
"name": "react-children-utilities", | ||
"version": "2.0.8", | ||
"version": "2.0.9", | ||
"description": "Recursive and extended utils for React children opaque data structure", | ||
@@ -59,4 +59,4 @@ "keywords": [ | ||
"@types/react-dom": "^16.9.5", | ||
"@typescript-eslint/eslint-plugin": "^2.21.0", | ||
"@typescript-eslint/parser": "^2.21.0", | ||
"@typescript-eslint/eslint-plugin": "^2.22.0", | ||
"@typescript-eslint/parser": "^2.22.0", | ||
"all-contributors-cli": "^6.14.0", | ||
@@ -73,8 +73,8 @@ "bundlesize": "^0.18.0", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-jest": "^23.8.0", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"eslint-plugin-react": "^7.18.3", | ||
"eslint-plugin-react": "^7.19.0", | ||
"eslint-plugin-react-hooks": "^2.5.0", | ||
"flow-bin": "^0.119.1", | ||
"flow-bin": "^0.120.1", | ||
"flowgen": "^1.10.0", | ||
@@ -94,6 +94,6 @@ "husky": "^4.2.3", | ||
"react-test-renderer": "^16.13.0", | ||
"rollup": "^1.31.1", | ||
"rollup": "^2.0.0", | ||
"rollup-plugin-terser": "^5.2.0", | ||
"ts-jest": "^25.2.1", | ||
"typescript": "^3.8.2" | ||
"typescript": "^3.8.3" | ||
}, | ||
@@ -100,0 +100,0 @@ "peerDependencies": { |
@@ -1,2 +0,2 @@ | ||
import{isValidElement as e,Children as t,cloneElement as r}from"react";const o=t=>e(t)&&Boolean(t.t.children),n=r=>e(r)&&o(r)&&t.toArray(r.t.children).reduce((t,r)=>t||e(r),!1),l=(o,c)=>t.toArray(o).filter(c).map(t=>e(t)&&n(t)?r(t,Object.assign(Object.assign({},t.t),{children:l(t.t.children,c)})):t),c=(r,o)=>{let l;return t.toArray(r).find(t=>o(t)?(l=t,!0):!(!e(t)||!n(t))&&(l=c(t.t.children,o),void 0!==l)),l},p=(r,o)=>{t.forEach(r,t=>{e(t)&&n(t)&&p(t.t.children,o),o(t)})},d=(o,l)=>t.map(o,t=>e(t)&&n(t)?l(r(t,Object.assign(Object.assign({},t.t),{children:d(t.t.children,l)}))):l(t)),i=(e,r)=>t.toArray(e).filter(r),a=(r,o=[],n="rest")=>t.toArray(r).reduce((t,r)=>{const l=Object.assign({},t);let c=n;return e(r)&&"string"==typeof r.type&&o.includes(r.type)&&(c=r.type),void 0===l[c]&&(l[c]=[]),l[c]=[...l[c],r],l},{}),b=e=>null==e||"boolean"==typeof e?"":e.toString(),h=r=>r instanceof Array||e(r)?t.toArray(r).reduce((t,r)=>{let n;return n=e(r)&&o(r)?h(r.t.children):b(r),t.concat(n)},""):b(r);var j=Object.assign(Object.assign({},t),{o:l,l:c,p:p,i:d,filter:i,h:a,j:o,s:n,O:h});export default j;export{l as deepFilter,c as deepFind,p as deepForEach,d as deepMap,i as filter,a as groupByType,o as hasChildren,n as hasComplexChildren,h as onlyText}; | ||
import{isValidElement as e,Children as t,cloneElement as r}from"react";const o=t=>e(t)&&Boolean(t.t.children),n=r=>e(r)&&o(r)&&t.toArray(r.t.children).reduce((t,r)=>t||e(r),!1),l=(o,c)=>t.toArray(o).filter(c).map(t=>e(t)&&n(t)?r(t,Object.assign(Object.assign({},t.t),{children:l(t.t.children,c)})):t),c=(r,o)=>{let l;return t.toArray(r).find(t=>o(t)?(l=t,!0):!(!e(t)||!n(t))&&(l=c(t.t.children,o),void 0!==l)),l},p=(r,o)=>{t.forEach(r,t=>{e(t)&&n(t)&&p(t.t.children,o),o(t)})},d=(o,l)=>t.map(o,t=>e(t)&&n(t)?l(r(t,Object.assign(Object.assign({},t.t),{children:d(t.t.children,l)}))):l(t)),i=(e,r)=>t.toArray(e).filter(r),a=(r,o=[],n="rest")=>t.toArray(r).reduce((t,r)=>{const l=Object.assign({},t);let c=n;return e(r)&&"string"==typeof r.type&&o.includes(r.type)&&(c=r.type),void 0===l[c]&&(l[c]=[]),l[c]=[...l[c],r],l},{}),b=e=>null==e||"boolean"==typeof e||"{}"===JSON.stringify(e)?"":e.toString(),O=r=>r instanceof Array||e(r)?t.toArray(r).reduce((t,r)=>{let n;return n=e(r)&&o(r)?O(r.t.children):b(r),t.concat(n)},""):b(r);var h=Object.assign(Object.assign({},t),{o:l,l:c,p:p,i:d,filter:i,O:a,h:o,j:n,s:O});export default h;export{l as deepFilter,c as deepFind,p as deepForEach,d as deepMap,i as filter,a as groupByType,o as hasChildren,n as hasComplexChildren,O as onlyText}; | ||
//# sourceMappingURL=react-children-utilities.min.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50787
208