@tangle/strategy
Advanced tools
Comparing version 3.0.0 to 3.0.1
28
index.js
@@ -5,3 +5,3 @@ const Validator = require('is-my-json-valid') | ||
const Concat = require('./concat') | ||
const Merge = require('./merge') | ||
const { Merge, IsConflict, IsValidMerge } = require('./merge') | ||
const isValidStrategy = require('./is-valid-strategy') | ||
@@ -49,4 +49,4 @@ const map = require('./map') | ||
this.merge = Merge(composition) | ||
this.isConflict = this.IsConflict(composition) | ||
this.isValidMerge = this.IsValidMerge(composition) | ||
this.isConflict = IsConflict(composition) | ||
this.isValidMerge = IsValidMerge(composition) | ||
} | ||
@@ -61,22 +61,6 @@ | ||
// mapToPure | ||
IsConflict (composition) { | ||
return function (graph, tipIds) { | ||
// graph = a graph containing nodeIds, transforms, previous, and history | ||
// tipIds = the tips of branches in the graph that may be conflicting | ||
return Object.entries(composition).some(([field, strategy]) => { | ||
return strategy.isConflict(graph, tipIds, field) | ||
}) | ||
} | ||
} | ||
// merge | ||
// isConflict | ||
// isValidMerge | ||
IsValidMerge (composition) { | ||
return function (graph, tipId) { | ||
// graph = a graph containing nodeIds, transforms, previous, and history | ||
// tipId = the merge node | ||
return Object.entries(composition).every(([field, strategy]) => { | ||
return strategy.isValidMerge(graph, tipId, field) | ||
}) | ||
} | ||
} | ||
/* Getters */ | ||
@@ -83,0 +67,0 @@ get fields () { return Object.keys(this._composition).sort() } |
38
merge.js
@@ -1,11 +0,33 @@ | ||
module.exports = function Merge (composition) { | ||
// composition is an Object made up of several strategy | ||
module.exports = { | ||
Merge (composition) { | ||
// composition is an Object made up of several strategy | ||
return function (graph, tipId) { | ||
const c = {} | ||
Object.entries(composition).forEach(([field, strategy]) => { | ||
c[field] = strategy.merge(graph, tipId, field) | ||
}) | ||
return c | ||
return function merge (graph, tipId) { | ||
const c = {} | ||
Object.entries(composition).forEach(([field, strategy]) => { | ||
c[field] = strategy.merge(graph, tipId, field) | ||
}) | ||
return c | ||
} | ||
}, | ||
IsConflict (composition) { | ||
return function isConflict (graph, tipIds) { | ||
// graph = a graph containing nodeIds, transforms, previous, and history | ||
// tipIds = the tips of branches in the graph that may be conflicting | ||
return Object.entries(composition).some(([field, strategy]) => { | ||
return strategy.isConflict(graph, tipIds, field) | ||
}) | ||
} | ||
}, | ||
IsValidMerge (composition) { | ||
return function isValidMerge (graph, tipId) { | ||
// graph = a graph containing nodeIds, transforms, previous, and history | ||
// tipId = the merge node | ||
return Object.entries(composition).every(([field, strategy]) => { | ||
return strategy.isValidMerge(graph, tipId, field) | ||
}) | ||
} | ||
} | ||
} |
{ | ||
"name": "@tangle/strategy", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "a toolkit for composing tangle reducing strategies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -34,2 +34,3 @@ # @tangle/strategy | ||
} | ||
const T2 = { | ||
@@ -36,0 +37,0 @@ title: { set: 'Brunch at Mixs' }, |
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
22418
541
156