{"id":18358830,"url":"https://github.com/uppercod/next-step","last_synced_at":"2026-05-02T03:06:29.489Z","repository":{"id":113251342,"uuid":"130283698","full_name":"UpperCod/next-step","owner":"UpperCod","description":"👟  Create an iterator similar to the return of a generating function, with which you can execute a list of functions next to complete it.","archived":false,"fork":false,"pushed_at":"2018-04-21T20:40:42.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T10:48:10.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/UpperCod.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":"2018-04-19T23:38:36.000Z","updated_at":"2018-04-21T20:40:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb3a6b50-71fe-4062-a985-9ac9b901b93f","html_url":"https://github.com/UpperCod/next-step","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"134c18eeebf3c29f20d8a2fc1a86ed2649204e2d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fnext-step","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fnext-step/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fnext-step/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fnext-step/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UpperCod","download_url":"https://codeload.github.com/UpperCod/next-step/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239036138,"owners_count":19571445,"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":[],"created_at":"2024-11-05T22:19:38.284Z","updated_at":"2026-05-02T03:06:29.455Z","avatar_url":"https://github.com/UpperCod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# next-step\n\nCreate an iterator similar to the return of a generating function, with which you can execute a list of functions next to complete it.\n\n## Generators\n\n```js\nfunction *sample(){\n    yield 1;\n    yield 2;\n    return 3;\n}\n\nlet iterator = sample();\n\n    iterator.next() // {value : 1 , done : false}\n    iterator.next() // {value : 2 , done : false}\n    iterator.next() // {value : 3 , done : false}\n    iterator.next() // {value : undefined , done : true}\n\n```\n\n## next-step\n\n```js\nimport step from \"next-step\";\n\nfunction sample(){\n    return step(\n        ()=\u003e1,\n        ()=\u003e2,\n        ()=\u003e3\n    );\n}\n\nlet iterator = sample();\n\n    iterator.next() // {value : 1 , done : false}\n    iterator.next() // {value : 2 , done : false}\n    iterator.next() // {value : 3 , done : false}\n    iterator.next() // {value : undefined , done : true}\n```\n\n## Motivation\n\nGenerators are the best advance for javascript, but its compatibility in browsers is not yet complete,\nI personally occupy them in my library [Kubox] (https://www.github.com/uppercod/kubox), for asynchronous handling in the change of state.\n\n### Ejemplo con kubox\n\n```js\nexport default function *api(state,value){\n   yield {loading : true};\n   yield fetch(\"//sample.api\")\n         .then((response)=\u003eresponse.json())\n         .then((response)=\u003e{loading:false,response})\n}\n```\n\n\u003e The `Kubox.recycle` method inside **kubox**, allows you to recycle the return of a generator by modifying the state as you iterate over it with the use of the **next** method, if` Kubox.recycle` You receive a promise, you wait until you run again **next**. I hope that the generators are a few RockStar 🤟 coming soon, much more than the asynchronous functions.\n\n### Example with kubox + next-step\n\n```js\nimport step from \"next-step\";\n\nexport default function api(state,value){\n   return step(\n       ()=\u003e({loading:true}),\n       ()=\u003efetch(\"//sample.api\")\n           .then((response)=\u003eresponse.json())\n           .then((response)=\u003e{loading:false,response})\n   )\n}\n```\n\n\u003e As you will notice there is not much difference, it is just a little less elegant, but it works in all browsers 🛠️.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fnext-step","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuppercod%2Fnext-step","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fnext-step/lists"}