Comparing version 1.5.4 to 1.5.5
71
index.js
@@ -472,54 +472,2 @@ const { Readable, Writable } = require('streamx') | ||
function opendir (path, opts, cb) { | ||
if (typeof opts === 'function') return opendir(path, null, opts) | ||
if (typeof cb !== 'function') throw typeError('ERR_INVALID_ARG_TYPE', 'Callback must be a function') | ||
if (typeof opts === 'string') opts = { encoding: opts } | ||
if (!opts) opts = {} | ||
const { | ||
encoding = 'utf8' | ||
} = opts | ||
const req = getReq() | ||
req.buffer = Buffer.allocUnsafe(binding.sizeofFSDir) | ||
req.callback = function (err, _, buf) { | ||
if (err) return cb(err, null) | ||
cb(null, new Dir(buf, encoding)) | ||
} | ||
binding.opendir(req.handle, path, req.buffer) | ||
} | ||
function readdir (dir, opts, cb) { | ||
if (typeof opts === 'function') return readdir(dir, null, opts) | ||
if (typeof cb !== 'function') throw typeError('ERR_INVALID_ARG_TYPE', 'Callback must be a function') | ||
if (typeof opts === 'string') opts = { encoding: opts } | ||
if (!opts) opts = {} | ||
if (typeof dir === 'string') { | ||
return opendir(dir, opts, (err, dir) => { | ||
if (err) return cb(err, null) | ||
return readdir(dir, opts, cb) | ||
}) | ||
} | ||
const { | ||
encoding = 'utf8', | ||
bufferSize = 32 | ||
} = opts | ||
const req = getReq() | ||
req.buffer = Buffer.allocUnsafe(binding.sizeofFSDirent * bufferSize) | ||
req.callback = function (err, _, buf) { | ||
if (err) return cb(err, null) | ||
binding.toDirent(dir._handle) | ||
} | ||
binding.readdir(req.handle, dir._handle, req.buffer) | ||
} | ||
function readFile (path, opts, cb) { | ||
@@ -758,15 +706,2 @@ if (typeof opts === 'function') return readFile(path, null, opts) | ||
class Dir extends Readable { | ||
constructor (handle, encoding) { | ||
super() | ||
this._handle = handle | ||
this._encoding = encoding | ||
} | ||
_read (cb) { | ||
cb(null) | ||
} | ||
} | ||
exports.promises = {} | ||
@@ -831,8 +766,2 @@ | ||
exports.opendir = opendir | ||
exports.promises.opendir = promisify(opendir) | ||
exports.readdir = readdir | ||
exports.promises.readdir = promisify(readdir) | ||
exports.ReadStream = FileReadStream | ||
@@ -839,0 +768,0 @@ exports.createReadStream = (path, options) => new FileReadStream(path, options) |
{ | ||
"name": "bare-fs", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "Native file system for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57983
605