node-relation
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,4 +1,7 @@ | ||
import AdvancedArray from './AdvancedArray'; | ||
declare type RelationNode = string | number | Symbol; | ||
declare type Relation = RelationNode[]; | ||
declare type RelationGroup = Relation[]; | ||
declare class Relation extends AdvancedArray<RelationNode> { | ||
} | ||
declare class RelationGroup extends AdvancedArray<Relation> { | ||
} | ||
/** | ||
@@ -5,0 +8,0 @@ * |
@@ -0,1 +1,14 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __values = (this && this.__values) || function(o) { | ||
@@ -32,2 +45,5 @@ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
(function (factory) { | ||
@@ -39,3 +55,3 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
define(["require", "exports", "./AdvancedArray"], factory); | ||
} | ||
@@ -46,2 +62,17 @@ })(function (require, exports) { | ||
exports.dropRelation = exports.getRelationEvery = exports.getRelation = exports.setRelation = exports.deleteNode = exports.getNodes = exports.hasNode = exports.clear = exports.create = void 0; | ||
var AdvancedArray_1 = __importDefault(require("./AdvancedArray")); | ||
var Relation = /** @class */ (function (_super) { | ||
__extends(Relation, _super); | ||
function Relation() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return Relation; | ||
}(AdvancedArray_1.default)); | ||
var RelationGroup = /** @class */ (function (_super) { | ||
__extends(RelationGroup, _super); | ||
function RelationGroup() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return RelationGroup; | ||
}(AdvancedArray_1.default)); | ||
/** | ||
@@ -58,3 +89,3 @@ * | ||
} | ||
var group = []; | ||
var group = new RelationGroup; | ||
try { | ||
@@ -83,3 +114,3 @@ for (var relations_1 = __values(relations), relations_1_1 = relations_1.next(); !relations_1_1.done; relations_1_1 = relations_1.next()) { | ||
function setRelation(group) { | ||
var e_2, _a, e_3, _b, e_4, _c, e_5, _d; | ||
var e_2, _a, e_3, _b, e_4, _c; | ||
var keys = []; | ||
@@ -89,24 +120,11 @@ for (var _i = 1; _i < arguments.length; _i++) { | ||
} | ||
var allKeys = new Set(__spread(keys)); | ||
var totalKeys = new Set; | ||
var lists = new Set; | ||
var allKeys = new AdvancedArray_1.default; | ||
allKeys.push.apply(allKeys, __spread(keys)); | ||
allKeys.deduplication(); | ||
var relations = new AdvancedArray_1.default; | ||
var newReleation = new (Relation.bind.apply(Relation, __spread([void 0], allKeys)))(); | ||
try { | ||
// 새로 받은 key를 보유하고 있는 모든 릴레이션을 받아와 lists 변수에 담습니다. | ||
for (var allKeys_1 = __values(allKeys), allKeys_1_1 = allKeys_1.next(); !allKeys_1_1.done; allKeys_1_1 = allKeys_1.next()) { | ||
var key = allKeys_1_1.value; | ||
try { | ||
for (var group_1 = (e_3 = void 0, __values(group)), group_1_1 = group_1.next(); !group_1_1.done; group_1_1 = group_1.next()) { | ||
var relation = group_1_1.value; | ||
var hasKey = relation.indexOf(key) !== -1; | ||
if (hasKey) | ||
lists.add(relation); | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (group_1_1 && !group_1_1.done && (_b = group_1.return)) _b.call(group_1); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
relations.ensure(getRelation(group, key)); | ||
} | ||
@@ -122,39 +140,28 @@ } | ||
try { | ||
// lists 변수에 담긴 릴레이션을 group 인스턴스에서 삭제합니다. | ||
// 이후 삭제된 릴레이션의 내용물을 prevRelation 변수에 담습니다. | ||
for (var lists_1 = __values(lists), lists_1_1 = lists_1.next(); !lists_1_1.done; lists_1_1 = lists_1.next()) { | ||
var relation = lists_1_1.value; | ||
var i = group.length; | ||
while (i--) { | ||
if (group[i] !== relation) | ||
continue; | ||
group.splice(i, 1); | ||
for (var relations_2 = __values(relations), relations_2_1 = relations_2.next(); !relations_2_1.done; relations_2_1 = relations_2.next()) { | ||
var relation = relations_2_1.value; | ||
try { | ||
for (var relation_1 = (e_4 = void 0, __values(relation)), relation_1_1 = relation_1.next(); !relation_1_1.done; relation_1_1 = relation_1.next()) { | ||
var relationNode = relation_1_1.value; | ||
newReleation.ensure(relationNode); | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
for (var relation_1 = (e_5 = void 0, __values(relation)), relation_1_1 = relation_1.next(); !relation_1_1.done; relation_1_1 = relation_1.next()) { | ||
var key = relation_1_1.value; | ||
totalKeys.add(key); | ||
} | ||
if (relation_1_1 && !relation_1_1.done && (_c = relation_1.return)) _c.call(relation_1); | ||
} | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (relation_1_1 && !relation_1_1.done && (_d = relation_1.return)) _d.call(relation_1); | ||
} | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
group.delete(relation); | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (lists_1_1 && !lists_1_1.done && (_c = lists_1.return)) _c.call(lists_1); | ||
if (relations_2_1 && !relations_2_1.done && (_b = relations_2.return)) _b.call(relations_2); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
// 새로운 릴레이션을 만듭니다. | ||
// 이 배열에는 이전에 prevRelation에 있던 모든 내용을 중복없이 하나로 합쳤습니다. | ||
var newKeys = __spread(allKeys).reduce(function (totalKeys, key) { return totalKeys.add(key); }, totalKeys); | ||
var newRelation = __spread(newKeys); | ||
group.push(newRelation); | ||
group.push(newReleation); | ||
return group; | ||
@@ -169,16 +176,16 @@ } | ||
function getNodes(group) { | ||
var e_6, _a; | ||
var lists = []; | ||
var e_5, _a; | ||
var lists = new Relation; | ||
try { | ||
for (var group_2 = __values(group), group_2_1 = group_2.next(); !group_2_1.done; group_2_1 = group_2.next()) { | ||
var relation = group_2_1.value; | ||
for (var group_1 = __values(group), group_1_1 = group_1.next(); !group_1_1.done; group_1_1 = group_1.next()) { | ||
var relation = group_1_1.value; | ||
lists.push.apply(lists, __spread(relation)); | ||
} | ||
} | ||
catch (e_6_1) { e_6 = { error: e_6_1 }; } | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (group_2_1 && !group_2_1.done && (_a = group_2.return)) _a.call(group_2); | ||
if (group_1_1 && !group_1_1.done && (_a = group_1.return)) _a.call(group_1); | ||
} | ||
finally { if (e_6) throw e_6.error; } | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
@@ -195,19 +202,18 @@ return __spread(new Set(lists)); | ||
function getRelation(group, u) { | ||
var e_7, _a; | ||
var e_6, _a; | ||
try { | ||
for (var group_3 = __values(group), group_3_1 = group_3.next(); !group_3_1.done; group_3_1 = group_3.next()) { | ||
var relation = group_3_1.value; | ||
var hasKey = relation.indexOf(u) !== -1; | ||
if (hasKey) | ||
for (var group_2 = __values(group), group_2_1 = group_2.next(); !group_2_1.done; group_2_1 = group_2.next()) { | ||
var relation = group_2_1.value; | ||
if (relation.has(u)) | ||
return relation; | ||
} | ||
} | ||
catch (e_7_1) { e_7 = { error: e_7_1 }; } | ||
catch (e_6_1) { e_6 = { error: e_6_1 }; } | ||
finally { | ||
try { | ||
if (group_3_1 && !group_3_1.done && (_a = group_3.return)) _a.call(group_3); | ||
if (group_2_1 && !group_2_1.done && (_a = group_2.return)) _a.call(group_2); | ||
} | ||
finally { if (e_7) throw e_7.error; } | ||
finally { if (e_6) throw e_6.error; } | ||
} | ||
return []; | ||
return new Relation; | ||
} | ||
@@ -273,3 +279,3 @@ exports.getRelation = getRelation; | ||
function getRelationEvery(groups) { | ||
var e_8, _a, e_9, _b; | ||
var e_7, _a, e_8, _b; | ||
var keys = []; | ||
@@ -286,3 +292,3 @@ for (var _i = 1; _i < arguments.length; _i++) { | ||
try { | ||
for (var keys_1 = (e_9 = void 0, __values(keys_2)), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) { | ||
for (var keys_1 = (e_8 = void 0, __values(keys_2)), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) { | ||
var key = keys_1_1.value; | ||
@@ -292,3 +298,3 @@ result.add(key); | ||
} | ||
catch (e_9_1) { e_9 = { error: e_9_1 }; } | ||
catch (e_8_1) { e_8 = { error: e_8_1 }; } | ||
finally { | ||
@@ -298,3 +304,3 @@ try { | ||
} | ||
finally { if (e_9) throw e_9.error; } | ||
finally { if (e_8) throw e_8.error; } | ||
} | ||
@@ -307,3 +313,3 @@ else { | ||
} | ||
catch (e_8_1) { e_8 = { error: e_8_1 }; } | ||
catch (e_7_1) { e_7 = { error: e_7_1 }; } | ||
finally { | ||
@@ -313,5 +319,5 @@ try { | ||
} | ||
finally { if (e_8) throw e_8.error; } | ||
finally { if (e_7) throw e_7.error; } | ||
} | ||
return __spread(result); | ||
return new (Relation.bind.apply(Relation, __spread([void 0], result)))(); | ||
} | ||
@@ -326,3 +332,3 @@ exports.getRelationEvery = getRelationEvery; | ||
function getRelationSome(groups) { | ||
var e_10, _a, e_11, _b; | ||
var e_9, _a, e_10, _b; | ||
var keys = []; | ||
@@ -338,3 +344,3 @@ for (var _i = 1; _i < arguments.length; _i++) { | ||
try { | ||
for (var keys_3 = (e_11 = void 0, __values(keys_4)), keys_3_1 = keys_3.next(); !keys_3_1.done; keys_3_1 = keys_3.next()) { | ||
for (var keys_3 = (e_10 = void 0, __values(keys_4)), keys_3_1 = keys_3.next(); !keys_3_1.done; keys_3_1 = keys_3.next()) { | ||
var key = keys_3_1.value; | ||
@@ -344,3 +350,3 @@ result.add(key); | ||
} | ||
catch (e_11_1) { e_11 = { error: e_11_1 }; } | ||
catch (e_10_1) { e_10 = { error: e_10_1 }; } | ||
finally { | ||
@@ -350,7 +356,7 @@ try { | ||
} | ||
finally { if (e_11) throw e_11.error; } | ||
finally { if (e_10) throw e_10.error; } | ||
} | ||
} | ||
} | ||
catch (e_10_1) { e_10 = { error: e_10_1 }; } | ||
catch (e_9_1) { e_9 = { error: e_9_1 }; } | ||
finally { | ||
@@ -360,6 +366,6 @@ try { | ||
} | ||
finally { if (e_10) throw e_10.error; } | ||
finally { if (e_9) throw e_9.error; } | ||
} | ||
return __spread(result); | ||
return new (Relation.bind.apply(Relation, __spread([void 0], result)))(); | ||
} | ||
}); |
{ | ||
"name": "node-relation", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Manage strings that are related to each other.", | ||
@@ -5,0 +5,0 @@ "main": "dist/NodeRelation.js", |
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
25209
7
558