-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transducers): add peek() xform, update readme
- Loading branch information
1 parent
0eff643
commit 26aa228
Showing
4 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { peek as _peek } from "@thi.ng/arrays"; | ||
import { Transducer } from "../api"; | ||
import { map } from "./map"; | ||
|
||
/** | ||
* Transducer version of {@link @thi.ng/api#peek}, i.e. extracts the | ||
* last item of an array. | ||
* | ||
* @example | ||
* ```ts | ||
* [...peek([ [1, 2, 3], [4, 5] ])] | ||
* // [ 3, 5 ] | ||
* ``` | ||
* | ||
* @param src - | ||
*/ | ||
export function peek<T>(): Transducer<T[], T>; | ||
export function peek<T>(src: Iterable<T[]>): IterableIterator<T>; | ||
export function peek<T>(src?: Iterable<T[]>): any { | ||
return map(_peek, src!); | ||
} |