Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-itertools

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-itertools - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/index.production.js

14

dist/each/index.js

@@ -1,10 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.each = void 0;
const react_1 = require("react");
function each(children, fn, options = {}) {
import { Children, isValidElement } from "react";
export function each(children, fn, options = {}) {
const breadthFirst = options["visit"] === "breadthFirst";
const maxDepth = options["maxDepth"] ?? -1;
const queue = [];
react_1.Children.forEach(children, (el) => queue.push([el, depth]));
Children.forEach(children, (el) => queue.push([el, depth]));
const scheduler = breadthFirst

@@ -26,8 +23,7 @@ ? (el, depth) => queue.push([el, depth])

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (react_1.isValidElement(element) && element.props.children) {
if (isValidElement(element) && element.props.children) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
react_1.Children.forEach(element.props.children, (el) => scheduler(el, depth + 1));
Children.forEach(element.props.children, (el) => scheduler(el, depth + 1));
}
}
}
exports.each = each;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filter = void 0;
const map_1 = require("../map");
function filter(children, fn, options = {}) {
return map_1.map(children, (el) => {
import { map } from "../map";
export function filter(children, fn, options = {}) {
return map(children, (el) => {
if (fn(el)) {

@@ -13,2 +10,1 @@ return el;

}
exports.filter = filter;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.find = void 0;
const each_1 = require("../each");
function find(children, fn, options = {}) {
import { each } from "../each";
export function find(children, fn, options = {}) {
let found;
each_1.each(children, (el, idx) => {
each(children, (el, idx) => {
if (fn(el, idx)) {

@@ -16,2 +13,1 @@ found = el;

}
exports.find = find;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.groupBy = void 0;
const reduce_1 = require("../reduce");
function groupBy(children, fn, options = {}) {
return reduce_1.reduce(children, (acc, current, idx) => {
import { reduce } from "../reduce";
export function groupBy(children, fn, options = {}) {
return reduce(children, (acc, current, idx) => {
const key = fn(current, idx);

@@ -18,2 +15,1 @@ const res = acc[key];

}
exports.groupBy = groupBy;

@@ -1,19 +0,7 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./each"), exports);
__exportStar(require("./filter"), exports);
__exportStar(require("./find"), exports);
__exportStar(require("./groupBy"), exports);
__exportStar(require("./map"), exports);
__exportStar(require("./options"), exports);
__exportStar(require("./reduce"), exports);
export * from "./each";
export * from "./filter";
export * from "./find";
export * from "./groupBy";
export * from "./map";
export * from "./options";
export * from "./reduce";

@@ -1,10 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.map = void 0;
const react_1 = require("react");
import { Children, cloneElement, isValidElement } from "react";
function _map(children, fn, maxDepth, depth) {
return react_1.Children.map(children, (child) => {
return Children.map(children, (child) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (react_1.isValidElement(child) && child.props.children && depth !== maxDepth) {
child = react_1.cloneElement(child, {
if (isValidElement(child) && child.props.children && depth !== maxDepth) {
child = cloneElement(child, {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment

@@ -27,6 +24,5 @@ children: _map(child.props.children, fn, maxDepth, depth + 1),

*/
function map(children, fn, options = {}) {
export function map(children, fn, options = {}) {
const maxDepth = options["maxDepth"] ?? -1;
return _map(children, fn, maxDepth, 0);
}
exports.map = map;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.reduce = void 0;
const each_1 = require("../each");
function reduce(children, fn, initialValue, options = {}) {
import { each } from "../each";
export function reduce(children, fn, initialValue, options = {}) {
const accumulated = initialValue;
each_1.each(children, (el, idx) => {
each(children, (el, idx) => {
fn(accumulated, el, idx);

@@ -13,2 +10,1 @@ return true;

}
exports.reduce = reduce;
{
"name": "react-itertools",
"version": "0.0.1",
"version": "0.0.2",
"description": "A suite of tools for manipulating React children",

@@ -12,2 +12,3 @@ "license": "MIT",

"main": "dist/index.js",
"module": "dist/index.js",
"files": [

@@ -17,3 +18,3 @@ "dist/*"

"scripts": {
"build": "yarn clean && yarn tsc",
"build": "yarn clean && yarn tsc && yarn webpack",
"clean": "rm -rf dist",

@@ -27,4 +28,13 @@ "lint": "yarn typecheck && prettier --check . && prettier-package-json --list-different '{,example/,}package.json' && eslint .",

},
"sideEffects": false,
"types": "dist/index.d.ts",
"peerDependencies": {
"react": ">= 16"
},
"devDependencies": {
"@babel/preset-env": "^7.14.1",
"@babel/preset-react": "^7.13.13",
"@babel/preset-typescript": "^7.13.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^13.1.8",
"@types/jest": "^26.0.15",

@@ -35,2 +45,3 @@ "@types/node": "^13.13.5",

"@typescript-eslint/parser": "^4.1.0",
"babel-loader": "^8.2.2",
"eslint": "^7.8.1",

@@ -44,3 +55,6 @@ "eslint-config-prettier": "^8.1.0",

"react": "^17.0.2",
"typescript": "^4.1.3"
"react-dom": "^17.0.2",
"typescript": "^4.1.3",
"webpack": "^5.37.0",
"webpack-cli": "^4.7.0"
},

@@ -47,0 +61,0 @@ "keywords": [

@@ -37,4 +37,7 @@ # React Itertools

🎁 Zero run time dependencies
🦶 [Small footprint](https://bundlephobia.com/result?p=react-itertools)
🌲 Tree shakeable
## Contributing 👫

@@ -41,0 +44,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc