{"id":16350873,"url":"https://github.com/kevva/p-one","last_synced_at":"2025-03-21T00:30:56.594Z","repository":{"id":57317413,"uuid":"92238842","full_name":"kevva/p-one","owner":"kevva","description":"Test whether some promise passes a testing function","archived":false,"fork":false,"pushed_at":"2019-03-15T09:23:30.000Z","size":7,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-10T16:06:28.821Z","etag":null,"topics":["async","async-await","async-functions","await","concurrency","iteration","nodejs","parallel","promise","test"],"latest_commit_sha":null,"homepage":null,"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/kevva.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-05-24T01:58:52.000Z","updated_at":"2024-04-05T19:04:43.000Z","dependencies_parsed_at":"2022-08-25T20:40:38.348Z","dependency_job_id":null,"html_url":"https://github.com/kevva/p-one","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevva%2Fp-one","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevva%2Fp-one/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevva%2Fp-one/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevva%2Fp-one/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevva","download_url":"https://codeload.github.com/kevva/p-one/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244094275,"owners_count":20397020,"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","async-await","async-functions","await","concurrency","iteration","nodejs","parallel","promise","test"],"created_at":"2024-10-11T01:06:36.602Z","updated_at":"2025-03-21T00:30:56.325Z","avatar_url":"https://github.com/kevva.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# p-one [![Build Status](https://travis-ci.org/kevva/p-one.svg?branch=master)](https://travis-ci.org/kevva/p-one)\n\n\u003e Test whether some promise passes a testing function\n\nLike [`Array.some`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) for promises.\n\n## Install\n\n```\n$ npm install --save p-one\n```\n\n\n## Usage\n\n```js\nconst pOne = require('p-one');\nconst getContinent = require('get-continent'); // not a real module\n\nconst places = [\n\tgetCapital('Norway').then(info =\u003e info.name),\n\t'Bangkok, Thailand',\n\t'Berlin, Germany',\n\t'Tokyo, Japan'\n];\n\nconst testFunction = async place =\u003e {\n\tconst continent = await getContinent(place);\n\treturn continent === 'europe';\n}\n\n(async () =\u003e {\n\tconst result = await pOne(places, testFunction)\n\tconsole.log(result);\n\t//=\u003e true\n})();\n```\n\n\n## API\n\n### pOne(input, testFunction, [options])\n\nReturns a `Promise` that is fulfilled when any promise in `input` and ones returned from `testFunction` are fulfilled, or rejects if any of the promises reject. The fulfilled value is a `boolean` that is `true` if any promise passed the test and `false` otherwise.\n\n#### input\n\nType: `Iterable\u003cPromise|any\u003e`\n\nIterated over concurrently in the `testFunction` function.\n\n#### testFunction(element, index)\n\nType: `Function`\n\nExpected to return a `Promise\u003cboolean\u003e` or `boolean`.\n\n#### options\n\nType: `Object`\n\n##### concurrency\n\nType: `number`\u003cbr\u003e\nDefault: `Infinity`\u003cbr\u003e\nMinimum: `1`\n\nNumber of concurrently pending promises returned by `testFunction`.\n\n\n## Related\n\n* [p-every](https://github.com/kevva/p-every) - Test whether all promises passes a testing function\n* [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently\n* [p-locate](https://github.com/sindresorhus/p-locate) - Get the first fulfilled promise that satisfies the provided testing function\n* [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently\n* [More…](https://github.com/sindresorhus/promise-fun)\n\n\n## License\n\nMIT © [Kevin Martensson](http://github.com/kevva)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevva%2Fp-one","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevva%2Fp-one","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevva%2Fp-one/lists"}