UNPKG

610 BJavaScriptView Raw
1const Writable = require('stream').Writable
2const path = require('path')
3const wrote = require('../')
4
5const HOME_DIR = require('os').homedir()
6
7const file = path.join(HOME_DIR, `wrote-${Math.floor(Math.random() * 1e5)}.data`)
8
9wrote(file)
10 .then((ws) => {
11 console.log(ws instanceof Writable) // true
12 console.log(ws.writable) // true
13 console.log(ws.path) // ~/wrote-35558.data
14 return wrote.erase(ws)
15 })
16 .then((ws) => {
17 console.log(ws.path) // ~/wrote-35558.data, but no longer exists
18 console.log(ws.writable) // false
19 })
20 .catch(console.error)