{"id":14982050,"url":"https://github.com/gulpjs/async-settle","last_synced_at":"2025-05-08T00:08:43.752Z","repository":{"id":14860677,"uuid":"17583980","full_name":"gulpjs/async-settle","owner":"gulpjs","description":"Settle an async function. It will always complete successfully with an object of the resulting state.","archived":false,"fork":false,"pushed_at":"2023-04-16T20:13:06.000Z","size":22,"stargazers_count":11,"open_issues_count":0,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T00:08:36.756Z","etag":null,"topics":[],"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/gulpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":["gulpjs","phated","yocontra"],"tidelift":"npm/gulp","open_collective":"gulpjs"}},"created_at":"2014-03-10T06:37:44.000Z","updated_at":"2024-01-31T11:33:26.000Z","dependencies_parsed_at":"2022-08-30T12:10:24.542Z","dependency_job_id":"d1e52a75-9d17-428c-af3f-49e08499d0cd","html_url":"https://github.com/gulpjs/async-settle","commit_stats":{"total_commits":21,"total_committers":6,"mean_commits":3.5,"dds":"0.38095238095238093","last_synced_commit":"cd7b2775b25759aa29dfffad20f6e5924c0aac8b"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fasync-settle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fasync-settle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fasync-settle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fasync-settle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/async-settle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973690,"owners_count":21834108,"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-09-24T14:04:42.017Z","updated_at":"2025-05-08T00:08:43.726Z","avatar_url":"https://github.com/gulpjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/gulpjs","https://github.com/sponsors/phated","https://github.com/sponsors/yocontra","https://tidelift.com/funding/github/npm/gulp","https://opencollective.com/gulpjs"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://gulpjs.com\"\u003e\n    \u003cimg height=\"257\" width=\"114\" src=\"https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# async-settle\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nSettle an async function. It will always complete successfully with an object of the resulting state.\n\nHandles completion and errors for callbacks, promises, observables and streams.\n\nWill run call the function on `nextTick`. This will cause all functions to be async.\n\n## Usage\n\n### Successful completion\n\n```js\nvar asyncSettle = require('async-settle');\n\nasyncSettle(\n  function (done) {\n    // do async things\n    done(null, 2);\n  },\n  function (error, result) {\n    // `error` will ALWAYS be null on execution of the first function.\n    // `result` will ALWAYS be a settled object with the result or error of the first function.\n  }\n);\n```\n\n### Failed completion\n\n```js\nvar asyncSettle = require('async-settle');\n\nasyncSettle(\n  function (done) {\n    // do async things\n    done(new Error('Some Error Occurred'));\n  },\n  function (error, result) {\n    // `error` will ALWAYS be null on execution of the first function.\n    // `result` will ALWAYS be a settled object with the result or error of the first function.\n  }\n);\n```\n\n## API\n\n### `asyncSettle(fn, callback)`\n\nTakes a function to execute (`fn`) and a function to call on completion (`callback`).\n\n#### `fn([done])`\n\nOptionally takes a callback (`done`) to call when async tasks are complete.\n\nExecuted in the context of [`async-done`][async-done], with all errors and results being settled.\n\nCompletion is handled by [`async-done` completion and error resolution][completions].\n\n#### `callback(error, result)`\n\nCalled on completion of `fn` and recieves a settled object as the `result` argument.\n\nThe `error` argument will always be `null`.\n\n#### Settled Object\n\nSettled values have two properties, `state` and `value`.\n\n`state` has two possible options `'error'` and `'success'`.\n\n`value` will be the value passed to original callback.\n\n## License\n\nMIT\n\n\u003c!-- prettier-ignore-start --\u003e\n[downloads-image]: https://img.shields.io/npm/dm/async-settle.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/async-settle\n[npm-image]: https://img.shields.io/npm/v/async-settle.svg?style=flat-square\n\n[ci-url]: https://github.com/gulpjs/async-settle/actions?query=workflow:dev\n[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/async-settle/dev.yml?branch=master\u0026style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/async-settle\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/async-settle/master.svg?style=flat-square\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n[async-done]: https://github.com/gulpjs/async-done\n[completions]: https://github.com/gulpjs/async-done#completion-and-error-resolution\n\u003c!-- prettier-ignore-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fasync-settle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Fasync-settle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fasync-settle/lists"}