-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Refactored typed arrays #18559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Refactored typed arrays #18559
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,7 +215,7 @@ interface String { | |
[Symbol.iterator](): IterableIterator<string>; | ||
} | ||
|
||
interface Int8Array { | ||
interface TypedArray<T> { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
|
@@ -231,243 +231,14 @@ interface Int8Array { | |
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Int8ArrayConstructor { | ||
new (elements: Iterable<number>): Int8Array; | ||
interface TypedArrayConstructor<T> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather we leave out |
||
new (elements: Iterable<number>): T; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; | ||
} | ||
|
||
interface Uint8Array { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Uint8ArrayConstructor { | ||
new (elements: Iterable<number>): Uint8Array; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; | ||
} | ||
|
||
interface Uint8ClampedArray { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Uint8ClampedArrayConstructor { | ||
new (elements: Iterable<number>): Uint8ClampedArray; | ||
|
||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; | ||
} | ||
|
||
interface Int16Array { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
|
||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
|
||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Int16ArrayConstructor { | ||
new (elements: Iterable<number>): Int16Array; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; | ||
} | ||
|
||
interface Uint16Array { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Uint16ArrayConstructor { | ||
new (elements: Iterable<number>): Uint16Array; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; | ||
} | ||
|
||
interface Int32Array { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Int32ArrayConstructor { | ||
new (elements: Iterable<number>): Int32Array; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; | ||
} | ||
|
||
interface Uint32Array { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Uint32ArrayConstructor { | ||
new (elements: Iterable<number>): Uint32Array; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; | ||
} | ||
|
||
interface Float32Array { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Float32ArrayConstructor { | ||
new (elements: Iterable<number>): Float32Array; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; | ||
} | ||
|
||
interface Float64Array { | ||
[Symbol.iterator](): IterableIterator<number>; | ||
/** | ||
* Returns an array of key, value pairs for every entry in the array | ||
*/ | ||
entries(): IterableIterator<[number, number]>; | ||
/** | ||
* Returns an list of keys in the array | ||
*/ | ||
keys(): IterableIterator<number>; | ||
/** | ||
* Returns an list of values in the array | ||
*/ | ||
values(): IterableIterator<number>; | ||
} | ||
|
||
interface Float64ArrayConstructor { | ||
new (elements: Iterable<number>): Float64Array; | ||
|
||
/** | ||
* Creates an array from an array-like or iterable object. | ||
* @param arrayLike An array-like or iterable object to convert to an array. | ||
* @param mapfn A mapping function to call on every element of the array. | ||
* @param thisArg Value of 'this' used to invoke the mapfn. | ||
*/ | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; | ||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): T; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,79 +16,7 @@ interface ReadonlyArray<T> { | |
includes(searchElement: T, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Int8Array { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Uint8Array { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Uint8ClampedArray { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Int16Array { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Uint16Array { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Int32Array { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Uint32Array { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Float32Array { | ||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
* @param fromIndex The position in this array at which to begin searching for searchElement. | ||
*/ | ||
includes(searchElement: number, fromIndex?: number): boolean; | ||
} | ||
|
||
interface Float64Array { | ||
interface TypedArray<T> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be generic. |
||
/** | ||
* Determines whether an array includes a certain element, returning true or false as appropriate. | ||
* @param searchElement The element to search for. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be generic.