bare-fs 1.6.7 → 1.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +9 -14
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Readable, Writable } = require('streamx')
1
+ const { Readable, Writable, getStreamError } = require('streamx')
2
2
  const binding = require('./binding')
3
3
 
4
4
  const sep = process.platform === 'win32' ? '\\' : '/'
@@ -981,7 +981,6 @@ class Dir extends Readable {
981
981
  this._handle = handle
982
982
  this._dirents = Buffer.allocUnsafe(binding.sizeofFSDirent * bufferSize)
983
983
  this._encoding = encoding
984
- this._closed = false
985
984
 
986
985
  this.path = path
987
986
  }
@@ -1009,25 +1008,21 @@ class Dir extends Readable {
1009
1008
  }
1010
1009
 
1011
1010
  _destroy (cb) {
1012
- if (this._closed) cb(null)
1013
- else this.close(cb)
1014
- }
1015
-
1016
- close (cb = noop) {
1017
- if (this._closed) return
1018
-
1019
- const self = this
1020
-
1021
1011
  const req = getReq()
1022
1012
 
1023
1013
  req.callback = function (err, _) {
1024
- if (err) return cb(err)
1025
- self._closed = true
1026
- cb(null)
1014
+ cb(err)
1027
1015
  }
1028
1016
 
1029
1017
  binding.closedir(req.handle, this._handle)
1030
1018
  }
1019
+
1020
+ close (cb = noop) {
1021
+ if (this.destroyed) return cb(null)
1022
+ this
1023
+ .once('close', () => cb(getStreamError(this)))
1024
+ .destroy()
1025
+ }
1031
1026
  }
1032
1027
 
1033
1028
  class Dirent {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-fs",
3
- "version": "1.6.7",
3
+ "version": "1.6.8",
4
4
  "description": "Native file system for Javascript",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -12,7 +12,7 @@
12
12
  "prebuilds"
13
13
  ],
14
14
  "scripts": {
15
- "test": "standard && bare test/all.js",
15
+ "test": "standard && bare test.js",
16
16
  "install": "bare-dev rebuild",
17
17
  "prebuild": "bare-dev prebuild"
18
18
  },