Socket
Socket
Sign inDemoInstall

react-nanny

Package Overview
Dependencies
3
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.14.0 to 2.14.1

3

CHANGELOG.md

@@ -0,1 +1,4 @@

## [2.14.1] - 2022-10-11
- Removed toChildrenArray because it caused issues in getting nested children in an array.
## [2.14.0] - 2022-04-08

@@ -2,0 +5,0 @@ - Created private toChildrenArray util to simplify code

1

lib/es5/_private/utils.d.ts
export declare const processTypes: (types: any[]) => any[];
export declare const toChildrenArray: (children: any) => any[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toChildrenArray = exports.processTypes = void 0;
exports.processTypes = void 0;
var React = require("react");

@@ -24,4 +24,1 @@ var typeOfComponent_1 = require("../typeOfComponent");

exports.processTypes = processTypes;
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
var toChildrenArray = function (children) { return Array.isArray(children) ? children : React.Children.toArray(children); };
exports.toChildrenArray = toChildrenArray;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildDeep = exports.getChild = void 0;
var utils_1 = require("../_private/utils");
var React = require("react");
/**

@@ -19,3 +19,3 @@ * Gets first child by specified predicate

var getChild = function (children, predicate) {
return utils_1.toChildrenArray(children).find(predicate);
return React.Children.toArray(children).find(predicate);
};

@@ -38,3 +38,3 @@ exports.getChild = getChild;

var _a;
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -41,0 +41,0 @@ var child = _children_1[_i];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildByTypeDeep = exports.getChildByType = void 0;
var React = require("react");
var utils_1 = require("./../_private/utils");
var getChildrenByType_1 = require("../getChildrenByType");
var typeOfComponent_1 = require("../typeOfComponent");
var utils_2 = require("./../_private/utils");
/**

@@ -42,3 +42,3 @@ * Gets first child by specified type

var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]);
var matches = utils_2.toChildrenArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) !== -1; });
var matches = React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) !== -1; });
if (prioritized) {

@@ -45,0 +45,0 @@ var _loop_1 = function (type) {

@@ -9,3 +9,3 @@ "use strict";

exports.getChildrenDeep = exports.getChildren = void 0;
var utils_1 = require("../_private/utils");
var React = require("react");
/**

@@ -25,3 +25,3 @@ * Gets all children by specified predicate

var getChildren = function (children, predicate) {
return utils_1.toChildrenArray(children).filter(predicate);
return React.Children.toArray(children).filter(predicate);
};

@@ -44,3 +44,3 @@ exports.getChildren = getChildren;

var _a;
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -47,0 +47,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -9,5 +9,5 @@ "use strict";

exports.getChildrenByTypeDeep = exports.getChildrenByType = void 0;
var React = require("react");
var utils_1 = require("../_private/utils");
var typeOfComponent_1 = require("../typeOfComponent");
var utils_2 = require("../_private/utils");
/**

@@ -46,3 +46,3 @@ * Gets all children by specified type

var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]);
return utils_2.toChildrenArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) !== -1; });
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) !== -1; });
};

@@ -82,3 +82,3 @@ exports.getChildrenByType = getChildrenByType;

var _c = _a === void 0 ? {} : _a, _d = _c.customTypeKey, customTypeKey = _d === void 0 ? '__TYPE' : _d;
var _children = utils_2.toChildrenArray(children);
var _children = React.Children.toArray(children);
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]);

@@ -85,0 +85,0 @@ var output = [];

@@ -9,4 +9,4 @@ "use strict";

exports.getChildrenWithDescendant = void 0;
var React = require("react");
var getChild_1 = require("../getChild");
var utils_1 = require("../_private/utils");
/**

@@ -23,3 +23,3 @@ * Gets all children by specified predicate or that have a descendant node in their lineage which matches the predicate

var getChildrenWithDescendant = function (children, predicate) {
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -26,0 +26,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -9,4 +9,4 @@ "use strict";

exports.getChildrenWithDescendantByType = void 0;
var React = require("react");
var getChildByType_1 = require("../getChildByType");
var utils_1 = require("../_private/utils");
/**

@@ -44,3 +44,3 @@ * Gets all children by specified type or that have a descendant node in their lineage which match the specified type

var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c;
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -47,0 +47,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -9,3 +9,3 @@ "use strict";

exports.getDescendantDepth = void 0;
var utils_1 = require("../_private/utils");
var React = require("react");
/**

@@ -30,7 +30,7 @@ * Gets the depth to the first descendant (or self) of each root child that match the specified predicate

var getDescendantDepth = function (children, predicate) {
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
// recursively get the depth of the first matching child
var getDepth = function (children, predicate, level) {
var _a;
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
for (var _i = 0, _children_2 = _children; _i < _children_2.length; _i++) {

@@ -37,0 +37,0 @@ var child = _children_2[_i];

@@ -9,5 +9,5 @@ "use strict";

exports.getDescendantDepthByType = void 0;
var React = require("react");
var typeOfComponent_1 = require("../typeOfComponent");
var utils_1 = require("../_private/utils");
var utils_2 = require("../_private/utils");
/**

@@ -51,3 +51,3 @@ * Gets the depth to the first descendant (or self) of each root child that match the specified types

var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c;
var _children = utils_2.toChildrenArray(children);
var _children = React.Children.toArray(children);
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]);

@@ -57,3 +57,3 @@ // recursively get the depth of the first matching child

var _a;
var _children = utils_2.toChildrenArray(children);
var _children = React.Children.toArray(children);
for (var _i = 0, _children_2 = _children; _i < _children_2.length; _i++) {

@@ -60,0 +60,0 @@ var child = _children_2[_i];

@@ -10,3 +10,2 @@ "use strict";

var React = require("react");
var utils_1 = require("../_private/utils");
/**

@@ -43,3 +42,3 @@ * Immutably override props of the children of the original component and (optionally) the original component

return React.cloneElement(component, Object.assign(_overrides, {
children: utils_1.toChildrenArray(component.props.children).map(function (child, index) { return React.cloneElement(child, getChildOverrides(child, index)); }),
children: React.Children.toArray(component.props.children).map(function (child, index) { return React.cloneElement(child, getChildOverrides(child, index)); }),
}));

@@ -72,3 +71,3 @@ }

return [];
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -75,0 +74,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -9,3 +9,3 @@ "use strict";

exports.removeChildrenDeep = exports.removeChildren = void 0;
var utils_1 = require("../_private/utils");
var React = require("react");
/**

@@ -25,3 +25,3 @@ * Removes all children by specified predicate

var removeChildren = function (children, predicate) {
return utils_1.toChildrenArray(children).filter(function (child) { return !predicate(child); });
return React.Children.toArray(children).filter(function (child) { return !predicate(child); });
};

@@ -44,3 +44,3 @@ exports.removeChildren = removeChildren;

var _a;
var _children = utils_1.toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -47,0 +47,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -9,5 +9,5 @@ "use strict";

exports.removeChildrenByTypeDeep = exports.removeChildrenByType = void 0;
var React = require("react");
var utils_1 = require("./../_private/utils");
var typeOfComponent_1 = require("../typeOfComponent");
var utils_2 = require("./../_private/utils");
/**

@@ -45,3 +45,3 @@ * Removes all children by specified type

var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]);
return utils_2.toChildrenArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) === -1; });
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent_1.typeOfComponent(child, customTypeKey)) === -1; });
};

@@ -81,3 +81,3 @@ exports.removeChildrenByType = removeChildrenByType;

var _c = _a === void 0 ? {} : _a, _d = _c.customTypeKey, customTypeKey = _d === void 0 ? '__TYPE' : _d;
var _children = utils_2.toChildrenArray(children);
var _children = React.Children.toArray(children);
var _types = utils_1.processTypes(Array.isArray(types) ? types : [types]);

@@ -84,0 +84,0 @@ var output = [];

export declare const processTypes: (types: any[]) => any[];
export declare const toChildrenArray: (children: any) => any[];

@@ -20,3 +20,1 @@ import * as React from 'react';

}); };
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export var toChildrenArray = function (children) { return Array.isArray(children) ? children : React.Children.toArray(children); };

@@ -1,2 +0,2 @@

import { toChildrenArray } from '../_private/utils';
import * as React from 'react';
/**

@@ -16,3 +16,3 @@ * Gets first child by specified predicate

export var getChild = function (children, predicate) {
return toChildrenArray(children).find(predicate);
return React.Children.toArray(children).find(predicate);
};

@@ -34,3 +34,3 @@ /**

var _a;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -37,0 +37,0 @@ var child = _children_1[_i];

@@ -0,5 +1,5 @@

import * as React from 'react';
import { processTypes } from './../_private/utils';
import { getChildrenByTypeDeep } from '../getChildrenByType';
import { typeOfComponent } from '../typeOfComponent';
import { toChildrenArray } from './../_private/utils';
/**

@@ -39,3 +39,3 @@ * Gets first child by specified type

var _types = processTypes(Array.isArray(types) ? types : [types]);
var matches = toChildrenArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) !== -1; });
var matches = React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) !== -1; });
if (prioritized) {

@@ -42,0 +42,0 @@ var _loop_1 = function (type) {

@@ -6,3 +6,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import { toChildrenArray } from '../_private/utils';
import * as React from 'react';
/**

@@ -22,3 +22,3 @@ * Gets all children by specified predicate

export var getChildren = function (children, predicate) {
return toChildrenArray(children).filter(predicate);
return React.Children.toArray(children).filter(predicate);
};

@@ -40,3 +40,3 @@ /**

var _a;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -43,0 +43,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -6,5 +6,5 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import * as React from 'react';
import { processTypes } from '../_private/utils';
import { typeOfComponent } from '../typeOfComponent';
import { toChildrenArray } from '../_private/utils';
/**

@@ -43,3 +43,3 @@ * Gets all children by specified type

var _types = processTypes(Array.isArray(types) ? types : [types]);
return toChildrenArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) !== -1; });
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) !== -1; });
};

@@ -78,3 +78,3 @@ /**

var _c = _a === void 0 ? {} : _a, _d = _c.customTypeKey, customTypeKey = _d === void 0 ? '__TYPE' : _d;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var _types = processTypes(Array.isArray(types) ? types : [types]);

@@ -81,0 +81,0 @@ var output = [];

@@ -6,4 +6,4 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import * as React from 'react';
import { getChildDeep } from '../getChild';
import { toChildrenArray } from '../_private/utils';
/**

@@ -20,3 +20,3 @@ * Gets all children by specified predicate or that have a descendant node in their lineage which matches the predicate

export var getChildrenWithDescendant = function (children, predicate) {
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -23,0 +23,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -6,4 +6,4 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import * as React from 'react';
import { getChildByTypeDeep } from '../getChildByType';
import { toChildrenArray } from '../_private/utils';
/**

@@ -41,3 +41,3 @@ * Gets all children by specified type or that have a descendant node in their lineage which match the specified type

var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -44,0 +44,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -6,3 +6,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import { toChildrenArray } from '../_private/utils';
import * as React from 'react';
/**

@@ -27,7 +27,7 @@ * Gets the depth to the first descendant (or self) of each root child that match the specified predicate

export var getDescendantDepth = function (children, predicate) {
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
// recursively get the depth of the first matching child
var getDepth = function (children, predicate, level) {
var _a;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
for (var _i = 0, _children_2 = _children; _i < _children_2.length; _i++) {

@@ -34,0 +34,0 @@ var child = _children_2[_i];

@@ -6,5 +6,5 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import * as React from 'react';
import { typeOfComponent } from '../typeOfComponent';
import { processTypes } from '../_private/utils';
import { toChildrenArray } from '../_private/utils';
/**

@@ -48,3 +48,3 @@ * Gets the depth to the first descendant (or self) of each root child that match the specified types

var _b = _a === void 0 ? {} : _a, _c = _b.customTypeKey, customTypeKey = _c === void 0 ? '__TYPE' : _c;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var _types = processTypes(Array.isArray(types) ? types : [types]);

@@ -54,3 +54,3 @@ // recursively get the depth of the first matching child

var _a;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
for (var _i = 0, _children_2 = _children; _i < _children_2.length; _i++) {

@@ -57,0 +57,0 @@ var child = _children_2[_i];

@@ -7,3 +7,2 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

import * as React from 'react';
import { toChildrenArray } from '../_private/utils';
/**

@@ -40,3 +39,3 @@ * Immutably override props of the children of the original component and (optionally) the original component

return React.cloneElement(component, Object.assign(_overrides, {
children: toChildrenArray(component.props.children).map(function (child, index) { return React.cloneElement(child, getChildOverrides(child, index)); }),
children: React.Children.toArray(component.props.children).map(function (child, index) { return React.cloneElement(child, getChildOverrides(child, index)); }),
}));

@@ -68,3 +67,3 @@ }

return [];
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -71,0 +70,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -6,3 +6,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import { toChildrenArray } from '../_private/utils';
import * as React from 'react';
/**

@@ -22,3 +22,3 @@ * Removes all children by specified predicate

export var removeChildren = function (children, predicate) {
return toChildrenArray(children).filter(function (child) { return !predicate(child); });
return React.Children.toArray(children).filter(function (child) { return !predicate(child); });
};

@@ -40,3 +40,3 @@ /**

var _a;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var output = [];

@@ -43,0 +43,0 @@ for (var _i = 0, _children_1 = _children; _i < _children_1.length; _i++) {

@@ -6,5 +6,5 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {

};
import * as React from 'react';
import { processTypes } from './../_private/utils';
import { typeOfComponent } from '../typeOfComponent';
import { toChildrenArray } from './../_private/utils';
/**

@@ -42,3 +42,3 @@ * Removes all children by specified type

var _types = processTypes(Array.isArray(types) ? types : [types]);
return toChildrenArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) === -1; });
return React.Children.toArray(children).filter(function (child) { return _types.indexOf(typeOfComponent(child, customTypeKey)) === -1; });
};

@@ -77,3 +77,3 @@ /**

var _c = _a === void 0 ? {} : _a, _d = _c.customTypeKey, customTypeKey = _d === void 0 ? '__TYPE' : _d;
var _children = toChildrenArray(children);
var _children = React.Children.toArray(children);
var _types = processTypes(Array.isArray(types) ? types : [types]);

@@ -80,0 +80,0 @@ var output = [];

{
"name": "react-nanny",
"version": "2.14.0",
"version": "2.14.1",
"description": "Utils to manage your React Children; find and filter children by type or custom function, enforce child content, and more!",

@@ -5,0 +5,0 @@ "main": "lib/es5/index.js",

@@ -18,3 +18,3 @@ [![Build Status](https://travis-ci.com/TheSpicyMeatball/react-nanny.svg?branch=main)](https://travis-ci.com/TheSpicyMeatball/react-nanny)

<p><b>Version:</b> 2.14.0</p>
<p><b>Version:</b> 2.14.1</p>

@@ -169,24 +169,24 @@ <h3>Dependencies</h3>

└───index.d.ts - 1.23 KB
└───index.js - 1.83 KB
└───index.js - 1.81 KB
└───/getChildByType
└───index.d.ts - 4.16 KB
└───index.js - 6.09 KB
└───index.js - 6.08 KB
└───/getChildren
└───index.d.ts - 1.21 KB
└───index.js - 2.09 KB
└───index.js - 2.07 KB
└───/getChildrenByType
└───index.d.ts - 3.59 KB
└───index.js - 5.05 KB
└───index.js - 5.03 KB
└───/getChildrenWithDescendant
└───index.d.ts - 638 Bytes
└───index.js - 1.33 KB
└───index.js - 1.31 KB
└───/getChildrenWithDescendantByType
└───index.d.ts - 2.26 KB
└───index.js - 3.03 KB
└───index.js - 3.02 KB
└───/getDescendantDepth
└───index.d.ts - 1.14 KB
└───index.js - 2.47 KB
└───index.js - 2.46 KB
└───/getDescendantDepthByType
└───index.d.ts - 2.39 KB
└───index.js - 3.95 KB
└───index.js - 3.93 KB
└───index.d.ts - 1.1 KB

@@ -199,9 +199,9 @@ └───index.js - 4.23 KB

└───index.d.ts - 2.72 KB
└───index.js - 4.71 KB
└───index.js - 4.66 KB
└───/removeChildren
└───index.d.ts - 1.22 KB
└───index.js - 2.59 KB
└───index.js - 2.57 KB
└───/removeChildrenByType
└───index.d.ts - 3.71 KB
└───index.js - 5.65 KB
└───index.js - 5.63 KB
└───/typeOfComponent

@@ -213,14 +213,14 @@ └───index.d.ts - 614 Bytes

└───/_private
└───utils.d.ts - 126 Bytes
└───utils.js - 1.16 KB
└───utils.d.ts - 61 Bytes
└───utils.js - 913 Bytes
└───/es6
└───/getChild
└───index.d.ts - 1.23 KB
└───index.js - 1.64 KB
└───index.js - 1.63 KB
└───/getChildByType
└───index.d.ts - 4.16 KB
└───index.js - 5.8 KB
└───index.js - 5.78 KB
└───/getChildren
└───index.d.ts - 1.21 KB
└───index.js - 1.88 KB
└───index.js - 1.87 KB
└───/getChildrenByType

@@ -231,12 +231,12 @@ └───index.d.ts - 3.59 KB

└───index.d.ts - 638 Bytes
└───index.js - 1.14 KB
└───index.js - 1.13 KB
└───/getChildrenWithDescendantByType
└───index.d.ts - 2.26 KB
└───index.js - 2.82 KB
└───index.js - 2.81 KB
└───/getDescendantDepth
└───index.d.ts - 1.14 KB
└───index.js - 2.31 KB
└───index.js - 2.3 KB
└───/getDescendantDepthByType
└───index.d.ts - 2.39 KB
└───index.js - 3.75 KB
└───index.js - 3.74 KB
└───index.d.ts - 1.1 KB

@@ -249,9 +249,9 @@ └───index.js - 905 Bytes

└───index.d.ts - 2.72 KB
└───index.js - 4.48 KB
└───index.js - 4.44 KB
└───/removeChildren
└───index.d.ts - 1.22 KB
└───index.js - 2.35 KB
└───index.js - 2.34 KB
└───/removeChildrenByType
└───index.d.ts - 3.71 KB
└───index.js - 5.33 KB
└───index.js - 5.32 KB
└───/typeOfComponent

@@ -263,4 +263,4 @@ └───index.d.ts - 614 Bytes

└───/_private
└───utils.d.ts - 126 Bytes
└───utils.js - 912 Bytes
└───utils.d.ts - 61 Bytes
└───utils.js - 700 Bytes
````
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc