Last active
March 19, 2018 15:05
-
-
Save lmcarreiro/de3751b450e52d5944fe452eaabcf092 to your computer and use it in GitHub Desktop.
Method declaration column-indented
This file contains 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
/** | |
* Filters an array by a predicate function. Returns the same array instance if the predicate is | |
* true for all elements, otherwise returns a new array instance containing the filtered subset. | |
*/ | |
export function filter<T, U extends T>(array: T[], f: (x: T) => x is U ): U[]; | |
export function filter<T >(array: T[], f: (x: T) => boolean): T[]; | |
export function filter<T, U extends T>(array: ReadonlyArray<T> , f: (x: T) => x is U ): ReadonlyArray<U>; | |
export function filter<T, U extends T>(array: ReadonlyArray<T> , f: (x: T) => boolean): ReadonlyArray<T>; | |
export function filter<T >(array: T[], f: (x: T) => boolean): T[] { | |
if (array) { | |
const len = array.length; | |
let i = 0; | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment