-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace Duplex with Transform (#282)
* fix: replace Duplex with Transform * chore: apply prettier
- Loading branch information
Showing
5 changed files
with
30 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { Duplex } from 'stream'; | ||
import { Transform } from 'stream'; | ||
import commitFileAsync from './actions/commit-file-async.js'; | ||
import type { MemFsEditorFile } from './index.js'; | ||
|
||
export const createCommitTransform = <EditorFile extends MemFsEditorFile = MemFsEditorFile>() => | ||
Duplex.from(async function* (generator: AsyncGenerator<EditorFile>) { | ||
for await (const file of generator) { | ||
await commitFileAsync(file); | ||
yield file; | ||
} | ||
export const createCommitTransform = () => | ||
new Transform({ | ||
objectMode: true, | ||
transform(file: MemFsEditorFile, _encoding, callback) { | ||
commitFileAsync(file).then( | ||
() => callback(null, file), | ||
(error) => callback(error), | ||
); | ||
}, | ||
}); |