1 | const Writable = require('stream').Writable
|
2 | const path = require('path')
|
3 | const wrote = require('../')
|
4 |
|
5 | const HOME_DIR = require('os').homedir()
|
6 |
|
7 | const file = path.join(HOME_DIR, `wrote-${Math.floor(Math.random() * 1e5)}.data`)
|
8 |
|
9 | wrote(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)
|