Check if a CreateWriteStream is writable in Node.js using Javascript
const isWritableStream = val =>
val !== null &&
typeof val === 'object' &&
typeof val.pipe === 'function' &&
typeof val._write === 'function' &&
typeof val._writableState === 'object';
const fs = require('fs');
isWritableStream(fs.createWriteStream('test.txt')); // true
Tags: CreateWriteStream, filesystem, fs, WriteStream, Node.js, Node, Javascript, Typescript
CC BY 4.0 no changes made – 30 Seconds of Code







