Skip to content

Commit

Permalink
Fix returned TS type on toArray() and consume() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Benoit authored Jun 3, 2022
1 parent 022edca commit 5f8ea04
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions circular-buffer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Mnemonist CircularBuffer Typings
* =================================
*/
import {IArrayLikeConstructor} from './utils/types';
import {IArrayLikeConstructor, TypedArray} from './utils/types';

export default class CircularBuffer<T> implements Iterable<T> {

Expand All @@ -23,12 +23,12 @@ export default class CircularBuffer<T> implements Iterable<T> {
peekLast(): T | undefined;
get(index: number): T | undefined;
forEach(callback: (item: T, index: number, buffer: this) => void, scope?: any): void;
toArray(): Iterable<T>;
toArray(): Array<T> | TypedArray;
values(): IterableIterator<T>;
entries(): IterableIterator<[number, T]>;
[Symbol.iterator](): IterableIterator<T>;
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}, ArrayClass: IArrayLikeConstructor, capacity?: number): CircularBuffer<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}, ArrayClass: IArrayLikeConstructor, capacity?: number): CircularBuffer<I>;
}
6 changes: 3 additions & 3 deletions fixed-deque.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Mnemonist FixedDeque Typings
* =============================
*/
import {IArrayLikeConstructor} from './utils/types';
import {IArrayLikeConstructor, TypedArray} from './utils/types';

export default class FixedDeque<T> implements Iterable<T> {

Expand All @@ -23,12 +23,12 @@ export default class FixedDeque<T> implements Iterable<T> {
peekLast(): T | undefined;
get(index: number): T | undefined;
forEach(callback: (item: T, index: number, buffer: this) => void, scope?: any): void;
toArray(): Iterable<T>;
toArray(): Array<T> | TypedArray;
values(): IterableIterator<T>;
entries(): IterableIterator<[number, T]>;
[Symbol.iterator](): IterableIterator<T>;
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}, ArrayClass: IArrayLikeConstructor, capacity?: number): FixedDeque<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}, ArrayClass: IArrayLikeConstructor, capacity?: number): FixedDeque<I>;
}
6 changes: 3 additions & 3 deletions fixed-reverse-heap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Mnemonist FixedReverseHeap Typings
* ===================================
*/
import {IArrayLikeConstructor} from './utils/types';
import {IArrayLikeConstructor, TypedArray} from './utils/types';

type HeapComparator<T> = (a: T, b: T) => number;

Expand All @@ -19,7 +19,7 @@ export default class FixedReverseHeap<T> {
// Methods
clear(): void;
push(item: T): number;
consume(): Iterable<T>;
toArray(): Iterable<T>;
consume(): Array<T> | TypedArray;
toArray(): Array<T> | TypedArray;
inspect(): any;
}
6 changes: 3 additions & 3 deletions fixed-stack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Mnemonist FixedStack Typings
* =============================
*/
import {IArrayLikeConstructor} from './utils/types';
import {IArrayLikeConstructor, TypedArray} from './utils/types';

export default class FixedStack<T> implements Iterable<T> {

Expand All @@ -19,7 +19,7 @@ export default class FixedStack<T> implements Iterable<T> {
pop(): T | undefined;
peek(): T | undefined;
forEach(callback: (item: T, index: number, stack: this) => void, scope?: any): void;
toArray(): Iterable<T>;
toArray(): Array<T> | TypedArray;
values(): IterableIterator<T>;
entries(): IterableIterator<[number, T]>;
[Symbol.iterator](): IterableIterator<T>;
Expand All @@ -29,7 +29,7 @@ export default class FixedStack<T> implements Iterable<T> {

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
ArrayClass: IArrayLikeConstructor,
capacity?: number
): FixedStack<I>;
Expand Down
22 changes: 11 additions & 11 deletions heap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export default class Heap<T> {
push(item: T): number;
peek(): T | undefined;
pop(): T | undefined;
replace(item: T): T | undefined;
pushpop(item: T): T | undefined;
replace(item: T): T | undefined;
pushpop(item: T): T | undefined;
toArray(): Array<T>;
consume(): Array<T>;
inspect(): any;

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
comparator?: HeapComparator<I>
): Heap<I>;
}
Expand All @@ -43,15 +43,15 @@ export class MinHeap<T> {
push(item: T): number;
peek(): T | undefined;
pop(): T | undefined;
replace(item: T): T | undefined;
pushpop(item: T): T | undefined;
replace(item: T): T | undefined;
pushpop(item: T): T | undefined;
toArray(): Array<T>;
consume(): Array<T>;
inspect(): any;

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
comparator?: HeapComparator<I>
): Heap<I>;
}
Expand All @@ -69,15 +69,15 @@ export class MaxHeap<T> {
push(item: T): number;
peek(): T | undefined;
pop(): T | undefined;
replace(item: T): T | undefined;
pushpop(item: T): T | undefined;
replace(item: T): T | undefined;
pushpop(item: T): T | undefined;
toArray(): Array<T>;
consume(): Array<T>;
inspect(): any;

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
comparator?: HeapComparator<I>
): Heap<I>;
}
Expand Down
2 changes: 2 additions & 0 deletions utils/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export type ArrayLike = IArrayLike | ArrayBuffer;
export interface IArrayLikeConstructor {
new(...args: any[]): ArrayLike;
}

export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;

0 comments on commit 5f8ea04

Please sign in to comment.