| 8501 | } |
| 8502 | |
| 8503 | function createEventEmitter(value) { |
| 8504 | var handlers = []; |
| 8505 | return { |
| 8506 | on: function on(handler) { |
| 8507 | handlers.push(handler); |
| 8508 | }, |
| 8509 | off: function off(handler) { |
| 8510 | handlers = handlers.filter(function (h) { |
| 8511 | return h !== handler; |
| 8512 | }); |
| 8513 | }, |
| 8514 | get: function get() { |
| 8515 | return value; |
| 8516 | }, |
| 8517 | set: function set(newValue, changedBits) { |
| 8518 | value = newValue; |
| 8519 | handlers.forEach(function (handler) { |
| 8520 | return handler(value, changedBits); |
| 8521 | }); |
| 8522 | } |
| 8523 | }; |
| 8524 | } |
| 8525 | |
| 8526 | function onlyChild(children) { |
| 8527 | return Array.isArray(children) ? children[0] : children; |