All files / src/hooks/hub hub.ts

100% Statements 3/3
100% Branches 4/4
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 204x                               4x 413x    
import { Hub } from '../../RuneHub'
 
/**
 * Gets the currently active hub.
 * Returns the current hub if one is active, otherwise returns the root hub.
 * @returns The current or root hub instance
 * @example
 * ```ts
 * const customHub = new Hub()
 *
 * customHub.use(() => {
 *   console.log(hub() === customHub)
 *   // true
 * })
 * ```
 */
export function hub () {
  return Hub.cur ?? Hub.root
}