Skip to content

Commit

Permalink
Use type inference in new replaceAt()
Browse files Browse the repository at this point in the history
  • Loading branch information
guigrpa committed Apr 2, 2017
1 parent 04c20c2 commit 2d2963b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/timm.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ export function removeAt<T>(array: Array<T>, idx: number): Array<T> {
// -- ```
export function replaceAt<T>(array: Array<T>, idx: number, newItem: T): Array<T> {
if (array[idx] === newItem) return array;

const len: number = array.length;
const result: Array<T> = Array(len);
const len = array.length;
const result = Array(len);
for (let i = 0; i < len; i++) {
result[i] = array[i];
}
Expand Down

0 comments on commit 2d2963b

Please sign in to comment.