Skip to content

Commit

Permalink
feat(arrays): add first()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 12, 2020
1 parent 72a3200 commit 3f5f722
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/arrays/src/peek.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Returns first element of given array or `undefined` if array is empty.
*
* @param buf - array
*/
export const first = <T>(buf: ArrayLike<T>) => buf[0];

/**
* Returns last element of given array or `undefined` if array is empty.
*
Expand Down

0 comments on commit 3f5f722

Please sign in to comment.