{"id":16837210,"url":"https://github.com/francoispqt/itur","last_synced_at":"2025-03-18T03:21:25.103Z","repository":{"id":57278644,"uuid":"107443373","full_name":"francoispqt/itur","owner":"francoispqt","description":"Async iterators made easy with generator control flow","archived":false,"fork":false,"pushed_at":"2017-10-19T16:40:31.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T05:47:06.559Z","etag":null,"topics":["async","control-flow","coroutines","generator","iterator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/francoispqt.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}},"created_at":"2017-10-18T17:51:10.000Z","updated_at":"2018-04-25T18:06:00.000Z","dependencies_parsed_at":"2022-09-09T14:10:44.431Z","dependency_job_id":null,"html_url":"https://github.com/francoispqt/itur","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoispqt%2Fitur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoispqt%2Fitur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoispqt%2Fitur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoispqt%2Fitur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francoispqt","download_url":"https://codeload.github.com/francoispqt/itur/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244147343,"owners_count":20405942,"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","control-flow","coroutines","generator","iterator"],"created_at":"2024-10-13T12:16:32.415Z","updated_at":"2025-03-18T03:21:25.022Z","avatar_url":"https://github.com/francoispqt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/francoispqt/itur.svg?branch=master)](https://travis-ci.org/francoispqt/itur)\n[![codecov](https://codecov.io/gh/francoispqt/iter/branch/master/graph/badge.svg)](https://codecov.io/gh/francoispqt/iter)\n# Itur\n*Async made easy with generator control flow*\n```bash\n$ npm i --save itur\n```\n## Basic example\n```javascript\nconst Itur = require('itur')\n\nconst main = function*() {\n    const result = yield Itur.reduce([1,2,3], function*(agg, key, value){\n        agg += yield Promise.resolve(value)\n        return agg\n    }, 0)\n\n    console.log(result) // 6\n}\n\nItur.run(main)()\n.catch(console.error)\n```\n\n## API\n### forEach\n```javascript\nItur.forEach([1,2,3], function*(key, value) {\n    yield Promise.resolve(key)\n})\n```\n### map\n```javascript\nconst result = yield Itur.map([1,2,3], function*(key, value) {\n    return yield Promise.resolve(key)\n})\n\nconsole.log(result) // [0,1,2]\n```\n### all\n```javascript\nconst result = yield Itur.all([1,2,3], function*(key, value) {\n    return yield Promise.resolve(key)\n})\n\nconsole.log(result) // [0,1,2]\n```\n### reduce\n```javascript\nconst result = yield Itur.reduce([1,2,3], function*(agg, key, value) {\n     agg += yield Promise.resolve(value)\n     return agg\n}, 0)\n\nconsole.log(result) // 6\n```\n### find\n```javascript\nconst result = yield Itur.find([1,2,3], function*(agg, key, value) {\n     return key === yield Promise.resolve(2)\n}, 0)\n\nconsole.log(result) // 3\n```\n### while\n```javascript\nlet c = 0\nItur.while(\n    () =\u003e c \u003c 10, \n    function*() {\n        yield Promise.resolve('do any async')\n        c++\n    }\n)\n```\n### range\n```javascript\nconst a = [1,2,3]\nconst fn = function*(key, value) {\n    return yield Promise.resolve('foobar')\n}\n\nfor (const i of Itur.range(a, fn)) {\n    console.log(i) // foobar\n}\n```\n### Chaining\nYou can chain certain operations. Example: \n```javascript\nconst result = yield Itur.map([1,2,3], function*(key, value) {\n    return key + yield Promise.resolve(value)\n})\n.reduce(function*(agg, key, value) {\n    agg.push(yield Promise.resolve(value))\n    return agg\n}, [])\n.find(function*(key, value) {\n    return key === 1\n})\n\nconsole.log(result) // 3\n```\n### Constructor syntax\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoispqt%2Fitur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancoispqt%2Fitur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoispqt%2Fitur/lists"}