javascript-collections-framework
    Preparing search index...

    Function unmodifiableSortedMap

    • Returns a read-only view of a sorted map: as unmodifiableSequencedMap, with nearest-entry navigation (floorEntry, ceilingEntry, …), the comparator, range views and a sorted key set, all unmodifiable too.

      When map is already a view this function returns (printed as UnmodifiableSortedMap), it is returned unchanged. When it is any other unmodifiable view or immutable collection from this copy of the library, the new view reads that collection's source instead, and entries it hands out stay read-only, so read-only wrappers never nest.

      Time: O(1); each operation costs what the map's costs.

      Type Parameters

      • K
      • V

      Parameters

      Returns ReadonlySortedMap<K, V>

      map itself, or an unmodifiable view printed as UnmodifiableSortedMap.

      TypeError when map is not a sorted map from this library.

      const levels = new TreeMap([[10, 'low'], [50, 'high']])
      unmodifiableSortedMap(levels).floorEntry(30)?.value // 'low'