{"id":16720333,"url":"https://github.com/tomokimiyauci/iterange","last_synced_at":"2025-09-02T19:45:14.701Z","repository":{"id":175708242,"uuid":"654228193","full_name":"TomokiMiyauci/iterange","owner":"TomokiMiyauci","description":"Numeric sequence lazy generator, TC39 proposal-iterator.range implementation","archived":false,"fork":false,"pushed_at":"2023-06-21T03:55:08.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-10T14:58:28.120Z","etag":null,"topics":["generator","iterable","iterator","numeric","proposal-iterator-range","range","sequence","tc39"],"latest_commit_sha":null,"homepage":"https://deno.land/x/iterange","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/TomokiMiyauci.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-15T16:53:06.000Z","updated_at":"2024-09-14T12:35:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"ce760604-d888-4ae2-870a-ecb7a4311513","html_url":"https://github.com/TomokiMiyauci/iterange","commit_stats":null,"previous_names":["tomokimiyauci/iterange"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fiterange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fiterange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fiterange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fiterange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomokiMiyauci","download_url":"https://codeload.github.com/TomokiMiyauci/iterange/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725527,"owners_count":20337666,"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":["generator","iterable","iterator","numeric","proposal-iterator-range","range","sequence","tc39"],"created_at":"2024-10-12T22:06:42.134Z","updated_at":"2025-03-15T11:41:10.916Z","avatar_url":"https://github.com/TomokiMiyauci.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iterange\n\n[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/iterange)\n[![deno doc](https://doc.deno.land/badge.svg)](https://deno.land/x/iterange/mod.ts)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/TomokiMiyauci/iterange)](https://github.com/TomokiMiyauci/iterange/releases)\n[![codecov](https://codecov.io/github/TomokiMiyauci/iterange/branch/main/graph/badge.svg)](https://codecov.io/gh/TomokiMiyauci/iterange)\n[![GitHub](https://img.shields.io/github/license/TomokiMiyauci/iterange)](https://github.com/TomokiMiyauci/iterange/blob/main/LICENSE)\n\n[![test](https://github.com/TomokiMiyauci/iterange/actions/workflows/test.yaml/badge.svg)](https://github.com/TomokiMiyauci/iterange/actions/workflows/test.yaml)\n[![NPM](https://nodei.co/npm/iterange.png?mini=true)](https://nodei.co/npm/iterange/)\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme)\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\nNumeric sequence lazy generator, TC39\n[proposal-iterator.range](https://github.com/tc39/proposal-iterator.range)\nimplementation.\n\n## Table of Contents \u003c!-- omit in toc --\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n  - [Incremental sequence](#incremental-sequence)\n  - [Decremental sequence](#decremental-sequence)\n  - [Step](#step)\n  - [Option](#option)\n    - [Inclusive end](#inclusive-end)\n    - [Step option](#step-option)\n  - [Bigint](#bigint)\n  - [Errors](#errors)\n  - [Polyfill](#polyfill)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\ndeno.land:\n\n```ts\nimport * as mod from \"https://deno.land/x/iterange/mod.ts\";\n```\n\nnpm:\n\n```bash\nnpm i iterange\n```\n\n## Usage\n\nShow you how to use in this section.\n\n### Incremental sequence\n\nSpecify `start` and `end`. By default, `step` is 1 and `end` is exclusive.\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst start = 0;\nconst end = 5;\n\nassertEquals([...range(start, end)], [0, 1, 2, 3, 4]);\n```\n\n### Decremental sequence\n\nIf `end` is less than `start`, a decremental sequence is generated.\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst iterator = range(1, -3);\n\nassertEquals(iterator.next().value, 1);\nassertEquals(iterator.next().value, 0);\nassertEquals(iterator.next().value, -1);\n```\n\n### Step\n\nYou can change the interval(step) of the sequence. The default is `1` (or `1n`\nfor bigint).\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst iterator = range(0, Infinity, 2);\n\nassertEquals(iterator.next().value, 0);\nassertEquals(iterator.next().value, 2);\nassertEquals(iterator.next().value, 4);\n```\n\n### Option\n\nThe third argument can be one of the following options:\n\n- `inclusive`\n- `step`\n\n#### Inclusive end\n\nBy default, `end` is exclusive. This can be changed by specifying options.\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nassertEquals([...range(0, 5, { inclusive: true })], [0, 1, 2, 3, 4, 5]);\n```\n\n#### Step option\n\nOption accepts another `step` field. This is equivalent to [step](#step).\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst iterator = range(0, -Infinity, { step: -2 });\n\nassertEquals(iterator.next().value, 0);\nassertEquals(iterator.next().value, -2);\nassertEquals(iterator.next().value, -4);\n```\n\n### Bigint\n\nThe range supports `bigint` as well as `number`.\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std/testing/asserts.ts\";\n\nconst iterator = range(0n, 100n, { step: 10n });\n\nassertEquals(iterator.next().value, 0n);\nassertEquals(iterator.next().value, 10n);\nassertEquals(iterator.next().value, 20n);\n```\n\nThat is, the following cannot be compiled and are type safe:\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\n\n//@ts-expect-error\nrange(0, 0n);\n//@ts-expect-error\nrange(0, 100, 3n);\n//@ts-expect-error\nrange(1n, Infinity, { step: 1 });\n```\n\n### Errors\n\nThrows `RangeError` in the following cases:\n\n- `start`, `end` or `step` is `NaN`\n- `start` is infinity\n- if `step` is 0, `start` and `end` are not the same\n\n```ts\nimport { range } from \"https://deno.land/x/iterange/mod.ts\";\nimport { assertThrows } from \"https://deno.land/std/testing/asserts.ts\";\n\nassertThrows(() =\u003e range(NaN, 0).next());\nassertThrows(() =\u003e range(0, NaN).next());\nassertThrows(() =\u003e range(0, Infinity, NaN).next());\nassertThrows(() =\u003e range(Infinity, Infinity).next());\nassertThrows(() =\u003e range(0n, 1n, { step: 0n }).next());\n```\n\n### Polyfill\n\nPolyfill affects the global object. You must be very careful when using it.\n\nDepends on the `Iterator` object. If there is no `Iterator`, a runtime error\nwill occur.\n\n```ts\nimport \"https://deno.land/x/iterange/polyfill.ts\";\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\n\nassert(Iterator.range);\n```\n\n## API\n\nSee [deno doc](https://deno.land/x/iterange?doc) for all APIs.\n\n## Contributing\n\nSee [contributing](CONTRIBUTING.md).\n\n## License\n\n[MIT](LICENSE) © 2023 Tomoki Miyauchi\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomokimiyauci%2Fiterange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomokimiyauci%2Fiterange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomokimiyauci%2Fiterange/lists"}