{"id":27168209,"url":"https://github.com/michaelpiper/susx","last_synced_at":"2025-10-29T02:53:26.724Z","repository":{"id":198914100,"uuid":"701813847","full_name":"michaelpiper/susX","owner":"michaelpiper","description":"Susceptive Extension for JS","archived":false,"fork":false,"pushed_at":"2023-11-07T19:07:50.000Z","size":61,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T23:34:55.991Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelpiper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-07T16:26:50.000Z","updated_at":"2025-01-16T22:23:31.000Z","dependencies_parsed_at":"2023-11-07T21:00:23.738Z","dependency_job_id":"be5e06f5-73ef-43dd-95c8-04d8e285024a","html_url":"https://github.com/michaelpiper/susX","commit_stats":null,"previous_names":["michaelpiper/susx"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelpiper%2FsusX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelpiper%2FsusX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelpiper%2FsusX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelpiper%2FsusX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelpiper","download_url":"https://codeload.github.com/michaelpiper/susX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247985827,"owners_count":21028765,"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":"2025-04-09T05:29:34.722Z","updated_at":"2025-10-29T02:53:21.704Z","avatar_url":"https://github.com/michaelpiper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SusX Library\n\n## Author\nMichael Piper\n\nThis library provides classes for managing subscriptions, objects, and event-driven behavior. It includes the following components:\n\n- `SusXObject`\n- `SusXObserver`\n- `SusXSubscription`\n- `SusX`\n- `SusXChangeObserver`\n\n## Usage\n\n```javascript\nimport {\n  SusXObject,\n  SusXObserver,\n  SusXSubscription,\n  SusX,\n  SusXChangeObserver\n} from 'susx';\n\n// ... (code continues)\n```\n\n## SusX\n\n### Example Usage:\n\n```javascript\nconst susX = new SusX(1);\n/// available command are\n/// 1) ctx.on() // will turn on the observer\n/// 2) ctx.off() // will turn off the observer\n/// 3) ctx.once() // will turn on the observer once and them remove it immediately after\nconst ctx: SusXChangeObserver\u003ctypeof susX\u003e = susX.valueChange((value)=\u003e{\n  console.log('value change', value);\n  assert(susX.value === value, 'value should be ' + susX.value);\n}).on();\n\nsusX.on('do not wait', async (value)=\u003e{\n  await susX.delay(20);\n  console.log('do not wait first listener', value);\n});\n\nsusX.on('do not wait', async (value)=\u003e{\n  await susX.delay(10);\n  console.log('do not wait second listener', value);\n});\n\nawait t.test(\"it would run the event in parallel and not wait for result\", async function () {\n  susX.emit('do not wait', 'emit');\n});\n\nawait t.test(\"it would run the event parallel and await for each listener to finish before the next\", async function () {\n  await susX.tap('do not wait', 'tap');\n});\n\nawait t.test(\"it would run the event concurrently and await for all listener to finish\",async  function () {\n  await susX.broadcast('do not wait', 'broadcast');\n  console.log('\"do not wait second\" will print before \"do not wait first\" broadcast complete',);\n});\n\n// More code...\n```\n\n## SusXSubscription\n\n### Example Usage:\n\n```javascript\nconst test1 = new SusXSubscription();\n\nawait test1.delay(200);\n\nconst logText: SusXObserver = test1.subscribe('long-text');\n\nlogText.on('data', (data) =\u003e {\n  console.log(data);\n  assert(data === text[currentText], 'Text Chunk should be same as source value' + \" source=\" + text[currentText]);\n});\n\nlogText.on('end', () =\u003e {\n  console.log('Long Text End');\n});\n\nfor(let chunk of text){\n  await test1.broadcast('long-text', chunk);\n}\n\ntest1.off('long-text');\n\n// More code...\n```\n\n## SusXObject\n\n### Example Usage:\n\n```javascript\nconst test1 = new SusXObject();\n\nsetTimeout(async function () {\n  console.log('waited for 2s to broadcast result hi');\n  test1.setObject({ hi: 'hi' }).putObject({ hi2: 'you' });\n  await test1.broadcast('hi', 'hi');\n  test1.emit('hi2', test1.value.hi2);\n  console.log('should be the last line result already returned');\n}, 2000);\n\nconst result2 = await test1.observe('hi2', function (data: any) {\n  console.log('this', this.getObject());\n  return data;\n});\n\nassert(result2 === 'you', 'result2 should be you' + ' result2=' + result2);\n\n// More code...\n```\n\n## Testing\n\nTo run the tests, use the following command:\n\n```bash\nnpm test\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests.\n\n## Issues\n\nIf you encounter any problems or have suggestions, please [open an issue](https://github.com/michaelpiper/SusX/issues).\n\n## Changelog\n\nFor details, see [CHANGELOG.md](CHANGELOG.md).\n\n---\n\nFeel free to customize and expand upon this template according to your specific project needs.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelpiper%2Fsusx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelpiper%2Fsusx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelpiper%2Fsusx/lists"}