{"id":13727459,"url":"https://github.com/hg-pyun/iterize","last_synced_at":"2025-04-28T16:11:03.474Z","repository":{"id":57278525,"uuid":"150928948","full_name":"hg-pyun/iterize","owner":"hg-pyun","description":"Use JavaScript Iterator, Easily","archived":false,"fork":false,"pushed_at":"2019-06-15T02:59:50.000Z","size":152,"stargazers_count":63,"open_issues_count":12,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-20T21:17:33.976Z","etag":null,"topics":["generator","iterator","javascript","library","minimalistic","typescript"],"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/hg-pyun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE_LOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2018-09-30T04:02:09.000Z","updated_at":"2024-03-15T13:06:05.000Z","dependencies_parsed_at":"2022-09-18T12:31:18.175Z","dependency_job_id":null,"html_url":"https://github.com/hg-pyun/iterize","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Fiterize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Fiterize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Fiterize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hg-pyun%2Fiterize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hg-pyun","download_url":"https://codeload.github.com/hg-pyun/iterize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342724,"owners_count":21574245,"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","iterator","javascript","library","minimalistic","typescript"],"created_at":"2024-08-03T01:03:57.742Z","updated_at":"2025-04-28T16:11:03.435Z","avatar_url":"https://github.com/hg-pyun.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# iterize\n\n[![npm](https://img.shields.io/npm/v/iterize.svg)](https://www.npmjs.com/package/iterize)\n[![npm](https://img.shields.io/npm/dt/iterize.svg)](https://www.npmjs.com/package/iterize)\n[![GitHub license](https://img.shields.io/github/license/hg-pyun/iterize.svg)](https://github.com/hg-pyun/iterize/blob/master/LICENSE)\n![Build Status](https://codebuild.ap-northeast-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoibC9MTUdiTUlIUkFGZzB3SThHMWc1WlI0N2I2TnhFT0RxcXozUVlrU1V6dk1iZzlyWHJvelRIMDJCMHowRE56cDc0N3NUcFIxQ0owSWlqektFR1JJaGI0PSIsIml2UGFyYW1ldGVyU3BlYyI6IkNnMUdYU01GTVpFbFpUNE0iLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D\u0026branch=master)\n\n\u003e Use JavaScript Iterator, Easily \n\n**iterize** is a minimalistic creator for the iterator. A great feature called Iterator was added into JavaScript. However, it's a strange concept for most of the front-end developers.\n**iterize** helps you create your code more easily and efficiently using the various attributes of the Iterable Protocol.\n\n## Why Powerful?\n\n#### Lazy Evaluation\n\nAn array does not need to be allocated to memory on compile-time, nor does it need to be declared explicitly. You can let it be calculated on run-time, or any time you want it to be used.\n\n#### Expressing Infinity\n\nIt was not easy to express the concept of infinity using the conventional syntax of JavaScript. **iterize** can help you express this concept effectively.\n\n#### Reuse\n\nMost functions of **iterize** are implemented as Higher-Order Functions. You can improve your productivity by reusing the functions you have already implemented before.\n\n# Install\n\n```bash\n$ npm install iterize --save\n```\n\nYou can import **iterize** using ESModule style.\n\n```js\nimport * as iterize from 'iterize';\n```\n```js\nimport {range} from 'iterize';\n```\nIf you want to use [UMD](https://github.com/umdjs/umd), please import `dist/iterize.umd.js` on your html file.\n```html\n\u003cscript src=\"iterize.umd.js\" /\u003e\n```\n\n# API\n- [Range](https://github.com/hg-pyun/iterize#range)\n- [Cycle](https://github.com/hg-pyun/iterize#cycle)\n- [Repeat](https://github.com/hg-pyun/iterize#repeat)\n- [Take](https://github.com/hg-pyun/iterize#take)\n\n## Range\n\nReturns a transmitter that increases with some steps within a certain range.\n\n#### Interface\n\n```typescript\nrange(start: number, end?: number, step?: number | Function): Iterator\n```\n\n#### Example\nYou can use with `for-of` syntax.\n```js\nimport {range} from 'iterize';\n\nfor (let number of range(5)) {\n    console.log(number);  // 0, 1, 2, 3, 4\n}\n\nfor (let number of range(0, 5)) {\n    console.log(number);  // 0, 1, 2, 3, 4\n}\n\nfor (let number of range(0, 5, 2)) {\n    console.log(number);  // 0, 2, 4\n}\n```\nWith the spread operator.\n```js\nimport {range} from 'iterize';\n[...range(5)];  // [0, 1, 2, 3, 4]\n[...range(0, 5)]; // [0, 1, 2, 3, 4]\n[...range(5, 0)]; // [5, 4, 3, 2, 1]\n[...range(1, 10, 1)]; // [1, 2, 3 ... 9]\n[...range(1, 10, x =\u003e x + 1)]; // [1, 2, 3 ... 9]\n[...range(2, 64, x =\u003e x * x)]; // [2, 4, 16]\n```\n\n## Cycle\n\n#### Interface\n\nReceives a string, an array or an iterator and returns an emitter that repeats infinitely.\n\n```typescript\ncycle(item: string | Array\u003cany\u003e | Iterator): Iterator\n```\n\n#### Example\n```js\nimport {cycle} from 'iterize';\n\nconst iter = cycle('ABCD');\niter.next(); // { value: 'A', done: false }\niter.next(); // { value: 'B', done: false }\niter.next(); // { value: 'C', done: false }\niter.next(); // { value: 'D', done: false }\niter.next(); // { value: 'A', done: false }\niter.next(); // { value: 'B', done: false }\n...\n```\n\n```js\nimport {cycle} from 'iterize';\n\nconst iter = cycle([0, 1, 2]);\niter.next(); // { value: 0, done: false }\niter.next(); // { value: 1, done: false }\niter.next(); // { value: 2, done: false }\niter.next(); // { value: 0, done: false }\niter.next(); // { value: 1, done: false }\niter.next(); // { value: 2, done: false }\n...\n```\n`Cycle` can also receive a range iterator.\n```js\nimport {cycle, range} from 'iterize';\n\nconst rangeIterator = range(0, 5, 2);\nconst iter = cycle(rangeIterator);\niter.next(); // { value: 0, done: false }\niter.next(); // { value: 2, done: false }\niter.next(); // { value: 4, done: false }\niter.next(); // { value: 0, done: false }\niter.next(); // { value: 2, done: false }\niter.next(); // { value: 4, done: false }\niter.next(); // { value: 0, done: false }\n...\n```\n\n## Repeat\nReturns the N copies of the input(number, string, or iterator).\n\n#### Interface\n\n```typescript\nrepeat(item: number | string | Function | Iterator, count: number): Iterator\n```\n\n#### Example\n```js\nimport {repeat} from 'iterize';\n\nfor (let number of repeat(1, 3)) {\n    console.log(number);  // [1, 1, 1]\n}\n```\nWith the spread operator.\n```js\nimport {repeat} from 'iterize';\n\n[...repeat(0, 5)];   // [0, 0, 0, 0, 0]\n[...repeat('a', 5)]; // ['a', 'a', 'a', 'a', 'a']\n```\n```js\nimport {repeat, range} from 'iterize';\n\nconst rangeIterator = range(1, 5, 1);\n[...repeat(rangeIterator, 2)]; // [1, 2, 3, 4, 1, 2, 3, 4]\n```\n\n## Take\n\nReturns the first N items of the iterator sequentially.\n\n#### Interface\n\n```typescript\ntake(predicate: number, iter: Iterator): Iterator\n```\n\n#### Example\n```js\nimport {take, cycle} from 'iterize';\n\nconst cycleIterator = cycle([1, 2, 3]);\nfor (let number of take(5, cycleIterator)) {\n    console.log(number);  // 1, 2, 3, 1, 2\n}\n```\n#### Interface\n\n```typescript\ntakeWhile(predicate: Function, iter: Iterator): Iterator\n```\n\n#### Example\n```js\nimport {takeWhile, range} from 'iterize';\n\nfor (let number of takeWhile(x =\u003e x \u003c 3, range(5))) {\n    console.log(number);  // 0, 1, 2\n}\n```\n\n# CONTRIBUTING\n\n### [Contributing Guide](https://github.com/hg-pyun/iterize/blob/master/CONTRIBUTE.md)\n\nRead contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to **iterize**.\n\n# LICENSE\n\n**iterize** is [MIT licensed](https://github.com/hg-pyun/iterize/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhg-pyun%2Fiterize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhg-pyun%2Fiterize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhg-pyun%2Fiterize/lists"}