New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-element-to-jsx-string

Package Overview
Dependencies
Maintainers
65
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-element-to-jsx-string - npm Package Compare versions

Comparing version

to
14.3.0

dist/cjs/formatter/createPropFilter.js.flow

9

CHANGELOG.md

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

# [14.3.0](https://github.com/algolia/react-element-to-jsx-string/compare/v14.2.0...v14.3.0) (2020-01-17)
### Features
* allow filterProps to be a function ([#417](https://github.com/algolia/react-element-to-jsx-string/issues/417)) ([c4908bb](https://github.com/algolia/react-element-to-jsx-string/commit/c4908bb))
# [14.2.0](https://github.com/algolia/react-element-to-jsx-string/compare/v14.1.0...v14.2.0) (2019-12-29)

@@ -2,0 +11,0 @@

21

dist/cjs/index.js

@@ -569,2 +569,14 @@ 'use strict';

function createPropFilter(props, filter) {
if (Array.isArray(filter)) {
return function (key) {
return filter.indexOf(key) === -1;
};
} else {
return function (key) {
return filter(props[key], key);
};
}
}
var compensateMultilineStringElementIndentation = function compensateMultilineStringElementIndentation(element, formattedElement, inline, lvl, options) {

@@ -635,10 +647,7 @@ var tabStop = options.tabStop;

var visibleAttributeNames = [];
Object.keys(props).filter(function (propName) {
return filterProps.indexOf(propName) === -1;
}).filter(onlyPropsWithOriginalValue(defaultProps, props)).forEach(function (propName) {
var propFilter = createPropFilter(props, filterProps);
Object.keys(props).filter(propFilter).filter(onlyPropsWithOriginalValue(defaultProps, props)).forEach(function (propName) {
return visibleAttributeNames.push(propName);
});
Object.keys(defaultProps).filter(function (defaultPropName) {
return filterProps.indexOf(defaultPropName) === -1;
}).filter(function () {
Object.keys(defaultProps).filter(propFilter).filter(function () {
return showDefaultProps;

@@ -645,0 +654,0 @@ }).filter(function (defaultPropName) {

@@ -562,2 +562,14 @@ import React, { Fragment, isValidElement } from 'react';

function createPropFilter(props, filter) {
if (Array.isArray(filter)) {
return function (key) {
return filter.indexOf(key) === -1;
};
} else {
return function (key) {
return filter(props[key], key);
};
}
}
var compensateMultilineStringElementIndentation = function compensateMultilineStringElementIndentation(element, formattedElement, inline, lvl, options) {

@@ -628,10 +640,7 @@ var tabStop = options.tabStop;

var visibleAttributeNames = [];
Object.keys(props).filter(function (propName) {
return filterProps.indexOf(propName) === -1;
}).filter(onlyPropsWithOriginalValue(defaultProps, props)).forEach(function (propName) {
var propFilter = createPropFilter(props, filterProps);
Object.keys(props).filter(propFilter).filter(onlyPropsWithOriginalValue(defaultProps, props)).forEach(function (propName) {
return visibleAttributeNames.push(propName);
});
Object.keys(defaultProps).filter(function (defaultPropName) {
return filterProps.indexOf(defaultPropName) === -1;
}).filter(function () {
Object.keys(defaultProps).filter(propFilter).filter(function () {
return showDefaultProps;

@@ -638,0 +647,0 @@ }).filter(function (defaultPropName) {

{
"name": "react-element-to-jsx-string",
"version": "14.2.0",
"version": "14.3.0",
"description": "Turn a ReactElement into the corresponding JSX string.",

@@ -44,4 +44,4 @@ "main": "dist/cjs/index.js",

"@babel/preset-react": "7.6.3",
"@commitlint/cli": "8.2.0",
"@commitlint/config-angular": "8.2.0",
"@commitlint/cli": "8.3.4",
"@commitlint/config-angular": "8.3.4",
"babel-eslint": "10.0.3",

@@ -57,3 +57,3 @@ "babel-jest": "24.9.0",

"eslint-config-prettier": "6.9.0",
"eslint-plugin-import": "2.19.1",
"eslint-plugin-import": "2.20.0",
"eslint-plugin-jest": "22.21.0",

@@ -64,3 +64,3 @@ "eslint-plugin-prettier": "3.1.2",

"expect": "24.9.0",
"flow-bin": "0.114.0",
"flow-bin": "0.115.0",
"flow-copy-source": "2.0.9",

@@ -76,3 +76,3 @@ "husky": "3.1.0",

"react-test-renderer": "16.12.0",
"rollup": "1.27.14",
"rollup": "1.29.0",
"rollup-plugin-babel": "4.3.3",

@@ -83,3 +83,3 @@ "rollup-plugin-commonjs": "10.1.0",

"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-sourcemaps": "0.4.2"
"rollup-plugin-sourcemaps": "0.5.0"
},

@@ -86,0 +86,0 @@ "peerDependencies": {

@@ -73,6 +73,10 @@ # react-element-to-jsx-string

**options.filterProps: array, default []**
**options.filterProps: string[] | (val: any, key: string) => boolean, default []**
Provide an array of props to filter for every component. For example ['key'] will suppress the key="" prop from being added.
If an array of strings is passed, filter out any prop who's name is in
the array. For example ['key'] will suppress the key="" prop from being added.
If a function is passed, it will be called for each prop with two arguments,
the prop value and key, and will filter out any that return false.
**options.showDefaultProps: boolean, default true**

@@ -79,0 +83,0 @@

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