{"id":30307950,"url":"https://github.com/thutasann/gonex","last_synced_at":"2026-03-11T20:34:06.241Z","repository":{"id":306740184,"uuid":"1027072886","full_name":"thutasann/gonex","owner":"thutasann","description":"High-Performance Go-Inspired Concurrency with True Parallelism for Node.js","archived":false,"fork":false,"pushed_at":"2025-08-28T15:55:10.000Z","size":705,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-04T22:16:19.958Z","etag":null,"topics":["concurrency","golang","multithreading","nodejs","parallelism","typescript","worker-threads"],"latest_commit_sha":null,"homepage":"https://thutasann.github.io/gonex/","language":"TypeScript","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/thutasann.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,"zenodo":null}},"created_at":"2025-07-27T08:53:16.000Z","updated_at":"2025-08-28T15:55:14.000Z","dependencies_parsed_at":"2025-08-12T14:23:46.602Z","dependency_job_id":"8bf77161-0d1d-4c7c-b8e3-73c4d9be8108","html_url":"https://github.com/thutasann/gonex","commit_stats":null,"previous_names":["thutasann/gonex"],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/thutasann/gonex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thutasann%2Fgonex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thutasann%2Fgonex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thutasann%2Fgonex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thutasann%2Fgonex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thutasann","download_url":"https://codeload.github.com/thutasann/gonex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thutasann%2Fgonex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30399428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T18:46:22.935Z","status":"ssl_error","status_checked_at":"2026-03-11T18:46:17.045Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["concurrency","golang","multithreading","nodejs","parallelism","typescript","worker-threads"],"created_at":"2025-08-17T11:35:14.406Z","updated_at":"2026-03-11T20:34:06.222Z","avatar_url":"https://github.com/thutasann.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# High-Performance Go-Inspired Concurrency with True Parallelism for Node.js\n\nA comprehensive TypeScript library that brings Go's powerful concurrency primitives to Node.js with **true parallelism** using Worker Threads, enabling robust, scalable concurrent programming patterns with multi-core performance.\n\n## Features\n\n### Core Concurrency Primitives\n\n- **Goroutines** - Lightweight concurrent functions with automatic scheduling\n- **Channels** - Typed communication between goroutines (buffered/unbuffered)\n- **Select** - Non-blocking channel operations with multiple cases\n- **WaitGroup** - Synchronization for multiple goroutines\n- **Mutex** - Mutual exclusion locks for shared resources\n- **RWMutex** - Read-write mutex for concurrent read access\n- **Once** - One-time initialization guarantees\n- **Cond** - Condition variables for signaling\n- **Semaphore** - Resource limiting and access control\n- **Context** - Cancellation, deadlines, and request-scoped values\n\n### True Parallelism with Worker Threads\n\n- **Multi-Core Execution** - Utilize all CPU cores for CPU-intensive tasks\n- **Automatic Load Balancing** - Round-robin distribution across worker threads\n- **Performance Optimized** - Minimal overhead with direct function execution\n- **Smart Fallback** - Automatic fallback to event-loop for I/O-bound tasks\n- **Execution Mode Tracking** - Clear logging of event-loop vs worker-thread execution\n- **External Imports** - Support for Node.js built-in modules and third-party packages in worker threads\n\n### Timing and Scheduling\n\n- **Ticker** - Periodic events with configurable intervals\n- **Timer** - One-time delayed events\n- **Sleep** - Cooperative yielding and delays\n\n### Advanced Patterns\n\n- **Worker Pool** - Managed goroutine pools for controlled concurrency\n- **Pipeline** - Chained processing with backpressure\n- **Fan-out/Fan-in** - Parallel processing patterns\n- **Rate Limiter** - Request throttling and rate control\n- **Circuit Breaker** - Fault tolerance and failure handling\n- **Retry** - Automatic retry mechanisms with exponential backoff\n\n## Installation\n\n```bash\nnpm install gonex\n```\n\n## 📦 NPM Package\n\nThis package is available on npm as [**gonex**](https://www.npmjs.com/package/gonex).\n\n[![npm version](https://img.shields.io/npm/v/gonex.svg)](https://www.npmjs.com/package/gonex)\n[![npm downloads](https://img.shields.io/npm/dm/gonex.svg)](https://www.npmjs.com/package/gonex)\n[![npm license](https://img.shields.io/npm/l/gonex.svg)](https://www.npmjs.com/package/gonex)\n\n**Install with:**\n\n```bash\nnpm install gonex\n# or\nyarn add gonex\n# or\npnpm add gonex\n```\n\n## 🚀 Quick Start\n\n```typescript\nimport { go, channel, select, waitGroup } from 'gonex';\n\n// Simple goroutine (event-loop)\ngo(async () =\u003e {\n  console.log('Hello from goroutine!');\n});\n\n// Channel communication\nconst ch = channel\u003cstring\u003e();\ngo(async () =\u003e {\n  await ch.send('Hello from sender!');\n});\n\ngo(async () =\u003e {\n  const msg = await ch.receive();\n  console.log(msg); // \"Hello from sender!\"\n});\n\n// WaitGroup synchronization\nconst wg = waitGroup();\nfor (let i = 0; i \u003c 3; i++) {\n  wg.add(1);\n  go(async () =\u003e {\n    await sleep(1000);\n    console.log('Worker completed');\n    wg.done();\n  });\n}\nawait wg.wait();\nconsole.log('All workers completed');\n\nawait shutdownParallelScheduler();\n```\n\n## 🚀 External imports in worker threads\n\n```typescript\nimport { initializeParallelScheduler, shutdownParallelScheduler } from 'gonex';\n\nawait initializeParallelScheduler({ useWorkerThreads: true });\n\nconst result = await go(\n  async () =\u003e {\n    const fs = require('node:fs');\n    const crypto = require('node:crypto');\n    const moment = (await import('moment')).default;\n\n    const moment_res = {\n      version: moment.version,\n      now: moment().format(),\n      isValid: moment().isValid(),\n    };\n\n    return {\n      fileExists: fs.existsSync('/tmp/test'),\n      randomBytes: crypto.randomBytes(4).toString('hex'),\n      ...moment_res,\n    };\n  },\n  [],\n  { useWorkerThreads: true }\n);\n```\n\n## 🚀 Parallelism Examples\n\n### CPU-Intensive Tasks with True Parallelism\n\n```typescript\nimport { go, goAll } from 'gonex';\n\n// CPU-intensive tasks run in parallel across multiple cores\nconst heavyTasks = [\n  () =\u003e {\n    let result = 0;\n    for (let i = 0; i \u003c 1000000000; i++) {\n      result += Math.sqrt(i);\n    }\n    return result;\n  },\n  () =\u003e {\n    let result = 0;\n    for (let i = 0; i \u003c 1000000000; i++) {\n      result += Math.pow(i, 2);\n    }\n    return result;\n  },\n];\n\n// Execute in parallel using worker threads\nconst results = await goAll(heavyTasks, [], { useWorkerThreads: true });\nconsole.log('All tasks completed in parallel!');\n```\n\n### Performance Comparison\n\n```typescript\nimport { go, goAll } from 'gonex';\n\n// Event-loop execution (single-threaded)\nconst eventLoopResults = await goAll(tasks, [], { useWorkerThreads: false });\n// Execution time: ~16 seconds\n\n// Worker thread execution (multi-core)\nconst parallelResults = await goAll(tasks, [], { useWorkerThreads: true });\n// Execution time: ~6 seconds (2.6x faster!)\n```\n\n## 📚 Documentation\n\n📖 **Full API Documentation:** [https://thutasann.github.io/gonex/](https://thutasann.github.io/gonex/)\n\n## 🚀 Architecture\n\nThis package is built with enterprise-level architecture principles:\n\n- **Zero Dependencies** - Pure TypeScript implementation\n- **Type Safety** - Full TypeScript support with generics\n- **True Parallelism** - Multi-core execution with Worker Threads\n- **Performance Optimized** - Minimal overhead, maximum speed\n- **Memory Efficient** - Proper resource management\n- **Extensible** - Plugin architecture for custom patterns\n- **Testable** - Comprehensive test coverage\n- **Documented** - Full API documentation with examples\n\n## 🚀 Development \u0026 Releases\n\nThis project uses automated CI/CD with GitHub Actions:\n\n- **CI/CD:** Automated testing, linting, and building on every push\n- **Releases:** Manual release workflow for controlled versioning\n- **Quality:** Comprehensive test coverage and TypeScript strict mode\n- **Documentation:** Auto-generated API docs\n\n### Contributing\n\n1. Fork the repository\n2. Create a feature branch from `develop`\n3. Make your changes\n4. Run tests: `npm test`\n5. Submit a pull request to `develop`\n\n### Release Process\n\nReleases are managed through GitHub Actions:\n\n1. Merge `develop` to `master`\n2. Go to Actions → Manual Release\n3. Choose version type (patch/minor/major)\n4. Automatic npm publish and GitHub release\n\n## 📄 License\n\nMIT License - see LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthutasann%2Fgonex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthutasann%2Fgonex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthutasann%2Fgonex/lists"}