{"id":20050031,"url":"https://github.com/kldzj/named-pipes","last_synced_at":"2025-05-05T11:31:03.003Z","repository":{"id":42506680,"uuid":"468002868","full_name":"kldzj/named-pipes","owner":"kldzj","description":"Create and write to or read from named pipes. Works on both Windows and Unix.","archived":false,"fork":false,"pushed_at":"2023-07-19T11:10:32.000Z","size":368,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-02T10:58:55.850Z","etag":null,"topics":["fifo","ipc","named-pipes","nodejs","socket"],"latest_commit_sha":null,"homepage":"https://npmjs.com/@kldzj/named-pipes","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kldzj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-09T16:17:49.000Z","updated_at":"2022-06-28T02:37:14.000Z","dependencies_parsed_at":"2023-02-08T04:01:50.544Z","dependency_job_id":null,"html_url":"https://github.com/kldzj/named-pipes","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kldzj%2Fnamed-pipes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kldzj%2Fnamed-pipes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kldzj%2Fnamed-pipes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kldzj%2Fnamed-pipes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kldzj","download_url":"https://codeload.github.com/kldzj/named-pipes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252488949,"owners_count":21756241,"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":["fifo","ipc","named-pipes","nodejs","socket"],"created_at":"2024-11-13T11:53:48.820Z","updated_at":"2025-05-05T11:31:02.673Z","avatar_url":"https://github.com/kldzj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"This package allows you to work with named pipes to write to or read from. You can listen to arbitrary named pipes, or you can create named pipes and write to them. It works on both Windows using `net.Socket` and Unix using `mkfifo`.\n\n## Installation\n\nUsing yarn:\n```sh-session\n$ yarn add @kldzj/named-pipes\n```\n\nUsing npm:\n```sh-session\n$ npm i -S @kldzj/named-pipes\n```\n\n## Example usage\n\n```typescript\nimport { createNamedPipe } from '@kldzj/named-pipes';\n\n// You may also name the pipe yourself,\n// or even pass a writable absolute path.\nconst pipe = createNamedPipe(/* '/var/cool.sock', 0o640 */);\nconsole.log('Path to socket:', pipe.path);\n\nconst sender = pipe.createSender();\nconst receiver = pipe.createReceiver();\n\n// sender.connect() will create the pipe\nawait sender.connect();\n// receiver.connect() will fail if the pipe does not exist\nawait receiver.connect();\n\n// handle data\nreceiver.on('data', (c) =\u003e console.log(c.toString()));\n// or pipe it somewhere\n// receiver.getReadableStream().pipe(someDestinationStream);\n\n// Sender might not be ready yet,\n// wait for socket to be connected\nsender.once('connected', () =\u003e {\n  // use the convenience write method\n  sender.write('hello world');\n  // or create a writable stream and pipe to it\n  // someSourceStream.pipe(sender.getWritableStream());\n});\n\n// once you're done, destroy the pipe\nawait pipe.destroy();\n```\n\n[View example on RunKit](https://runkit.com/ddreck/named-pipes)\n\n## Notes\n\nIt is recommended to use the `createNamedPipe` function instead of using the exported classes directly.\n\nThe order in which you connect the sender and receiver is important. If you are writing to a pipe and then reading from it, you should connect the sender first.\n\nIf you intend on only reading from a pipe, you do not need a sender. Vice versa, if you intend on only write to a pipe, you do not need a receiver.\n\n### `createNamedPipe(name?: string, mode?: number)`\n\nIn case the pipe name is not an absolute path, the pipe will be created in the os tmp directory. If the pipe name is omitted, a random name will be generated.\n\nOn Windows, the mode is ignored.\n\n### NamedPipe\n\nIs a reference to a named pipe. You can use it to create a sender or receiver, or to destroy the pipe. On its own, it's not going to do anything. You can use the `.path` property to get the absolute path.\n\nTo actually create a named pipe you need to create a `Sender` using `.createSender()`. Returns `SocketSender` on Windows and `FIFOSender` on Unix.\n\nTo listen to a named pipe you need to create a `Receiver` using `.createReceiver()`. Returns `SocketReceiver` on Windows and `FIFOReceiver` on Unix.\n\n`.exists()` should be used to check if the pipe exists before creating a `Receiver`.\n\n`.destroy()` will destroy all the receivers, the sender and all its existing connections.\n\n### Sender\n\nThe sender will create a socket server on Windows or a FIFO on Unix and listen for incoming connections on the specified path. There will be a maximum of one sender per pipe. You must call `.connect()` to actually create the socket.\n\n**Important:** The sender might not be ready after the `.connect()` promise has resolved, so you should use the `.once('connect', () =\u003e {})` event to wait for the socket to be connected before writing, otherwise you'll have thread blocking issues.\n\nUse `.getWritableStream()` to get a writable stream that you can pipe to.\n\nIt will fail to connect (start the server) if:\n- the path is already in use\n- the path is not writable\n\n### Receiver\n\nThe receiver will create a socket client and connect to the specified path. You must call `.connect()` before you can start reading.\n\nUse `.getReadableStream()` to get a readable stream that you can pipe somewhere.\n\nIt will fail to connect if:\n- the path does not exist\n- the path is not readable\n- the path is not a socket","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkldzj%2Fnamed-pipes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkldzj%2Fnamed-pipes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkldzj%2Fnamed-pipes/lists"}