All files / src/internal/views/read-only refuse.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 2/2
100% Lines 2/2

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 20 21 22 23 24 25                      7001x                     52x    
// The error every read-only collection, view, cursor and entry throws for a change.
 
import { NoSuchElementError, UnsupportedOperationError } from '../../../errors/errors'
 
/**
 * The error a refused change throws: `<where>: the collection cannot be changed`.
 *
 * @param where - The API to name: `ImmutableList.add`, `ImmutableList.cursor.remove`, ….
 * @internal
 */
export function refuse(where: string): UnsupportedOperationError {
  return new UnsupportedOperationError(`${where}: the collection cannot be changed`)
}
 
/**
 * The error a read-only view throws for an end of an empty collection: `<where>: the collection is
 * empty`.
 *
 * @param where - The API to name: `UnmodifiableSortedSet.getFirst`, ….
 * @internal
 */
export function empty(where: string): NoSuchElementError {
  return new NoSuchElementError(`${where}: the collection is empty`)
}