Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fs-stream-sync

bluelovers554ISC2.0.19TypeScript support: included

File System SyncWriteStream/SyncReadStream implementation from Node.js Core

File System, ReadStream, SyncReadStream, SyncWriteStream, WriteStream, fs, fs.stream, node, node.js, stream, sync

readme

fs-stream-sync

File System SyncWriteStream/SyncReadStream implementation from Node.js Core

install

npm install fs-stream-sync

know issues

  • not 100% same as ReadStream/WriteStream
  • some event not trigger as expect
  • some api still async
  • SyncWriteStream.write can't append

wellcome send pr, make this near original fs.stream

usage

import {
    ReadStream, WriteStream,
    SyncReadStream, SyncWriteStream,

    createReadStream, createWriteStream,
    createSyncReadStream, createSyncWriteStream
} from 'fs-stream-sync';
import * as fs from "fs-extra";
import * as FsStream from "fs-stream-sync";

fs.ensureDirSync('./temp')
fs.removeSync('./temp/temp1.txt')

let file = './temp/temp1.txt'

let s = FsStream.createSyncWriteStream(file, {
    flags: 'w+',
});

[
    'open',
    'ready',
    'close',
    'finish',
].forEach(function (name)
{
    s.on(name, function (...argv)
    {
        console.log(name, argv);
    })
})

s.open()

let text = ''

let line = `test${0}\n`

s.write(line)

text += line

s.on('close', function (...argv)
{
    let buf = fs.readFileSync(file)

    console.log('close2', argv, buf.toString() === text);
})

s.destroy()

let buf = fs.readFileSync(file)

console.log(buf.toString() === text);
open [ 4 ]
ready []
close []
close2 [] true
true

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.0.19 (2024-08-29)

🛠 Build System

2.0.18 (2022-10-02)

🔖 Miscellaneous

2.0.17 (2022-09-29)

🔖 Miscellaneous

2.0.16 (2022-09-29)

🔖 Miscellaneous

2.0.15 (2022-09-28)

🚨 Tests

🔖 Miscellaneous

2.0.14 (2022-08-11)

♻️ Chores

📌 Dependencies

🔖 Miscellaneous

2.0.13 (2022-08-11)

♻️ Chores

📌 Dependencies

2.0.12 (2022-08-11)

📌 Dependencies

2.0.11 (2022-05-11)

♻️ Chores

🔖 Miscellaneous

2.0.10 (2022-05-11)

♻️ Chores

2.0.9 (2021-12-29)

🛠 Build System

🔖 Miscellaneous

2.0.8 (2021-12-29)

🛠 Build System

🔖 Miscellaneous

2.0.7 (2021-12-29)

🛠 Build System

🔖 Miscellaneous

2.0.6 (2021-12-06)

♻️ Chores

2.0.5 (2021-08-13)

♻️ Chores

2.0.4 (2021-07-08)

🛠 Build System

2.0.3 (2021-02-12)

🛠 Build System

2.0.2 (2020-06-20)

📦 Code Refactoring

2.0.1 (2020-06-16)

📦 Code Refactoring

🔖 Miscellaneous

  • Add 'packages/fs-stream-sync/' from commit '4bcd71c4653b710789916e50edfe2f3cfe6ed0d2' (a665876)