{"id":19932738,"url":"https://github.com/mixmaxhq/synchronize-helpers","last_synced_at":"2025-07-08T20:33:25.519Z","repository":{"id":49157629,"uuid":"65386837","full_name":"mixmaxhq/synchronize-helpers","owner":"mixmaxhq","description":"This module provides helpers for wrapping sync.defer() for synchronize.js.","archived":false,"fork":false,"pushed_at":"2023-08-09T19:54:50.000Z","size":18,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-30T12:47:22.589Z","etag":null,"topics":["unsupported"],"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/mixmaxhq.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":"2016-08-10T13:56:33.000Z","updated_at":"2023-08-09T19:54:51.000Z","dependencies_parsed_at":"2024-11-19T20:50:21.176Z","dependency_job_id":null,"html_url":"https://github.com/mixmaxhq/synchronize-helpers","commit_stats":{"total_commits":7,"total_committers":5,"mean_commits":1.4,"dds":0.7142857142857143,"last_synced_commit":"cfb3db9a0aece35ee9742a707bb600c453d7128f"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mixmaxhq/synchronize-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsynchronize-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsynchronize-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsynchronize-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsynchronize-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixmaxhq","download_url":"https://codeload.github.com/mixmaxhq/synchronize-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fsynchronize-helpers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264343941,"owners_count":23593814,"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":["unsupported"],"created_at":"2024-11-12T23:11:23.560Z","updated_at":"2025-07-08T20:33:25.473Z","avatar_url":"https://github.com/mixmaxhq.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## synchronize-helpers\n\n[![Build Status](https://travis-ci.org/mixmaxhq/synchronize-helpers.svg?branch=master)](https://travis-ci.org/mixmaxhq/synchronize-helpers)\n\nThis module provides helpers for wrapping `sync.defer()` for `synchronize.js`.\n`wrapException` is used to ensure that we won't throw an exception in a\n`sync.parallel` block which would otherwise halt processing of the block.\nWhile `swallowException` is useful to swallow any exceptions that would\notherwise be thrown (when we'd rather handle the returned data as undefined\nvs try/catch which can be useful if in a `sync.parallel` block where we\nexpect certain errors can occur).\n\n## Install\n\n```\n$ npm install synchronize-helpers\n```\nor\n```\n$ npm install synchronize-helpers --save\n```\n\n## API\n\n### wrapException(done, errArray)\n\nA common pattern is to use a `parallel` block from `synchronize` to run code\nconcurrently. `wrapException` allows you to defer error handling until the end\nby providing an error to hold all exceptions that occur.\n\n```js\nvar sync = require('synchronize');\nvar wrapException = require('synchronize-helpers').wrapException;\nvar thrownErrors = [];\n\nsync.parallel(function() {\n  doA(wrapException(sync.defer(), thrownErrors));\n  doB(wrapException(sync.defer(), thrownErrors));\n  doC(wrapException(sync.defer(), thrownErrors));\n});\n\nsync.await();\n\nconsole.dir(thrownErrors);\n```\n\n### swallowException(done)\n\nThere is also the situation where one might be retrieving data, and instead of\nhandling any errors, would rather consider the data to be undefined. A concrete\ncase would be retrieving instance metadata but not wanting to write conditional\ncode for determining whether the environment was production, staging, dev,\ntesting, etc. As such, we could do the following:\n\n```js\nvar sync = require('synchronize');\nvar swallowException = require('synchronize-helpers').swallowException;\n\nsync.parallel(function() {\n  doA(swallowException(sync.defer()));\n  doB(swallowException(sync.defer()));\n  doC(swallowException(sync.defer()));\n});\n\nvar data = sync.await();\nconsole.dir(data);\n```\n\n## Release History\n* 1.0.0 Initial release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fsynchronize-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixmaxhq%2Fsynchronize-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fsynchronize-helpers/lists"}