Options
All
  • Public
  • Public/Protected
  • All
Menu

A type of Set that has the additional guarantee that the iteration order of values will be the order in which they were added.

The iteration behavior of OrderedSet is the same as native ES6 Set.

Note that OrderedSet are more expensive than non-ordered Set and may consume more memory. OrderedSet#add is amortized O(log32 N), but not stable.

Type parameters

  • T

Callable

  • Create a new immutable OrderedSet containing the values of the provided collection-like.

    Note: OrderedSet is a factory function and not a class, and does not use the new keyword during construction.

    Returns OrderedSet<any>

  • A type of Set that has the additional guarantee that the iteration order of values will be the order in which they were added.

    The iteration behavior of OrderedSet is the same as native ES6 Set.

    Note that OrderedSet are more expensive than non-ordered Set and may consume more memory. OrderedSet#add is amortized O(log32 N), but not stable.

    Type parameters

    • T

    Returns OrderedSet<T>

  • A type of Set that has the additional guarantee that the iteration order of values will be the order in which they were added.

    The iteration behavior of OrderedSet is the same as native ES6 Set.

    Note that OrderedSet are more expensive than non-ordered Set and may consume more memory. OrderedSet#add is amortized O(log32 N), but not stable.

    Type parameters

    • T

    Parameters

    Returns OrderedSet<T>

Index

Properties

size

size: number

The number of items in this OrderedSet.

Functions

isOrderedSet

  • isOrderedSet(maybeOrderedSet: any): boolean
  • True if the provided value is an OrderedSet.

    Parameters

    • maybeOrderedSet: any

    Returns boolean

Methods

Set

  • Create a new immutable Set containing the values of the provided collection-like.

    Note: Set is a factory function and not a class, and does not use the new keyword during construction.

    Returns Set<any>

  • Type parameters

    • T

    Returns Set<T>

  • Type parameters

    • T

    Parameters

    Returns Set<T>

  • Similar to Collection(), but always returns a Collection.Set.

    Note: Collection.Set is a factory function and not a class, and does not use the new keyword during construction.

    Type parameters

    • T

    Parameters

    Returns Set<T>

add

  • add(value: T): this
  • Returns a new Set which also includes this value.

    Note: add can be used in withMutations.

    Parameters

    • value: T

    Returns this

asImmutable

  • asImmutable(): this
  • see

    Map#asImmutable

    Returns this

asMutable

  • asMutable(): this
  • Note: Not all methods can be used on a mutable collection or within withMutations! Check the documentation for each method to see if it mentions being safe to use in withMutations.

    see

    Map#asMutable

    Returns this

clear

  • clear(): this
  • Returns a new Set containing no values.

    Note: clear can be used in withMutations.

    Returns this

concat

  • Type parameters

    • C

    Parameters

    • Rest ...collections: Array<Iterable<C>>

    Returns OrderedSet<T | C>

delete

  • delete(value: T): this
  • Returns a new Set which excludes this value.

    Note: delete can be used in withMutations.

    Note: delete cannot be safely used in IE8, use remove if supporting old browsers.

    alias

    remove

    Parameters

    • value: T

    Returns this

filter

  • filter<F>(predicate: function, context?: any): OrderedSet<F>
  • filter(predicate: function, context?: any): this
  • Returns a new OrderedSet with only the values for which the predicate function returns true.

    Note: filter() always returns a new instance, even if it results in not filtering out any values.

    Type parameters

    • F: T

    Parameters

    • predicate: function
        • (value: T, key: T, iter: this): boolean
        • Parameters

          • value: T
          • key: T
          • iter: this

          Returns boolean

    • Optional context: any

    Returns OrderedSet<F>

  • Parameters

    • predicate: function
        • (value: T, key: T, iter: this): any
        • Parameters

          • value: T
          • key: T
          • iter: this

          Returns any

    • Optional context: any

    Returns this

flatMap

  • flatMap<M>(mapper: function, context?: any): OrderedSet<M>
  • Flat-maps the OrderedSet, returning a new OrderedSet.

    Similar to set.map(...).flatten(true).

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value: T, key: T, iter: this): Iterable<M>
        • Parameters

          • value: T
          • key: T
          • iter: this

          Returns Iterable<M>

    • Optional context: any

    Returns OrderedSet<M>

fromKeys

  • Set.fromKeys() creates a new immutable Set containing the keys from this Collection or JavaScript Object.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Parameters

    • obj: object
      • [key: string]: any

    Returns Set<string>

  • OrderedSet.fromKeys() creates a new immutable OrderedSet containing the keys from this Collection or JavaScript Object.

    Type parameters

    • T

    Parameters

    Returns OrderedSet<T>

  • Parameters

    • obj: object
      • [key: string]: any

    Returns OrderedSet<string>

