jtaro-module
Advanced tools
+1
-1
| { | ||
| "name": "jtaro-module", | ||
| "version": "0.3.2", | ||
| "version": "0.3.3", | ||
| "description": "Explain the ES6 module to Es5 syntax", | ||
@@ -5,0 +5,0 @@ "main": "src/server.js", |
+20
-1
@@ -1,2 +0,2 @@ | ||
| /*! JTaro-Module client.js v0.3.2 ~ (c) 2017-2018 Author:BarZu Git:https://github.com/chjtx/JTaro-Module/ */ | ||
| /*! JTaro-Module client.js v0.3.3 ~ (c) 2017-2018 Author:BarZu Git:https://github.com/chjtx/JTaro-Module/ */ | ||
| /* global io */ | ||
@@ -50,2 +50,3 @@ /** | ||
| if (!fathers[i].children) fathers[i].children = [] | ||
| // 匹配来源 | ||
| if (fathers[i].path === child.from) { | ||
@@ -65,2 +66,6 @@ hasThisChild = false | ||
| pushIntoFather(child, fathers[i].children) | ||
| if (fathers[i].path === child.path) { | ||
| // 子树已存在该树中 | ||
| findChildFrom(child.path, fathers[i].children, child.path) | ||
| } | ||
| } | ||
@@ -70,2 +75,16 @@ } | ||
| // 查找是否循环引用 | ||
| function findChildFrom (p, children, childPath) { | ||
| for (var i = 0, l = children.length; i < l; i++) { | ||
| if (children[i].path === childPath) { | ||
| console.error('Can\'t cyclic import! `' + p + ' -> ' + children[i].path + '`') | ||
| return | ||
| } else { | ||
| if (children[i].children && children[i].children.length) { | ||
| findChildFrom(p + ' -> ' + children[i].path, children[i].children, childPath) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // 从父级移除 | ||
@@ -72,0 +91,0 @@ function removeFromFather (child, fathers) { |
35752
1.96%701
2.64%