react-tree-walker
Advanced tools
Comparing version 2.1.2 to 2.1.3
155
package.json
{ | ||
"name": "react-tree-walker", | ||
"version": "2.1.2", | ||
"description": "Walk a React element tree, executing a provided function against each node.", | ||
"version": "2.1.3", | ||
"description": | ||
"Walk a React element tree, executing a provided function against each node.", | ||
"license": "MIT", | ||
"main": "commonjs/index.js", | ||
"files": [ | ||
"*.js", | ||
"*.md", | ||
"umd", | ||
"commonjs" | ||
], | ||
"files": ["*.js", "*.md", "umd", "commonjs"], | ||
"repository": { | ||
@@ -19,9 +15,3 @@ "type": "git", | ||
"author": "Sean Matheson <sean@ctrlplusb.com>", | ||
"keywords": [ | ||
"react", | ||
"react-element", | ||
"util", | ||
"tree", | ||
"visitor" | ||
], | ||
"keywords": ["react", "react-element", "util", "tree", "visitor"], | ||
"scripts": { | ||
@@ -31,3 +21,4 @@ "precommit": "lint-staged && npm run test", | ||
"check": "npm run lint && npm run test", | ||
"clean": "rimraf ./commonjs && rimraf ./umd && rimraf ./coverage && rimraf ./umd", | ||
"clean": | ||
"rimraf ./commonjs && rimraf ./umd && rimraf ./coverage && rimraf ./umd", | ||
"lint": "eslint src", | ||
@@ -39,65 +30,93 @@ "prepublish": "npm run build", | ||
}, | ||
"jest": { | ||
"collectCoverageFrom": [ | ||
"src/**/*.{js,jsx}" | ||
], | ||
"snapshotSerializers": [ | ||
"<rootDir>/node_modules/enzyme-to-json/serializer" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/(commonjs|coverage|flow-typed|node_modules|tools|umd)/" | ||
] | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"prettier-eslint --write", | ||
"git add" | ||
] | ||
}, | ||
"peerDependencies": { | ||
"react": "^0.14.0 || ^15.0.0" | ||
"react": "^0.14.0 || ^15.0.0 || ^16.0.0" | ||
}, | ||
"devDependencies": { | ||
"app-root-dir": "1.0.2", | ||
"babel-cli": "6.24.1", | ||
"babel-core": "6.25.0", | ||
"babel-eslint": "7.2.3", | ||
"babel-jest": "20.0.3", | ||
"babel-loader": "^7.1.0", | ||
"babel-polyfill": "6.23.0", | ||
"babel-preset-env": "1.5.2", | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.0.1", | ||
"babel-jest": "^21.2.0", | ||
"babel-loader": "^7.1.2", | ||
"babel-polyfill": "^6.26.0", | ||
"babel-preset-env": "^1.6.0", | ||
"babel-preset-latest": "6.24.1", | ||
"babel-preset-react": "6.24.1", | ||
"babel-preset-stage-3": "6.24.1", | ||
"babel-register": "6.24.1", | ||
"codecov": "2.2.0", | ||
"cross-env": "5.0.1", | ||
"enzyme": "2.8.2", | ||
"enzyme-to-json": "1.5.1", | ||
"eslint": "3.19.0", | ||
"eslint-config-airbnb": "15.0.1", | ||
"eslint-plugin-import": "2.3.0", | ||
"eslint-plugin-jsx-a11y": "5.0.3", | ||
"eslint-plugin-react": "^7.1.0", | ||
"gzip-size": "3.0.0", | ||
"husky": "0.13.4", | ||
"babel-register": "^6.26.0", | ||
"codecov": "^2.3.0", | ||
"cross-env": "^5.0.5", | ||
"enzyme": "^3.1.0", | ||
"enzyme-to-json": "^3.1.2", | ||
"eslint": "^4.8.0", | ||
"eslint-config-airbnb": "^16.0.0", | ||
"eslint-config-prettier": "^2.6.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.2", | ||
"eslint-plugin-react": "^7.4.0", | ||
"gzip-size": "^4.0.0", | ||
"husky": "^0.14.3", | ||
"in-publish": "2.0.0", | ||
"jest": "20.0.4", | ||
"lint-staged": "^4.0.0", | ||
"prettier": "1.4.4", | ||
"prettier-eslint": "6.3.0", | ||
"prettier-eslint-cli": "^4.1.1", | ||
"jest": "^21.2.1", | ||
"lint-staged": "^4.2.3", | ||
"prettier": "^1.7.4", | ||
"pretty-bytes": "4.0.2", | ||
"prop-types": "^15.5.10", | ||
"ramda": "0.24.1", | ||
"react": "^15.6.1", | ||
"react-addons-test-utils": "^15.6.0", | ||
"react-dom": "^15.6.1", | ||
"prop-types": "^15.6.0", | ||
"ramda": "^0.25.0", | ||
"react": "^16.0.0", | ||
"react-addons-test-utils": "^15.6.2", | ||
"react-dom": "^16.0.0", | ||
"readline-sync": "1.4.7", | ||
"rimraf": "2.6.1", | ||
"sinon": "^2.3.5", | ||
"webpack": "^3.0.0", | ||
"webpack-dev-middleware": "1.10.2", | ||
"webpack-hot-middleware": "2.18.0" | ||
"rimraf": "^2.6.2", | ||
"sinon": "^4.0.1", | ||
"webpack": "^3.6.0", | ||
"webpack-dev-middleware": "^1.12.0", | ||
"webpack-hot-middleware": "^2.19.1" | ||
}, | ||
"jest": { | ||
"collectCoverageFrom": ["src/**/*.{js,jsx}"], | ||
"snapshotSerializers": ["<rootDir>/node_modules/enzyme-to-json/serializer"], | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/(commonjs|coverage|flow-typed|node_modules|tools|umd)/" | ||
] | ||
}, | ||
"lint-staged": { | ||
"src/**/*.js": ["prettier --write", "git add"] | ||
}, | ||
"eslintConfig": { | ||
"root": true, | ||
"parser": "babel-eslint", | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true, | ||
"jest": true | ||
}, | ||
"extends": ["airbnb", "prettier"], | ||
"rules": { | ||
"camelcase": 0, | ||
"import/prefer-default-export": 0, | ||
"import/no-extraneous-dependencies": 0, | ||
"no-underscore-dangle": 0, | ||
"react/no-array-index-key": 0, | ||
"react/react-in-jsx-scope": 0, | ||
"semi": [2, "never"], | ||
"react/forbid-prop-types": 0, | ||
"react/jsx-filename-extension": 0, | ||
"react/sort-comp": 0 | ||
} | ||
}, | ||
"eslintIgnore": [ | ||
"flow-typed/", | ||
"tools/flow/", | ||
"node_modules/", | ||
"commonjs/", | ||
"coverage/", | ||
"umd/" | ||
], | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} | ||
} |
@@ -37,4 +37,5 @@ # react-tree-walker 🌲 | ||
getValue() { | ||
return this.props.value; | ||
getData() { | ||
// Return a promise or a sync value | ||
return Promise.resolve(this.props.value); | ||
} | ||
@@ -79,9 +80,12 @@ | ||
function visitor(element, instance, context) { | ||
if (instance && typeof instance.getValue) { | ||
const value = instance.getValue() | ||
if (value === 4) { | ||
// stop traversal on this branch of tree. | ||
return false | ||
} | ||
values.push(instance.getValue()); | ||
if (instance && typeof instance.getData) { | ||
return instance.getData() | ||
.then((value) => { | ||
values.push(value); | ||
return value === 4 | ||
// prevent traversing "4"'s children | ||
? false | ||
: true | ||
} | ||
}) | ||
} | ||
@@ -88,0 +92,0 @@ return true |
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
26565
40
101