Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@antongolub
Copy link
Collaborator

const p1 = $`echo foo && sleep 0.05 && echo bar && sleep 0.05 && echo baz && sleep 0.05 && echo qux`
const p2 = $`echo 1 && sleep 0.05 && echo 2 && sleep 0.05 && echo 3`
const p3 = $`cat`

p1.pipe(p3)
p2.pipe(p3)

setTimeout(() => p1.unpipe(p3), 105)

const { stdout } = await p3
assert.equal(stdout, 'foo\n1\nbar\n2\n\3')
  • Tests pass
  • Appropriate changes to README are included in PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new unpipe() method to the ProcessPromise class, allowing developers to remove processes from existing pipelines during execution. This complements the existing pipe() functionality by providing a way to dynamically control data flow between processes.

  • Adds ProcessPromise.unpipe() method for removing processes from pipelines
  • Refactors piping implementation to support dynamic unpipe operations
  • Updates type definitions to include a run() method on promisified streams

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/core.ts Core implementation of unpipe() method and refactored piping logic
test/core.test.js Test coverage for the new unpipe() functionality
test/export.test.js Export validation tests for new static method
test-d/core.test-d.ts TypeScript type definition updates for promisified streams
docs/process-promise.md Documentation and usage examples for unpipe()
src/util.ts Minor type annotation cleanup
build/core.cjs Compiled JavaScript output
.size-limit.json Updated bundle size limits

}, 150)

const { stdout } = await p3
assert.equal(stdout, 'foo\n1\nbar\n2\n3\n')
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in the expected output string. It should be '3\n' instead of '3' to match the documented example.

Suggested change
assert.equal(stdout, 'foo\n1\nbar\n2\n3\n')
assert.equal(stdout, 'foo\n1\nbar\n2\n3\n\n')

Copilot uses AI. Check for mistakes.

assert.equal((await p1).stdout, 'foo\nbar\nbaz\nqux')
assert.equal((await p2).stdout, '1\n2\n3')
assert.equal((await p3).stdout, 'foo\n1\nbar\n2\n3')
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected output is missing the final newline character. Based on the test implementation, it should be 'foo\n1\nbar\n2\n3\n' to match the actual behavior.

Suggested change
assert.equal((await p3).stdout, 'foo\n1\nbar\n2\n3')
assert.equal((await p3).stdout, 'foo\n1\nbar\n2\n3\n')

Copilot uses AI. Check for mistakes.
@antongolub antongolub merged commit 23da874 into google:main Aug 1, 2025
28 checks passed
@antongolub antongolub deleted the pp-unpipe branch August 1, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant