ancient-graph-spreading
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -1,2 +0,2 @@ | ||
#### 0.0.7 (2016-9-24) | ||
#### 0.0.8 (2016-9-26) | ||
@@ -9,2 +9,5 @@ ##### Documentation Changes | ||
* **queue:** | ||
* Callback support ([795e56c6](https://github.com/AncientSouls/GraphSpreading/commit/795e56c60c1bf1c411780af06a2992e17c36c84e)) | ||
* Removeв duplicate methods from queue ([1a27a350](https://github.com/AncientSouls/GraphSpreading/commit/1a27a3504fb8a9556f701c98d05545bee19531f0)) | ||
* **launched:** Manager of field launched move out of Path and Spreader graph. ([11f82123](https://github.com/AncientSouls/GraphSpreading/commit/11f82123a61ea82bc0bde50f43addb7c35ec22bb)) | ||
@@ -31,1 +34,5 @@ * **each:** Move each into custom async callbacks method in class. ([30a7653c](https://github.com/AncientSouls/GraphSpreading/commit/30a7653c8704dda963f554facc963d6f0849c08c)) | ||
##### Refactors | ||
* **queue:** Rename mayBeEndedLaunched to removeFromLaunched ([f845211b](https://github.com/AncientSouls/GraphSpreading/commit/f845211b03dddc1136ba1a5accc51d62709891c4)) | ||
140
lib/queue.js
@@ -55,4 +55,4 @@ 'use strict'; | ||
}, { | ||
key: 'mayBeEndedLaunched', | ||
value: function mayBeEndedLaunched(launchedLinkId, launchedToRemove) { | ||
key: 'removeFromLaunched', | ||
value: function removeFromLaunched(launchedLinkId, launchedToRemove) { | ||
var launchedGraph = this._getGraph(launchedLinkId); | ||
@@ -76,3 +76,4 @@ this.graphSpreading.spreadGraph.count({ process: launchedLinkId }, undefined, function (error, count) { | ||
/** | ||
* Reacts to insert a new path. | ||
* Reacts to insert a new path and reacts to update launched remove unspread, but spread still exists. This method triggers the first step of the second spread queue. | ||
* If passed callback, then not be called removeFromLaunched. | ||
* | ||
@@ -82,11 +83,12 @@ * @param {PathGraph} pathGraph | ||
* @param {string[]} pathLink.launched - ['spread'] | ||
* @param {Function} [callback] | ||
*/ | ||
}, { | ||
key: 'insertedPathLink', | ||
value: function insertedPathLink(pathGraph, pathLink) { | ||
key: 'spreadByPath', | ||
value: function spreadByPath(pathGraph, pathLink, callback) { | ||
var _this = this; | ||
this.graphSpreading.spreadByPathLink(pathGraph, pathLink, { process: pathLink.id }, undefined, function () { | ||
_this.mayBeEndedLaunched(pathLink.id, 'spread'); | ||
if (callback) callback();else _this.removeFromLaunched(pathLink.id, 'spread'); | ||
}); | ||
@@ -96,3 +98,4 @@ } | ||
/** | ||
* Reacts to update source or target in path. Then it launched two queues, unspread and spread. This method triggers the first step of the first unspread queue. After removal of unspread from launched from path, you need to start the second queue with method updatedLaunchedUnspreadPathLink. | ||
* Reacts to remove path and reacts to update source or target in path. Then it launched two queues, unspread and spread. This method triggers the first step of the first unspread queue. After removal of unspread from launched from path, you need to start the second queue with method spreadByPath. | ||
* If passed callback, then not be called removeFromLaunched. | ||
* | ||
@@ -102,11 +105,12 @@ * @param {PathGraph} pathGraph | ||
* @param {string[]} pathLink.launched - ['unspread', 'spread'] | ||
* @param {Function} [callback] | ||
*/ | ||
}, { | ||
key: 'updatedSourceOrTargetPathLink', | ||
value: function updatedSourceOrTargetPathLink(pathGraph, pathLink) { | ||
key: 'unspreadByPath', | ||
value: function unspreadByPath(pathGraph, pathLink, callback) { | ||
var _this2 = this; | ||
this.graphSpreading.unspreadByPathId(pathLink.id, { process: pathLink.id }, undefined, function () { | ||
_this2.mayBeEndedLaunched(pathLink.id, 'unspread'); | ||
if (callback) callback();else _this2.removeFromLaunched(pathLink.id, 'unspread'); | ||
}); | ||
@@ -116,35 +120,4 @@ } | ||
/** | ||
* Reacts to update launched remove unspread, but spread still exists. This method triggers the first step of the second spread queue. | ||
* | ||
* @param {PathGraph} pathGraph | ||
* @param {PathLink} pathLink | ||
* @param {string[]} pathLink.launched - ['spread'] | ||
*/ | ||
}, { | ||
key: 'updatedLaunchedUnspreadPathLink', | ||
value: function updatedLaunchedUnspreadPathLink(pathGraph, pathLink) { | ||
this.insertedPathLink(pathGraph, pathLink); | ||
} | ||
/** | ||
* Reacts to remove path. Similar to the method updatedSourceOrTargetPathLink, but the work is gone with pathGraph.removed. | ||
* | ||
* @param {PathGraph} pathGraph | ||
* @param {PathLink} pathLink | ||
* @param {string[]} pathLink.launched - ['unspread'] | ||
*/ | ||
}, { | ||
key: 'removedPathLink', | ||
value: function removedPathLink(pathGraph, pathLink) { | ||
var _this3 = this; | ||
this.graphSpreading.unspreadByPathId(pathLink.id, { process: pathLink.id }, undefined, function () { | ||
_this3.mayBeEndedLaunched(pathLink.id, 'unspread'); | ||
}); | ||
} | ||
/** | ||
* Reacts to insert new spread link. Link can be inserted with field process as step in queue or with field launched as start of queue. | ||
* If passed callback, then not be called removeFromLaunched. | ||
* | ||
@@ -154,8 +127,9 @@ * @param {SpreadLink} spreadLink | ||
* @param {string[]} [pathLink.process] | ||
* @param {Function} [callback] | ||
*/ | ||
}, { | ||
key: 'insertedSpreadLink', | ||
value: function insertedSpreadLink(spreadLink) { | ||
var _this4 = this; | ||
key: 'spreadBySpread', | ||
value: function spreadBySpread(spreadLink, callback) { | ||
var _this3 = this; | ||
@@ -174,5 +148,5 @@ var context = {}, | ||
if (process) { | ||
_this4.graphSpreading.spreadGraph.update(spreadLink.id, { process: { remove: context.process } }); | ||
_this3.graphSpreading.spreadGraph.update(spreadLink.id, { process: { remove: context.process } }); | ||
} | ||
_this4.mayBeEndedLaunched(context.process, 'spread'); | ||
if (callback) callback();else _this3.removeFromLaunched(context.process, 'spread'); | ||
}); | ||
@@ -183,10 +157,12 @@ } | ||
* Reacts to remove spread link. | ||
* If passed callback, then not be called removeFromLaunched. | ||
* | ||
* @param {SpreadLink} spreadLink | ||
* @param {Function} [callback] | ||
*/ | ||
}, { | ||
key: 'removedSpreadLink', | ||
value: function removedSpreadLink(spreadLink) { | ||
var _this5 = this; | ||
key: 'unspreadBySpread', | ||
value: function unspreadBySpread(spreadLink, callback) { | ||
var _this4 = this; | ||
@@ -205,7 +181,7 @@ var context = { process: {} }, | ||
} | ||
this.graphSpreading.unspreadFromRemovedSpreadLinkByPrevId(spreadLink.id, context, undefined, function () { | ||
this.graphSpreading.unspreadFromunspreadBySpreadByPrevId(spreadLink.id, context, undefined, function () { | ||
if (process) { | ||
_this5.graphSpreading.spreadGraph.removed.update(spreadLink.id, { process: { remove: context.process } }); | ||
_this4.graphSpreading.spreadGraph.removed.update(spreadLink.id, { process: { remove: context.process } }); | ||
} | ||
_this5.mayBeEndedLaunched(launched, 'unspread'); | ||
if (callback) callback();else _this4.removeFromLaunched(launched, 'unspread'); | ||
}); | ||
@@ -215,3 +191,4 @@ } | ||
/** | ||
* Reacts to insert a new spreader. | ||
* Reacts to insert a new spreader and reacts to update launched remove unspread, but spread still exists. This method triggers the first step of the second spread queue. | ||
* If passed callback, then not be called removeFromLaunched. | ||
* | ||
@@ -221,12 +198,13 @@ * @param {SpreaderGraph} spreaderGraph | ||
* @param {string[]} spreaderLink.launched - ['spread'] | ||
* @param {Function} [callback] | ||
*/ | ||
}, { | ||
key: 'insertedSpreaderLink', | ||
value: function insertedSpreaderLink(spreaderGraph, spreaderLink) { | ||
key: 'spreadBySpreader', | ||
value: function spreadBySpreader(spreaderGraph, spreaderLink, callback) { | ||
var _graphSpreading$sprea, | ||
_this6 = this; | ||
_this5 = this; | ||
this.graphSpreading.spreadNewSpreadLink((_graphSpreading$sprea = {}, _defineProperty(_graphSpreading$sprea, this.graphSpreading.spreadGraph.constantField, spreaderLink[spreaderGraph.constantField]), _defineProperty(_graphSpreading$sprea, this.graphSpreading.spreadGraph.variableField, spreaderLink[spreaderGraph.variableField]), _defineProperty(_graphSpreading$sprea, 'spreader', spreaderLink.id), _graphSpreading$sprea), { process: spreaderLink.id }, function () { | ||
_this6.mayBeEndedLaunched(spreaderLink.id, 'spread'); | ||
if (callback) callback();else _this5.removeFromLaunched(spreaderLink.id, 'spread'); | ||
}); | ||
@@ -236,3 +214,4 @@ } | ||
/** | ||
* Reacts to update source or target in spreader. Then it launched two queues, unspread and spread. This method triggers the first step of the first unspread queue. After removal of unspread from launched from spreader, you need to start the second queue with method updatedLaunchedUnspreadSpreaderLink. | ||
* Reacts to remove spreader link and reacts to update source or target in spreader. Then it launched two queues, unspread and spread. This method triggers the first step of the first unspread queue. After removal of unspread from launched from spreader, you need to start the second queue with method spreadBySpreader. | ||
* If passed callback, then not be called removeFromLaunched. | ||
* | ||
@@ -242,8 +221,9 @@ * @param {SpreaderGraph} spreaderGraph | ||
* @param {string[]} spreaderLink.launched - ['unspread', 'spread'] | ||
* @param {Function} [callback] | ||
*/ | ||
}, { | ||
key: 'updatedSourceOrTargetSpreaderLink', | ||
value: function updatedSourceOrTargetSpreaderLink(spreaderGraph, spreaderLink) { | ||
var _this7 = this; | ||
key: 'unspreadBySpreader', | ||
value: function unspreadBySpreader(spreaderGraph, spreaderLink, callback) { | ||
var _this6 = this; | ||
@@ -253,39 +233,5 @@ this.graphSpreading.spreadGraph.remove({ | ||
}, function (error, count) { | ||
_this7.mayBeEndedLaunched(spreaderLink.id, 'unspread'); | ||
if (callback) callback();else _this6.removeFromLaunched(spreaderLink.id, 'unspread'); | ||
}, { modifier: { process: { add: spreaderLink.id } } }); | ||
} | ||
/** | ||
* Reacts to update launched remove unspread, but spread still exists. This method triggers the first step of the second spread queue. | ||
* | ||
* @param {SpreaderGraph} spreaderGraph | ||
* @param {SpreaderLink} spreaderLink | ||
* @param {string[]} spreaderLink.launched - ['spread'] | ||
*/ | ||
}, { | ||
key: 'updatedLaunchedUnspreadSpreaderLink', | ||
value: function updatedLaunchedUnspreadSpreaderLink(spreaderGraph, spreaderLink) { | ||
this.insertedSpreaderLink(spreaderGraph, spreaderLink); | ||
} | ||
/** | ||
* Reacts to remove spreader link. Similar to the method updatedSourceOrTargetSpreaderLink, but the work is gone with spreaderGraph.removed. | ||
* | ||
* @param {SpreaderGraph} spreaderGraph | ||
* @param {SpreaderLink} spreaderLink | ||
* @param {string[]} spreaderLink.launched - ['unspread'] | ||
*/ | ||
}, { | ||
key: 'removedSpreaderLink', | ||
value: function removedSpreaderLink(spreaderGraph, spreaderLink) { | ||
var _this8 = this; | ||
this.graphSpreading.spreadGraph.remove({ | ||
spreader: spreaderLink.id | ||
}, function (error, count) { | ||
_this8.mayBeEndedLaunched(spreaderLink.id, 'unspread'); | ||
}, { modifier: { process: { add: spreaderLink.id } } }); | ||
} | ||
}]); | ||
@@ -292,0 +238,0 @@ |
@@ -296,9 +296,9 @@ 'use strict'; | ||
* @param {Object} [context] | ||
* @param {GraphSpreading~unspreadFromRemovedSpreadLinkByPrevIdHandler} [handler] | ||
* @param {GraphSpreading~unspreadFromRemovedSpreadLinkByPrevIdCallback} [callback] | ||
* @param {GraphSpreading~unspreadFromunspreadBySpreadByPrevIdHandler} [handler] | ||
* @param {GraphSpreading~unspreadFromunspreadBySpreadByPrevIdCallback} [callback] | ||
*/ | ||
}, { | ||
key: 'unspreadFromRemovedSpreadLinkByPrevId', | ||
value: function unspreadFromRemovedSpreadLinkByPrevId(spreadLinkId, context, handler, callback) { | ||
key: 'unspreadFromunspreadBySpreadByPrevId', | ||
value: function unspreadFromunspreadBySpreadByPrevId(spreadLinkId, context, handler, callback) { | ||
var _this9 = this; | ||
@@ -329,3 +329,3 @@ | ||
* | ||
* @callback GraphSpreading~unspreadFromRemovedSpreadLinkByPrevIdHandler | ||
* @callback GraphSpreading~unspreadFromunspreadBySpreadByPrevIdHandler | ||
* @param {Error} [error] | ||
@@ -338,3 +338,3 @@ * @param {SpreadLink} [spreadLink] | ||
* | ||
* @callback GraphSpreading~unspreadFromRemovedSpreadLinkByPrevIdCallback | ||
* @callback GraphSpreading~unspreadFromunspreadBySpreadByPrevIdCallback | ||
* @param {Error} [error] | ||
@@ -341,0 +341,0 @@ * @param {number} [count] |
{ | ||
"name": "ancient-graph-spreading", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Automatic maintenance spreading of graph according other graphs.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -19,3 +19,3 @@ 'use strict'; | ||
function testQueue(generageGraphSpreading, ids) { | ||
it('#insertedPathLink', function (done) { | ||
it('#spreadByPath', function (done) { | ||
var _generageGraphSpreadi = generageGraphSpreading(); | ||
@@ -32,9 +32,9 @@ | ||
spreadGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreadLink(newLink); | ||
queueSpreading.spreadBySpread(newLink); | ||
}); | ||
spreadGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedSpreadLink(oldLink); | ||
queueSpreading.unspreadBySpread(oldLink); | ||
}); | ||
pathGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedPathLink(pathGraph, newLink); | ||
queueSpreading.spreadByPath(pathGraph, newLink); | ||
}); | ||
@@ -60,3 +60,3 @@ pathGraph.on('update', function (oldLink, newLink) { | ||
}); | ||
it('#updatedSourceOrTargetPathLink #updatedLaunchedUnspreadPathLink', function (done) { | ||
it('#unspreadByPath #spreadByPath', function (done) { | ||
var _generageGraphSpreadi2 = generageGraphSpreading(); | ||
@@ -73,13 +73,13 @@ | ||
spreadGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreadLink(newLink); | ||
queueSpreading.spreadBySpread(newLink); | ||
}); | ||
spreadGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedSpreadLink(oldLink); | ||
queueSpreading.unspreadBySpread(oldLink); | ||
}); | ||
pathGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedPathLink(pathGraph, newLink); | ||
queueSpreading.spreadByPath(pathGraph, newLink); | ||
}); | ||
pathGraph.on('update', function (oldLink, newLink) { | ||
if (oldLink.source != newLink.source || oldLink.target != newLink.target) { | ||
queueSpreading.updatedSourceOrTargetPathLink(pathGraph, newLink); | ||
queueSpreading.unspreadByPath(pathGraph, newLink); | ||
} else if (!_lodash2.default.isEqual(oldLink.launched, newLink.launched)) { | ||
@@ -113,3 +113,3 @@ if (newLink.id == mainPathLink && newLink.launched == 0) { | ||
} else { | ||
queueSpreading.updatedLaunchedUnspreadPathLink(pathGraph, newLink); | ||
queueSpreading.spreadByPath(pathGraph, newLink); | ||
} | ||
@@ -129,3 +129,3 @@ } | ||
it('#removedPathLink', function (done) { | ||
it('#unspreadByPath', function (done) { | ||
var _generageGraphSpreadi3 = generageGraphSpreading(); | ||
@@ -142,19 +142,19 @@ | ||
spreadGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreadLink(newLink); | ||
queueSpreading.spreadBySpread(newLink); | ||
}); | ||
spreadGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedSpreadLink(oldLink); | ||
queueSpreading.unspreadBySpread(oldLink); | ||
}); | ||
pathGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedPathLink(pathGraph, newLink); | ||
queueSpreading.spreadByPath(pathGraph, newLink); | ||
}); | ||
pathGraph.on('update', function (oldLink, newLink) { | ||
if (oldLink.source != newLink.source || oldLink.target != newLink.target) { | ||
queueSpreading.updatedSourceOrTargetPathLink(pathGraph, newLink); | ||
queueSpreading.unspreadByPath(pathGraph, newLink); | ||
} else if (!_lodash2.default.isEqual(oldLink.launched, newLink.launched)) { | ||
queueSpreading.updatedLaunchedUnspreadPathLink(pathGraph, newLink); | ||
queueSpreading.spreadByPath(pathGraph, newLink); | ||
} | ||
}); | ||
pathGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedPathLink(pathGraph, oldLink); | ||
queueSpreading.unspreadByPath(pathGraph, oldLink); | ||
}); | ||
@@ -161,0 +161,0 @@ pathGraph.removed.on('update', function (oldLink, newLink) { |
@@ -19,3 +19,3 @@ 'use strict'; | ||
function testSpreader(generageGraphSpreading, ids) { | ||
it('#insertedSpreaderLink', function (done) { | ||
it('#spreadBySpreader', function (done) { | ||
var _generageGraphSpreadi = generageGraphSpreading(); | ||
@@ -31,10 +31,10 @@ | ||
spreadGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreadLink(newLink); | ||
queueSpreading.spreadBySpread(newLink); | ||
}); | ||
spreadGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedSpreadLink(oldLink); | ||
queueSpreading.unspreadBySpread(oldLink); | ||
}); | ||
spreaderGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreaderLink(spreaderGraph, newLink); | ||
queueSpreading.spreadBySpreader(spreaderGraph, newLink); | ||
}); | ||
@@ -70,3 +70,3 @@ | ||
it('#updatedSourceOrTargetSpreaderLink #updatedLaunchedUnspreadSpreaderLink', function (done) { | ||
it('#unspreadBySpreader #spreadBySpreader', function (done) { | ||
var _generageGraphSpreadi2 = generageGraphSpreading(); | ||
@@ -82,10 +82,10 @@ | ||
spreadGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreadLink(newLink); | ||
queueSpreading.spreadBySpread(newLink); | ||
}); | ||
spreadGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedSpreadLink(oldLink); | ||
queueSpreading.unspreadBySpread(oldLink); | ||
}); | ||
spreaderGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreaderLink(spreaderGraph, newLink); | ||
queueSpreading.spreadBySpreader(spreaderGraph, newLink); | ||
}); | ||
@@ -95,3 +95,3 @@ | ||
if (oldLink.source != newLink.source || oldLink.target != newLink.target) { | ||
queueSpreading.updatedSourceOrTargetSpreaderLink(spreaderGraph, newLink); | ||
queueSpreading.unspreadBySpreader(spreaderGraph, newLink); | ||
} else { | ||
@@ -102,3 +102,3 @@ if (newLink.target == ids[1]) { | ||
if (newLink.launched.length) { | ||
queueSpreading.updatedLaunchedUnspreadSpreaderLink(spreaderGraph, newLink); | ||
queueSpreading.spreadBySpreader(spreaderGraph, newLink); | ||
} else { | ||
@@ -131,3 +131,3 @@ spreadGraph.fetch({}, undefined, function (error, results) { | ||
it('#removedSpreaderLink', function (done) { | ||
it('#unspreadBySpreader', function (done) { | ||
var _generageGraphSpreadi3 = generageGraphSpreading(); | ||
@@ -143,10 +143,10 @@ | ||
spreadGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreadLink(newLink); | ||
queueSpreading.spreadBySpread(newLink); | ||
}); | ||
spreadGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedSpreadLink(oldLink); | ||
queueSpreading.unspreadBySpread(oldLink); | ||
}); | ||
spreaderGraph.on('insert', function (oldLink, newLink) { | ||
queueSpreading.insertedSpreaderLink(spreaderGraph, newLink); | ||
queueSpreading.spreadBySpreader(spreaderGraph, newLink); | ||
}); | ||
@@ -158,3 +158,3 @@ spreaderGraph.on('update', function (oldLink, newLink) { | ||
spreaderGraph.on('remove', function (oldLink, newLink) { | ||
queueSpreading.removedSpreaderLink(spreaderGraph, oldLink); | ||
queueSpreading.unspreadBySpreader(spreaderGraph, oldLink); | ||
}); | ||
@@ -161,0 +161,0 @@ |
@@ -163,3 +163,3 @@ 'use strict'; | ||
it('#unspreadFromRemovedSpreadLinkByPrevId', function (done) { | ||
it('#unspreadFromunspreadBySpreadByPrevId', function (done) { | ||
var _generateGraphSpreadi3 = generateGraphSpreading(); | ||
@@ -177,3 +177,3 @@ | ||
spreadGraph.remove(spreadLinkId0, function (error, count) { | ||
graphSpreading.unspreadFromRemovedSpreadLinkByPrevId(spreadLinkId0, function (error, spreadLink1) { | ||
graphSpreading.unspreadFromunspreadBySpreadByPrevId(spreadLinkId0, function (error, spreadLink1) { | ||
_chai.assert.ifError(error); | ||
@@ -180,0 +180,0 @@ }, function (error, count) { |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
204116
1688