{"id":21698729,"url":"https://github.com/th-ch/yamux-js","last_synced_at":"2025-04-06T03:10:03.316Z","repository":{"id":42234340,"uuid":"305069632","full_name":"th-ch/yamux-js","owner":"th-ch","description":"Node.js (TypeScript/JavaScript) port of the multiplexing library for Golang made by HashiCorp: https://github.com/hashicorp/yamux","archived":false,"fork":false,"pushed_at":"2025-01-03T19:15:31.000Z","size":172,"stargazers_count":16,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T02:07:23.135Z","etag":null,"topics":["hashicorp","javascript","multiplexer","multiplexing","nodejs","typescript","yamux"],"latest_commit_sha":null,"homepage":"https://github.com/th-ch/yamux-js","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/th-ch.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-18T09:51:03.000Z","updated_at":"2025-03-29T21:14:06.000Z","dependencies_parsed_at":"2025-01-20T19:10:48.588Z","dependency_job_id":"296bcc79-e071-48c9-85d6-27c64195ddb4","html_url":"https://github.com/th-ch/yamux-js","commit_stats":{"total_commits":49,"total_committers":5,"mean_commits":9.8,"dds":"0.20408163265306123","last_synced_commit":"03b8b84c5fde55e4f6ca49f552bc853675420193"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th-ch%2Fyamux-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th-ch%2Fyamux-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th-ch%2Fyamux-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th-ch%2Fyamux-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/th-ch","download_url":"https://codeload.github.com/th-ch/yamux-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"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":["hashicorp","javascript","multiplexer","multiplexing","nodejs","typescript","yamux"],"created_at":"2024-11-25T19:36:19.210Z","updated_at":"2025-04-06T03:10:03.292Z","avatar_url":"https://github.com/th-ch.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yamux-js\n\n[![npm version](https://badge.fury.io/js/yamux-js.svg)](https://www.npmjs.com/package/yamux-js)\n[![Build status](https://img.shields.io/github/actions/workflow/status/th-ch/yamux-js/node.js.yml?branch=master)](https://github.com/th-ch/yamux-js)\n[![GitHub license](https://img.shields.io/github/license/th-ch/yamux-js.svg)](https://github.com/th-ch/yamux-js/blob/master/LICENSE)\n\nYamux-js (Yet another Multiplexer) is a Node.js (TypeScript/JavaScript) port of the multiplexing library for Golang made by HashiCorp: https://github.com/hashicorp/yamux. The 2 libraries are fully interoperable (you can have a client in Golang and a server in JS, or the other way around).\n\n_From https://github.com/hashicorp/yamux:_\n\nIt relies on an underlying connection to provide reliability and ordering, such as TCP or Unix domain sockets, and provides stream-oriented multiplexing. It is inspired by SPDY but is not interoperable with it.\n\nYamux features include:\n\n-   Bi-directional streams\n    -   Streams can be opened by either client or server\n    -   Useful for NAT traversal\n    -   Server-side push support\n-   Flow control\n    -   Avoid starvation\n    -   Back-pressure to prevent overwhelming a receiver\n-   Keep Alives\n    -   Enables persistent connections over a load balancer\n-   Efficient\n    -   Enables thousands of logical streams with low overhead\n\n## Installation\n\nInstall Yamux-js using [`yarn`](https://yarnpkg.com/en/package/jest):\n\n```bash\nyarn add yamux-js\n```\n\nOr [`npm`](https://www.npmjs.com/package/yamux-js):\n\n```bash\nnpm install --save yamux-js\n```\n\n## Usage\n\n### Client side\n\n```js\nvar {Client} = require('yamux-js');\n\nvar client = new Client();\nclient.on('error', (err) =\u003e {\n    console.log('An error occured:', err);\n});\nclient.pipe(commonXXXChannel).pipe(client);\n\nvar stream1 = client.open();\nstream1.on('data', (data) =\u003e {\n    console.log('recv:', data.toString());\n});\nstream1.on('error', (err) =\u003e {\n    console.log('An error occured:', err);\n});\nstream1.write('Sending data');\n\nvar stream2 = client.open();\n// ...\n```\n\n### Server side\n\n```js\nvar {Server} = require('yamux-js');\n\nvar server = new Server((stream) =\u003e {\n    stream.on('data', (data) =\u003e {\n        console.log('recv:', data.toString());\n        stream.write('Sending back data');\n    });\n    stream.on('error', (err) =\u003e {\n        console.log('An error occured:', err);\n    });\n});\nserver.on('error', (err) =\u003e {\n    console.log('An error occured:', err);\n});\n\nserver.pipe(commonXXXChannel).pipe(server);\n```\n\n\u003e _See also a [full example with `net.createServer`](https://github.com/th-ch/yamux-js/issues/13#issuecomment-1410279418)_\n\n### Configuration\n\nBoth `Server` and `Client` can take a custom config as last argument in their constructor:\n\n```js\n{\n    // AcceptBacklog is used to limit how many streams may be\n    // waiting an accept.\n    // WARNING [Difference with the Go implementation]: total number of streams, not in-flight\n    acceptBacklog: number; // default: 256\n\n    // EnableKeepalive is used to do a period keep alive\n    // messages using a ping.\n    enableKeepAlive: boolean; // default: true\n\n    // KeepAliveInterval is how often to perform the keep alive\n    keepAliveInterval: number; // In seconds, default: 30\n\n    // ConnectionWriteTimeout is meant to be a \"safety valve\" timeout after\n    // we which will suspect a problem with the underlying connection and\n    // close it. This is only applied to writes, where's there's generally\n    // an expectation that things will move along quickly.\n    connectionWriteTimeout: number; // In seconds, default: 10\n\n    // MaxStreamWindowSize is used to control the maximum\n    // window size that we allow for a stream.\n    maxStreamWindowSize: number; // default: 256 * 1024 (256 KB)\n\n    // Logger is used to pass in the logger to be used.\n    logger: typeof console.log; // default: console.log\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fth-ch%2Fyamux-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fth-ch%2Fyamux-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fth-ch%2Fyamux-js/lists"}