|
141 | 141 | * ```js
|
142 | 142 | * List.of(1, 2, 3, 4).toJS();
|
143 | 143 | * // [ 1, 2, 3, 4 ]
|
| 144 | + * |
| 145 | + * List.of({x:1}, 2, [3], 4).toJS(); |
| 146 | + * // [ { x: 1 }, 2, [ 3 ], 4 ] |
144 | 147 | * ```
|
145 | 148 | */
|
146 | 149 | function of<T>(...values: T[]): List<T>;
|
|
155 | 158 | *
|
156 | 159 | * const plainArray = [1, 2, 3, 4];
|
157 | 160 | * const listFromPlainArray = List(plainArray);
|
| 161 | + * |
| 162 | + * const plainSet = new Set([1, 2, 3, 4]); |
158 | 163 | * const listFromPlainSet = List(plainSet);
|
159 |
| - * const listFromIterableArray = List(plainArray[Symbol.iterator]()); |
| 164 | + * |
| 165 | + * const iterableArray = plainArray[Symbol.iterator](); |
| 166 | + * const listFromIterableArray = List(iterableArray); |
160 | 167 | *
|
161 | 168 | * listFromPlainArray.toJS(); // [ 1, 2, 3, 4 ]
|
162 | 169 | * listFromPlainSet.toJS(); // [ 1, 2, 3, 4 ]
|
163 | 170 | * listFromIterableArray.toJS(); // [ 1, 2, 3, 4 ]
|
| 171 | + * |
| 172 | + * Immutable.is(listFromPlainArray, listFromIterableSet); // true |
| 173 | + * Immutable.is(listFromPlainSet, listFromIterableSet) // true |
| 174 | + * Immutable.is(listFromPlainSet, listFromPlainArray) // true |
164 | 175 | * ```
|
165 | 176 | */
|
166 | 177 | export function List<T>(): List<T>;
|
|
191 | 202 | * originalList.set(1, 1).toJS(); // [ 0, 1 ]
|
192 | 203 | * originalList.set(0, 'overwritten').toJS(); // [ 'overwritten' ]
|
193 | 204 | *
|
194 |
| - * List().set(50000, 'value').size; // 50001 |
| 205 | + * List().set(50000, 'value').size; |
| 206 | + * //50001 |
195 | 207 | * ```
|
196 | 208 | */
|
197 | 209 | set(index: number, value: T): List<T>;
|
|
210 | 222 | * @alias remove
|
211 | 223 | *
|
212 | 224 | * ```js
|
213 |
| - * List([10, 11, 12, 13, 14]).delete(0).toJS(); |
214 |
| - * // [ 11, 12, 13, 14 ] |
| 225 | + * List([0, 1, 2, 3, 4]).delete(0).toJS(); |
| 226 | + * // [ 1, 2, 3, 4 ] |
215 | 227 | * ```
|
216 | 228 | */
|
217 | 229 | delete(index: number): List<T>;
|
|
224 | 236 | * This is synonymous with `list.splice(index, 0, value)
|
225 | 237 | *
|
226 | 238 | * ```js
|
227 |
| - * List([10, 11, 12, 13, 15]).insert(5, 14).toJS(); |
228 |
| - * // [ 10, 11, 12, 13, 14, 15 ] |
| 239 | + * List([0, 1, 2, 3, 4]).insert(6, 5).toJS(); |
| 240 | + * // [ 0, 1, 2, 3, 4, 5 ] |
229 | 241 | * ```
|
230 | 242 | */
|
231 | 243 | insert(index: number, value: T): List<T>;
|
|
270 | 282 | * values ahead to higher indices.
|
271 | 283 | *
|
272 | 284 | * ```js
|
273 |
| - * List([11, 12, 13]).unshift(10).toJS(); |
274 |
| - * // [ 10, 11, 13, 14 ] |
| 285 | + * List([ 2, 3, 4]).unshift(1).toJS(); |
| 286 | + * // [ 1, 2, 3, 4 ] |
275 | 287 | * ```
|
276 | 288 | */
|
277 | 289 | unshift(...values: T[]): List<T>;
|
|
285 | 297 | * value in this List.
|
286 | 298 | *
|
287 | 299 | * ```js
|
288 |
| - * List([10, 11, 12, 13, 14]).shift(0).toJS(); |
289 |
| - * // [ 11, 12, 13, 14 ] |
| 300 | + * List([ 0, 1, 2, 3, 4]).shift(0).toJS(); |
| 301 | + * // [ 1, 2, 3, 4 ] |
290 | 302 | * ```
|
291 | 303 | */
|
292 | 304 | shift(): List<T>;
|
|
1150 | 1162 | /**
|
1151 | 1163 | * Alias for `Stack.first()`.
|
1152 | 1164 | */
|
1153 |
| - peek(): T; |
| 1165 | + peek(): T | undefined; |
1154 | 1166 |
|
1155 | 1167 |
|
1156 | 1168 | // Persistent changes
|
|
1691 | 1703 | * `index` may be a negative number, which indexes back from the end of the
|
1692 | 1704 | * Iterable. `s.get(-1)` gets the last item in the Iterable.
|
1693 | 1705 | */
|
1694 |
| - get(index: number, notSetValue?: T): T; |
| 1706 | + get(index: number, notSetValue?: T): T | undefined; |
1695 | 1707 |
|
1696 | 1708 |
|
1697 | 1709 | // Conversion to Seq
|
|
1928 | 1940 | * so if `notSetValue` is not provided and this method returns `undefined`,
|
1929 | 1941 | * that does not guarantee the key was not found.
|
1930 | 1942 | */
|
1931 |
| - get(key: K, notSetValue?: V): V; |
| 1943 | + get(key: K, notSetValue?: V): V | undefined; |
1932 | 1944 |
|
1933 | 1945 | /**
|
1934 | 1946 | * True if a key exists within this `Iterable`, using `Immutable.is` to determine equality
|
|
1945 | 1957 | /**
|
1946 | 1958 | * The first value in the Iterable.
|
1947 | 1959 | */
|
1948 |
| - first(): V; |
| 1960 | + first(): V | undefined; |
1949 | 1961 |
|
1950 | 1962 | /**
|
1951 | 1963 | * The last value in the Iterable.
|
1952 | 1964 | */
|
1953 |
| - last(): V; |
| 1965 | + last(): V | undefined; |
1954 | 1966 |
|
1955 | 1967 |
|
1956 | 1968 | // Reading deep values
|
|
2497 | 2509 | predicate: (value: V, key: K, iter: /*this*/Iterable<K, V>) => boolean,
|
2498 | 2510 | context?: any,
|
2499 | 2511 | notSetValue?: V
|
2500 |
| - ): V; |
| 2512 | + ): V | undefined; |
2501 | 2513 |
|
2502 | 2514 | /**
|
2503 | 2515 | * Returns the last value for which the `predicate` returns true.
|
|
2508 | 2520 | predicate: (value: V, key: K, iter: /*this*/Iterable<K, V>) => boolean,
|
2509 | 2521 | context?: any,
|
2510 | 2522 | notSetValue?: V
|
2511 |
| - ): V; |
| 2523 | + ): V | undefined; |
2512 | 2524 |
|
2513 | 2525 | /**
|
2514 | 2526 | * Returns the first [key, value] entry for which the `predicate` returns true.
|
|
2517 | 2529 | predicate: (value: V, key: K, iter: /*this*/Iterable<K, V>) => boolean,
|
2518 | 2530 | context?: any,
|
2519 | 2531 | notSetValue?: V
|
2520 |
| - ): /*[K, V]*/Array<any>; |
| 2532 | + ): /*[K, V]*/Array<any> | undefined; |
2521 | 2533 |
|
2522 | 2534 | /**
|
2523 | 2535 | * Returns the last [key, value] entry for which the `predicate`
|
|
2529 | 2541 | predicate: (value: V, key: K, iter: /*this*/Iterable<K, V>) => boolean,
|
2530 | 2542 | context?: any,
|
2531 | 2543 | notSetValue?: V
|
2532 |
| - ): /*[K, V]*/Array<any>; |
| 2544 | + ): /*[K, V]*/Array<any> | undefined; |
2533 | 2545 |
|
2534 | 2546 | /**
|
2535 | 2547 | * Returns the key for which the `predicate` returns true.
|
2536 | 2548 | */
|
2537 | 2549 | findKey(
|
2538 | 2550 | predicate: (value: V, key: K, iter: /*this*/Iterable.Keyed<K, V>) => boolean,
|
2539 | 2551 | context?: any
|
2540 |
| - ): K; |
| 2552 | + ): K | undefined; |
2541 | 2553 |
|
2542 | 2554 | /**
|
2543 | 2555 | * Returns the last key for which the `predicate` returns true.
|
|
2547 | 2559 | findLastKey(
|
2548 | 2560 | predicate: (value: V, key: K, iter: /*this*/Iterable.Keyed<K, V>) => boolean,
|
2549 | 2561 | context?: any
|
2550 |
| - ): K; |
| 2562 | + ): K | undefined; |
2551 | 2563 |
|
2552 | 2564 | /**
|
2553 | 2565 | * Returns the key associated with the search value, or undefined.
|
2554 | 2566 | */
|
2555 |
| - keyOf(searchValue: V): K; |
| 2567 | + keyOf(searchValue: V): K | undefined; |
2556 | 2568 |
|
2557 | 2569 | /**
|
2558 | 2570 | * Returns the last key associated with the search value, or undefined.
|
2559 | 2571 | */
|
2560 |
| - lastKeyOf(searchValue: V): K; |
| 2572 | + lastKeyOf(searchValue: V): K | undefined; |
2561 | 2573 |
|
2562 | 2574 | /**
|
2563 | 2575 | * Returns the maximum value in this collection. If any values are
|
|
2574 | 2586 | * If `comparator` returns 0 and either value is NaN, undefined, or null,
|
2575 | 2587 | * that value will be returned.
|
2576 | 2588 | */
|
2577 |
| - max(comparator?: (valueA: V, valueB: V) => number): V; |
| 2589 | + max(comparator?: (valueA: V, valueB: V) => number): V | undefined; |
2578 | 2590 |
|
2579 | 2591 | /**
|
2580 | 2592 | * Like `max`, but also accepts a `comparatorValueMapper` which allows for
|
|
2586 | 2598 | maxBy<C>(
|
2587 | 2599 | comparatorValueMapper: (value: V, key: K, iter: /*this*/Iterable<K, V>) => C,
|
2588 | 2600 | comparator?: (valueA: C, valueB: C) => number
|
2589 |
| - ): V; |
| 2601 | + ): V | undefined; |
2590 | 2602 |
|
2591 | 2603 | /**
|
2592 | 2604 | * Returns the minimum value in this collection. If any values are
|
|
2603 | 2615 | * If `comparator` returns 0 and either value is NaN, undefined, or null,
|
2604 | 2616 | * that value will be returned.
|
2605 | 2617 | */
|
2606 |
| - min(comparator?: (valueA: V, valueB: V) => number): V; |
| 2618 | + min(comparator?: (valueA: V, valueB: V) => number): V | undefined; |
2607 | 2619 |
|
2608 | 2620 | /**
|
2609 | 2621 | * Like `min`, but also accepts a `comparatorValueMapper` which allows for
|
|
2615 | 2627 | minBy<C>(
|
2616 | 2628 | comparatorValueMapper: (value: V, key: K, iter: /*this*/Iterable<K, V>) => C,
|
2617 | 2629 | comparator?: (valueA: C, valueB: C) => number
|
2618 |
| - ): V; |
| 2630 | + ): V | undefined; |
2619 | 2631 |
|
2620 | 2632 |
|
2621 | 2633 | // Comparison
|
|
2721 | 2733 | * @ignore
|
2722 | 2734 | */
|
2723 | 2735 | export interface Iterator<T> {
|
2724 |
| - next(): { value: T; done: boolean; } |
| 2736 | + next(): { value: T; done: boolean; } | undefined |
2725 | 2737 | }
|
2726 | 2738 |
|
2727 | 2739 |
|
0 commit comments