Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
exotic-structures / dist / typings / FlatArrayPairs.d.ts
Size: Mime:
declare const findIndexPlusOne: (needle: any, haystack: any) => any;
declare const atIndexPlusOne: (needle: any, haystack: any) => any;
declare const findIndexMinusOne: (needle: any, haystack: any) => number;
declare const atIndexMinusOne: (needle: any, haystack: any) => any;
/**
 * @desc allows any key val
 * @type {Array}
 * @HACK @FIXME @TODO
 * - BABEL HATES EXTENDING NATIVES
 * - Compiled with ts | buble to enable it
 * - you've been able to do this for years
 *
 * @TODO Set
 * https://stackoverflow.com/questions/7069052/how-to-obtain-index-of-a-given-set-element-without-iteration
 */
interface Pair<Key, Value> extends Array<[Key, Value]> {
}
/**
 * @todo use mobx array?
 */
declare type IndexPredicate = (x: number) => boolean;
interface FlatArrayPairs<Key, Value> {
    type: any;
    typed(type: any): void;
    has(key: Key): boolean;
    set(key: Key, value: Value): this;
    add(key: Key, value: Value): this;
    add(key: [Key, Value]): this;
    addPair(pair: [Key, Value] | [Key, Value][]): this;
    get(key: Key): Value | undefined;
    getKey(value: Value): Key | undefined;
    toPairs(): Pair<Key, Value>[];
    allocate: Array<undefined>;
    half(indexPredicate: IndexPredicate): Array<Key | Value>;
    keys(): Key[];
    values(): Value[];
}
declare class FlatPairArray<Key, Value> extends Array implements FlatArrayPairs<Key, Value> {
    type: any;
    typed(type: any): this;
    has(key: Key): boolean;
    set(key: Key, value: Value): this;
    add(key: Key | [Key, Value], value?: Value): this;
    get(key: Key): Value | undefined;
    getKey(value: Value): Key | undefined;
    /**
     * @param indexPredicate match current index (isEven, isOdd, etc)
     * @return keys or values
     *
     * @example
     *    const pairs = new FlatPairArray([ [1, '2'], [3, '4'] ])
     *    //=> [1, '2', 3, '4']
     *
     *    pairs.half(isEven)
     *    //=> []
     */
    half(indexPredicate: IndexPredicate): Key[] | Value[];
    toPairs(): Pair<Key, Value>[];
    readonly allocate: Array<undefined>;
    /**
     * @name concatPair?
     *
     * @example
     *    new FlatPairArray().(pair: [Key, Value] | [Key, Value][]([ [1, '2'], [3, '4'] ])
     *    //=> [1, '2', 3, '4']
     */
    addPair(pair: [Key, Value] | [Key, Value][]): this;
    keys(): Key[] & IterableIterator<number>;
    values(): Value[] & IterableIterator<number>;
}
export { FlatPairArray as FlatArrayPairs, FlatPairArray as FlatPairArrays, FlatPairArray, findIndexPlusOne, atIndexPlusOne, findIndexMinusOne, atIndexMinusOne, };
export default FlatPairArray;