* @constructor BlockNode * @extends {Node} * Holds a set with blocks * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks * An array with blocks, where a block is constructed as an * Object with properties block, which is a Node, and
(blocks)
| 21 | * is true by default |
| 22 | */ |
| 23 | constructor (blocks) { |
| 24 | super() |
| 25 | // validate input, copy blocks |
| 26 | if (!Array.isArray(blocks)) throw new Error('Array expected') |
| 27 | this.blocks = blocks.map(function (block) { |
| 28 | const node = block && block.node |
| 29 | const visible = block && |
| 30 | block.visible !== undefined |
| 31 | ? block.visible |
| 32 | : true |
| 33 | |
| 34 | if (!isNode(node)) throw new TypeError('Property "node" must be a Node') |
| 35 | if (typeof visible !== 'boolean') { throw new TypeError('Property "visible" must be a boolean') } |
| 36 | |
| 37 | return { node, visible } |
| 38 | }) |
| 39 | } |
| 40 | |
| 41 | static name = name |
| 42 | get type () { return name } |