UNPKG

129 kBSource Map (JSON)View Raw
1{"version":3,"names":["iter","object","ArrayIterator","each","fn","value","index","it","undefined","next","ArrayExt","firstIndexOf","array","start","stop","span","n","length","Math","max","min","i","j","lastIndexOf","findFirstIndex","findLastIndex","d","reverse","a","b","removeAt","findFirstValue","findLastValue","lowerBound","begin","half","middle","upperBound","shallowEqual","slice","options","step","Error","floor","result","move","fromIndex","toIndex","rotate","delta","pivot","fill","insert","removeFirstOf","removeLastOf","removeAllOf","count","removeFirstWhere","removeLastWhere","removeAllWhere","source","this","_index","_source","prototype","clone","KeyIterator","keys","Object","_keys","key","ValueIterator","ItemIterator","FnIterator","_fn","call","ChainIterator","_cloned","_active","active","EmptyIterator","EnumerateIterator","FilterIterator","MapIterator","Private","RangeIterator","_start","_stop","_step","_length","rangeLength","Infinity","ceil","RepeatIterator","_value","_count","RetroArrayIterator","StrideIterator","StringExt","findIndices","query","indices","Array","indexOf","matchSumOfSquares","score","matchSumOfDeltas","last","highlight","k","push","cmp","TakeIterator","ZipIterator","map","objects","_i","arguments","vmin","vmax","initial","first","TypeError","accumulator","second","retro","pair","edges","sorted","visited","Set","graph","Map","edge","fromNode","toNode","children","get","set","forEach","v","visit","node","has","add"],"sources":["../src/iter.ts","../src/array.ts","../src/chain.ts","../src/empty.ts","../src/enumerate.ts","../src/filter.ts","../src/map.ts","../src/range.ts","../src/repeat.ts","../src/retro.ts","../src/stride.ts","../src/string.ts","../src/take.ts","../src/zip.ts","../src/find.ts","../src/reduce.ts","../src/sort.ts"],"sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\n\n/**\n * An object which can produce an iterator over its values.\n */\nexport interface IIterable<T> {\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n *\n * #### Notes\n * Depending on the iterable, the returned iterator may or may not be\n * a new object. A collection or other container-like object should\n * typically return a new iterator, while an iterator itself should\n * normally return `this`.\n */\n iter(): IIterator<T>;\n}\n\n/**\n * An object which traverses a collection of values.\n *\n * #### Notes\n * An `IIterator` is itself an `IIterable`. Most implementations of\n * `IIterator` should simply return `this` from the `iter()` method.\n */\nexport interface IIterator<T> extends IIterable<T> {\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n *\n * #### Notes\n * The cloned iterator can be consumed independently of the current\n * iterator. In essence, it is a copy of the iterator value stream\n * which starts at the current location.\n *\n * This can be useful for lookahead and stream duplication.\n */\n clone(): IIterator<T>;\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n *\n * #### Notes\n * The `undefined` value is used to signal the end of iteration and\n * should therefore not be used as a value in a collection.\n *\n * The use of the `undefined` sentinel is an explicit design choice\n * which favors performance over purity. The ES6 iterator design of\n * returning a `{ value, done }` pair is suboptimal, as it requires\n * an object allocation on each iteration; and an `isDone()` method\n * would increase implementation and runtime complexity.\n */\n next(): T | undefined;\n}\n\n/**\n * A type alias for an iterable or builtin array-like object.\n */\nexport type IterableOrArrayLike<T> = IIterable<T> | ArrayLike<T>;\n\n/**\n * Create an iterator for an iterable object.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @returns A new iterator for the given object.\n *\n * #### Notes\n * This function allows iteration algorithms to operate on user-defined\n * iterable types and builtin array-like objects in a uniform fashion.\n */\nexport function iter<T>(object: IterableOrArrayLike<T>): IIterator<T> {\n let it: IIterator<T>;\n if (typeof (object as any).iter === 'function') {\n it = (object as IIterable<T>).iter();\n } else {\n it = new ArrayIterator<T>(object as ArrayLike<T>);\n }\n return it;\n}\n\n/**\n * Create an iterator for the keys in an object.\n *\n * @param object - The object of interest.\n *\n * @returns A new iterator for the keys in the given object.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { each, keys } from '@lumino/algorithm';\n *\n * let data = { one: 1, two: 2, three: 3 };\n *\n * each(keys(data), key => { console.log(key); }); // 'one', 'two', 'three'\n * ```\n */\nexport function iterKeys<T>(object: {\n readonly [key: string]: T;\n}): IIterator<string> {\n return new KeyIterator(object);\n}\n\n/**\n * Create an iterator for the values in an object.\n *\n * @param object - The object of interest.\n *\n * @returns A new iterator for the values in the given object.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { each, values } from '@lumino/algorithm';\n *\n * let data = { one: 1, two: 2, three: 3 };\n *\n * each(values(data), value => { console.log(value); }); // 1, 2, 3\n * ```\n */\nexport function iterValues<T>(object: {\n readonly [key: string]: T;\n}): IIterator<T> {\n return new ValueIterator<T>(object);\n}\n\n/**\n * Create an iterator for the items in an object.\n *\n * @param object - The object of interest.\n *\n * @returns A new iterator for the items in the given object.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { each, items } from '@lumino/algorithm';\n *\n * let data = { one: 1, two: 2, three: 3 };\n *\n * each(items(data), value => { console.log(value); }); // ['one', 1], ['two', 2], ['three', 3]\n * ```\n */\nexport function iterItems<T>(object: {\n readonly [key: string]: T;\n}): IIterator<[string, T]> {\n return new ItemIterator<T>(object);\n}\n\n/**\n * Create an iterator for an iterator-like function.\n *\n * @param fn - A function which behaves like an iterator `next` method.\n *\n * @returns A new iterator for the given function.\n *\n * #### Notes\n * The returned iterator **cannot** be cloned.\n *\n * #### Example\n * ```typescript\n * import { each, iterFn } from '@lumino/algorithm';\n *\n * let it = iterFn((() => {\n * let i = 0;\n * return () => i > 3 ? undefined : i++;\n * })());\n *\n * each(it, v => { console.log(v); }); // 0, 1, 2, 3\n * ```\n */\nexport function iterFn<T>(fn: () => T | undefined): IIterator<T> {\n return new FnIterator<T>(fn);\n}\n\n/**\n * Invoke a function for each value in an iterable.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param fn - The callback function to invoke for each value.\n *\n * #### Notes\n * Iteration can be terminated early by returning `false` from the\n * callback function.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { each } from '@lumino/algorithm';\n *\n * let data = [5, 7, 0, -2, 9];\n *\n * each(data, value => { console.log(value); });\n * ```\n */\nexport function each<T>(\n object: IterableOrArrayLike<T>,\n fn: (value: T, index: number) => boolean | void\n): void {\n let index = 0;\n let it = iter(object);\n let value: T | undefined;\n while ((value = it.next()) !== undefined) {\n if (fn(value, index++) === false) {\n return;\n }\n }\n}\n\n/**\n * Test whether all values in an iterable satisfy a predicate.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param fn - The predicate function to invoke for each value.\n *\n * @returns `true` if all values pass the test, `false` otherwise.\n *\n * #### Notes\n * Iteration terminates on the first `false` predicate result.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { every } from '@lumino/algorithm';\n *\n * let data = [5, 7, 1];\n *\n * every(data, value => value % 2 === 0); // false\n * every(data, value => value % 2 === 1); // true\n * ```\n */\nexport function every<T>(\n object: IterableOrArrayLike<T>,\n fn: (value: T, index: number) => boolean\n): boolean {\n let index = 0;\n let it = iter(object);\n let value: T | undefined;\n while ((value = it.next()) !== undefined) {\n if (!fn(value, index++)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Test whether any value in an iterable satisfies a predicate.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param fn - The predicate function to invoke for each value.\n *\n * @returns `true` if any value passes the test, `false` otherwise.\n *\n * #### Notes\n * Iteration terminates on the first `true` predicate result.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { some } from '@lumino/algorithm';\n *\n * let data = [5, 7, 1];\n *\n * some(data, value => value === 7); // true\n * some(data, value => value === 3); // false\n * ```\n */\nexport function some<T>(\n object: IterableOrArrayLike<T>,\n fn: (value: T, index: number) => boolean\n): boolean {\n let index = 0;\n let it = iter(object);\n let value: T | undefined;\n while ((value = it.next()) !== undefined) {\n if (fn(value, index++)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Create an array from an iterable of values.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @returns A new array of values from the given object.\n *\n * #### Example\n * ```typescript\n * import { iter, toArray } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5, 6];\n *\n * let stream = iter(data);\n *\n * toArray(stream); // [1, 2, 3, 4, 5, 6];\n * ```\n */\nexport function toArray<T>(object: IterableOrArrayLike<T>): T[] {\n let index = 0;\n let result: T[] = [];\n let it = iter(object);\n let value: T | undefined;\n while ((value = it.next()) !== undefined) {\n result[index++] = value;\n }\n return result;\n}\n\n/**\n * Create an object from an iterable of key/value pairs.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @returns A new object mapping keys to values.\n *\n * #### Example\n * ```typescript\n * import { toObject } from '@lumino/algorithm';\n *\n * let data = [['one', 1], ['two', 2], ['three', 3]];\n *\n * toObject(data); // { one: 1, two: 2, three: 3 }\n * ```\n */\nexport function toObject<T>(\n object: IterableOrArrayLike<[string, T]>\n): { [key: string]: T } {\n let it = iter(object);\n let pair: [string, T] | undefined;\n let result: { [key: string]: T } = {};\n while ((pair = it.next()) !== undefined) {\n result[pair[0]] = pair[1];\n }\n return result;\n}\n\n/**\n * An iterator for an array-like object.\n *\n * #### Notes\n * This iterator can be used for any builtin JS array-like object.\n */\nexport class ArrayIterator<T> implements IIterator<T> {\n /**\n * Construct a new array iterator.\n *\n * @param source - The array-like object of interest.\n */\n constructor(source: ArrayLike<T>) {\n this._source = source;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n let result = new ArrayIterator<T>(this._source);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n if (this._index >= this._source.length) {\n return undefined;\n }\n return this._source[this._index++];\n }\n\n private _index = 0;\n private _source: ArrayLike<T>;\n}\n\n/**\n * An iterator for the keys in an object.\n *\n * #### Notes\n * This iterator can be used for any JS object.\n */\nexport class KeyIterator implements IIterator<string> {\n /**\n * Construct a new key iterator.\n *\n * @param source - The object of interest.\n *\n * @param keys - The keys to iterate, if known.\n */\n constructor(\n source: { readonly [key: string]: any },\n keys = Object.keys(source)\n ) {\n this._source = source;\n this._keys = keys;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<string> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<string> {\n let result = new KeyIterator(this._source, this._keys);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): string | undefined {\n if (this._index >= this._keys.length) {\n return undefined;\n }\n let key = this._keys[this._index++];\n if (key in this._source) {\n return key;\n }\n return this.next();\n }\n\n private _index = 0;\n private _keys: string[];\n private _source: { readonly [key: string]: any };\n}\n\n/**\n * An iterator for the values in an object.\n *\n * #### Notes\n * This iterator can be used for any JS object.\n */\nexport class ValueIterator<T> implements IIterator<T> {\n /**\n * Construct a new value iterator.\n *\n * @param source - The object of interest.\n *\n * @param keys - The keys to iterate, if known.\n */\n constructor(\n source: { readonly [key: string]: T },\n keys = Object.keys(source)\n ) {\n this._source = source;\n this._keys = keys;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n let result = new ValueIterator<T>(this._source, this._keys);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n if (this._index >= this._keys.length) {\n return undefined;\n }\n let key = this._keys[this._index++];\n if (key in this._source) {\n return this._source[key];\n }\n return this.next();\n }\n\n private _index = 0;\n private _keys: string[];\n private _source: { readonly [key: string]: T };\n}\n\n/**\n * An iterator for the items in an object.\n *\n * #### Notes\n * This iterator can be used for any JS object.\n */\nexport class ItemIterator<T> implements IIterator<[string, T]> {\n /**\n * Construct a new item iterator.\n *\n * @param source - The object of interest.\n *\n * @param keys - The keys to iterate, if known.\n */\n constructor(\n source: { readonly [key: string]: T },\n keys = Object.keys(source)\n ) {\n this._source = source;\n this._keys = keys;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<[string, T]> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<[string, T]> {\n let result = new ItemIterator<T>(this._source, this._keys);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): [string, T] | undefined {\n if (this._index >= this._keys.length) {\n return undefined;\n }\n let key = this._keys[this._index++];\n if (key in this._source) {\n return [key, this._source[key]];\n }\n return this.next();\n }\n\n private _index = 0;\n private _keys: string[];\n private _source: { readonly [key: string]: T };\n}\n\n/**\n * An iterator for an iterator-like function.\n */\nexport class FnIterator<T> implements IIterator<T> {\n /**\n * Construct a new function iterator.\n *\n * @param fn - The iterator-like function of interest.\n */\n constructor(fn: () => T | undefined) {\n this._fn = fn;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n throw new Error('An `FnIterator` cannot be cloned.');\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n return this._fn.call(undefined);\n }\n\n private _fn: () => T | undefined;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\n\n/**\n * The namespace for array-specific algorithms.\n */\nexport namespace ArrayExt {\n /**\n * Find the index of the first occurrence of a value in an array.\n *\n * @param array - The array-like object to search.\n *\n * @param value - The value to locate in the array. Values are\n * compared using strict `===` equality.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the first occurrence of the value, or `-1`\n * if the value is not found.\n *\n * #### Notes\n * If `stop < start` the search will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = ['one', 'two', 'three', 'four', 'one'];\n * ArrayExt.firstIndexOf(data, 'red'); // -1\n * ArrayExt.firstIndexOf(data, 'one'); // 0\n * ArrayExt.firstIndexOf(data, 'one', 1); // 4\n * ArrayExt.firstIndexOf(data, 'two', 2); // -1\n * ArrayExt.firstIndexOf(data, 'two', 2, 1); // 1\n * ```\n */\n export function firstIndexOf<T>(\n array: ArrayLike<T>,\n value: T,\n start = 0,\n stop = -1\n ): number {\n let n = array.length;\n if (n === 0) {\n return -1;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let span: number;\n if (stop < start) {\n span = stop + 1 + (n - start);\n } else {\n span = stop - start + 1;\n }\n for (let i = 0; i < span; ++i) {\n let j = (start + i) % n;\n if (array[j] === value) {\n return j;\n }\n }\n return -1;\n }\n\n /**\n * Find the index of the last occurrence of a value in an array.\n *\n * @param array - The array-like object to search.\n *\n * @param value - The value to locate in the array. Values are\n * compared using strict `===` equality.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the last occurrence of the value, or `-1`\n * if the value is not found.\n *\n * #### Notes\n * If `start < stop` the search will wrap at the front of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = ['one', 'two', 'three', 'four', 'one'];\n * ArrayExt.lastIndexOf(data, 'red'); // -1\n * ArrayExt.lastIndexOf(data, 'one'); // 4\n * ArrayExt.lastIndexOf(data, 'one', 1); // 0\n * ArrayExt.lastIndexOf(data, 'two', 0); // -1\n * ArrayExt.lastIndexOf(data, 'two', 0, 1); // 1\n * ```\n */\n export function lastIndexOf<T>(\n array: ArrayLike<T>,\n value: T,\n start = -1,\n stop = 0\n ): number {\n let n = array.length;\n if (n === 0) {\n return -1;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let span: number;\n if (start < stop) {\n span = start + 1 + (n - stop);\n } else {\n span = start - stop + 1;\n }\n for (let i = 0; i < span; ++i) {\n let j = (start - i + n) % n;\n if (array[j] === value) {\n return j;\n }\n }\n return -1;\n }\n\n /**\n * Find the index of the first value which matches a predicate.\n *\n * @param array - The array-like object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the first matching value, or `-1` if no\n * matching value is found.\n *\n * #### Notes\n * If `stop < start` the search will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` which is non-integral.\n *\n * Modifying the length of the array while searching.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function isEven(value: number): boolean {\n * return value % 2 === 0;\n * }\n *\n * let data = [1, 2, 3, 4, 3, 2, 1];\n * ArrayExt.findFirstIndex(data, isEven); // 1\n * ArrayExt.findFirstIndex(data, isEven, 4); // 5\n * ArrayExt.findFirstIndex(data, isEven, 6); // -1\n * ArrayExt.findFirstIndex(data, isEven, 6, 5); // 1\n * ```\n */\n export function findFirstIndex<T>(\n array: ArrayLike<T>,\n fn: (value: T, index: number) => boolean,\n start = 0,\n stop = -1\n ): number {\n let n = array.length;\n if (n === 0) {\n return -1;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let span: number;\n if (stop < start) {\n span = stop + 1 + (n - start);\n } else {\n span = stop - start + 1;\n }\n for (let i = 0; i < span; ++i) {\n let j = (start + i) % n;\n if (fn(array[j], j)) {\n return j;\n }\n }\n return -1;\n }\n\n /**\n * Find the index of the last value which matches a predicate.\n *\n * @param object - The array-like object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the last matching value, or `-1` if no\n * matching value is found.\n *\n * #### Notes\n * If `start < stop` the search will wrap at the front of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` which is non-integral.\n *\n * Modifying the length of the array while searching.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function isEven(value: number): boolean {\n * return value % 2 === 0;\n * }\n *\n * let data = [1, 2, 3, 4, 3, 2, 1];\n * ArrayExt.findLastIndex(data, isEven); // 5\n * ArrayExt.findLastIndex(data, isEven, 4); // 3\n * ArrayExt.findLastIndex(data, isEven, 0); // -1\n * ArrayExt.findLastIndex(data, isEven, 0, 1); // 5\n * ```\n */\n export function findLastIndex<T>(\n array: ArrayLike<T>,\n fn: (value: T, index: number) => boolean,\n start = -1,\n stop = 0\n ): number {\n let n = array.length;\n if (n === 0) {\n return -1;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let d: number;\n if (start < stop) {\n d = start + 1 + (n - stop);\n } else {\n d = start - stop + 1;\n }\n for (let i = 0; i < d; ++i) {\n let j = (start - i + n) % n;\n if (fn(array[j], j)) {\n return j;\n }\n }\n return -1;\n }\n\n /**\n * Find the first value which matches a predicate.\n *\n * @param array - The array-like object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The first matching value, or `undefined` if no matching\n * value is found.\n *\n * #### Notes\n * If `stop < start` the search will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` which is non-integral.\n *\n * Modifying the length of the array while searching.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function isEven(value: number): boolean {\n * return value % 2 === 0;\n * }\n *\n * let data = [1, 2, 3, 4, 3, 2, 1];\n * ArrayExt.findFirstValue(data, isEven); // 2\n * ArrayExt.findFirstValue(data, isEven, 2); // 4\n * ArrayExt.findFirstValue(data, isEven, 6); // undefined\n * ArrayExt.findFirstValue(data, isEven, 6, 5); // 2\n * ```\n */\n export function findFirstValue<T>(\n array: ArrayLike<T>,\n fn: (value: T, index: number) => boolean,\n start = 0,\n stop = -1\n ): T | undefined {\n let index = findFirstIndex(array, fn, start, stop);\n return index !== -1 ? array[index] : undefined;\n }\n\n /**\n * Find the last value which matches a predicate.\n *\n * @param object - The array-like object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The last matching value, or `undefined` if no matching\n * value is found.\n *\n * #### Notes\n * If `start < stop` the search will wrap at the front of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` which is non-integral.\n *\n * Modifying the length of the array while searching.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function isEven(value: number): boolean {\n * return value % 2 === 0;\n * }\n *\n * let data = [1, 2, 3, 4, 3, 2, 1];\n * ArrayExt.findLastValue(data, isEven); // 2\n * ArrayExt.findLastValue(data, isEven, 4); // 4\n * ArrayExt.findLastValue(data, isEven, 0); // undefined\n * ArrayExt.findLastValue(data, isEven, 0, 1); // 2\n * ```\n */\n export function findLastValue<T>(\n array: ArrayLike<T>,\n fn: (value: T, index: number) => boolean,\n start = -1,\n stop = 0\n ): T | undefined {\n let index = findLastIndex(array, fn, start, stop);\n return index !== -1 ? array[index] : undefined;\n }\n\n /**\n * Find the index of the first element which compares `>=` to a value.\n *\n * @param array - The sorted array-like object to search.\n *\n * @param value - The value to locate in the array.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n * It should return `< 0` if an element is less than a value, `0` if\n * an element is equal to a value, or `> 0` if an element is greater\n * than a value.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the first element which compares `>=` to the\n * value, or `length` if there is no such element. If the computed\n * index for `stop` is less than `start`, then the computed index\n * for `start` is returned.\n *\n * #### Notes\n * The array must already be sorted in ascending order according to\n * the comparison function.\n *\n * #### Complexity\n * Logarithmic.\n *\n * #### Undefined Behavior\n * Searching a range which is not sorted in ascending order.\n *\n * A `start` or `stop` which is non-integral.\n *\n * Modifying the length of the array while searching.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n * return a - b;\n * }\n *\n * let data = [0, 3, 4, 7, 7, 9];\n * ArrayExt.lowerBound(data, 0, numberCmp); // 0\n * ArrayExt.lowerBound(data, 6, numberCmp); // 3\n * ArrayExt.lowerBound(data, 7, numberCmp); // 3\n * ArrayExt.lowerBound(data, -1, numberCmp); // 0\n * ArrayExt.lowerBound(data, 10, numberCmp); // 6\n * ```\n */\n export function lowerBound<T, U>(\n array: ArrayLike<T>,\n value: U,\n fn: (element: T, value: U) => number,\n start = 0,\n stop = -1\n ): number {\n let n = array.length;\n if (n === 0) {\n return 0;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let begin = start;\n let span = stop - start + 1;\n while (span > 0) {\n let half = span >> 1;\n let middle = begin + half;\n if (fn(array[middle], value) < 0) {\n begin = middle + 1;\n span -= half + 1;\n } else {\n span = half;\n }\n }\n return begin;\n }\n\n /**\n * Find the index of the first element which compares `>` than a value.\n *\n * @param array - The sorted array-like object to search.\n *\n * @param value - The value to locate in the array.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n * It should return `< 0` if an element is less than a value, `0` if\n * an element is equal to a value, or `> 0` if an element is greater\n * than a value.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the first element which compares `>` than the\n * value, or `length` if there is no such element. If the computed\n * index for `stop` is less than `start`, then the computed index\n * for `start` is returned.\n *\n * #### Notes\n * The array must already be sorted in ascending order according to\n * the comparison function.\n *\n * #### Complexity\n * Logarithmic.\n *\n * #### Undefined Behavior\n * Searching a range which is not sorted in ascending order.\n *\n * A `start` or `stop` which is non-integral.\n *\n * Modifying the length of the array while searching.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n * return a - b;\n * }\n *\n * let data = [0, 3, 4, 7, 7, 9];\n * ArrayExt.upperBound(data, 0, numberCmp); // 1\n * ArrayExt.upperBound(data, 6, numberCmp); // 3\n * ArrayExt.upperBound(data, 7, numberCmp); // 5\n * ArrayExt.upperBound(data, -1, numberCmp); // 0\n * ArrayExt.upperBound(data, 10, numberCmp); // 6\n * ```\n */\n export function upperBound<T, U>(\n array: ArrayLike<T>,\n value: U,\n fn: (element: T, value: U) => number,\n start = 0,\n stop = -1\n ): number {\n let n = array.length;\n if (n === 0) {\n return 0;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let begin = start;\n let span = stop - start + 1;\n while (span > 0) {\n let half = span >> 1;\n let middle = begin + half;\n if (fn(array[middle], value) > 0) {\n span = half;\n } else {\n begin = middle + 1;\n span -= half + 1;\n }\n }\n return begin;\n }\n\n /**\n * Test whether two arrays are shallowly equal.\n *\n * @param a - The first array-like object to compare.\n *\n * @param b - The second array-like object to compare.\n *\n * @param fn - The comparison function to apply to the elements. It\n * should return `true` if the elements are \"equal\". The default\n * compares elements using strict `===` equality.\n *\n * @returns Whether the two arrays are shallowly equal.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * Modifying the length of the arrays while comparing.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let d1 = [0, 3, 4, 7, 7, 9];\n * let d2 = [0, 3, 4, 7, 7, 9];\n * let d3 = [42];\n * ArrayExt.shallowEqual(d1, d2); // true\n * ArrayExt.shallowEqual(d2, d3); // false\n * ```\n */\n export function shallowEqual<T>(\n a: ArrayLike<T>,\n b: ArrayLike<T>,\n fn?: (a: T, b: T) => boolean\n ): boolean {\n // Check for object identity first.\n if (a === b) {\n return true;\n }\n\n // Bail early if the lengths are different.\n if (a.length !== b.length) {\n return false;\n }\n\n // Compare each element for equality.\n for (let i = 0, n = a.length; i < n; ++i) {\n if (fn ? !fn(a[i], b[i]) : a[i] !== b[i]) {\n return false;\n }\n }\n\n // The array are shallowly equal.\n return true;\n }\n\n /**\n * Create a slice of an array subject to an optional step.\n *\n * @param array - The array-like object of interest.\n *\n * @param options - The options for configuring the slice.\n *\n * @returns A new array with the specified values.\n *\n * @throws An exception if the slice `step` is `0`.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start`, `stop`, or `step` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [0, 3, 4, 7, 7, 9];\n * ArrayExt.slice(data); // [0, 3, 4, 7, 7, 9]\n * ArrayExt.slice(data, { start: 2 }); // [4, 7, 7, 9]\n * ArrayExt.slice(data, { start: 0, stop: 4 }); // [0, 3, 4, 7]\n * ArrayExt.slice(data, { step: 2 }); // [0, 4, 7]\n * ArrayExt.slice(data, { step: -1 }); // [9, 7, 7, 4, 3, 0]\n * ```\n */\n export function slice<T>(\n array: ArrayLike<T>,\n options: slice.IOptions = {}\n ): T[] {\n // Extract the options.\n let { start, stop, step } = options;\n\n // Set up the `step` value.\n if (step === undefined) {\n step = 1;\n }\n\n // Validate the step size.\n if (step === 0) {\n throw new Error('Slice `step` cannot be zero.');\n }\n\n // Look up the length of the array.\n let n = array.length;\n\n // Set up the `start` value.\n if (start === undefined) {\n start = step < 0 ? n - 1 : 0;\n } else if (start < 0) {\n start = Math.max(start + n, step < 0 ? -1 : 0);\n } else if (start >= n) {\n start = step < 0 ? n - 1 : n;\n }\n\n // Set up the `stop` value.\n if (stop === undefined) {\n stop = step < 0 ? -1 : n;\n } else if (stop < 0) {\n stop = Math.max(stop + n, step < 0 ? -1 : 0);\n } else if (stop >= n) {\n stop = step < 0 ? n - 1 : n;\n }\n\n // Compute the slice length.\n let length;\n if ((step < 0 && stop >= start) || (step > 0 && start >= stop)) {\n length = 0;\n } else if (step < 0) {\n length = Math.floor((stop - start + 1) / step + 1);\n } else {\n length = Math.floor((stop - start - 1) / step + 1);\n }\n\n // Compute the sliced result.\n let result: T[] = [];\n for (let i = 0; i < length; ++i) {\n result[i] = array[start + i * step];\n }\n\n // Return the result.\n return result;\n }\n\n /**\n * The namespace for the `slice` function statics.\n */\n export namespace slice {\n /**\n * The options for the `slice` function.\n */\n export interface IOptions {\n /**\n * The starting index of the slice, inclusive.\n *\n * Negative values are taken as an offset from the end\n * of the array.\n *\n * The default is `0` if `step > 0` else `n - 1`.\n */\n start?: number;\n\n /**\n * The stopping index of the slice, exclusive.\n *\n * Negative values are taken as an offset from the end\n * of the array.\n *\n * The default is `n` if `step > 0` else `-n - 1`.\n */\n stop?: number;\n\n /**\n * The step value for the slice.\n *\n * This must not be `0`.\n *\n * The default is `1`.\n */\n step?: number;\n }\n }\n\n /**\n * An array-like object which supports item assignment.\n */\n export type MutableArrayLike<T> = {\n readonly length: number;\n [index: number]: T;\n };\n\n /**\n * Move an element in an array from one index to another.\n *\n * @param array - The mutable array-like object of interest.\n *\n * @param fromIndex - The index of the element to move. Negative\n * values are taken as an offset from the end of the array.\n *\n * @param toIndex - The target index of the element. Negative\n * values are taken as an offset from the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `fromIndex` or `toIndex` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from from '@lumino/algorithm';\n *\n * let data = [0, 1, 2, 3, 4];\n * ArrayExt.move(data, 1, 2); // [0, 2, 1, 3, 4]\n * ArrayExt.move(data, 4, 2); // [0, 2, 4, 1, 3]\n * ```\n */\n export function move<T>(\n array: MutableArrayLike<T>,\n fromIndex: number,\n toIndex: number\n ): void {\n let n = array.length;\n if (n <= 1) {\n return;\n }\n if (fromIndex < 0) {\n fromIndex = Math.max(0, fromIndex + n);\n } else {\n fromIndex = Math.min(fromIndex, n - 1);\n }\n if (toIndex < 0) {\n toIndex = Math.max(0, toIndex + n);\n } else {\n toIndex = Math.min(toIndex, n - 1);\n }\n if (fromIndex === toIndex) {\n return;\n }\n let value = array[fromIndex];\n let d = fromIndex < toIndex ? 1 : -1;\n for (let i = fromIndex; i !== toIndex; i += d) {\n array[i] = array[i + d];\n }\n array[toIndex] = value;\n }\n\n /**\n * Reverse an array in-place.\n *\n * @param array - The mutable array-like object of interest.\n *\n * @param start - The index of the first element in the range to be\n * reversed, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * reversed, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` index which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [0, 1, 2, 3, 4];\n * ArrayExt.reverse(data, 1, 3); // [0, 3, 2, 1, 4]\n * ArrayExt.reverse(data, 3); // [0, 3, 2, 4, 1]\n * ArrayExt.reverse(data); // [1, 4, 2, 3, 0]\n * ```\n */\n export function reverse<T>(\n array: MutableArrayLike<T>,\n start = 0,\n stop = -1\n ): void {\n let n = array.length;\n if (n <= 1) {\n return;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n while (start < stop) {\n let a = array[start];\n let b = array[stop];\n array[start++] = b;\n array[stop--] = a;\n }\n }\n\n /**\n * Rotate the elements of an array in-place.\n *\n * @param array - The mutable array-like object of interest.\n *\n * @param delta - The amount of rotation to apply to the elements. A\n * positive value will rotate the elements to the left. A negative\n * value will rotate the elements to the right.\n *\n * @param start - The index of the first element in the range to be\n * rotated, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * rotated, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `delta`, `start`, or `stop` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [0, 1, 2, 3, 4];\n * ArrayExt.rotate(data, 2); // [2, 3, 4, 0, 1]\n * ArrayExt.rotate(data, -2); // [0, 1, 2, 3, 4]\n * ArrayExt.rotate(data, 10); // [0, 1, 2, 3, 4]\n * ArrayExt.rotate(data, 9); // [4, 0, 1, 2, 3]\n * ArrayExt.rotate(data, 2, 1, 3); // [4, 2, 0, 1, 3]\n * ```\n */\n export function rotate<T>(\n array: MutableArrayLike<T>,\n delta: number,\n start = 0,\n stop = -1\n ): void {\n let n = array.length;\n if (n <= 1) {\n return;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n if (start >= stop) {\n return;\n }\n let length = stop - start + 1;\n if (delta > 0) {\n delta = delta % length;\n } else if (delta < 0) {\n delta = ((delta % length) + length) % length;\n }\n if (delta === 0) {\n return;\n }\n let pivot = start + delta;\n reverse(array, start, pivot - 1);\n reverse(array, pivot, stop);\n reverse(array, start, stop);\n }\n\n /**\n * Fill an array with a static value.\n *\n * @param array - The mutable array-like object to fill.\n *\n * @param value - The static value to use to fill the array.\n *\n * @param start - The index of the first element in the range to be\n * filled, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * filled, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * #### Notes\n * If `stop < start` the fill will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * A `start` or `stop` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = ['one', 'two', 'three', 'four'];\n * ArrayExt.fill(data, 'r'); // ['r', 'r', 'r', 'r']\n * ArrayExt.fill(data, 'g', 1); // ['r', 'g', 'g', 'g']\n * ArrayExt.fill(data, 'b', 2, 3); // ['r', 'g', 'b', 'b']\n * ArrayExt.fill(data, 'z', 3, 1); // ['z', 'z', 'b', 'z']\n * ```\n */\n export function fill<T>(\n array: MutableArrayLike<T>,\n value: T,\n start = 0,\n stop = -1\n ): void {\n let n = array.length;\n if (n === 0) {\n return;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let span: number;\n if (stop < start) {\n span = stop + 1 + (n - start);\n } else {\n span = stop - start + 1;\n }\n for (let i = 0; i < span; ++i) {\n array[(start + i) % n] = value;\n }\n }\n\n /**\n * Insert a value into an array at a specific index.\n *\n * @param array - The array of interest.\n *\n * @param index - The index at which to insert the value. Negative\n * values are taken as an offset from the end of the array.\n *\n * @param value - The value to set at the specified index.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * An `index` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [0, 1, 2];\n * ArrayExt.insert(data, 0, -1); // [-1, 0, 1, 2]\n * ArrayExt.insert(data, 2, 12); // [-1, 0, 12, 1, 2]\n * ArrayExt.insert(data, -1, 7); // [-1, 0, 12, 1, 7, 2]\n * ArrayExt.insert(data, 6, 19); // [-1, 0, 12, 1, 7, 2, 19]\n * ```\n */\n export function insert<T>(array: Array<T>, index: number, value: T): void {\n let n = array.length;\n if (index < 0) {\n index = Math.max(0, index + n);\n } else {\n index = Math.min(index, n);\n }\n for (let i = n; i > index; --i) {\n array[i] = array[i - 1];\n }\n array[index] = value;\n }\n\n /**\n * Remove and return a value at a specific index in an array.\n *\n * @param array - The array of interest.\n *\n * @param index - The index of the value to remove. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The value at the specified index, or `undefined` if the\n * index is out of range.\n *\n * #### Complexity\n * Linear.\n *\n * #### Undefined Behavior\n * An `index` which is non-integral.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [0, 12, 23, 39, 14, 12, 75];\n * ArrayExt.removeAt(data, 2); // 23\n * ArrayExt.removeAt(data, -2); // 12\n * ArrayExt.removeAt(data, 10); // undefined;\n * ```\n */\n export function removeAt<T>(array: Array<T>, index: number): T | undefined {\n let n = array.length;\n if (index < 0) {\n index += n;\n }\n if (index < 0 || index >= n) {\n return undefined;\n }\n let value = array[index];\n for (let i = index + 1; i < n; ++i) {\n array[i - 1] = array[i];\n }\n array.length = n - 1;\n return value;\n }\n\n /**\n * Remove the first occurrence of a value from an array.\n *\n * @param array - The array of interest.\n *\n * @param value - The value to remove from the array. Values are\n * compared using strict `===` equality.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the removed value, or `-1` if the value\n * is not contained in the array.\n *\n * #### Notes\n * If `stop < start` the search will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [0, 12, 23, 39, 14, 12, 75];\n * ArrayExt.removeFirstOf(data, 12); // 1\n * ArrayExt.removeFirstOf(data, 17); // -1\n * ArrayExt.removeFirstOf(data, 39, 3); // -1\n * ArrayExt.removeFirstOf(data, 39, 3, 2); // 2\n * ```\n */\n export function removeFirstOf<T>(\n array: Array<T>,\n value: T,\n start = 0,\n stop = -1\n ): number {\n let index = firstIndexOf(array, value, start, stop);\n if (index !== -1) {\n removeAt(array, index);\n }\n return index;\n }\n\n /**\n * Remove the last occurrence of a value from an array.\n *\n * @param array - The array of interest.\n *\n * @param value - The value to remove from the array. Values are\n * compared using strict `===` equality.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The index of the removed value, or `-1` if the value\n * is not contained in the array.\n *\n * #### Notes\n * If `start < stop` the search will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [0, 12, 23, 39, 14, 12, 75];\n * ArrayExt.removeLastOf(data, 12); // 5\n * ArrayExt.removeLastOf(data, 17); // -1\n * ArrayExt.removeLastOf(data, 39, 2); // -1\n * ArrayExt.removeLastOf(data, 39, 2, 3); // 3\n * ```\n */\n export function removeLastOf<T>(\n array: Array<T>,\n value: T,\n start = -1,\n stop = 0\n ): number {\n let index = lastIndexOf(array, value, start, stop);\n if (index !== -1) {\n removeAt(array, index);\n }\n return index;\n }\n\n /**\n * Remove all occurrences of a value from an array.\n *\n * @param array - The array of interest.\n *\n * @param value - The value to remove from the array. Values are\n * compared using strict `===` equality.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The number of elements removed from the array.\n *\n * #### Notes\n * If `stop < start` the search will conceptually wrap at the end of\n * the array, however the array will be traversed front-to-back.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * let data = [14, 12, 23, 39, 14, 12, 19, 14];\n * ArrayExt.removeAllOf(data, 12); // 2\n * ArrayExt.removeAllOf(data, 17); // 0\n * ArrayExt.removeAllOf(data, 14, 1, 4); // 1\n * ```\n */\n export function removeAllOf<T>(\n array: Array<T>,\n value: T,\n start = 0,\n stop = -1\n ): number {\n let n = array.length;\n if (n === 0) {\n return 0;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let count = 0;\n for (let i = 0; i < n; ++i) {\n if (start <= stop && i >= start && i <= stop && array[i] === value) {\n count++;\n } else if (\n stop < start &&\n (i <= stop || i >= start) &&\n array[i] === value\n ) {\n count++;\n } else if (count > 0) {\n array[i - count] = array[i];\n }\n }\n if (count > 0) {\n array.length = n - count;\n }\n return count;\n }\n\n /**\n * Remove the first occurrence of a value which matches a predicate.\n *\n * @param array - The array of interest.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The removed `{ index, value }`, which will be `-1` and\n * `undefined` if the value is not contained in the array.\n *\n * #### Notes\n * If `stop < start` the search will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function isEven(value: number): boolean {\n * return value % 2 === 0;\n * }\n *\n * let data = [0, 12, 23, 39, 14, 12, 75];\n * ArrayExt.removeFirstWhere(data, isEven); // { index: 0, value: 0 }\n * ArrayExt.removeFirstWhere(data, isEven, 2); // { index: 3, value: 14 }\n * ArrayExt.removeFirstWhere(data, isEven, 4); // { index: -1, value: undefined }\n * ```\n */\n export function removeFirstWhere<T>(\n array: Array<T>,\n fn: (value: T, index: number) => boolean,\n start = 0,\n stop = -1\n ): { index: number; value: T | undefined } {\n let value: T | undefined;\n let index = findFirstIndex(array, fn, start, stop);\n if (index !== -1) {\n value = removeAt(array, index);\n }\n return { index, value };\n }\n\n /**\n * Remove the last occurrence of a value which matches a predicate.\n *\n * @param array - The array of interest.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The removed `{ index, value }`, which will be `-1` and\n * `undefined` if the value is not contained in the array.\n *\n * #### Notes\n * If `start < stop` the search will wrap at the end of the array.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function isEven(value: number): boolean {\n * return value % 2 === 0;\n * }\n *\n * let data = [0, 12, 23, 39, 14, 12, 75];\n * ArrayExt.removeLastWhere(data, isEven); // { index: 5, value: 12 }\n * ArrayExt.removeLastWhere(data, isEven, 2); // { index: 1, value: 12 }\n * ArrayExt.removeLastWhere(data, isEven, 2, 1); // { index: -1, value: undefined }\n * ```\n */\n export function removeLastWhere<T>(\n array: Array<T>,\n fn: (value: T, index: number) => boolean,\n start = -1,\n stop = 0\n ): { index: number; value: T | undefined } {\n let value: T | undefined;\n let index = findLastIndex(array, fn, start, stop);\n if (index !== -1) {\n value = removeAt(array, index);\n }\n return { index, value };\n }\n\n /**\n * Remove all occurrences of values which match a predicate.\n *\n * @param array - The array of interest.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @param start - The index of the first element in the range to be\n * searched, inclusive. The default value is `0`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @param stop - The index of the last element in the range to be\n * searched, inclusive. The default value is `-1`. Negative values\n * are taken as an offset from the end of the array.\n *\n * @returns The number of elements removed from the array.\n *\n * #### Notes\n * If `stop < start` the search will conceptually wrap at the end of\n * the array, however the array will be traversed front-to-back.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { ArrayExt } from '@lumino/algorithm';\n *\n * function isEven(value: number): boolean {\n * return value % 2 === 0;\n * }\n *\n * function isNegative(value: number): boolean {\n * return value < 0;\n * }\n *\n * let data = [0, 12, -13, -9, 23, 39, 14, -15, 12, 75];\n * ArrayExt.removeAllWhere(data, isEven); // 4\n * ArrayExt.removeAllWhere(data, isNegative, 0, 3); // 2\n * ```\n */\n export function removeAllWhere<T>(\n array: Array<T>,\n fn: (value: T, index: number) => boolean,\n start = 0,\n stop = -1\n ): number {\n let n = array.length;\n if (n === 0) {\n return 0;\n }\n if (start < 0) {\n start = Math.max(0, start + n);\n } else {\n start = Math.min(start, n - 1);\n }\n if (stop < 0) {\n stop = Math.max(0, stop + n);\n } else {\n stop = Math.min(stop, n - 1);\n }\n let count = 0;\n for (let i = 0; i < n; ++i) {\n if (start <= stop && i >= start && i <= stop && fn(array[i], i)) {\n count++;\n } else if (stop < start && (i <= stop || i >= start) && fn(array[i], i)) {\n count++;\n } else if (count > 0) {\n array[i - count] = array[i];\n }\n }\n if (count > 0) {\n array.length = n - count;\n }\n return count;\n }\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator, iter, IterableOrArrayLike } from './iter';\n\n/**\n * Chain together several iterables.\n *\n * @param objects - The iterable or array-like objects of interest.\n *\n * @returns An iterator which yields the values of the iterables\n * in the order in which they are supplied.\n *\n * #### Example\n * ```typescript\n * import { chain, toArray } from '@lumino/algorithm';\n *\n * let data1 = [1, 2, 3];\n * let data2 = [4, 5, 6];\n *\n * let stream = chain(data1, data2);\n *\n * toArray(stream); // [1, 2, 3, 4, 5, 6]\n * ```\n */\nexport function chain<T>(...objects: IterableOrArrayLike<T>[]): IIterator<T> {\n return new ChainIterator<T>(iter(objects.map(iter)));\n}\n\n/**\n * An iterator which chains together several iterators.\n */\nexport class ChainIterator<T> implements IIterator<T> {\n /**\n * Construct a new chain iterator.\n *\n * @param source - The iterator of iterators of interest.\n */\n constructor(source: IIterator<IIterator<T>>) {\n this._source = source;\n this._active = undefined;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n let result = new ChainIterator<T>(this._source.clone());\n result._active = this._active && this._active.clone();\n result._cloned = true;\n this._cloned = true;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n if (this._active === undefined) {\n let active = this._source.next();\n if (active === undefined) {\n return undefined;\n }\n this._active = this._cloned ? active.clone() : active;\n }\n let value = this._active.next();\n if (value !== undefined) {\n return value;\n }\n this._active = undefined;\n return this.next();\n }\n\n private _source: IIterator<IIterator<T>>;\n private _active: IIterator<T> | undefined;\n private _cloned = false;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator } from './iter';\n\n/**\n * Create an empty iterator.\n *\n * @returns A new iterator which yields nothing.\n *\n * #### Example\n * ```typescript\n * import { empty, toArray } from '@lumino/algorithm';\n *\n * let stream = empty<number>();\n *\n * toArray(stream); // []\n * ```\n */\nexport function empty<T>(): IIterator<T> {\n return new EmptyIterator<T>();\n}\n\n/**\n * An iterator which is always empty.\n */\nexport class EmptyIterator<T> implements IIterator<T> {\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n return new EmptyIterator<T>();\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n return undefined;\n }\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator, iter, IterableOrArrayLike } from './iter';\n\n/**\n * Enumerate an iterable object.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param start - The starting enum value. The default is `0`.\n *\n * @returns An iterator which yields the enumerated values.\n *\n * #### Example\n * ```typescript\n * import { enumerate, toArray } from '@lumino/algorithm';\n *\n * let data = ['foo', 'bar', 'baz'];\n *\n * let stream = enumerate(data, 1);\n *\n * toArray(stream); // [[1, 'foo'], [2, 'bar'], [3, 'baz']]\n * ```\n */\nexport function enumerate<T>(\n object: IterableOrArrayLike<T>,\n start = 0\n): IIterator<[number, T]> {\n return new EnumerateIterator<T>(iter(object), start);\n}\n\n/**\n * An iterator which enumerates the source values.\n */\nexport class EnumerateIterator<T> implements IIterator<[number, T]> {\n /**\n * Construct a new enumerate iterator.\n *\n * @param source - The iterator of values of interest.\n *\n * @param start - The starting enum value.\n */\n constructor(source: IIterator<T>, start: number) {\n this._source = source;\n this._index = start;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<[number, T]> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<[number, T]> {\n return new EnumerateIterator<T>(this._source.clone(), this._index);\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): [number, T] | undefined {\n let value = this._source.next();\n if (value === undefined) {\n return undefined;\n }\n return [this._index++, value];\n }\n\n private _source: IIterator<T>;\n private _index: number;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator, iter, IterableOrArrayLike } from './iter';\n\n/**\n * Filter an iterable for values which pass a test.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param fn - The predicate function to invoke for each value.\n *\n * @returns An iterator which yields the values which pass the test.\n *\n * #### Example\n * ```typescript\n * import { filter, toArray } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5, 6];\n *\n * let stream = filter(data, value => value % 2 === 0);\n *\n * toArray(stream); // [2, 4, 6]\n * ```\n */\nexport function filter<T>(\n object: IterableOrArrayLike<T>,\n fn: (value: T, index: number) => boolean\n): IIterator<T> {\n return new FilterIterator<T>(iter(object), fn);\n}\n\n/**\n * An iterator which yields values which pass a test.\n */\nexport class FilterIterator<T> implements IIterator<T> {\n /**\n * Construct a new filter iterator.\n *\n * @param source - The iterator of values of interest.\n *\n * @param fn - The predicate function to invoke for each value.\n */\n constructor(source: IIterator<T>, fn: (value: T, index: number) => boolean) {\n this._source = source;\n this._fn = fn;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n let result = new FilterIterator<T>(this._source.clone(), this._fn);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n let fn = this._fn;\n let it = this._source;\n let value: T | undefined;\n while ((value = it.next()) !== undefined) {\n if (fn(value, this._index++)) {\n return value;\n }\n }\n return undefined;\n }\n\n private _index = 0;\n private _source: IIterator<T>;\n private _fn: (value: T, index: number) => boolean;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator, iter, IterableOrArrayLike } from './iter';\n\n/**\n * Transform the values of an iterable with a mapping function.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param fn - The mapping function to invoke for each value.\n *\n * @returns An iterator which yields the transformed values.\n *\n * #### Example\n * ```typescript\n * import { map, toArray } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3];\n *\n * let stream = map(data, value => value * 2);\n *\n * toArray(stream); // [2, 4, 6]\n * ```\n */\nexport function map<T, U>(\n object: IterableOrArrayLike<T>,\n fn: (value: T, index: number) => U\n): IIterator<U> {\n return new MapIterator<T, U>(iter(object), fn);\n}\n\n/**\n * An iterator which transforms values using a mapping function.\n */\nexport class MapIterator<T, U> implements IIterator<U> {\n /**\n * Construct a new map iterator.\n *\n * @param source - The iterator of values of interest.\n *\n * @param fn - The mapping function to invoke for each value.\n */\n constructor(source: IIterator<T>, fn: (value: T, index: number) => U) {\n this._source = source;\n this._fn = fn;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<U> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<U> {\n let result = new MapIterator<T, U>(this._source.clone(), this._fn);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): U | undefined {\n let value = this._source.next();\n if (value === undefined) {\n return undefined;\n }\n return this._fn.call(undefined, value, this._index++);\n }\n\n private _index = 0;\n private _source: IIterator<T>;\n private _fn: (value: T, index: number) => U;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator } from './iter';\n\n/**\n * Create an iterator of evenly spaced values.\n *\n * @param start - The starting value for the range, inclusive.\n *\n * @param stop - The stopping value for the range, exclusive.\n *\n * @param step - The distance between each value.\n *\n * @returns An iterator which produces evenly spaced values.\n *\n * #### Notes\n * In the single argument form of `range(stop)`, `start` defaults to\n * `0` and `step` defaults to `1`.\n *\n * In the two argument form of `range(start, stop)`, `step` defaults\n * to `1`.\n */\nexport function range(\n start: number,\n stop?: number,\n step?: number\n): IIterator<number> {\n if (stop === undefined) {\n return new RangeIterator(0, start, 1);\n }\n if (step === undefined) {\n return new RangeIterator(start, stop, 1);\n }\n return new RangeIterator(start, stop, step);\n}\n\n/**\n * An iterator which produces a range of evenly spaced values.\n */\nexport class RangeIterator implements IIterator<number> {\n /**\n * Construct a new range iterator.\n *\n * @param start - The starting value for the range, inclusive.\n *\n * @param stop - The stopping value for the range, exclusive.\n *\n * @param step - The distance between each value.\n */\n constructor(start: number, stop: number, step: number) {\n this._start = start;\n this._stop = stop;\n this._step = step;\n this._length = Private.rangeLength(start, stop, step);\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<number> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<number> {\n let result = new RangeIterator(this._start, this._stop, this._step);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): number | undefined {\n if (this._index >= this._length) {\n return undefined;\n }\n return this._start + this._step * this._index++;\n }\n\n private _index = 0;\n private _length: number;\n private _start: number;\n private _stop: number;\n private _step: number;\n}\n\n/**\n * The namespace for the module implementation details.\n */\nnamespace Private {\n /**\n * Compute the effective length of a range.\n *\n * @param start - The starting value for the range, inclusive.\n *\n * @param stop - The stopping value for the range, exclusive.\n *\n * @param step - The distance between each value.\n *\n * @returns The number of steps need to traverse the range.\n */\n export function rangeLength(\n start: number,\n stop: number,\n step: number\n ): number {\n if (step === 0) {\n return Infinity;\n }\n if (start > stop && step > 0) {\n return 0;\n }\n if (start < stop && step < 0) {\n return 0;\n }\n return Math.ceil((stop - start) / step);\n }\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator } from './iter';\n\n/**\n * Create an iterator which repeats a value a number of times.\n *\n * @param value - The value to repeat.\n *\n * @param count - The number of times to repeat the value.\n *\n * @returns A new iterator which repeats the specified value.\n *\n * #### Example\n * ```typescript\n * import { repeat, toArray } from '@lumino/algorithm';\n *\n * let stream = repeat(7, 3);\n *\n * toArray(stream); // [7, 7, 7]\n * ```\n */\nexport function repeat<T>(value: T, count: number): IIterator<T> {\n return new RepeatIterator<T>(value, count);\n}\n\n/**\n * Create an iterator which yields a value a single time.\n *\n * @param value - The value to wrap in an iterator.\n *\n * @returns A new iterator which yields the value a single time.\n *\n * #### Example\n * ```typescript\n * import { once, toArray } from '@lumino/algorithm';\n *\n * let stream = once(7);\n *\n * toArray(stream); // [7]\n * ```\n */\nexport function once<T>(value: T): IIterator<T> {\n return new RepeatIterator<T>(value, 1);\n}\n\n/**\n * An iterator which repeats a value a specified number of times.\n */\nexport class RepeatIterator<T> implements IIterator<T> {\n /**\n * Construct a new repeat iterator.\n *\n * @param value - The value to repeat.\n *\n * @param count - The number of times to repeat the value.\n */\n constructor(value: T, count: number) {\n this._value = value;\n this._count = count;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n return new RepeatIterator<T>(this._value, this._count);\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n if (this._count <= 0) {\n return undefined;\n }\n this._count--;\n return this._value;\n }\n\n private _value: T;\n private _count: number;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator } from './iter';\n\n/**\n * An object which can produce a reverse iterator over its values.\n */\nexport interface IRetroable<T> {\n /**\n * Get a reverse iterator over the object's values.\n *\n * @returns An iterator which yields the object's values in reverse.\n */\n retro(): IIterator<T>;\n}\n\n/**\n * A type alias for a retroable or builtin array-like object.\n */\nexport type RetroableOrArrayLike<T> = IRetroable<T> | ArrayLike<T>;\n\n/**\n * Create an iterator for a retroable object.\n *\n * @param object - The retroable or array-like object of interest.\n *\n * @returns An iterator which traverses the object's values in reverse.\n *\n * #### Example\n * ```typescript\n * import { retro, toArray } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5, 6];\n *\n * let stream = retro(data);\n *\n * toArray(stream); // [6, 5, 4, 3, 2, 1]\n * ```\n */\nexport function retro<T>(object: RetroableOrArrayLike<T>): IIterator<T> {\n let it: IIterator<T>;\n if (typeof (object as any).retro === 'function') {\n it = (object as IRetroable<T>).retro();\n } else {\n it = new RetroArrayIterator<T>(object as ArrayLike<T>);\n }\n return it;\n}\n\n/**\n * An iterator which traverses an array-like object in reverse.\n *\n * #### Notes\n * This iterator can be used for any builtin JS array-like object.\n */\nexport class RetroArrayIterator<T> implements IIterator<T> {\n /**\n * Construct a new retro iterator.\n *\n * @param source - The array-like object of interest.\n */\n constructor(source: ArrayLike<T>) {\n this._source = source;\n this._index = source.length - 1;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n let result = new RetroArrayIterator<T>(this._source);\n result._index = this._index;\n return result;\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n if (this._index < 0 || this._index >= this._source.length) {\n return undefined;\n }\n return this._source[this._index--];\n }\n\n private _index: number;\n private _source: ArrayLike<T>;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator, iter, IterableOrArrayLike } from './iter';\n\n/**\n * Iterate over an iterable using a stepped increment.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param step - The distance to step on each iteration. A value\n * of less than `1` will behave the same as a value of `1`.\n *\n * @returns An iterator which traverses the iterable step-wise.\n *\n * #### Example\n * ```typescript\n * import { stride, toArray } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5, 6];\n *\n * let stream = stride(data, 2);\n *\n * toArray(stream); // [1, 3, 5];\n * ```\n */\nexport function stride<T>(\n object: IterableOrArrayLike<T>,\n step: number\n): IIterator<T> {\n return new StrideIterator<T>(iter(object), step);\n}\n\n/**\n * An iterator which traverses a source iterator step-wise.\n */\nexport class StrideIterator<T> implements IIterator<T> {\n /**\n * Construct a new stride iterator.\n *\n * @param source - The iterator of values of interest.\n *\n * @param step - The distance to step on each iteration. A value\n * of less than `1` will behave the same as a value of `1`.\n */\n constructor(source: IIterator<T>, step: number) {\n this._source = source;\n this._step = step;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n return new StrideIterator<T>(this._source.clone(), this._step);\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n let value = this._source.next();\n for (let n = this._step - 1; n > 0; --n) {\n this._source.next();\n }\n return value;\n }\n\n private _source: IIterator<T>;\n private _step: number;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\n\n/**\n * The namespace for string-specific algorithms.\n */\nexport namespace StringExt {\n /**\n * Find the indices of characters in a source text.\n *\n * @param source - The source text which should be searched.\n *\n * @param query - The characters to locate in the source text.\n *\n * @param start - The index to start the search.\n *\n * @returns The matched indices, or `null` if there is no match.\n *\n * #### Complexity\n * Linear on `sourceText`.\n *\n * #### Notes\n * In order for there to be a match, all of the characters in `query`\n * **must** appear in `source` in the order given by `query`.\n *\n * Characters are matched using strict `===` equality.\n */\n export function findIndices(\n source: string,\n query: string,\n start = 0\n ): number[] | null {\n let indices = new Array<number>(query.length);\n for (let i = 0, j = start, n = query.length; i < n; ++i, ++j) {\n j = source.indexOf(query[i], j);\n if (j === -1) {\n return null;\n }\n indices[i] = j;\n }\n return indices;\n }\n\n /**\n * The result of a string match function.\n */\n export interface IMatchResult {\n /**\n * A score which indicates the strength of the match.\n *\n * The documentation of a given match function should specify\n * whether a lower or higher score is a stronger match.\n */\n score: number;\n\n /**\n * The indices of the matched characters in the source text.\n *\n * The indices will appear in increasing order.\n */\n indices: number[];\n }\n\n /**\n * A string matcher which uses a sum-of-squares algorithm.\n *\n * @param source - The source text which should be searched.\n *\n * @param query - The characters to locate in the source text.\n *\n * @param start - The index to start the search.\n *\n * @returns The match result, or `null` if there is no match.\n * A lower `score` represents a stronger match.\n *\n * #### Complexity\n * Linear on `sourceText`.\n *\n * #### Notes\n * This scoring algorithm uses a sum-of-squares approach to determine\n * the score. In order for there to be a match, all of the characters\n * in `query` **must** appear in `source` in order. The index of each\n * matching character is squared and added to the score. This means\n * that early and consecutive character matches are preferred, while\n * late matches are heavily penalized.\n */\n export function matchSumOfSquares(\n source: string,\n query: string,\n start = 0\n ): IMatchResult | null {\n let indices = findIndices(source, query, start);\n if (!indices) {\n return null;\n }\n let score = 0;\n for (let i = 0, n = indices.length; i < n; ++i) {\n let j = indices[i] - start;\n score += j * j;\n }\n return { score, indices };\n }\n\n /**\n * A string matcher which uses a sum-of-deltas algorithm.\n *\n * @param source - The source text which should be searched.\n *\n * @param query - The characters to locate in the source text.\n *\n * @param start - The index to start the search.\n *\n * @returns The match result, or `null` if there is no match.\n * A lower `score` represents a stronger match.\n *\n * #### Complexity\n * Linear on `sourceText`.\n *\n * #### Notes\n * This scoring algorithm uses a sum-of-deltas approach to determine\n * the score. In order for there to be a match, all of the characters\n * in `query` **must** appear in `source` in order. The delta between\n * the indices are summed to create the score. This means that groups\n * of matched characters are preferred, while fragmented matches are\n * penalized.\n */\n export function matchSumOfDeltas(\n source: string,\n query: string,\n start = 0\n ): IMatchResult | null {\n let indices = findIndices(source, query, start);\n if (!indices) {\n return null;\n }\n let score = 0;\n let last = start - 1;\n for (let i = 0, n = indices.length; i < n; ++i) {\n let j = indices[i];\n score += j - last - 1;\n last = j;\n }\n return { score, indices };\n }\n\n /**\n * Highlight the matched characters of a source text.\n *\n * @param source - The text which should be highlighted.\n *\n * @param indices - The indices of the matched characters. They must\n * appear in increasing order and must be in bounds of the source.\n *\n * @param fn - The function to apply to the matched chunks.\n *\n * @returns An array of unmatched and highlighted chunks.\n */\n export function highlight<T>(\n source: string,\n indices: ReadonlyArray<number>,\n fn: (chunk: string) => T\n ): Array<string | T> {\n // Set up the result array.\n let result: Array<string | T> = [];\n\n // Set up the counter variables.\n let k = 0;\n let last = 0;\n let n = indices.length;\n\n // Iterator over each index.\n while (k < n) {\n // Set up the chunk indices.\n let i = indices[k];\n let j = indices[k];\n\n // Advance the right chunk index until it's non-contiguous.\n while (++k < n && indices[k] === j + 1) {\n j++;\n }\n\n // Extract the unmatched text.\n if (last < i) {\n result.push(source.slice(last, i));\n }\n\n // Extract and highlight the matched text.\n if (i < j + 1) {\n result.push(fn(source.slice(i, j + 1)));\n }\n\n // Update the last visited index.\n last = j + 1;\n }\n\n // Extract any remaining unmatched text.\n if (last < source.length) {\n result.push(source.slice(last));\n }\n\n // Return the highlighted result.\n return result;\n }\n\n /**\n * A 3-way string comparison function.\n *\n * @param a - The first string of interest.\n *\n * @param b - The second string of interest.\n *\n * @returns `-1` if `a < b`, else `1` if `a > b`, else `0`.\n */\n export function cmp(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n }\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator, iter, IterableOrArrayLike } from './iter';\n\n/**\n * Take a fixed number of items from an iterable.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param count - The number of items to take from the iterable.\n *\n * @returns An iterator which yields the specified number of items\n * from the source iterable.\n *\n * #### Notes\n * The returned iterator will exhaust early if the source iterable\n * contains an insufficient number of items.\n */\nexport function take<T>(\n object: IterableOrArrayLike<T>,\n count: number\n): IIterator<T> {\n return new TakeIterator<T>(iter(object), count);\n}\n\n/**\n * An iterator which takes a fixed number of items from a source.\n */\nexport class TakeIterator<T> implements IIterator<T> {\n /**\n * Construct a new take iterator.\n *\n * @param source - The iterator of interest.\n *\n * @param count - The number of items to take from the source.\n */\n constructor(source: IIterator<T>, count: number) {\n this._source = source;\n this._count = count;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T> {\n return new TakeIterator<T>(this._source.clone(), this._count);\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T | undefined {\n if (this._count <= 0) {\n return undefined;\n }\n let value = this._source.next();\n if (value === undefined) {\n return undefined;\n }\n this._count--;\n return value;\n }\n\n private _count: number;\n private _source: IIterator<T>;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { IIterator, iter, IterableOrArrayLike } from './iter';\n\n/**\n * Iterate several iterables in lockstep.\n *\n * @param objects - The iterable or array-like objects of interest.\n *\n * @returns An iterator which yields successive tuples of values where\n * each value is taken in turn from the provided iterables. It will\n * be as long as the shortest provided iterable.\n *\n * #### Example\n * ```typescript\n * import { zip, toArray } from '@lumino/algorithm';\n *\n * let data1 = [1, 2, 3];\n * let data2 = [4, 5, 6];\n *\n * let stream = zip(data1, data2);\n *\n * toArray(stream); // [[1, 4], [2, 5], [3, 6]]\n * ```\n */\nexport function zip<T>(...objects: IterableOrArrayLike<T>[]): IIterator<T[]> {\n return new ZipIterator<T>(objects.map(iter));\n}\n\n/**\n * An iterator which iterates several sources in lockstep.\n */\nexport class ZipIterator<T> implements IIterator<T[]> {\n /**\n * Construct a new zip iterator.\n *\n * @param source - The iterators of interest.\n */\n constructor(source: IIterator<T>[]) {\n this._source = source;\n }\n\n /**\n * Get an iterator over the object's values.\n *\n * @returns An iterator which yields the object's values.\n */\n iter(): IIterator<T[]> {\n return this;\n }\n\n /**\n * Create an independent clone of the iterator.\n *\n * @returns A new independent clone of the iterator.\n */\n clone(): IIterator<T[]> {\n return new ZipIterator<T>(this._source.map(it => it.clone()));\n }\n\n /**\n * Get the next value from the iterator.\n *\n * @returns The next value from the iterator, or `undefined`.\n */\n next(): T[] | undefined {\n let result = new Array<T>(this._source.length);\n for (let i = 0, n = this._source.length; i < n; ++i) {\n let value = this._source[i].next();\n if (value === undefined) {\n return undefined;\n }\n result[i] = value;\n }\n return result;\n }\n\n private _source: IIterator<T>[];\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { iter, IterableOrArrayLike } from './iter';\n\n/**\n * Find the first value in an iterable which matches a predicate.\n *\n * @param object - The iterable or array-like object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @returns The first matching value, or `undefined` if no matching\n * value is found.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { find } from '@lumino/algorithm';\n *\n * interface IAnimal { species: string, name: string };\n *\n * function isCat(value: IAnimal): boolean {\n * return value.species === 'cat';\n * }\n *\n * let data: IAnimal[] = [\n * { species: 'dog', name: 'spot' },\n * { species: 'cat', name: 'fluffy' },\n * { species: 'alligator', name: 'pocho' }\n * ];\n *\n * find(data, isCat).name; // 'fluffy'\n * ```\n */\nexport function find<T>(\n object: IterableOrArrayLike<T>,\n fn: (value: T, index: number) => boolean\n): T | undefined {\n let index = 0;\n let it = iter(object);\n let value: T | undefined;\n while ((value = it.next()) !== undefined) {\n if (fn(value, index++)) {\n return value;\n }\n }\n return undefined;\n}\n\n/**\n * Find the index of the first value which matches a predicate.\n *\n * @param object - The iterable or array-like object to search.\n *\n * @param fn - The predicate function to apply to the values.\n *\n * @returns The index of the first matching value, or `-1` if no\n * matching value is found.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { findIndex } from '@lumino/algorithm';\n *\n * interface IAnimal { species: string, name: string };\n *\n * function isCat(value: IAnimal): boolean {\n * return value.species === 'cat';\n * }\n *\n * let data: IAnimal[] = [\n * { species: 'dog', name: 'spot' },\n * { species: 'cat', name: 'fluffy' },\n * { species: 'alligator', name: 'pocho' }\n * ];\n *\n * findIndex(data, isCat); // 1\n * ```\n */\nexport function findIndex<T>(\n object: IterableOrArrayLike<T>,\n fn: (value: T, index: number) => boolean\n): number {\n let index = 0;\n let it = iter(object);\n let value: T | undefined;\n while ((value = it.next()) !== undefined) {\n if (fn(value, index++)) {\n return index - 1;\n }\n }\n return -1;\n}\n\n/**\n * Find the minimum value in an iterable.\n *\n * @param object - The iterable or array-like object to search.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n * It should return `< 0` if the first value is less than the second.\n * `0` if the values are equivalent, or `> 0` if the first value is\n * greater than the second.\n *\n * @returns The minimum value in the iterable. If multiple values are\n * equivalent to the minimum, the left-most value is returned. If\n * the iterable is empty, this returns `undefined`.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { min } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n * return a - b;\n * }\n *\n * min([7, 4, 0, 3, 9, 4], numberCmp); // 0\n * ```\n */\nexport function min<T>(\n object: IterableOrArrayLike<T>,\n fn: (first: T, second: T) => number\n): T | undefined {\n let it = iter(object);\n let value = it.next();\n if (value === undefined) {\n return undefined;\n }\n let result = value;\n while ((value = it.next()) !== undefined) {\n if (fn(value, result) < 0) {\n result = value;\n }\n }\n return result;\n}\n\n/**\n * Find the maximum value in an iterable.\n *\n * @param object - The iterable or array-like object to search.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n * It should return `< 0` if the first value is less than the second.\n * `0` if the values are equivalent, or `> 0` if the first value is\n * greater than the second.\n *\n * @returns The maximum value in the iterable. If multiple values are\n * equivalent to the maximum, the left-most value is returned. If\n * the iterable is empty, this returns `undefined`.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { max } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n * return a - b;\n * }\n *\n * max([7, 4, 0, 3, 9, 4], numberCmp); // 9\n * ```\n */\nexport function max<T>(\n object: IterableOrArrayLike<T>,\n fn: (first: T, second: T) => number\n): T | undefined {\n let it = iter(object);\n let value = it.next();\n if (value === undefined) {\n return undefined;\n }\n let result = value;\n while ((value = it.next()) !== undefined) {\n if (fn(value, result) > 0) {\n result = value;\n }\n }\n return result;\n}\n\n/**\n * Find the minimum and maximum values in an iterable.\n *\n * @param object - The iterable or array-like object to search.\n *\n * @param fn - The 3-way comparison function to apply to the values.\n * It should return `< 0` if the first value is less than the second.\n * `0` if the values are equivalent, or `> 0` if the first value is\n * greater than the second.\n *\n * @returns A 2-tuple of the `[min, max]` values in the iterable. If\n * multiple values are equivalent, the left-most values are returned.\n * If the iterable is empty, this returns `undefined`.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { minmax } from '@lumino/algorithm';\n *\n * function numberCmp(a: number, b: number): number {\n * return a - b;\n * }\n *\n * minmax([7, 4, 0, 3, 9, 4], numberCmp); // [0, 9]\n * ```\n */\nexport function minmax<T>(\n object: IterableOrArrayLike<T>,\n fn: (first: T, second: T) => number\n): [T, T] | undefined {\n let it = iter(object);\n let value = it.next();\n if (value === undefined) {\n return undefined;\n }\n let vmin = value;\n let vmax = value;\n while ((value = it.next()) !== undefined) {\n if (fn(value, vmin) < 0) {\n vmin = value;\n } else if (fn(value, vmax) > 0) {\n vmax = value;\n }\n }\n return [vmin, vmax];\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { iter, IterableOrArrayLike } from './iter';\n\n/**\n * Summarize all values in an iterable using a reducer function.\n *\n * @param object - The iterable or array-like object of interest.\n *\n * @param fn - The reducer function to invoke for each value.\n *\n * @param initial - The initial value to start accumulation.\n *\n * @returns The final accumulated value.\n *\n * #### Notes\n * The `reduce` function follows the conventions of `Array#reduce`.\n *\n * If the iterator is empty, an initial value is required. That value\n * will be used as the return value. If no initial value is provided,\n * an error will be thrown.\n *\n * If the iterator contains a single item and no initial value is\n * provided, the single item is used as the return value.\n *\n * Otherwise, the reducer is invoked for each element in the iterable.\n * If an initial value is not provided, the first element will be used\n * as the initial accumulated value.\n *\n * #### Complexity\n * Linear.\n *\n * #### Example\n * ```typescript\n * import { reduce } from '@lumino/algorithm';\n *\n * let data = [1, 2, 3, 4, 5];\n *\n * let sum = reduce(data, (a, value) => a + value); // 15\n * ```\n */\nexport function reduce<T>(\n object: IterableOrArrayLike<T>,\n fn: (accumulator: T, value: T, index: number) => T\n): T;\nexport function reduce<T, U>(\n object: IterableOrArrayLike<T>,\n fn: (accumulator: U, value: T, index: number) => U,\n initial: U\n): U;\nexport function reduce<T>(\n object: IterableOrArrayLike<T>,\n fn: (accumulator: any, value: T, index: number) => any,\n initial?: any\n): any {\n // Setup the iterator and fetch the first value.\n let index = 0;\n let it = iter(object);\n let first = it.next();\n\n // An empty iterator and no initial value is an error.\n if (first === undefined && initial === undefined) {\n throw new TypeError('Reduce of empty iterable with no initial value.');\n }\n\n // If the iterator is empty, return the initial value.\n if (first === undefined) {\n return initial;\n }\n\n // If the iterator has a single item and no initial value, the\n // reducer is not invoked and the first item is the return value.\n let second = it.next();\n if (second === undefined && initial === undefined) {\n return first;\n }\n\n // If iterator has a single item and an initial value is provided,\n // the reducer is invoked and that result is the return value.\n if (second === undefined) {\n return fn(initial, first, index++);\n }\n\n // Setup the initial accumlated value.\n let accumulator: any;\n if (initial === undefined) {\n accumulator = fn(first, second, index++);\n } else {\n accumulator = fn(fn(initial, first, index++), second, index++);\n }\n\n // Iterate the rest of the values, updating the accumulator.\n let next: T | undefined;\n while ((next = it.next()) !== undefined) {\n accumulator = fn(accumulator, next, index++);\n }\n\n // Return the final accumulated value.\n return accumulator;\n}\n","// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2017, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { each, IterableOrArrayLike } from './iter';\n\n/**\n * Topologically sort an iterable of edges.\n *\n * @param edges - The iterable or array-like object of edges to sort.\n * An edge is represented as a 2-tuple of `[fromNode, toNode]`.\n *\n * @returns The topologically sorted array of nodes.\n *\n * #### Notes\n * If a cycle is present in the graph, the cycle will be ignored and\n * the return value will be only approximately sorted.\n *\n * #### Example\n * ```typescript\n * import { topologicSort } from '@lumino/algorithm';\n *\n * let data = [\n * ['d', 'e'],\n * ['c', 'd'],\n * ['a', 'b'],\n * ['b', 'c']\n * ];\n *\n * topologicSort(data); // ['a', 'b', 'c', 'd', 'e']\n * ```\n */\nexport function topologicSort<T>(edges: IterableOrArrayLike<[T, T]>): T[] {\n // Setup the shared sorting state.\n let sorted: T[] = [];\n let visited = new Set<T>();\n let graph = new Map<T, T[]>();\n\n // Add the edges to the graph.\n each(edges, addEdge);\n\n // Visit each node in the graph.\n graph.forEach((v, k) => {\n visit(k);\n });\n\n // Return the sorted results.\n return sorted;\n\n // Add an edge to the graph.\n function addEdge(edge: [T, T]): void {\n let [fromNode, toNode] = edge;\n let children = graph.get(toNode);\n if (children) {\n children.push(fromNode);\n } else {\n graph.set(toNode, [fromNode]);\n }\n }\n\n // Recursively visit the node.\n function visit(node: T): void {\n if (visited.has(node)) {\n return;\n }\n visited.add(node);\n let children = graph.get(node);\n if (children) {\n children.forEach(visit);\n }\n sorted.push(node);\n }\n}\n"],"mappings":"iQAoFgBA,EAAQC,GAOtB,MALoC,mBAAxBA,EAAeD,KACnBC,EAAwBD,OAEzB,IAAIE,EAAiBD,EAG9B,C,SA8HgBE,EACdF,EACAG,GAKA,IAHA,IAEIC,EAFAC,EAAQ,EACRC,EAAKP,EAAKC,QAEiBO,KAAvBH,EAAQE,EAAGE,SACjB,IAA2B,IAAvBL,EAAGC,EAAOC,KACZ,MAGN,CCzNiBI,kBAAjB,SAAiBA,GAyCf,SAAgBC,EACdC,EACAP,EACAQ,EACAC,QADA,IAAAD,MAAA,QACA,IAAAC,OAAQ,GAER,IAcIC,EAdAC,EAAIJ,EAAMK,OACd,GAAU,IAAND,EACF,OAAQ,EAGRH,EADEA,EAAQ,EACFK,KAAKC,IAAI,EAAGN,EAAQG,GAEpBE,KAAKE,IAAIP,EAAOG,EAAI,GAS5BD,GANAD,EADEA,EAAO,EACFI,KAAKC,IAAI,EAAGL,EAAOE,GAEnBE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