{"id":17443241,"url":"https://github.com/jamestalmage/native-stream-type","last_synced_at":"2025-05-07T09:12:21.693Z","repository":{"id":57308316,"uuid":"85896432","full_name":"jamestalmage/native-stream-type","owner":"jamestalmage","description":"Find the native stream type, validate it for child_process use","archived":false,"fork":false,"pushed_at":"2017-03-24T16:55:30.000Z","size":6,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T09:12:14.354Z","etag":null,"topics":["node","spawn","stream"],"latest_commit_sha":null,"homepage":"","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/jamestalmage.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}},"created_at":"2017-03-23T02:10:25.000Z","updated_at":"2017-10-21T12:20:15.000Z","dependencies_parsed_at":"2022-09-09T07:50:36.835Z","dependency_job_id":null,"html_url":"https://github.com/jamestalmage/native-stream-type","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamestalmage%2Fnative-stream-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamestalmage%2Fnative-stream-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamestalmage%2Fnative-stream-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamestalmage%2Fnative-stream-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamestalmage","download_url":"https://codeload.github.com/jamestalmage/native-stream-type/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252847515,"owners_count":21813457,"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":["node","spawn","stream"],"created_at":"2024-10-17T16:59:33.160Z","updated_at":"2025-05-07T09:12:21.672Z","avatar_url":"https://github.com/jamestalmage.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# native-stream-type [![Build Status](https://travis-ci.org/jamestalmage/native-stream-type.svg?branch=master)](https://travis-ci.org/jamestalmage/native-stream-type)\n\n\u003e Find the native stream type, validate it for child_process use\n\nThe [`stdio` option in `child_process.spawn`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio) allows only certain types of streams. You can use this module to determine if an object is an allowed stream type.\n\nYou can use this module to validate stream arguments before passing to `child_process`.\n\n\n## Install\n\n```\n$ npm install --save native-stream-type\n```\n\n\n## Usage\n\n```js\nconst nativeStreamType = require('native-stream-type');\n\nnativeStreamType(process.stdin);\n//=\u003e 'tty'\n```\n\n\n## API\n\n### nativeStreamType(obj)\n\nReturns a `string` (`pipe` | `tty` | `tcp` | `udp`) if `obj` is one of the native backed stream implementations.\n \nReturns `false` if `obj` is not one of the above native streams.\n\nNote that `udp` sockets don't necessarily implement a stream interface (see \"Notes\" section below).\n\n#### obj\n\nType: `Stream`\n\nAn object that might be a native stream implementation.\n\n\n## Notes\n\nThis uses the undocumented `process.binding(...)`. At present, the Node team is avoiding deprecation, so it should be safe to use.\n\nYou are allowed to pass UDP sockets as a `stdio` option, even though they do not implement the stream interface. Thus, getting a truthy return value does not guarantee a stream. Passing a UDP socket will spawn without throwing an error, but I have yet to figure out how to actually transfer any data to the child process when using one. You may want to guard against non streams using [`is-stream`](https://github.com/sindresorhus/is-stream).\n\nImplementation derived from Node internals [here](https://github.com/nodejs/node/blob/98e54b0bd4854bdb3e2949d1b6b20d6777fb7cde/lib/internal/child_process.js#L14-L18), [here](https://github.com/nodejs/node/blob/98e54b0bd4854bdb3e2949d1b6b20d6777fb7cde/lib/internal/child_process.js#L254-L261), and [here](https://github.com/nodejs/node/blob/98e54b0bd4854bdb3e2949d1b6b20d6777fb7cde/lib/internal/child_process.js#L846-L856).\n\n## License\n\nMIT © [James Talmage](http://github.com/jamestalmage)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamestalmage%2Fnative-stream-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamestalmage%2Fnative-stream-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamestalmage%2Fnative-stream-type/lists"}