Created
June 5, 2025 18:27
-
-
Save sergey-shandar/c252d01dda3c04f1bc28d671597a329f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| export const values | |
| : <T>(a: readonly T[]) => Iterable<T> | |
| = a => ({ *[Symbol.iterator]() { yield *a } }) | |
| const unitTest = () => { | |
| // const it = [1, 2, 3] |> values //< F# style pipe | |
| // const it = [1, 2, 3] |> values(%) //< Hack style pipe | |
| const x = values([1, 2, 3]) | |
| const result = Array.from(x) | |
| const r = JSON.stringify(result) | |
| if (r !== JSON.stringify([1, 2, 3])) { | |
| throw new Error(`Expected [1, 2, 3], but got ${r}`) | |
| } | |
| } | |
| unitTest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment