Beispiel #1
0
const onReadersUpdate = message => {
  each(([id, descriptor]) => {
    if (descriptor) {
      readers[id] = parse(descriptor);
    }
    else {
      delete readers[id];
    }
  }, pairs(message.data));
};
  setup: function(params={}) {
    const { sidebars } = validate(this, params);

    this.sidebars = sidebars;

    each(([key, Sidebar]) => {
      const { label } = validate(Sidebar.prototype);
      const { id } = Sidebar.prototype;

      /* TODO register sidebar */
      registerSidebar({
        id: id,
        sidebarClass: Sidebar
      });

    }, pairs(sidebars));

    gDevTools.on("inspector-ready", onInspectorReady);
  },
Beispiel #3
0
exports["test pairs"] = assert => {
  assert.deepEqual([...pairs(null)], [], "pairs on null is empty");
  assert.deepEqual([...pairs(void(0))], [], "pairs on void is empty");
  assert.deepEqual([...pairs({})], [], "empty sequence");
  assert.deepEqual([...pairs({a: 1})], [["a", 1]], "single pair");
  assert.deepEqual([...pairs({a: 1, b: 2, c: 3})].sort(),
                   [["a", 1], ["b", 2], ["c", 3]],
                   "creates pairs");
  let items = [];
  for (let [key, value] of pairs({a: 1, b: 2, c: 3}))
    items.push([key, value]);

  assert.deepEqual(items.sort(),
                   [["a", 1], ["b", 2], ["c", 3]],
                   "for of works on pairs");


  assert.deepEqual([...pairs([])], [], "pairs on empty array is empty");
  assert.deepEqual([...pairs([1])], [[0, 1]], "pairs on array is [index, element]");
  assert.deepEqual([...pairs([1, 2, 3])],
                   [[0, 1], [1, 2], [2, 3]],
                   "for arrays it pair of [index, element]");

  assert.deepEqual([...pairs("")], [], "pairs on empty string is empty");
  assert.deepEqual([...pairs("a")], [[0, "a"]], "pairs on char is [0, char]");
  assert.deepEqual([...pairs("hello")],
                   [[0, "h"], [1, "e"], [2, "l"], [3, "l"], [4, "o"]],
                   "for strings it's pair of [index, char]");

  assert.deepEqual([...pairs(new Map())],
                   [],
                   "pairs on empty map is empty");
  assert.deepEqual([...pairs(new Map([[1, 3]]))],
                   [[1, 3]],
                   "pairs on single mapping single mapping");
  assert.deepEqual([...pairs(new Map([[1, 2], [3, 4]]))],
                   [[1, 2], [3, 4]],
                   "pairs on map returs key vaule pairs");

  assert.throws(() => pairs(new Set()),
                "can't pair set");

  assert.throws(() => pairs(4),
                "can't pair number");

  assert.throws(() => pairs(true),
                "can't pair boolean");
};
Beispiel #4
0
 assert.throws(() => pairs(true),
Beispiel #5
0
 assert.throws(() => pairs(4),
Beispiel #6
0
 assert.throws(() => pairs(new Set()),
Beispiel #7
0
const read = node =>
  object(...map(([id, read]) => [id, read(node, id)], pairs(readers)));