Options
All
  • Public
  • Public/Protected
  • All
Menu

Package map

@typed/map

Useful functions for working immutable ReadonlyMaps.

Index

Variables

Const appendTo

appendTo: { <A, B>(key: A, value: B, map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>; <A, B>(key: A, value: B): (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>>; <A, B>(key: A): { (value: B, map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>; (value: B): (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>> } } = curry(__appendTo)

Type declaration

    • <A, B>(key: A, value: B, map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>
    • <A, B>(key: A, value: B): (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>>
    • <A, B>(key: A): { (value: B, map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>; (value: B): (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>> }
    • Type parameters

      • A

      • B

      Parameters

      • key: A
      • value: B
      • map: ReadonlyMap<A, ReadonlyArray<B>>

      Returns ReadonlyMap<A, ReadonlyArray<B>>

    • Type parameters

      • A

      • B

      Parameters

      • key: A
      • value: B

      Returns (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>>

        • (map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>
        • Parameters

          • map: ReadonlyMap<A, ReadonlyArray<B>>

          Returns ReadonlyMap<A, ReadonlyArray<B>>

    • Type parameters

      • A

      • B

      Parameters

      • key: A

      Returns { (value: B, map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>; (value: B): (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>> }

        • (value: B, map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>
        • (value: B): (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>>
        • Parameters

          • value: B
          • map: ReadonlyMap<A, ReadonlyArray<B>>

          Returns ReadonlyMap<A, ReadonlyArray<B>>

        • Parameters

          • value: B

          Returns (map: ReadonlyMap<A, ReadonlyArray<B>>) => ReadonlyMap<A, ReadonlyArray<B>>

            • (map: ReadonlyMap<A, ReadonlyArray<B>>): ReadonlyMap<A, ReadonlyArray<B>>
            • Parameters

              • map: ReadonlyMap<A, ReadonlyArray<B>>

              Returns ReadonlyMap<A, ReadonlyArray<B>>

Const collectBy

collectBy: { <A, B>(fn: Arity1<A, B>, iterable: Iterable<A>): ReadonlyMap<B, ReadonlyArray<A>>; <A, B>(fn: Arity1<A, B>): (iterable: Iterable<A>) => ReadonlyMap<B, ReadonlyArray<A>> } = curry(__collectBy)

Index an Iterable into a ReadonlyMap

Type declaration

    • <A, B>(fn: Arity1<A, B>, iterable: Iterable<A>): ReadonlyMap<B, ReadonlyArray<A>>
    • <A, B>(fn: Arity1<A, B>): (iterable: Iterable<A>) => ReadonlyMap<B, ReadonlyArray<A>>
    • Type parameters

      • A

      • B

      Parameters

      • fn: Arity1<A, B>
      • iterable: Iterable<A>

      Returns ReadonlyMap<B, ReadonlyArray<A>>

    • Type parameters

      • A

      • B

      Parameters

      Returns (iterable: Iterable<A>) => ReadonlyMap<B, ReadonlyArray<A>>

        • (iterable: Iterable<A>): ReadonlyMap<B, ReadonlyArray<A>>
        • Parameters

          • iterable: Iterable<A>

          Returns ReadonlyMap<B, ReadonlyArray<A>>

Const forEach

forEach: { <A, B>(fn: Arity2<A, B>, map: ReadonlyMap<A, B>): ReadonlyMap<A, B>; <A, B>(fn: Arity2<A, B>): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B> } = curry(__forEach)

Type declaration

    • <A, B>(fn: Arity2<A, B>, map: ReadonlyMap<A, B>): ReadonlyMap<A, B>
    • <A, B>(fn: Arity2<A, B>): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B>
    • Type parameters

      • A

      • B

      Parameters

      • fn: Arity2<A, B>
      • map: ReadonlyMap<A, B>

      Returns ReadonlyMap<A, B>

    • Type parameters

      • A

      • B

      Parameters

      Returns (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B>

        • (map: ReadonlyMap<A, B>): ReadonlyMap<A, B>
        • Parameters

          • map: ReadonlyMap<A, B>

          Returns ReadonlyMap<A, B>

Const getOr

getOr: { <A, B>(key: A, fallback: IO<B>, map: ReadonlyMap<A, B>): B; <A, B>(key: A, fallback: IO<B>): (map: ReadonlyMap<A, B>) => B; <A>(key: A): { <B>(fallback: IO<B>, map: ReadonlyMap<A, B>): B; <B>(fallback: IO<B>): (map: ReadonlyMap<A, B>) => B } } = curry(function getOr<A, B>(key: A, fallback: IO<B>, map: ReadonlyMap<A, B>): B {return map.has(key) ? map.get(key)! : fallback()})

Type declaration

    • <A, B>(key: A, fallback: IO<B>, map: ReadonlyMap<A, B>): B
    • <A, B>(key: A, fallback: IO<B>): (map: ReadonlyMap<A, B>) => B
    • <A>(key: A): { <B>(fallback: IO<B>, map: ReadonlyMap<A, B>): B; <B>(fallback: IO<B>): (map: ReadonlyMap<A, B>) => B }
    • Type parameters

      • A

      • B

      Parameters

      • key: A
      • fallback: IO<B>
      • map: ReadonlyMap<A, B>

      Returns B

    • Type parameters

      • A

      • B

      Parameters

      • key: A
      • fallback: IO<B>

      Returns (map: ReadonlyMap<A, B>) => B

        • (map: ReadonlyMap<A, B>): B
        • Parameters

          • map: ReadonlyMap<A, B>

          Returns B

    • Type parameters

      • A

      Parameters

      • key: A

      Returns { <B>(fallback: IO<B>, map: ReadonlyMap<A, B>): B; <B>(fallback: IO<B>): (map: ReadonlyMap<A, B>) => B }

        • <B>(fallback: IO<B>, map: ReadonlyMap<A, B>): B
        • <B>(fallback: IO<B>): (map: ReadonlyMap<A, B>) => B
        • Type parameters

          • B

          Parameters

          • fallback: IO<B>
          • map: ReadonlyMap<A, B>

          Returns B

        • Type parameters

          • B

          Parameters

          • fallback: IO<B>

          Returns (map: ReadonlyMap<A, B>) => B

            • (map: ReadonlyMap<A, B>): B
            • Parameters

              • map: ReadonlyMap<A, B>

              Returns B

Const has

has: { <A, B>(value: A, set: ReadonlyMap<A, B>): boolean; <A>(value: A): <B>(set: ReadonlyMap<A, B>) => boolean } = curry(__has)

Type declaration

    • <A, B>(value: A, set: ReadonlyMap<A, B>): boolean
    • <A>(value: A): <B>(set: ReadonlyMap<A, B>) => boolean
    • Type parameters

      • A

      • B

      Parameters

      • value: A
      • set: ReadonlyMap<A, B>

      Returns boolean

    • Type parameters

      • A

      Parameters

      • value: A

      Returns <B>(set: ReadonlyMap<A, B>) => boolean

        • <B>(set: ReadonlyMap<A, B>): boolean
        • Type parameters

          • B

          Parameters

          • set: ReadonlyMap<A, B>

          Returns boolean

Const map

map: { <A, B, C>(fn: Arity2<A, B, C>, map: ReadonlyMap<A, B>): ReadonlyMap<A, C>; <A, B, C>(fn: Arity2<A, B, C>): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, C> } = curry(__map)

Type declaration

    • <A, B, C>(fn: Arity2<A, B, C>, map: ReadonlyMap<A, B>): ReadonlyMap<A, C>
    • <A, B, C>(fn: Arity2<A, B, C>): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, C>
    • Type parameters

      • A

      • B

      • C

      Parameters

      • fn: Arity2<A, B, C>
      • map: ReadonlyMap<A, B>

      Returns ReadonlyMap<A, C>

    • Type parameters

      • A

      • B

      • C

      Parameters

      Returns (map: ReadonlyMap<A, B>) => ReadonlyMap<A, C>

        • (map: ReadonlyMap<A, B>): ReadonlyMap<A, C>
        • Parameters

          • map: ReadonlyMap<A, B>

          Returns ReadonlyMap<A, C>

Const remove

remove: { <A, B>(key: A, map: ReadonlyMap<A, B>): ReadonlyMap<A, B>; <A, B>(key: A): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B> } = curry(<A, B>(key: A, map: ReadonlyMap<A, B>): ReadonlyMap<A, B> =>withMutations((x) => x.delete(key), map),)

Type declaration

    • <A, B>(key: A, map: ReadonlyMap<A, B>): ReadonlyMap<A, B>
    • <A, B>(key: A): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B>
    • Type parameters

      • A

      • B

      Parameters

      • key: A
      • map: ReadonlyMap<A, B>

      Returns ReadonlyMap<A, B>

    • Type parameters

      • A

      • B

      Parameters

      • key: A

      Returns (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B>

        • (map: ReadonlyMap<A, B>): ReadonlyMap<A, B>
        • Parameters

          • map: ReadonlyMap<A, B>

          Returns ReadonlyMap<A, B>

Const withMutations

withMutations: { <A, B>(fn: (map: Map<A, B>) => void, map: ReadonlyMap<A, B>): ReadonlyMap<A, B>; <A, B>(fn: (map: Map<A, B>) => void): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B> } = curry(__withMutations)

Create an updated ReadonlyMap by mutating a copy of the initial map

Type declaration

    • <A, B>(fn: (map: Map<A, B>) => void, map: ReadonlyMap<A, B>): ReadonlyMap<A, B>
    • <A, B>(fn: (map: Map<A, B>) => void): (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B>
    • Type parameters

      • A

      • B

      Parameters

      • fn: (map: Map<A, B>) => void
          • (map: Map<A, B>): void
          • Parameters

            • map: Map<A, B>

            Returns void

      • map: ReadonlyMap<A, B>

      Returns ReadonlyMap<A, B>

    • Type parameters

      • A

      • B

      Parameters

      • fn: (map: Map<A, B>) => void
          • (map: Map<A, B>): void
          • Parameters

            • map: Map<A, B>

            Returns void

      Returns (map: ReadonlyMap<A, B>) => ReadonlyMap<A, B>

        • (map: ReadonlyMap<A, B>): ReadonlyMap<A, B>
        • Parameters

          • map: ReadonlyMap<A, B>

          Returns ReadonlyMap<A, B>

Functions

Const empty

  • empty<A, B>(): ReadonlyMap<A, B>

Const entries

  • entries<A, B>(map: ReadonlyMap<A, B>): IterableIterator<keyof [A, B]>

Const keysOf

  • keysOf<A>(map: ReadonlyMap<A, unknown>): IterableIterator<A>

Const size

  • size(set: ReadonlyMap<unknown, unknown>): number

Const valuesOf

  • valuesOf<A>(map: ReadonlyMap<unknown, A>): IterableIterator<A>

Generated using TypeDoc