{"_id":"sync-child-process","_rev":"2-c0c7ca64ff32900303c1ffc84c160c29","name":"sync-child-process","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"sync-child-process","version":"1.0.0","author":{"name":"Google Inc."},"license":"MIT","_id":"sync-child-process@1.0.0","maintainers":[{"name":"nex3","email":"nex342@gmail.com"}],"homepage":"https://github.com/sass/sync-child-process#readme","bugs":{"url":"https://github.com/sass/sync-child-process/issues"},"dist":{"shasum":"1b29d5e33d7606d960ace7c08fd1b4944e6f900b","tarball":"https://registry.npmjs.org/sync-child-process/-/sync-child-process-1.0.0.tgz","fileCount":13,"integrity":"sha512-kbn3D+9BCU4KNwJXAifmyiYeVJF/kfhX5HWfw8UzQgg1P/tgolcIEpoaZmhm+Qdgojt0lQkLZ7GxxG4y4zOEZA==","signatures":[{"sig":"MEUCIQCqj2sfuM4essNEPMV3xxX+Pbp5nRjM84abjtPznGqeNgIgLw7yuywfcQ6pTBQYZw42ZlnJAgIDPHBXQ0FaPHG7EuQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":57717},"main":"dist/lib/index.js","types":"dist/lib/index.d.ts","engines":{"node":">=16.0.0"},"exports":{"types":"./dist/lib/index.d.ts","default":"./dist/lib/index.js"},"gitHead":"5b8e9bbb11d421e5bc4eada78b1b437ee1f9f4df","scripts":{"fix":"gts fix","test":"jest","check":"npm-run-all check:gts check:tsc","clean":"gts clean","compile":"tsc -p tsconfig.build.json","check:gts":"gts check","check:tsc":"tsc --noEmit"},"_npmUser":{"name":"nex3","email":"nex342@gmail.com"},"repository":{"url":"git+https://github.com/sass/sync-child-process.git","type":"git"},"_npmVersion":"10.7.0","description":"Run a subprocess synchronously and interactively in Node.js","directories":{},"_nodeVersion":"22.2.0","dependencies":{"sync-message-port":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"gts":"^6.0.2","jest":"^29.4.1","ts-jest":"^29.0.5","ts-node":"^10.2.1","typescript":"^5.0.2","@types/jest":"^29.4.0","@types/node":"^22.0.0","npm-run-all":"^4.1.5"},"_npmOperationalInternal":{"tmp":"tmp/sync-child-process_1.0.0_1730413061479_0.7451385408934939","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"sync-child-process","version":"1.0.1","author":{"name":"Google Inc."},"license":"MIT","_id":"sync-child-process@1.0.1","maintainers":[{"name":"nex3","email":"nex342@gmail.com"}],"homepage":"https://github.com/sass/sync-child-process#readme","bugs":{"url":"https://github.com/sass/sync-child-process/issues"},"dist":{"shasum":"74d298fe5449db09e39cdb318262c8a31191f8a9","tarball":"https://registry.npmjs.org/sync-child-process/-/sync-child-process-1.0.1.tgz","fileCount":13,"integrity":"sha512-acr1BU3LMG0hsRibMJQ26fm8d+BaEttt6gsDDMKMawD4286K9GyLzS6Lo7+9V8VGKIT8FIBu6yywgWn3DtYUDw==","signatures":[{"sig":"MEUCIQCtqlUbVed2gbrzykJ9HuWcuP8jh0+z0ygSw8+7+Pm1ZwIgbZP1gW7shs4NxYAL+cRCicJ7aFY+ClByZyVbJIpW2Vw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":58725},"main":"dist/lib/index.js","types":"dist/lib/index.d.ts","engines":{"node":">=16.0.0"},"exports":{"types":"./dist/lib/index.d.ts","default":"./dist/lib/index.js"},"gitHead":"df51425d5b0a5a4cb15f1d641191fdf08a68f28a","scripts":{"fix":"gts fix","test":"jest","check":"npm-run-all check:gts check:tsc","clean":"gts clean","compile":"tsc -p tsconfig.build.json","check:gts":"gts check","check:tsc":"tsc --noEmit"},"_npmUser":{"name":"nex3","email":"nex342@gmail.com"},"repository":{"url":"git+https://github.com/sass/sync-child-process.git","type":"git"},"_npmVersion":"10.9.0","description":"Run a subprocess synchronously and interactively in Node.js","directories":{},"_nodeVersion":"22.11.0","dependencies":{"sync-message-port":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"gts":"^6.0.2","jest":"^29.4.1","ts-jest":"^29.0.5","ts-node":"^10.2.1","typedoc":"^0.26.11","typescript":"^5.0.2","@types/jest":"^29.4.0","@types/node":"^22.0.0","npm-run-all":"^4.1.5"},"_npmOperationalInternal":{"tmp":"tmp/sync-child-process_1.0.1_1730752115008_0.9401003514741739","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"sync-child-process","version":"1.0.2","description":"Run a subprocess synchronously and interactively in Node.js","repository":{"type":"git","url":"git+https://github.com/sass/sync-child-process.git"},"author":{"name":"Google Inc."},"license":"MIT","exports":{"types":"./dist/lib/index.d.ts","default":"./dist/lib/index.js"},"main":"dist/lib/index.js","types":"dist/lib/index.d.ts","engines":{"node":">=16.0.0"},"scripts":{"check":"npm-run-all check:gts check:tsc","check:gts":"gts check","check:tsc":"tsc --noEmit","clean":"gts clean","compile":"tsc -p tsconfig.build.json","doc":"typedoc lib/index.ts","fix":"gts fix","test":"jest"},"devDependencies":{"@types/jest":"^29.4.0","@types/node":"^22.0.0","gts":"^6.0.2","jest":"^29.4.1","npm-run-all":"^4.1.5","ts-jest":"^29.0.5","ts-node":"^10.2.1","typedoc":"^0.26.11","typescript":"^5.0.2"},"dependencies":{"sync-message-port":"^1.0.0"},"_id":"sync-child-process@1.0.2","gitHead":"a1924b347d16dd49c40993480c9726772697b1c1","bugs":{"url":"https://github.com/sass/sync-child-process/issues"},"homepage":"https://github.com/sass/sync-child-process#readme","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-8lD+t2KrrScJ/7KXCSyfhT3/hRq78rC0wBFqNJXv3mZyn6hW2ypM05JmlSvtqRbeq6jqA94oHbxAr2vYsJ8vDA==","shasum":"45e7c72e756d1243e80b547ea2e17957ab9e367f","tarball":"https://registry.npmjs.org/sync-child-process/-/sync-child-process-1.0.2.tgz","fileCount":13,"unpackedSize":58760,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA59d7FT6T2w5Xu37LqJxn+MDvPowyX7smCa+cSWpm/kAiBHbF8dmb+AmEWnkfH4akgGAEAQUrWi4+GSW9WFXoKbXA=="}]},"_npmUser":{"name":"nex3","email":"nex342@gmail.com"},"directories":{},"maintainers":[{"name":"nex3","email":"nex342@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sync-child-process_1.0.2_1730754212564_0.37212100385481417"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-31T22:17:41.478Z","modified":"2024-11-04T21:03:32.931Z","1.0.0":"2024-10-31T22:17:41.774Z","1.0.1":"2024-11-04T20:28:35.172Z","1.0.2":"2024-11-04T21:03:32.727Z"},"bugs":{"url":"https://github.com/sass/sync-child-process/issues"},"author":{"name":"Google Inc."},"license":"MIT","homepage":"https://github.com/sass/sync-child-process#readme","repository":{"type":"git","url":"git+https://github.com/sass/sync-child-process.git"},"description":"Run a subprocess synchronously and interactively in Node.js","maintainers":[{"name":"nex3","email":"nex342@gmail.com"}],"readme":"# `sync-child-process`\n\nThis package exposes a `SyncChildProcess` class that allows Node.js to run a\nsubprocess synchronously *and* interactively.\n\n[**API Docs**]\n\n[**API Docs**]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html\n\n## Usage\n\nUse [`new SyncChildProcess()`] to start running a subprocess. This supports the\nsame API as [`child_process.spawn()`] other than a few options. You can send\ninput to the process using [`process.stdin`], and receive events from it\n(stdout, stderr, or exit) using [`process.next()`]. This implements [the\niterator protocol], but *not* the iterable protocol because it's intrinsically\nstateful.\n\n[`new SyncChildProcess()`]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html#constructor\n[`child_process.spawn()`]: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options\n[`process.stdin`]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html#stdin\n[`process.next()`]: https://sass.github.io/sync-child-process/classes/SyncChildProcess.html#next\n[the iterator protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol\n\n```js\nimport {SyncChildProcess} from 'sync-child-process';\n// or\n// const {SyncChildProcess} = require('sync-child-process');\n\nconst node = new SyncChildProcess('node', ['--interactive']);\n\nfor (;;) {\n  if (node.next().value.data.toString().endsWith('> ')) break;\n}\n\nnode.stdin.write(\"41 * Math.pow(2, 5)\\n\");\nconsole.log((node.next().value.data.toString().split(\"\\n\")[0]));\nnode.stdin.write(\".exit\\n\");\nconsole.log(`Node exited with exit code ${node.next().value.code}`);\n```\n\n## Why synchrony?\n\nSee [the `sync-message-port` documentation] for an explanation of why running\ncode synchronously can be valuable even in an asynchronous ecosystem like\nNode.js\n\n[the `sync-message-port` documentation]: https://github.com/sass/sync-message-port?tab=readme-ov-file#why-synchrony\n\n### Why not `child_process.spawnSync()`?\n\nAlthough Node's built-in [`child_process.spawnSync()`] function does run\nsynchronously, it's not interactive. It only returns once the process has run to\ncompletion and exited, which means it's not suitable for any long-lived\nsubprocess that interleaves sending and receiving data, such as when using the\n[embedded Sass protocol].\n\n[`child_process.spawnSync()`]: https://nodejs.org/api/child_process.html#child_processspawnsynccommand-args-options\n[embedded Sass protocol]: https://github.com/sass/sass/blob/main/spec/embedded-protocol.md\n\n---\n\nDisclaimer: this is not an official Google product.\n","readmeFilename":"README.md"}