{"id":21331428,"url":"https://github.com/eibens/peek","last_synced_at":"2026-05-18T17:05:29.746Z","repository":{"id":102373346,"uuid":"384803812","full_name":"eibens/peek","owner":"eibens","description":"Add a peek function to iterators in TypeScript for Deno.","archived":false,"fork":false,"pushed_at":"2021-07-11T08:51:36.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-04T00:35:31.305Z","etag":null,"topics":["deno","iterable","iterator","peek","typescript","utility"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eibens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-10T22:07:58.000Z","updated_at":"2021-07-11T08:51:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"0c82fddb-60ee-4c46-81bc-a7882eac2844","html_url":"https://github.com/eibens/peek","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/eibens/peek","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eibens%2Fpeek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eibens%2Fpeek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eibens%2Fpeek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eibens%2Fpeek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eibens","download_url":"https://codeload.github.com/eibens/peek/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eibens%2Fpeek/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33184769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","iterable","iterator","peek","typescript","utility"],"created_at":"2024-11-21T22:33:05.852Z","updated_at":"2026-05-18T17:05:29.719Z","avatar_url":"https://github.com/eibens.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# peek\n\n[peek] implements a peeking iterator in TypeScript for [Deno].\n\n[![License][license-shield]](LICENSE) [![Deno doc][deno-doc-shield]][deno-doc]\n[![Deno module][deno-land-shield]][deno-land]\n[![Github tag][github-shield]][github] [![Build][build-shield]][build]\n[![Code coverage][coverage-shield]][coverage]\n\n# Motivation\n\nA peeking iterator allows one to look at the next item without taking it. This\ncan be useful if one only wants to consume items while a certain condition is\nmet. For example, a scheduler algorithm that only schedules tasks within a\ncertain time window can use a peeking iterator to check whether the event should\nbe scheduled, otherwise leaving it in the iterator for the next scheduling\ncycle.\n\n# [mod.ts](mod.ts)\n\nThis module exports all other modules.\n\n# [peeking.ts](peeking.ts)\n\nThe `fromIterator` function creates a `PeekingIterator` from a normal `Iterator`\nby implementing the `peek` function.\n\n```ts\nimport {\n  fromIterator,\n  PeekingIterator,\n} from \"https://deno.land/x/peek/peeking.ts\";\n\nconst peeking: PeekingIterator = fromIterator(\n  \"abc\"[Symbol.iterator](),\n);\n\nconst preview: number = peeking.peek();\nconsole.assert(preview === \"a\");\n\n// The item is still in the iterator.\nconst next = peeking.next();\nconsole.assert(next.value === \"a\");\n```\n\nThe `fromIterable` function creates a `PeekingIterator` from an `Iterable`.\n\n```ts\nimport { fromIterable } from \"https://deno.land/x/peek/peeking.ts\";\n\nconst peeking = fromIterable(\"abc\");\n\nconsole.assert(typeof peeking.peek === \"function\");\n```\n\n# [take_while.ts](take_while.ts)\n\nThe `takeWhile` generator function removes items from a `PeekingIterator` as\nlong as the specified `condition` is met.\n\n```ts\nimport { fromIterable } from \"https://deno.land/x/peek/peeking.ts\";\nimport { takeWhile } from \"https://deno.land/x/peek/take_while.ts\";\n\nconst peeking = fromIterable(\"abcde\");\nconst abc = takeWhile(peeking, (x) =\u003e x !== \"d\");\n\nconsole.assert([...abc].join(\"\") === \"abc\");\n```\n\n[peek]: #\n[Deno]: https://deno.land\n\n\u003c!-- badges --\u003e\n\n[github]: https://github.com/eibens/peek\n[github-shield]: https://img.shields.io/github/v/tag/eibens/peek?label\u0026logo=github\n[coverage-shield]: https://img.shields.io/codecov/c/github/eibens/peek?logo=codecov\u0026label\n[license-shield]: https://img.shields.io/github/license/eibens/peek?color=informational\n[coverage]: https://codecov.io/gh/eibens/peek\n[build]: https://github.com/eibens/peek/actions/workflows/ci.yml\n[build-shield]: https://img.shields.io/github/workflow/status/eibens/peek/ci?logo=github\u0026label\n[deno-doc]: https://doc.deno.land/https/deno.land/x/peek/mod.ts\n[deno-doc-shield]: https://img.shields.io/badge/doc-informational?logo=deno\n[deno-land]: https://deno.land/x/peek\n[deno-land-shield]: https://img.shields.io/badge/x/peek-informational?logo=deno\u0026label\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feibens%2Fpeek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feibens%2Fpeek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feibens%2Fpeek/lists"}