hyperdrive
Advanced tools
Comparing version 11.10.0 to 11.11.0
36
index.js
@@ -425,3 +425,5 @@ const Hyperbee = require('hyperbee') | ||
entries (range, opts) { | ||
return this.db.createReadStream(range, { ...opts, keyEncoding }) | ||
const stream = this.db.createReadStream(range, { ...opts, keyEncoding }) | ||
if (opts && opts.ignore) stream._readableState.map = createStreamMapIgnore(opts.ignore) | ||
return stream | ||
} | ||
@@ -458,3 +460,3 @@ | ||
// atm always recursive, but we should add some depth thing to it | ||
list (folder, opts) { | ||
list (folder, opts = {}) { | ||
if (typeof folder === 'object') return this.list(undefined, folder) | ||
@@ -464,5 +466,5 @@ | ||
if (opts && opts.recursive === false) return shallowReadStream(this.db, folder, false) | ||
return this.entries(prefixRange(folder)) | ||
const ignore = opts.ignore ? normalizeIgnore(opts.ignore) : null | ||
const stream = opts && opts.recursive === false ? shallowReadStream(this.db, folder, false, ignore) : this.entries(prefixRange(folder), { ignore }) | ||
return stream | ||
} | ||
@@ -472,3 +474,3 @@ | ||
folder = std(folder || '/', true) | ||
return shallowReadStream(this.db, folder, true) | ||
return shallowReadStream(this.db, folder, true, null) | ||
} | ||
@@ -611,3 +613,3 @@ | ||
function shallowReadStream (files, folder, keys) { | ||
function shallowReadStream (files, folder, keys, ignore) { | ||
let prev = '/' | ||
@@ -644,2 +646,8 @@ let prevName = '' | ||
prevName = name | ||
if (ignore && isIgnored(node.key, ignore)) { | ||
this._read(cb) | ||
return | ||
} | ||
this.push(keys ? name : node) | ||
@@ -718,1 +726,15 @@ cb(null) | ||
} | ||
function normalizeIgnore (ignore) { | ||
return [].concat(ignore).map(e => unixPathResolve('/', e)) | ||
} | ||
function isIgnored (key, ignore) { | ||
return ignore.some(e => e === key || key.startsWith(e + '/')) | ||
} | ||
function createStreamMapIgnore (ignore) { | ||
return (node) => { | ||
return isIgnored(node.key, ignore) ? null : node | ||
} | ||
} |
{ | ||
"name": "hyperdrive", | ||
"version": "11.10.0", | ||
"version": "11.11.0", | ||
"description": "Hyperdrive is a secure, real-time distributed file system", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -222,3 +222,4 @@ # Hyperdrive | ||
{ | ||
recursive: true | false // Whether to descend into all subfolders or not | ||
recursive: true | false // Whether to descend into all subfolders or not, | ||
ignore: String || Array // Ignore files and folders by name. | ||
} | ||
@@ -225,0 +226,0 @@ ``` |
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
41107
564
382
1
2038