Skip to content

Commit

Permalink
4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nullice committed Apr 23, 2018
1 parent f0dcafb commit cd6dd05
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ ArrayBuffer to Buffer
| --- | --- | --- |
| object | <code>object</code> | |
| eachFunc | <code>function</code> | 处理函数 |
| [checkCycle] | <code>boolean</code> | 是否检查循环引用 |
| [checkCycle] | <code>boolean</code> \| <code>function</code> | 是否检查循环引用,为 true 会跳过循环引用,还可以提供一个函数 checkCycleCallback(target,path) 来处理一些事 |

<a name="StringSTR"></a>

Expand Down
15 changes: 12 additions & 3 deletions dist/Richang.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,15 @@ var ObjectOBJ = {
*
* @param {object} object
* @param {function} eachFunc 处理函数
* @param {boolean} [checkCycle] 是否检查循环引用
* @param {boolean|function} [checkCycle] 是否检查循环引用,为 true 会跳过循环引用,还可以提供一个函数 checkCycleCallback(target, path, cyclePath) 来处理一些事
*/
pathEach: function pathEach(object, eachFunc, checkCycle) {

if (checkCycle) {
var useCycleCallback = typeof checkCycle === "function";
var cycleCache = new WeakMap();
cycleCache.set(object, true);

cycleCache.set(object, useCycleCallback ? [] : true);
}

_each(object, [], 0);
Expand All @@ -377,9 +379,16 @@ var ObjectOBJ = {
// 检查循环引用
if (checkCycle && (typeof item === "undefined" ? "undefined" : _typeof(item)) === "object") {
if (cycleCache.get(item)) {
if (useCycleCallback) {
checkCycle(item, path, cycleCache.get(item));
}
continue; // >_< 忽略循环引用
} else {
cycleCache.set(item, true);
if (useCycleCallback) {
cycleCache.set(item, [].concat(toConsumableArray(path), [key]));
} else {
cycleCache.set(item, true);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/Richang.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/RichangEs.bundle.js

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions dist/RichangEs.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,15 @@ var ObjectOBJ = {
*
* @param {object} object
* @param {function} eachFunc 处理函数
* @param {boolean} [checkCycle] 是否检查循环引用
* @param {boolean|function} [checkCycle] 是否检查循环引用,为 true 会跳过循环引用,还可以提供一个函数 checkCycleCallback(target, path, cyclePath) 来处理一些事
*/
pathEach: function pathEach(object, eachFunc, checkCycle) {

if (checkCycle) {
var useCycleCallback = typeof checkCycle === "function";
var cycleCache = new WeakMap();
cycleCache.set(object, true);

cycleCache.set(object, useCycleCallback ? [] : true);
}

_each(object, [], 0);
Expand All @@ -371,9 +373,16 @@ var ObjectOBJ = {
// 检查循环引用
if (checkCycle && (typeof item === "undefined" ? "undefined" : _typeof(item)) === "object") {
if (cycleCache.get(item)) {
if (useCycleCallback) {
checkCycle(item, path, cycleCache.get(item));
}
continue; // >_< 忽略循环引用
} else {
cycleCache.set(item, true);
if (useCycleCallback) {
cycleCache.set(item, [].concat(toConsumableArray(path), [key]));
} else {
cycleCache.set(item, true);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/RichangNode.bundle.js

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions dist/RichangNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1428,13 +1428,15 @@ var ObjectOBJ = {
*
* @param {object} object
* @param {function} eachFunc 处理函数
* @param {boolean} [checkCycle] 是否检查循环引用
* @param {boolean|function} [checkCycle] 是否检查循环引用,为 true 会跳过循环引用,还可以提供一个函数 checkCycleCallback(target, path, cyclePath) 来处理一些事
*/
pathEach: function pathEach(object, eachFunc, checkCycle) {

if (checkCycle) {
var useCycleCallback = typeof checkCycle === "function";
var cycleCache = new WeakMap();
cycleCache.set(object, true);

cycleCache.set(object, useCycleCallback ? [] : true);
}

_each(object, [], 0);
Expand All @@ -1449,9 +1451,16 @@ var ObjectOBJ = {
// 检查循环引用
if (checkCycle && (typeof item === "undefined" ? "undefined" : _typeof(item)) === "object") {
if (cycleCache.get(item)) {
if (useCycleCallback) {
checkCycle(item, path, cycleCache.get(item));
}
continue; // >_< 忽略循环引用
} else {
cycleCache.set(item, true);
if (useCycleCallback) {
cycleCache.set(item, [].concat(toConsumableArray(path), [key]));
} else {
cycleCache.set(item, true);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/RichangNode.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/RichangNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ ArrayBuffer to Buffer
| --- | --- | --- |
| object | <code>object</code> | |
| eachFunc | <code>function</code> | 处理函数 |
| [checkCycle] | <code>boolean</code> | 是否检查循环引用 |
| [checkCycle] | <code>boolean</code> \| <code>function</code> | 是否检查循环引用,为 true 会跳过循环引用,还可以提供一个函数 checkCycleCallback(target,path) 来处理一些事 |

<a name="StringSTR"></a>

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "richang.js",
"version": "4.1.1",
"version": "4.3.0",
"description": "richang js code.",
"main": "dist/Richang.js",
"module": "dist/RichangEs.js",
"jsnext:main": "dist/RichangEs.js",
"scripts": {
"test": "jest",
"test-coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls",
"build-and-publish": "npm run build && npm run build-min && npm run build-node-bundle && npm run doc && npm run publish",
"build-and-publish": "npm run build-all && windows-gen-d.ts && npm run doc && npm run publish",
"publish": "npm publish --registry=https://registry.npmjs.org/ --disturl=/",
"watch": "rollup -c -w",
"build": "rollup -c",
Expand Down

0 comments on commit cd6dd05

Please sign in to comment.