@devsnicket/eunice-dependency-and-structure
Advanced tools
Comparing version 1.4.1 to 2.0.0
@@ -8,4 +8,4 @@ require("array.prototype.flat") | ||
const | ||
findChildItemsAndCreateDependsUpon = require("./findChildItemsAndCreateDependsUpon"), | ||
findItemWithIdentifierFromStack = require("./findItemWithIdentifierFromStack"), | ||
findItemsOfDependsUponOrGetIdentifiers = require("./findItemsOfDependsUponOrGetIdentifiers"), | ||
updateItem = require("./updateItem"); | ||
@@ -31,18 +31,18 @@ | ||
updateItem({ | ||
dependsUponItems: | ||
item.dependsUpon.flatMap(findItemsFromDependsUpon), | ||
dependsUpon: | ||
item.dependsUpon.flatMap(findItemsAndCreateDependsUpon), | ||
item, | ||
}); | ||
function findItemsFromDependsUpon( | ||
dependsUpon, | ||
function findItemsAndCreateDependsUpon( | ||
dependUpon, | ||
) { | ||
return ( | ||
findItemsWhenString() | ||
whenString() | ||
|| | ||
findItemsOfDependsUponOrGetIdentifiers({ | ||
dependsUpon, | ||
dependsUponItem: | ||
findChildItemsAndCreateDependsUpon({ | ||
dependUpon, | ||
parent: | ||
findItemWithIdentifier( | ||
dependsUpon.id, | ||
dependUpon.id, | ||
), | ||
@@ -52,12 +52,15 @@ }) | ||
function findItemsWhenString() { | ||
function whenString() { | ||
return ( | ||
typeof dependsUpon === "string" | ||
typeof dependUpon === "string" | ||
&& | ||
[ | ||
findItemWithIdentifier( | ||
dependsUpon, | ||
) | ||
|| | ||
dependsUpon, | ||
{ | ||
item: | ||
findItemWithIdentifier( | ||
dependUpon, | ||
) | ||
|| | ||
dependUpon, | ||
}, | ||
] | ||
@@ -64,0 +67,0 @@ ); |
module.exports = | ||
({ | ||
dependsUponItems, | ||
dependsUpon, | ||
item, | ||
}) => { | ||
item.dependsUpon = dependsUponItems; | ||
item.dependsUpon = dependsUpon; | ||
for (const dependsUponItem of dependsUponItems) | ||
if (typeof dependsUponItem === "object") | ||
for (const { item: dependUponItem } of dependsUpon) | ||
if (typeof dependUponItem === "object") | ||
addDependent({ | ||
dependent: item, | ||
item: dependsUponItem, | ||
item: dependUponItem, | ||
}); | ||
@@ -14,0 +14,0 @@ }; |
const | ||
createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -45,3 +46,3 @@ | ||
child.dependsUpon = [ level[1] ]; | ||
child.dependsUpon = mapItemsToDependsUpon([ level[1] ]); | ||
level[1].dependents = [ child ]; | ||
@@ -48,0 +49,0 @@ |
const | ||
testDependsUponChildMissingFromMissing = require("./testDependsUponChildMissingFromMissing"), | ||
testDependsUponMissing = require("./testDependsUponMissing"), | ||
testDependsUponTwoChildrenMissingFromMissing = require("./testDependsUponTwoChildrenMissingFromMissing"), | ||
testFirstDependsUponChildMissingFromSecond = require("./testFirstDependsUponChildMissingFromSecond"), | ||
testFirstDependsUponChildOfSecond = require("./testFirstDependsUponChildOfSecond"), | ||
@@ -12,3 +15,6 @@ testFirstDependsUponSecond = require("./testFirstDependsUponSecond"), | ||
() => { | ||
testDependsUponChildMissingFromMissing(); | ||
testDependsUponMissing(); | ||
testDependsUponTwoChildrenMissingFromMissing(); | ||
testFirstDependsUponChildMissingFromSecond(); | ||
testFirstDependsUponChildOfSecond(); | ||
@@ -15,0 +21,0 @@ testFirstDependsUponSecond(); |
const | ||
createItemYaml = require("../../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../../testCreateStackFromYaml"); | ||
@@ -10,3 +11,3 @@ | ||
stack[0][0].dependsUpon = [ "missing" ]; | ||
stack[0][0].dependsUpon = mapItemsToDependsUpon([ "missing" ]); | ||
@@ -13,0 +14,0 @@ testCreateStackFromYaml({ |
@@ -25,3 +25,3 @@ const | ||
level[0].dependsUpon = [ child ]; | ||
level[0].dependsUpon = [ { item: child, parent: level[1] } ]; | ||
child.dependents = [ level[0] ]; | ||
@@ -37,4 +37,9 @@ | ||
createItemYaml({ | ||
dependsUpon: { id: "item2", items: "child" }, | ||
id: "item1", | ||
dependsUpon: | ||
{ | ||
id: "item2", | ||
items: "child", | ||
}, | ||
id: | ||
"item1", | ||
}), | ||
@@ -41,0 +46,0 @@ createItemYaml({ |
const | ||
createItemYaml = require("../../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../../testCreateStackFromYaml"); | ||
@@ -20,3 +21,3 @@ | ||
level[0].dependsUpon = [ level[1] ]; | ||
level[0].dependsUpon = mapItemsToDependsUpon([ level[1] ]); | ||
level[1].dependents = [ level[0] ]; | ||
@@ -23,0 +24,0 @@ |
@@ -31,3 +31,13 @@ const | ||
level[0].dependsUpon = [ children[0], children[1] ]; | ||
level[0].dependsUpon = | ||
[ | ||
{ | ||
item: children[0], | ||
parent: level[1], | ||
}, | ||
{ | ||
item: children[1], | ||
parent: level[1], | ||
}, | ||
]; | ||
children[0].dependents = [ level[0] ]; | ||
@@ -44,4 +54,9 @@ children[1].dependents = [ level[0] ]; | ||
createItemYaml({ | ||
dependsUpon: { id: "item2", items: [ "child1", "child2" ] }, | ||
id: "item1", | ||
dependsUpon: | ||
{ | ||
id: "item2", | ||
items: [ "child1", "child2" ], | ||
}, | ||
id: | ||
"item1", | ||
}), | ||
@@ -48,0 +63,0 @@ createItemYaml({ |
const | ||
createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -42,4 +43,4 @@ | ||
level[0].dependsUpon = [ level[2] ]; | ||
level[1].dependsUpon = [ level[2] ]; | ||
level[0].dependsUpon = mapItemsToDependsUpon([ level[2] ]); | ||
level[1].dependsUpon = mapItemsToDependsUpon([ level[2] ]); | ||
@@ -46,0 +47,0 @@ level[2].dependents = [ level[0], level[1] ]; |
const | ||
createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -50,3 +51,3 @@ | ||
firstChild.dependsUpon = [ parent ]; | ||
firstChild.dependsUpon = mapItemsToDependsUpon([ parent ]); | ||
parent.dependents = [ firstChild ]; | ||
@@ -53,0 +54,0 @@ } |
const | ||
createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -46,3 +47,3 @@ | ||
items[0].dependsUpon = [ child ]; | ||
items[0].dependsUpon = mapItemsToDependsUpon([ child ]); | ||
child.dependents = [ items[0] ]; | ||
@@ -49,0 +50,0 @@ |
const | ||
createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -59,3 +60,3 @@ | ||
items[0].dependsUpon = [ grandchild ]; | ||
items[0].dependsUpon = mapItemsToDependsUpon([ grandchild ]); | ||
grandchild.dependents = [ items[0] ]; | ||
@@ -62,0 +63,0 @@ |
@@ -5,2 +5,3 @@ const | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -31,3 +32,3 @@ | ||
parent.dependsUpon = [ child ]; | ||
parent.dependsUpon = mapItemsToDependsUpon([ child ]); | ||
child.dependents = [ parent ]; | ||
@@ -60,3 +61,3 @@ | ||
child.dependsUpon = [ parent ]; | ||
child.dependsUpon = mapItemsToDependsUpon([ parent ]); | ||
parent.dependents = [ child ]; | ||
@@ -63,0 +64,0 @@ |
const | ||
createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -28,5 +29,5 @@ | ||
item.dependsUpon = mapItemsToDependsUpon([ item ]); | ||
item.dependents = [ item ]; | ||
item.dependsUpon = [ item ]; | ||
} | ||
}; |
const | ||
createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -29,4 +30,4 @@ | ||
child.dependsUpon = mapItemsToDependsUpon([ child ]); | ||
child.dependents = [ child ]; | ||
child.dependsUpon = [ child ]; | ||
@@ -68,4 +69,4 @@ return stack; | ||
parent.dependsUpon = mapItemsToDependsUpon([ parent ]); | ||
parent.dependents = [ parent ]; | ||
parent.dependsUpon = [ parent ]; | ||
@@ -72,0 +73,0 @@ return stack; |
@@ -5,2 +5,3 @@ const | ||
createUpperAndLowerStack = require("../../../tests/createUpperAndLowerStack"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -35,3 +36,3 @@ | ||
upper.dependsUpon = [ lower ]; | ||
upper.dependsUpon = mapItemsToDependsUpon([ lower ]); | ||
lower.dependents = [ upper ]; | ||
@@ -64,3 +65,3 @@ | ||
lower.dependsUpon = [ upper ]; | ||
lower.dependsUpon = mapItemsToDependsUpon([ upper ]); | ||
upper.dependents = [ lower ]; | ||
@@ -67,0 +68,0 @@ |
@@ -77,5 +77,5 @@ module.exports = createYamlFromStack; | ||
? | ||
getIdentifierPropertyOrValue(dependsUpon[0]) | ||
createDependUpon(dependsUpon[0]) | ||
: | ||
dependsUpon.map(getIdentifierPropertyOrValue), | ||
dependsUpon.map(createDependUpon), | ||
} | ||
@@ -85,6 +85,12 @@ ); | ||
function getIdentifierPropertyOrValue( | ||
value, | ||
function createDependUpon( | ||
dependUpon, | ||
) { | ||
return value.id || value; | ||
return getIdentifierPropertyOrValue(dependUpon.item); | ||
function getIdentifierPropertyOrValue( | ||
value, | ||
) { | ||
return value.id || value; | ||
} | ||
} | ||
@@ -91,0 +97,0 @@ |
@@ -5,4 +5,4 @@ require("array.prototype.flat").shim(); | ||
const findItemWithIdentifierFromStack = require("./findItemWithIdentifierFromStack"), | ||
findItemsOfDependsUponOrGetIdentifiers = require("./findItemsOfDependsUponOrGetIdentifiers"), | ||
const findChildItemsAndCreateDependsUpon = require("./findChildItemsAndCreateDependsUpon"), | ||
findItemWithIdentifierFromStack = require("./findItemWithIdentifierFromStack"), | ||
updateItem = require("./updateItem"); | ||
@@ -21,14 +21,16 @@ | ||
if (item.dependsUpon) updateItem({ | ||
dependsUponItems: item.dependsUpon.flatMap(findItemsFromDependsUpon), | ||
dependsUpon: item.dependsUpon.flatMap(findItemsAndCreateDependsUpon), | ||
item | ||
}); | ||
function findItemsFromDependsUpon(dependsUpon) { | ||
return findItemsWhenString() || findItemsOfDependsUponOrGetIdentifiers({ | ||
dependsUpon, | ||
dependsUponItem: findItemWithIdentifier(dependsUpon.id) | ||
function findItemsAndCreateDependsUpon(dependUpon) { | ||
return whenString() || findChildItemsAndCreateDependsUpon({ | ||
dependUpon, | ||
parent: findItemWithIdentifier(dependUpon.id) | ||
}); | ||
function findItemsWhenString() { | ||
return typeof dependsUpon === "string" && [findItemWithIdentifier(dependsUpon) || dependsUpon]; | ||
function whenString() { | ||
return typeof dependUpon === "string" && [{ | ||
item: findItemWithIdentifier(dependUpon) || dependUpon | ||
}]; | ||
} | ||
@@ -35,0 +37,0 @@ |
module.exports = ({ | ||
dependsUponItems, | ||
dependsUpon, | ||
item | ||
}) => { | ||
item.dependsUpon = dependsUponItems; | ||
item.dependsUpon = dependsUpon; | ||
for (const dependsUponItem of dependsUponItems) if (typeof dependsUponItem === "object") addDependent({ | ||
dependent: item, | ||
item: dependsUponItem | ||
}); | ||
for (const _ref of dependsUpon) { | ||
const { item: dependUponItem } = _ref; | ||
if (typeof dependUponItem === "object") addDependent({ | ||
dependent: item, | ||
item: dependUponItem | ||
}); | ||
} | ||
}; | ||
@@ -12,0 +16,0 @@ |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -28,3 +29,3 @@ | ||
child.dependsUpon = [level[1]]; | ||
child.dependsUpon = mapItemsToDependsUpon([level[1]]); | ||
level[1].dependents = [child]; | ||
@@ -31,0 +32,0 @@ |
@@ -1,2 +0,5 @@ | ||
const testDependsUponMissing = require("./testDependsUponMissing"), | ||
const testDependsUponChildMissingFromMissing = require("./testDependsUponChildMissingFromMissing"), | ||
testDependsUponMissing = require("./testDependsUponMissing"), | ||
testDependsUponTwoChildrenMissingFromMissing = require("./testDependsUponTwoChildrenMissingFromMissing"), | ||
testFirstDependsUponChildMissingFromSecond = require("./testFirstDependsUponChildMissingFromSecond"), | ||
testFirstDependsUponChildOfSecond = require("./testFirstDependsUponChildOfSecond"), | ||
@@ -7,3 +10,6 @@ testFirstDependsUponSecond = require("./testFirstDependsUponSecond"), | ||
module.exports = () => describe("mapping", () => { | ||
testDependsUponChildMissingFromMissing(); | ||
testDependsUponMissing(); | ||
testDependsUponTwoChildrenMissingFromMissing(); | ||
testFirstDependsUponChildMissingFromSecond(); | ||
testFirstDependsUponChildOfSecond(); | ||
@@ -10,0 +16,0 @@ testFirstDependsUponSecond(); |
const createItemYaml = require("../../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../../testCreateStackFromYaml"); | ||
@@ -8,3 +9,3 @@ | ||
stack[0][0].dependsUpon = ["missing"]; | ||
stack[0][0].dependsUpon = mapItemsToDependsUpon(["missing"]); | ||
@@ -11,0 +12,0 @@ testCreateStackFromYaml({ |
@@ -15,3 +15,3 @@ const createItemYaml = require("../../../../tests/createItemYaml"), | ||
level[0].dependsUpon = [child]; | ||
level[0].dependsUpon = [{ item: child, parent: level[1] }]; | ||
child.dependents = [level[0]]; | ||
@@ -23,3 +23,6 @@ | ||
yaml: [[createItemYaml({ | ||
dependsUpon: { id: "item2", items: "child" }, | ||
dependsUpon: { | ||
id: "item2", | ||
items: "child" | ||
}, | ||
id: "item1" | ||
@@ -26,0 +29,0 @@ }), createItemYaml({ |
const createItemYaml = require("../../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../../testCreateStackFromYaml"); | ||
@@ -10,3 +11,3 @@ | ||
level[0].dependsUpon = [level[1]]; | ||
level[0].dependsUpon = mapItemsToDependsUpon([level[1]]); | ||
level[1].dependents = [level[0]]; | ||
@@ -13,0 +14,0 @@ |
@@ -15,3 +15,9 @@ const createItemYaml = require("../../../../tests/createItemYaml"), | ||
level[0].dependsUpon = [children[0], children[1]]; | ||
level[0].dependsUpon = [{ | ||
item: children[0], | ||
parent: level[1] | ||
}, { | ||
item: children[1], | ||
parent: level[1] | ||
}]; | ||
children[0].dependents = [level[0]]; | ||
@@ -24,3 +30,6 @@ children[1].dependents = [level[0]]; | ||
yaml: [[createItemYaml({ | ||
dependsUpon: { id: "item2", items: ["child1", "child2"] }, | ||
dependsUpon: { | ||
id: "item2", | ||
items: ["child1", "child2"] | ||
}, | ||
id: "item1" | ||
@@ -27,0 +36,0 @@ }), createItemYaml({ |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -25,4 +26,4 @@ | ||
level[0].dependsUpon = [level[2]]; | ||
level[1].dependsUpon = [level[2]]; | ||
level[0].dependsUpon = mapItemsToDependsUpon([level[2]]); | ||
level[1].dependsUpon = mapItemsToDependsUpon([level[2]]); | ||
@@ -29,0 +30,0 @@ level[2].dependents = [level[0], level[1]]; |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -31,3 +32,3 @@ | ||
firstChild.dependsUpon = [parent]; | ||
firstChild.dependsUpon = mapItemsToDependsUpon([parent]); | ||
parent.dependents = [firstChild]; | ||
@@ -34,0 +35,0 @@ } |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -27,3 +28,3 @@ | ||
items[0].dependsUpon = [child]; | ||
items[0].dependsUpon = mapItemsToDependsUpon([child]); | ||
child.dependents = [items[0]]; | ||
@@ -30,0 +31,0 @@ |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -33,3 +34,3 @@ | ||
items[0].dependsUpon = [grandchild]; | ||
items[0].dependsUpon = mapItemsToDependsUpon([grandchild]); | ||
grandchild.dependents = [items[0]]; | ||
@@ -36,0 +37,0 @@ |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createParentChildLevels = require("../../../tests/createParentChildLevels"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -25,3 +26,3 @@ | ||
parent.dependsUpon = [child]; | ||
parent.dependsUpon = mapItemsToDependsUpon([child]); | ||
child.dependents = [parent]; | ||
@@ -49,3 +50,3 @@ | ||
child.dependsUpon = [parent]; | ||
child.dependsUpon = mapItemsToDependsUpon([parent]); | ||
parent.dependents = [child]; | ||
@@ -52,0 +53,0 @@ |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -24,6 +25,6 @@ | ||
item.dependsUpon = mapItemsToDependsUpon([item]); | ||
item.dependents = [item]; | ||
item.dependsUpon = [item]; | ||
} | ||
}; | ||
//# sourceMappingURL=testSelfDependent.js.map |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -24,4 +25,4 @@ | ||
child.dependsUpon = mapItemsToDependsUpon([child]); | ||
child.dependents = [child]; | ||
child.dependsUpon = [child]; | ||
@@ -54,4 +55,4 @@ return stack; | ||
parent.dependsUpon = mapItemsToDependsUpon([parent]); | ||
parent.dependents = [parent]; | ||
parent.dependsUpon = [parent]; | ||
@@ -58,0 +59,0 @@ return stack; |
const createItemYaml = require("../../../tests/createItemYaml"), | ||
createStackFromLevels = require("../../../tests/createStackFromLevels"), | ||
createUpperAndLowerStack = require("../../../tests/createUpperAndLowerStack"), | ||
mapItemsToDependsUpon = require("../../../tests/mapItemsToDependsUpon"), | ||
testCreateStackFromYaml = require("../testCreateStackFromYaml"); | ||
@@ -24,3 +25,3 @@ | ||
upper.dependsUpon = [lower]; | ||
upper.dependsUpon = mapItemsToDependsUpon([lower]); | ||
lower.dependents = [upper]; | ||
@@ -45,3 +46,3 @@ | ||
lower.dependsUpon = [upper]; | ||
lower.dependsUpon = mapItemsToDependsUpon([upper]); | ||
upper.dependents = [lower]; | ||
@@ -48,0 +49,0 @@ |
@@ -41,8 +41,12 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
return dependsUpon && { | ||
dependsUpon: dependsUpon.length === 1 ? getIdentifierPropertyOrValue(dependsUpon[0]) : dependsUpon.map(getIdentifierPropertyOrValue) | ||
dependsUpon: dependsUpon.length === 1 ? createDependUpon(dependsUpon[0]) : dependsUpon.map(createDependUpon) | ||
}; | ||
} | ||
function getIdentifierPropertyOrValue(value) { | ||
return value.id || value; | ||
function createDependUpon(dependUpon) { | ||
return getIdentifierPropertyOrValue(dependUpon.item); | ||
function getIdentifierPropertyOrValue(value) { | ||
return value.id || value; | ||
} | ||
} | ||
@@ -49,0 +53,0 @@ |
@@ -19,3 +19,3 @@ /* istanbul ignore file: test would be a mirror of implementation */ | ||
* @typedef Item | ||
* @property {(Item | String)[]} [dependsUpon] | ||
* @property {(DependUpon|DependUponMissingItem|DependUponMissingParent)[]} [dependsUpon] | ||
* @property {Item[]} [dependents] | ||
@@ -26,2 +26,14 @@ * @property {String} [id] | ||
* | ||
* @typedef DependUpon | ||
* @property {Item} item | ||
* @property {Item} [parent] | ||
* | ||
* @typedef DependUponMissingItem | ||
* @property {String} item | ||
* @property {Item} [parent] | ||
* | ||
* @typedef DependUponMissingParent | ||
* @property {String} item | ||
* @property {String} [parent] | ||
* | ||
* @typedef {String | (String | YamlItem | (String | YamlItem)[])[]} Yaml | ||
@@ -28,0 +40,0 @@ * |
14
index.js
@@ -21,3 +21,3 @@ /* istanbul ignore file: test would be a mirror of implementation */ | ||
* @typedef Item | ||
* @property {(Item | String)[]} [dependsUpon] | ||
* @property {(DependUpon|DependUponMissingItem|DependUponMissingParent)[]} [dependsUpon] | ||
* @property {Item[]} [dependents] | ||
@@ -28,2 +28,14 @@ * @property {String} [id] | ||
* | ||
* @typedef DependUpon | ||
* @property {Item} item | ||
* @property {Item} [parent] | ||
* | ||
* @typedef DependUponMissingItem | ||
* @property {String} item | ||
* @property {Item} [parent] | ||
* | ||
* @typedef DependUponMissingParent | ||
* @property {String} item | ||
* @property {String} [parent] | ||
* | ||
* @typedef {String | (String | YamlItem | (String | YamlItem)[])[]} Yaml | ||
@@ -30,0 +42,0 @@ * |
@@ -65,3 +65,3 @@ { | ||
}, | ||
"version": "1.4.1" | ||
"version": "2.0.0" | ||
} |
@@ -8,2 +8,3 @@ const | ||
formatStackForDescription = require("../formatStackForDescription"), | ||
mapItemsToDependsUpon = require("../mapItemsToDependsUpon"), | ||
testDependencyBetweenTwoItem = require("./testDependencyBetweenTwoItem"), | ||
@@ -105,3 +106,3 @@ testFirstDependsUponSecondAndThird = require("./testFirstDependsUponSecondAndThird"); | ||
{ | ||
dependsUpon: [ "missing" ], | ||
dependsUpon: mapItemsToDependsUpon([ "missing" ]), | ||
id: "item1", | ||
@@ -108,0 +109,0 @@ }, |
const | ||
createFirstAndSecondLevel = require("./createFirstAndSecondLevel"), | ||
createItemYaml = require("../createItemYaml"), | ||
createStackFromLevels = require("../createStackFromLevels"); | ||
createStackFromLevels = require("../createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../mapItemsToDependsUpon"); | ||
@@ -37,3 +38,3 @@ module.exports = | ||
first.dependsUpon = [ second ]; | ||
first.dependsUpon = [ { item: second } ]; | ||
second.dependents = [ first ]; | ||
@@ -66,3 +67,3 @@ | ||
second.dependsUpon = [ first ]; | ||
second.dependsUpon = mapItemsToDependsUpon([ first ]); | ||
first.dependents = [ second ]; | ||
@@ -69,0 +70,0 @@ |
const | ||
createItemYaml = require("../createItemYaml"), | ||
createStackFromLevels = require("../createStackFromLevels"); | ||
createStackFromLevels = require("../createStackFromLevels"), | ||
mapItemsToDependsUpon = require("../mapItemsToDependsUpon"); | ||
@@ -37,3 +38,3 @@ module.exports = | ||
level[0].dependsUpon = dependentItems; | ||
level[0].dependsUpon = mapItemsToDependsUpon(dependentItems); | ||
@@ -40,0 +41,0 @@ dependentItems[0].dependents = |
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
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
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
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
144004
101
2652