diff --git a/flow-typed/npm/immutable_v4.x.x.js b/flow-typed/npm/immutable_v4.x.x.js new file mode 100644 index 000000000..2ecc9f922 --- /dev/null +++ b/flow-typed/npm/immutable_v4.x.x.js @@ -0,0 +1,1263 @@ +/** + * This file provides type definitions for use with the Flow type checker. + * + * An important caveat when using these definitions is that the types for + * `Collection.Keyed`, `Collection.Indexed`, `Seq.Keyed`, and so on are stubs. + * When referring to those types, you can get the proper definitions by + * importing the types `KeyedCollection`, `IndexedCollection`, `KeyedSeq`, etc. + * For example, + * + * import { Seq } from 'immutable' + * import type { IndexedCollection, IndexedSeq } from 'immutable' + * + * const someSeq: IndexedSeq = Seq.Indexed.of(1, 2, 3) + * + * function takesASeq>(iter: TS): TS { + * return iter.butLast() + * } + * + * takesASeq(someSeq) + * + * @flow + */ + +declare module 'immutable' { + /** + * This file provides type definitions for use with the Flow type checker. + * + * An important caveat when using these definitions is that the types for + * `Collection.Keyed`, `Collection.Indexed`, `Seq.Keyed`, and so on are stubs. + * When referring to those types, you can get the proper definitions by + * importing the types `KeyedCollection`, `IndexedCollection`, `KeyedSeq`, etc. + * For example, + * + * import { Seq } from 'immutable' + * import type { IndexedCollection, IndexedSeq } from 'immutable' + * + * const someSeq: IndexedSeq = Seq.Indexed.of(1, 2, 3) + * + * function takesASeq>(iter: TS): TS { + * return iter.butLast() + * } + * + * takesASeq(someSeq) + * + * @flow + */ + + declare class _Collection /*implements ValueObject*/ { + equals(other: mixed): boolean; + hashCode(): number; + get(key: K, ..._: []): V | void; + get(key: K, notSetValue: NSV): V | NSV; + has(key: K): boolean; + includes(value: V): boolean; + contains(value: V): boolean; + first(): V | void; + last(): V | void; + + getIn(searchKeyPath: Iterable, notSetValue?: mixed): any; + hasIn(searchKeyPath: Iterable): boolean; + + update(updater: (value: this) => U): U; + + toJS(): Array | { [key: string]: mixed }; + toJSON(): Array | { [key: string]: V }; + toArray(): Array; + toObject(): { [key: string]: V }; + toMap(): Map; + toOrderedMap(): OrderedMap; + toSet(): Set; + toOrderedSet(): OrderedSet; + toList(): List; + toStack(): Stack; + toSeq(): Seq; + toKeyedSeq(): KeyedSeq; + toIndexedSeq(): IndexedSeq; + toSetSeq(): SetSeq; + + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[K, V]>; + + keySeq(): IndexedSeq; + valueSeq(): IndexedSeq; + entrySeq(): IndexedSeq<[K, V]>; + + reverse(): this; + sort(comparator?: (valueA: V, valueB: V) => number): this; + + sortBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): this; + + groupBy( + grouper: (value: V, key: K, iter: this) => G, + context?: mixed + ): KeyedSeq; + + forEach( + sideEffect: (value: V, key: K, iter: this) => any, + context?: mixed + ): number; + + slice(begin?: number, end?: number): this; + rest(): this; + butLast(): this; + skip(amount: number): this; + skipLast(amount: number): this; + skipWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + skipUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + take(amount: number): this; + takeLast(amount: number): this; + takeWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + takeUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + + filter( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; + + filterNot( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; + + reduce( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: mixed, + ): R; + reduce( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + reduceRight( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: mixed, + ): R; + reduceRight( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + every(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean; + some(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean; + join(separator?: string): string; + isEmpty(): boolean; + count(predicate?: (value: V, key: K, iter: this) => mixed, context?: mixed): number; + countBy(grouper: (value: V, key: K, iter: this) => G, context?: mixed): Map; + + find( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed, + notSetValue?: NSV + ): V | NSV; + findLast( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed, + notSetValue?: NSV + ): V | NSV; + + findEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; + findLastEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; + + findKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void; + findLastKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void; + + keyOf(searchValue: V): K | void; + lastKeyOf(searchValue: V): K | void; + + max(comparator?: (valueA: V, valueB: V) => number): V; + maxBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V; + min(comparator?: (valueA: V, valueB: V) => number): V; + minBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V; + + isSubset(iter: Iterable): boolean; + isSuperset(iter: Iterable): boolean; + } + + declare function isImmutable(maybeImmutable: mixed): boolean %checks(maybeImmutable instanceof Collection); + declare function isCollection(maybeCollection: mixed): boolean %checks(maybeCollection instanceof Collection); + declare function isKeyed(maybeKeyed: mixed): boolean %checks(maybeKeyed instanceof KeyedCollection); + declare function isIndexed(maybeIndexed: mixed): boolean %checks(maybeIndexed instanceof IndexedCollection); + declare function isAssociative(maybeAssociative: mixed): boolean %checks( + maybeAssociative instanceof KeyedCollection || + maybeAssociative instanceof IndexedCollection + ); + declare function isOrdered(maybeOrdered: mixed): boolean %checks( + maybeOrdered instanceof IndexedCollection || + maybeOrdered instanceof OrderedMap || + maybeOrdered instanceof OrderedSet + ); + declare function isValueObject(maybeValue: mixed): boolean; + + declare interface ValueObject { + equals(other: mixed): boolean; + hashCode(): number; + } + + declare class Collection extends _Collection { + static Keyed: typeof KeyedCollection; + static Indexed: typeof IndexedCollection; + static Set: typeof SetCollection; + + static isCollection: typeof isCollection; + static isKeyed: typeof isKeyed; + static isIndexed: typeof isIndexed; + static isAssociative: typeof isAssociative; + static isOrdered: typeof isOrdered; + } + + declare class KeyedCollection extends Collection { + static (iter?: Iterable<[K, V]>): KeyedCollection; + static (obj?: { [key: K]: V }): KeyedCollection; + + toJS(): { [key: string]: mixed }; + toJSON(): { [key: string]: V }; + @@iterator(): Iterator<[K, V]>; + toSeq(): KeyedSeq; + flip(): KeyedCollection; + + concat(...iters: Array>): KeyedCollection; + concat(...iters: Array<{[key: string]: C}>): KeyedCollection; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): KeyedCollection; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): KeyedCollection; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): KeyedCollection; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): KeyedCollection; + + flatten(depth?: number): KeyedCollection; + flatten(shallow?: boolean): KeyedCollection; + } + + // Collection.Keyed = KeyedCollection + + declare class IndexedCollection<+T> extends Collection { + static (iter?: Iterable): IndexedCollection; + + toJS(): Array; + toJSON(): Array; + @@iterator(): Iterator; + toSeq(): IndexedSeq; + fromEntrySeq(): KeyedSeq; + interpose(separator: T): this; + interleave(...collections: Iterable[]): this; + splice( + index: number, + removeNum: number, + ...values: T[] + ): this; + + zip( + a: Iterable, + ..._: [] + ): IndexedCollection<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedCollection; + + indexOf(searchValue: T): number; + lastIndexOf(searchValue: T): number; + findIndex( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): number; + findLastIndex( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): number; + + concat(...iters: Array | C>): IndexedCollection; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): IndexedCollection; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): IndexedCollection; + + flatten(depth?: number): IndexedCollection; + flatten(shallow?: boolean): IndexedCollection; + } + + declare class SetCollection<+T> extends Collection { + static (iter?: Iterable): SetCollection; + + toJS(): Array; + toJSON(): Array; + @@iterator(): Iterator; + toSeq(): SetSeq; + + concat(...iters: Array | C>): SetCollection; + + // `map` and `flatMap` cannot be defined further up the hiearchy, because the + // implementation for `KeyedCollection` allows the value type to change without + // constraining the key type. That does not work for `SetCollection` - the value + // and key types *must* match. + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): SetCollection; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): SetCollection; + + flatten(depth?: number): SetCollection; + flatten(shallow?: boolean): SetCollection; + } + + declare function isSeq(maybeSeq: mixed): boolean %checks(maybeSeq instanceof Seq); + declare class Seq extends _Collection { + static Keyed: typeof KeyedSeq; + static Indexed: typeof IndexedSeq; + static Set: typeof SetSeq; + + static (iter: KeyedSeq): KeyedSeq; + static (iter: SetSeq): SetSeq; + static (iter?: Iterable): IndexedSeq; + static (iter: { [key: K]: V }): KeyedSeq; + + static of(...values: T[]): IndexedSeq; + + static isSeq: typeof isSeq; + + size: number | void; + cacheResult(): this; + toSeq(): this; + } + + declare class KeyedSeq extends Seq mixins KeyedCollection { + static (iter?: Iterable<[K, V]>): KeyedSeq; + static (iter?: { [key: K]: V }): KeyedSeq; + + // Override specialized return types + flip(): KeyedSeq; + + concat(...iters: Array>): KeyedSeq; + concat(...iters: Array<{[key: string]: C}>): KeyedSeq; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): KeyedSeq; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): KeyedSeq; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): KeyedSeq; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): KeyedSeq; + + flatten(depth?: number): KeyedSeq; + flatten(shallow?: boolean): KeyedSeq; + } + + declare class IndexedSeq<+T> extends Seq mixins IndexedCollection { + static (iter?: Iterable): IndexedSeq; + + static of(...values: T[]): IndexedSeq; + + // Override specialized return types + + concat(...iters: Array | C>): IndexedSeq; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): IndexedSeq; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): IndexedSeq; + + flatten(depth?: number): IndexedSeq; + flatten(shallow?: boolean): IndexedSeq; + + zip( + a: Iterable, + ..._: [] + ): IndexedSeq<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedSeq; + } + + declare class SetSeq<+T> extends Seq mixins SetCollection { + static (iter?: Iterable): IndexedSeq; + + static of(...values: T[]): IndexedSeq; + + // Override specialized return types + + concat(...iters: Array | C>): SetSeq; + + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): SetSeq; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): SetSeq; + + flatten(depth?: number): SetSeq; + flatten(shallow?: boolean): SetSeq; + } + + declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof List); + declare class List<+T> extends IndexedCollection { + static (collection?: Iterable): List; + + static of(...values: T[]): List; + + static isList: typeof isList; + + size: number; + + set(index: number, value: U): List; + delete(index: number): this; + remove(index: number): this; + insert(index: number, value: U): List; + clear(): this; + push(...values: U[]): List; + pop(): this; + unshift(...values: U[]): List; + shift(): this; + + update(updater: (value: this) => U): U; + update(index: number, updater: (value: T) => U): List; + update(index: number, notSetValue: U, updater: (value: T) => U): List; + + merge(...collections: Iterable[]): List; + + mergeWith( + merger: (oldVal: T, newVal: U, key: number) => V, + ...collections: Iterable[] + ): List; + + mergeDeep(...collections: Iterable[]): List; + + mergeDeepWith( + merger: (oldVal: T, newVal: U, key: number) => V, + ...collections: Iterable[] + ): List; + + setSize(size: number): this; + setIn(keyPath: Iterable, value: mixed): this; + deleteIn(keyPath: Iterable, value: mixed): this; + removeIn(keyPath: Iterable, value: mixed): this; + + updateIn( + keyPath: Iterable, + notSetValue: mixed, + updater: (value: any) => mixed + ): this; + updateIn( + keyPath: Iterable, + updater: (value: any) => mixed + ): this; + + mergeIn(keyPath: Iterable, ...collections: Iterable[]): this; + mergeDeepIn(keyPath: Iterable, ...collections: Iterable[]): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + concat(...iters: Array | C>): List; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): List; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): List; + + flatten(depth?: number): List; + flatten(shallow?: boolean): List; + + zip( + a: Iterable, + ..._: [] + ): List<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): List<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): List<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): List<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): List<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): List; + } + + declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map); + declare class Map extends KeyedCollection { + static (obj?: {[key: K]: V}): Map; + static (collection: Iterable<[K, V]>): Map; + + static isMap: typeof isMap; + + size: number; + + set(key: K_, value: V_): Map; + delete(key: K): this; + remove(key: K): this; + clear(): this; + + deleteAll(keys: Iterable): Map; + removeAll(keys: Iterable): Map; + + update(updater: (value: this) => U): U; + update(key: K, updater: (value: V) => V_): Map; + update(key: K, notSetValue: V_, updater: (value: V) => V_): Map; + + merge( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): Map; + + mergeWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): Map; + + mergeDeep( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): Map; + + mergeDeepWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): Map; + + setIn(keyPath: Iterable, value: mixed): this; + deleteIn(keyPath: Iterable, value: mixed): this; + removeIn(keyPath: Iterable, value: mixed): this; + + updateIn( + keyPath: Iterable, + notSetValue: mixed, + updater: (value: any) => mixed + ): this; + updateIn( + keyPath: Iterable, + updater: (value: any) => mixed + ): this; + + mergeIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + flip(): Map; + + concat(...iters: Array>): Map; + concat(...iters: Array<{[key: string]: C}>): Map; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): Map; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): Map; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): Map; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): Map; + + flatten(depth?: number): Map; + flatten(shallow?: boolean): Map; + } + + declare function isOrderedMap(maybeOrderedMap: mixed): boolean %checks(maybeOrderedMap instanceof OrderedMap); + declare class OrderedMap extends Map { + static (obj?: {[key: K]: V}): OrderedMap; + static (collection: Iterable<[K, V]>): OrderedMap; + + static isOrderedMap: typeof isOrderedMap; + + size: number; + + set(key: K_, value: V_): OrderedMap; + delete(key: K): this; + remove(key: K): this; + clear(): this; + + update(updater: (value: this) => U): U; + update(key: K, updater: (value: V) => V_): OrderedMap; + update(key: K, notSetValue: V_, updater: (value: V) => V_): OrderedMap; + + merge( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): OrderedMap; + + mergeWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): OrderedMap; + + mergeDeep( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): OrderedMap; + + mergeDeepWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): OrderedMap; + + setIn(keyPath: Iterable, value: mixed): this; + deleteIn(keyPath: Iterable, value: mixed): this; + removeIn(keyPath: Iterable, value: mixed): this; + + updateIn( + keyPath: Iterable, + notSetValue: mixed, + updater: (value: any) => mixed + ): this; + updateIn( + keyPath: Iterable, + updater: (value: any) => mixed + ): this; + + mergeIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + flip(): OrderedMap; + + concat(...iters: Array>): OrderedMap; + concat(...iters: Array<{[key: string]: C}>): OrderedMap; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): OrderedMap; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): OrderedMap; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): OrderedMap; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): OrderedMap; + + flatten(depth?: number): OrderedMap; + flatten(shallow?: boolean): OrderedMap; + } + + declare function isSet(maybeSet: mixed): boolean %checks(maybeSet instanceof Set); + declare class Set<+T> extends SetCollection { + static (collection?: Iterable): Set; + + static of(...values: T[]): Set; + static fromKeys(iter: Iterable<[T, mixed]>): Set; + static fromKeys(object: { [key: K]: V }): Set; + + static intersect(sets: Iterable>): Set; + static union(sets: Iterable>): Set; + + static isSet: typeof isSet; + + size: number; + + add(value: U): Set; + delete(value: T): this; + remove(value: T): this; + clear(): this; + union(...collections: Iterable[]): Set; + merge(...collections: Iterable[]): Set; + intersect(...collections: Iterable[]): Set; + subtract(...collections: Iterable[]): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + concat(...iters: Array | C>): Set; + + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): Set; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): Set; + + flatten(depth?: number): Set; + flatten(shallow?: boolean): Set; + } + + // Overrides except for `isOrderedSet` are for specialized return types + declare function isOrderedSet(maybeOrderedSet: mixed): boolean %checks(maybeOrderedSet instanceof OrderedSet); + declare class OrderedSet<+T> extends Set { + static (collection: Iterable): OrderedSet; + static (_: void): OrderedSet; + + static of(...values: T[]): OrderedSet; + static fromKeys(iter: Iterable<[T, mixed]>): OrderedSet; + static fromKeys(object: { [key: K]: V }): OrderedSet; + + static isOrderedSet: typeof isOrderedSet; + + size: number; + + add(value: U): OrderedSet; + union(...collections: Iterable[]): OrderedSet; + merge(...collections: Iterable[]): OrderedSet; + intersect(...collections: Iterable[]): OrderedSet; + + concat(...iters: Array | C>): OrderedSet; + + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): OrderedSet; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): OrderedSet; + + flatten(depth?: number): OrderedSet; + flatten(shallow?: boolean): OrderedSet; + + zip( + a: Iterable, + ..._: [] + ): OrderedSet<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): OrderedSet<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): OrderedSet; + } + + declare function isStack(maybeStack: mixed): boolean %checks(maybeStack instanceof Stack); + declare class Stack<+T> extends IndexedCollection { + static (collection?: Iterable): Stack; + + static isStack(maybeStack: mixed): boolean; + static of(...values: T[]): Stack; + + static isStack: typeof isStack; + + size: number; + + peek(): T; + clear(): this; + unshift(...values: U[]): Stack; + unshiftAll(iter: Iterable): Stack; + shift(): this; + push(...values: U[]): Stack; + pushAll(iter: Iterable): Stack; + pop(): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + concat(...iters: Array | C>): Stack; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): Stack; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): Stack; + + flatten(depth?: number): Stack; + flatten(shallow?: boolean): Stack; + + zip( + a: Iterable, + ..._: [] + ): Stack<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): Stack<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): Stack<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): Stack<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): Stack<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): Stack; + } + + declare function Range(start?: number, end?: number, step?: number): IndexedSeq; + declare function Repeat(value: T, times?: number): IndexedSeq; + + declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordClass); + declare class Record { + static (spec: Values, name?: string): Class>; + constructor(spec: Values, name?: string): Class>; + + static isRecord: typeof isRecord; + + static getDescriptiveName(record: RecordClass<*>): string; + } + + declare class RecordClass { + static (values?: $Shape | Iterable<[string, any]>): RecordClass & T; + constructor(values?: $Shape | Iterable<[string, any]>): RecordClass & T; + + size: number; + + has(key: string): boolean; + get>(key: K): /*T[K]*/any; + + equals(other: any): boolean; + hashCode(): number; + + set>(key: K, value: /*T[K]*/any): this; + update>(key: K, updater: (value: /*T[K]*/any) => /*T[K]*/any): this; + merge(...collections: Array<$Shape | Iterable<[string, any]>>): this; + mergeDeep(...collections: Array<$Shape | Iterable<[string, any]>>): this; + + mergeWith( + merger: (oldVal: any, newVal: any, key: $Keys) => any, + ...collections: Array<$Shape | Iterable<[string, any]>> + ): this; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => any, + ...collections: Array<$Shape | Iterable<[string, any]>> + ): this; + + delete>(key: K): this; + remove>(key: K): this; + clear(): this; + + setIn(keyPath: Iterable, value: any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + + toSeq(): KeyedSeq<$Keys, any>; + + toJS(): { [key: $Keys]: mixed }; + toJSON(): T; + toObject(): T; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + @@iterator(): Iterator<[$Keys, any]>; + } + + declare function fromJS( + jsValue: mixed, + reviver?: ( + key: string | number, + sequence: KeyedCollection | IndexedCollection, + path?: Array + ) => mixed + ): mixed; + + declare function is(first: mixed, second: mixed): boolean; + declare function hash(value: mixed): number; +} + +/** + * BSD License + * + * For Immutable JS software + * + * Copyright (c) 2014-2015, Facebook, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name Facebook nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ \ No newline at end of file