{"id":15137696,"url":"https://github.com/humptydumptyeiz/pneasync","last_synced_at":"2026-02-09T17:01:31.484Z","repository":{"id":57116823,"uuid":"308097609","full_name":"humptydumptyeiz/pNeAsync","owner":"humptydumptyeiz","description":"This piece of code promisifies nested awaits","archived":false,"fork":false,"pushed_at":"2020-10-31T07:50:33.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-29T12:10:08.971Z","etag":null,"topics":["async","await","nested-arrays","nodejs","promise"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/humptydumptyeiz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-28T17:51:06.000Z","updated_at":"2020-10-31T07:50:35.000Z","dependencies_parsed_at":"2022-08-22T22:20:18.466Z","dependency_job_id":null,"html_url":"https://github.com/humptydumptyeiz/pNeAsync","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/humptydumptyeiz/pNeAsync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humptydumptyeiz%2FpNeAsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humptydumptyeiz%2FpNeAsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humptydumptyeiz%2FpNeAsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humptydumptyeiz%2FpNeAsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humptydumptyeiz","download_url":"https://codeload.github.com/humptydumptyeiz/pNeAsync/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humptydumptyeiz%2FpNeAsync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29273139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T13:47:44.167Z","status":"ssl_error","status_checked_at":"2026-02-09T13:47:43.721Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","await","nested-arrays","nodejs","promise"],"created_at":"2024-09-26T07:01:41.726Z","updated_at":"2026-02-09T17:01:31.467Z","avatar_url":"https://github.com/humptydumptyeiz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# p(romisify)Ne(sted)Async\n\n## A handy tool to promisify nested arrays\n\n\n***Installation***\n\n``\nnpm i @humptydumptyeiz/pneasync\n``\n\n***Run Tests***\n\n``\nnpm test\n``\n\n***Usage :***\n\nSuppose args is an array of objects which define some category, each object having categoryId as a property. Suppose\nsomeAsyncFunction takes categoryId of elements of the above array and returns an array of sub category objects, each\nhaving subCategoryId as a property. Suppose anotherAsyncFunction takes subCategoryId of each element of subcategory\narray and returns an array of products.\n\nIf we want to get all subcategories and products corresponding to each category, we can run a for loop inside another\nwith awaits before each async function call and collect the results. However, this will make the code synchronous.\n\nTo resolve this, use pNeAsync.\n\n\n**Arguments** \n1. list - array to iterate over.\n2. factorList - it is an array each of whose element is an object of the form - \n\n      \n        {\n          argFoo:     // function which takes in each element of the list\n          foo:        // async function which takes the value returned by argFoo as argument\n        }\n3. failFast - default value is ``true``. When ``true`` the function will throw errors and instead of handling them and\n              will cause exception.\n              When ``false`` the function will handle errors and push them into an array which will be returned with the\n              result.       \n\n**Return Value**\n\n1. ``failFast === true \u0026\u0026 Exception`` - exception will be raised\n2. ``failFast === false \u0026\u0026 Exception``  -  \n```   \n      [[// this is the result \n        {\n            parent: obj1,\n            children: [\n                {\n                   parent: obj2\n                   children: [...]   \n                },\n                ...\n            ]\n        },\n        ...\n       ], [{      // this is the error array\n           object:    // object under use when exception occurred,\n           depth:     // depth of nesting at which the exception occurred,\n           arg        // arg variable from factorList element,\n           typeOfArg, // typeOfArg variable from factorList,\n           foo        // foo variable from factorList element,\n           error:     // exception raised\n     }, ...]]\n```\n\nLength of factor list decides the depth of the nesting. So, each element of the factorList is an object containing\narg, foo and typeOfArg for increasing depths of nesting\n\n    \n      const list = [{id: 1, name: 'a'}, {id: 2, name: 'b'}, ...];\n      const factors = [{argFoo: elm =\u003e elm.id, foo: someAsyncFoo},\n                       {argFoo: elm =\u003e elm.subCategoryId, foo: anotherAsyncFoo}];\n      \n      async function anyFunction(arr){\n        return await pneAsync(list, factors)\n      }\n    \n                  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumptydumptyeiz%2Fpneasync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumptydumptyeiz%2Fpneasync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumptydumptyeiz%2Fpneasync/lists"}