Skip to content

Commit 2a723e9

Browse files
committed
feat(first): replace "head" with "first"
The new name is much clearer. The old name will continue to work but is deprecated. (cherry picked from commit 51ffc0f)
1 parent 7d4d287 commit 2a723e9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,20 @@ export function coerce<T>(array: ArrayLike<T>): readonly T[] {
6363
return isArray(array) ? array : copy(array);
6464
}
6565

66-
export function head<T>(array: ArrayLike<T>): T | null {
66+
export function first<T>(array: ArrayLike<T>): T | null {
6767
return array.length === 0 ? null : array[0];
6868
}
6969

70+
/** @deprecated Use {@link first} instead. */
71+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
72+
// @ts-ignore duplicate identifier: This is the exported declaration, the implementation is below.
73+
export function head<T>(array: ArrayLike<T>): T | null;
74+
75+
/** @internal This implementation is for internal use only, the exported declaration is above */
76+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
77+
// @ts-ignore duplicate identifier: This is the actual implementation, the exported declaration is above.
78+
const head = first;
79+
7080
export function tail<T>(array: ArrayLike<T>): T[] {
7181
return nativeSlice.call(array, 1);
7282
}

0 commit comments

Comments
 (0)