UNPKG

493 BJavaScriptView Raw
1import { WriteStream } from 'node:fs'
2import { openSync } from './temp.js'
3
4export default class TempWriteStream extends WriteStream {
5 constructor (template, options) {
6 options = (typeof options === 'string') ? { encoding: options } : (options || {})
7
8 const flags = options.flags === undefined ? 'w' : options.flags
9 const mode = options.mode === undefined ? 0o666 : options.mode
10 const { fd, path } = openSync(template, flags, mode)
11
12 super(path, { ...options, fd })
13 }
14}