Function isEmpty

  • Category

    Check if a readonly Map is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • map: ReadonlyMap<unknown, unknown>

      The Map to check

    Returns map is ReadonlyMap<never, never>

    true if map is empty, false otherwise

    Map

    isEmpty(new Map([1, 2, 3])); // false
    
    isEmpty(new Map()); // true
    
  • Category

    Check if a Map is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • map: Map<unknown, unknown>

      The Map to check

    Returns map is Map<never, never>

    true if map is empty, false otherwise

    Map

    isEmpty(new Map([['a', 1], ['b', 2], ['c', 3]])); // false
    
    isEmpty(new Map()); // true
    
  • Category

    Check if a readonly Set is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • set: ReadonlySet<unknown>

      The Set to check

    Returns set is ReadonlySet<never>

    true if set is empty, false otherwise

    Set

    isEmpty(new Set([1, 2, 3])); // false
    
    isEmpty(new Set()); // true
    
  • Category

    Check if a Set is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • set: Set<unknown>

      The Set to check

    Returns set is Set<never>

    true if set is empty, false otherwise

    Set

    isEmpty(new Set([1, 2, 3])); // false
    
    isEmpty(new Set()); // true
    
  • Category

    Check if a string is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • string: string

      The string to check

    Returns string is ""

    true if string is empty, false otherwise

    String

    isEmpty('hello'); // false
    
    isEmpty(''); // true
    
  • Category

    Check if a readonly array is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • array: readonly unknown[]

      The array to check

    Returns array is readonly []

    true if array is empty, false otherwise

    Array

    isEmpty([1, 2, 3]); // false
    
    isEmpty([]); // true
    
  • Category

    Check if an array is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • array: unknown[]

      The array to check

    Returns array is []

    true if array is empty, false otherwise

    Array

    isEmpty([1, 2, 3]); // false
    
    isEmpty([]); // true
    
  • Category

    Check if an iterable is empty.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • iterable: Iterable<unknown>

      The iterable to check

    Returns iterable is Iterable<never>

    true if iterable is empty, false otherwise

    Iterable

    isEmpty([1, 2, 3]); // false
    
    isEmpty([]); // true