{"id":13724988,"url":"https://github.com/TomerAberbach/betterator","last_synced_at":"2025-05-07T19:32:17.178Z","repository":{"id":45990844,"uuid":"350197535","full_name":"TomerAberbach/betterator","owner":"TomerAberbach","description":"💯 A better sync and async iterator API.","archived":false,"fork":false,"pushed_at":"2024-10-15T03:47:20.000Z","size":314,"stargazers_count":58,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-04T21:13:39.273Z","etag":null,"topics":["async-iterable","async-iterator","iterable","iterator","javascript","npm-package"],"latest_commit_sha":null,"homepage":"https://npm.im/betterator","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomerAberbach.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","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},"funding":{"github":"TomerAberbach"}},"created_at":"2021-03-22T03:42:27.000Z","updated_at":"2025-02-20T10:09:38.000Z","dependencies_parsed_at":"2025-03-01T06:30:33.080Z","dependency_job_id":null,"html_url":"https://github.com/TomerAberbach/betterator","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fbetterator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fbetterator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fbetterator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Fbetterator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomerAberbach","download_url":"https://codeload.github.com/TomerAberbach/betterator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252943838,"owners_count":21829320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["async-iterable","async-iterator","iterable","iterator","javascript","npm-package"],"created_at":"2024-08-03T01:02:08.940Z","updated_at":"2025-05-07T19:32:16.870Z","avatar_url":"https://github.com/TomerAberbach.png","language":"TypeScript","funding_links":["https://github.com/sponsors/TomerAberbach"],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  betterator\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/betterator\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/betterator\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/TomerAberbach/betterator/actions\"\u003e\n    \u003cimg src=\"https://github.com/TomerAberbach/betterator/workflows/CI/badge.svg\" alt=\"CI\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://unpkg.com/betterator/dist/index.min.js\"\u003e\n    \u003cimg src=\"http://img.badgesize.io/https://unpkg.com/betterator/dist/index.min.js?compression=gzip\u0026label=gzip\" alt=\"gzip size\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://unpkg.com/betterator/dist/index.min.js\"\u003e\n    \u003cimg src=\"http://img.badgesize.io/https://unpkg.com/betterator/dist/index.min.js?compression=brotli\u0026label=brotli\" alt=\"brotli size\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  A better sync and async iterator API.\n\u003c/div\u003e\n\n## Features\n\n- **Intuitive:** easy to use `hasNext` and `getNext` methods\n- **Familiar:** lots of other programming languages use the same API\n- **Tiny:** ~400 bytes minzipped\n- **Awesome Name:** you have to admit it's pretty rad :sunglasses:\n\n## Install\n\n```sh\n$ npm i betterator\n```\n\n## Usage\n\n```js\nimport { Betterator, AsyncBetterator } from 'betterator'\n\nconst slothActivities = [`sleeping`, `eating`, `climbing`]\n\n// Or `new Betterator(slothActivities[Symbol.iterator]())`\nconst iterator = Betterator.fromIterable(slothActivities)\n\nwhile (iterator.hasNext()) {\n  console.log(iterator.getNext())\n}\n//=\u003e sleeping\n//=\u003e eating\n//=\u003e climbing\n\ntry {\n  iterator.getNext()\n} catch (e) {\n  console.log(e.message)\n}\n//=\u003e Doesn't have next\n\nconsole.log(iterator.getNextOr(() =\u003e `being lazy`))\n//=\u003e being lazy\n\nconst asyncSlothActivities = (async function* () {\n  yield* slothActivities\n})()\n\n// Or `new AsyncBetterator(slothActivities[Symbol.asyncIterator]())`\nconst asyncIterator = AsyncBetterator.fromAsyncIterable(asyncSlothActivities)\n\nwhile (await asyncIterator.hasNext()) {\n  console.log(await asyncIterator.getNext())\n}\n//=\u003e sleeping\n//=\u003e eating\n//=\u003e climbing\n\ntry {\n  await asyncIterator.getNext()\n} catch (e) {\n  console.log(e.message)\n}\n//=\u003e Doesn't have next\n\nconst delay = timeout =\u003e new Promise(resolve =\u003e setTimeout(resolve, timeout))\nconsole.log(\n  await asyncIterator.getNextOr(() =\u003e delay(10).then(() =\u003e `being lazy`)),\n)\n//=\u003e being lazy\n```\n\nSee the [type definitions](https://unpkg.com/betterator/dist/index.d.ts) for\nmore documentation.\n\n## Contributing\n\nStars are always welcome!\n\nFor bugs and feature requests,\n[please create an issue](https://github.com/TomerAberbach/betterator/issues/new).\n\nFor pull requests, please read the\n[contributing guidelines](https://github.com/TomerAberbach/betterator/blob/main/contributing.md).\n\n## License\n\n[Apache 2.0](https://github.com/TomerAberbach/betterator/blob/main/license)\n\nThis is not an official Google product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTomerAberbach%2Fbetterator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTomerAberbach%2Fbetterator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTomerAberbach%2Fbetterator/lists"}