Merge pull request #38489 from microsoft/removeDuplicateInfo

Remove duplicate JSDoc comments
This commit is contained in:
Daniel Rosenwasser
2020-05-12 12:52:15 -07:00
committed by GitHub
4 changed files with 108 additions and 6 deletions
+16
View File
@@ -129,6 +129,22 @@ namespace ts {
return map;
}
/**
* Creates a new array with `element` interspersed in between each element of `input`
* if there is more than 1 value in `input`. Otherwise, returns the existing array.
*/
export function intersperse<T>(input: T[], element: T): T[] {
if (input.length <= 1) {
return input;
}
const result: T[] = [];
for (let i = 0, n = input.length; i < n; i++) {
if (i) result.push(element);
result.push(input[i]);
}
return result;
}
/**
* Iterates through `array` by index and performs the callback on each element of array until the callback
* returns a falsey value, then returns false.