{"id":19974557,"url":"https://github.com/twooster/testsync","last_synced_at":"2025-09-19T22:09:38.950Z","repository":{"id":142825123,"uuid":"184401907","full_name":"twooster/testsync","owner":"twooster","description":"JS Helper for Testing Intricate Asynchronous Code","archived":false,"fork":false,"pushed_at":"2021-01-22T15:32:47.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T17:44:32.066Z","etag":null,"topics":["async","helper","javascript","promise","testing"],"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/twooster.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":"2019-05-01T10:40:14.000Z","updated_at":"2021-01-22T15:32:49.000Z","dependencies_parsed_at":"2023-05-14T10:30:55.907Z","dependency_job_id":null,"html_url":"https://github.com/twooster/testsync","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/twooster/testsync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twooster%2Ftestsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twooster%2Ftestsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twooster%2Ftestsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twooster%2Ftestsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twooster","download_url":"https://codeload.github.com/twooster/testsync/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twooster%2Ftestsync/sbom","scorecard":{"id":904368,"data":{"date":"2025-08-18","repo":{"name":"github.com/twooster/testsync","commit":"175039f4e0005bacc5b83368b3733b8bcac6a3ae"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-24T16:48:10.783Z","repository_id":142825123,"created_at":"2025-08-24T16:48:10.783Z","updated_at":"2025-08-24T16:48:10.783Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273854786,"owners_count":25180013,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","helper","javascript","promise","testing"],"created_at":"2024-11-13T03:15:24.306Z","updated_at":"2025-09-19T22:09:38.911Z","avatar_url":"https://github.com/twooster.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [TestSync](https://github.com/twooster/testsync): A Helper for Testing Intricate Async Logic\n\nTestSync is a little helper library to aid in testing intricate ordering of\nasynchronous code in Javascript. TypeScript typings are included.\n\nThis library is feature complete and new new development is anticipated\n(though who knows).\n\n## Installation\n\nYou probably want to use this library as a dev dependency:\n\n```shell\nnpm install --save-dev testsync\n```\n\n## Motivation\n\nSometimes you need to build intricate test cases around asynchronous logic to\nensure that, given certain ordering of operations of asynchronous code, things\nstill operate correctly. This can be tricky to guarantee in any asynchronous\nsystem! This library can help.\n\nIt does this by providing \"synchronization points\" (promises) that can be\n`await`ed in your code. Once awaited enough times, the synchronization promises\nwill automatically resolved, and your code will continue.\n\n## Example\n\nImagine you have an asynchronous cache, and you want to validate that given a\ncertain order of operations on that cache, things behave as expected. How might\nyou test that? With testsync, it's easy:\n\n```javascript\nconst sync = require('testsync')\n\nconst [precache, cached] = sync()\n\nconst url = 'http://example.org'\nconst cache = new AsyncCache()\n\nasync function worker1() {\n  const data = await fetchUrl(url)\n  await precache\n  await cache.set(url, data)\n  await cached\n}\n\nasync function worker2() {\n  expect(await cache.get(url)).to.be.undefined\n  await precache\n  await cached\n  expect(await cache.get(url)).to.be.ok\n}\n\nawait Promise.all([worker1(), worker2()])\n```\n\n## Usage\n\nThe API is very simple. First import the `sync` function (all of the below\nwill work equivalently):\n\n```javascript\nconst { sync } = require('testsync')\nconst sync = require('testsync')\nimport sync from 'testsync'\nimport { sync } from 'testsync'\n```\n\nThe `sync` method has the signature:\n\n```javascript\nfunction * sync(awaitCount = 2)\n```\n\nThis is a generator function that returns as many synchronization points as\nyou'd like. They will resolve only when they've been `await`ed (or `.then`d)\nthe specified (`count`, default 2) number of times. The promise will\nnever throw.\n\nTo create new promises, use destructuring:\n\n```javascript\nconst [beforeUpdate, afterUpdate, afterSave] = sync()\nconst [threeWaySyncPoint] = sync(3)\n```\n\nYou can create as many synchronization points as you like this way. Afterwards,\njust await them as normal (from within separate async contexts, obviously), and\nwhen the promise is being awaited in the minimum number of places, it will\nautomatically resolve:\n\n```javascript\nconst [a, b]\n\nawait Promise.all([\n  new Promise(resolve =\u003e {\n    await a\n    await b\n    resolve()\n  }),\n  new Promise(resolve =\u003e {\n    await a\n    await b\n    resolve()\n  })\n])\n```\n\n### Further Semantics\n\n```javascript\nconst [a, b, c] = sync()     // equivalent to sync(2)\nawait Promise.all([a, a])    // resolves, `a` is awaited twice\nawait Promise.all([b])       // never resolves, only awaited once\nawait Promise.all([c, c, c]) // can be awaited more than `count` times\n\nconst [d, e] = sync(3)\nawait Promise.all([d, d])    // again never resolves, must be awaited 3 times\nawait Promise.all([e, e, e]) // resolves\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwooster%2Ftestsync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwooster%2Ftestsync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwooster%2Ftestsync/lists"}