intersect

  • Set.intersect() creates a new immutable Set that is the intersection of a collection of other sets.

    const { Set } = require('immutable')
    const intersected = Set.intersect([
      Set([ 'a', 'b', 'c' ])
      Set([ 'c', 'a', 't' ])
    ])
    // Set [ "a", "c"" ]

    Type parameters

    • T

    Parameters

    Returns Set<T>

isSet

  • isSet(maybeSet: any): boolean
  • True if the provided value is a Set

    Parameters

    • maybeSet: any

    Returns boolean

map

  • map<M>(mapper: function, context?: any): OrderedSet<M>
  • Returns a new Set with values passed through a mapper function.

    OrderedSet([ 1, 2 ]).map(x => 10 * x)
    // OrderedSet [10, 20]

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value: T, key: T, iter: this): M
        • Parameters

          • value: T
          • key: T
          • iter: this

          Returns M

    • Optional context: any

    Returns OrderedSet<M>

merge

  • Type parameters

    • C

    Parameters

    • Rest ...collections: Array<Iterable<C>>

    Returns OrderedSet<T | C>

of

  • of<T>(...values: Array<T>): Set<T>
  • of<T>(...values: Array<T>): OrderedSet<T>
  • Creates a new Set containing values.

    Type parameters

    • T

    Parameters

    • Rest ...values: Array<T>

    Returns Set<T>

  • Creates a new OrderedSet containing values.

    Type parameters

    • T

    Parameters

    • Rest ...values: Array<T>

    Returns OrderedSet<T>

remove

  • remove(value: T): this
  • Parameters

    • value: T

    Returns this

subtract

  • subtract(...collections: Array<Iterable<T>>): this
  • Returns a Set excluding any values contained within collections.

    const { OrderedSet } = require('immutable')
    OrderedSet([ 1, 2, 3 ]).subtract([1, 3])
    // OrderedSet [2]

    Note: subtract can be used in withMutations.

    Parameters

    • Rest ...collections: Array<Iterable<T>>

    Returns this

union

  • Returns an OrderedSet including any value from collections that does not already exist in this OrderedSet.

    Note: union can be used in withMutations.

    alias

    merge

    alias

    concat

    Type parameters

    • C

    Parameters

    • Rest ...collections: Array<Iterable<C>>

    Returns OrderedSet<T | C>

  • Set.union() creates a new immutable Set that is the union of a collection of other sets.

    const { Set } = require('immutable')
    const unioned = Set.union([
      Set([ 'a', 'b', 'c' ])
      Set([ 'c', 'a', 't' ])
    ])
    // Set [ "a", "b", "c", "t"" ]

    Type parameters

    • T

    Parameters

    Returns Set<T>

wasAltered

  • wasAltered(): boolean
  • see

    Map#wasAltered

    Returns boolean

withMutations

  • withMutations(mutator: function): this
  • Note: Not all methods can be used on a mutable collection or within withMutations! Check the documentation for each method to see if it mentions being safe to use in withMutations.

    see

    Map#withMutations

    Parameters

    • mutator: function
        • (mutable: this): any
        • Parameters

          • mutable: this

          Returns any

    Returns this

zip

  • Returns an OrderedSet of the same type "zipped" with the provided collections.

    Like zipWith, but using the default zipper: creating an Array.

    const a = OrderedSet([ 1, 2, 3 ])
    const b = OrderedSet([ 4, 5, 6 ])
    const c = a.zip(b)
    // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]

    Type parameters

    • U

    Parameters

    Returns OrderedSet<[T, U]>

  • Type parameters

    • U

    • V

    Parameters

    Returns OrderedSet<[T, U, V]>

  • Parameters

    • Rest ...collections: Array<Collection<any, any>>

    Returns OrderedSet<any>

zipAll

  • Returns a OrderedSet of the same type "zipped" with the provided collections.

    Unlike zip, zipAll continues zipping until the longest collection is exhausted. Missing values from shorter collections are filled with undefined.

    const a = OrderedSet([ 1, 2 ]);
    const b = OrderedSet([ 3, 4, 5 ]);
    const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]

    Note: Since zipAll will return a collection as large as the largest input, some results may contain undefined values. TypeScript cannot account for these without cases (as of v2.5).

    Type parameters

    • U

    Parameters

    Returns OrderedSet<[T, U]>

  • Type parameters

    • U

    • V

    Parameters

    Returns OrderedSet<[T, U, V]>

  • Parameters

    • Rest ...collections: Array<Collection<any, any>>

    Returns OrderedSet<any>

zipWith

  • Returns an OrderedSet of the same type "zipped" with the provided collections by using a custom zipper function.

    see

    Seq.Indexed.zipWith

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherCollection: Collection<any, U>

    Returns OrderedSet<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherCollection: Collection<any, U>
    • thirdCollection: Collection<any, V>

    Returns OrderedSet<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...collections: Array<Collection<any, any>>

    Returns OrderedSet<Z>

Generated using TypeDoc