*/ function timeout($seconds = 0): Promise { $promise = new Promise; Loop\setTimeout([$promise, 'fulfill'], $seconds); return $promise; } /** * Returns the closest node of a specific type * * @param Node $node * @param string $type The node class name * @return Node|null $type */ function getClosestNode(Node $node, string $type) { $n = $node; while ($n = $n->getAttribute('parentNode')) { if ($n instanceof $type) { return $n; } } }