Skip to content

Commit

Permalink
feat(transducers): add peek() helper fn
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 2, 2018
1 parent ff91987 commit e50fd10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/transducers/src/func/peek.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Returns last element of given array.
*
* @param x
*/
export function peek<T>(x: ArrayLike<T>) {
return x[x.length - 1];
}
1 change: 1 addition & 0 deletions packages/transducers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export * from "./func/juxtr";
export * from "./func/key-selector";
export * from "./func/lookup";
export * from "./func/odd";
export * from "./func/peek";
export * from "./func/renamer";
export * from "./func/swizzler";
export * from "./func/weighted-random";
Expand Down

0 comments on commit e50fd10

Please sign in to comment.