Example #1
0
suite.test("decomposeObjectValues", () => {
    assertThat(Util.decomposeObjectValues({})).isEqualTo([]);
    assertThat(Util.decomposeObjectValues({a: "x"})).isEqualTo(["x"]);
    assertThat(Util.decomposeObjectValues({a: {b: "y"}})).isEqualTo([{b: "y"}]);
    assertThat(Util.decomposeObjectValues({a: "x", b: "y"})).isEqualTo(["x", "y"]);
    assertThat(Util.decomposeObjectValues({b: "y", a: "x"})).isEqualTo(["x", "y"]);
    assertThat(Util.decomposeObjectValues({a: []})).isEqualTo([]);
    assertThat(Util.decomposeObjectValues({a: [1, 2, 3]})).isEqualTo([1, 2, 3]);
    assertThat(Util.decomposeObjectValues({a: [1, 2, 3], b: "x", c: [4, 5]})).isEqualTo([1, 2, 3, "x", 4, 5]);
    assertThat(Util.decomposeObjectValues({a: [1, [2, 4], 3]})).isEqualTo([1, 2, 4, 3]);
    assertThat(Util.decomposeObjectValues({a: [1, [], 3]})).isEqualTo([1, 3]);
});
Example #2
0
File: Gate.js Project: perak/Quirk
 /**
  * @param {T} gatesObj
  * @returns {T}
  * @template T
  */
 static makeFamily(gatesObj) {
     let oldGates = Util.decomposeObjectValues(gatesObj);
     let newGates = oldGates.map(e => e._copy());
     for (let g of newGates) {
         g.gateFamily = newGates;
     }
     return Util.recomposedObjectValues(gatesObj, newGates);
 }