is-what
    Preparing search index...

    Function isInstanceOf

    • Checks if a value is an instance of a class or a class name. Useful when you want to check if a value is an instance of a class that may not be defined in the current scope. For example, if you want to check if a value is an OffscreenCanvas instance, you might not want to do the song and dance of using typeof OffscreenCanvas !== 'undefined' and then shimming OffscreenCanvas if the types aren't around.

      Type Parameters

      Parameters

      • value: unknown

        The value to recursively check

      • class_: T

        A string or class that the value should be an instance of

      Returns value is T

      if (isInstanceOf(value, 'OffscreenCanvas')) {
      // value is an OffscreenCanvas
      }
    • Checks if a value is an instance of a class or a class name. Useful when you want to check if a value is an instance of a class that may not be defined in the current scope. For example, if you want to check if a value is an OffscreenCanvas instance, you might not want to do the song and dance of using typeof OffscreenCanvas !== 'undefined' and then shimming OffscreenCanvas if the types aren't around.

      Type Parameters

      • K extends GlobalClassName

      Parameters

      • value: unknown

        The value to recursively check

      • className: K

      Returns value is typeof globalThis[K]

      if (isInstanceOf(value, 'OffscreenCanvas')) {
      // value is an OffscreenCanvas
      }
    • Checks if a value is an instance of a class or a class name. Useful when you want to check if a value is an instance of a class that may not be defined in the current scope. For example, if you want to check if a value is an OffscreenCanvas instance, you might not want to do the song and dance of using typeof OffscreenCanvas !== 'undefined' and then shimming OffscreenCanvas if the types aren't around.

      Parameters

      • value: unknown

        The value to recursively check

      • className: string

      Returns value is object

      if (isInstanceOf(value, 'OffscreenCanvas')) {
      // value is an OffscreenCanvas
      }