From 439669d2a5d2146c69cbb9b7c8d236e333a0c069 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Wed, 2 Oct 2024 18:53:24 +0300 Subject: [PATCH] docs: mention pipe split feature --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf91c41..dd8aea1 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ const p = $`echo "5\\n3\\n1\\n4\\n2"` const sorted = $({input: p})`sort` // 1\n2\n3\n4\n5 ``` -- [x] Pipe as literal +- [x] Pipe literals ```ts const result = $`echo "5\\n3\\n1\\n4\\n2"` @@ -84,6 +84,21 @@ const piped2 = (await result).pipe`sort` const piped3 = result.pipe($`sort`) ``` +- [x] Pipe splitting +```ts +const result = $`echo 1; sleep 1; echo 2; sleep 1; echo 3` +const piped1 = result.pipe`cat` +let piped2: any + +setTimeout(() => { + piped2 = result.pipe`cat` +}, 1500) + +await piped1 +assert.equal((await piped1).toString(), '1\n2\n3') +assert.equal((await piped2).toString(), '1\n2\n3') +``` + - [x] Presets ```ts const $$ = $({sync: true, cmd: 'echo foo'})