Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding function to return all files since rooot #874

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,24 @@ var out = {
options.type = "nodebuffer";
}
return this.generateInternalStream(options).toNodejsStream(onUpdate);
}
},

/**
* Return all files since root in the form {relativePath, file}
* @returns {Array} An array of items files
*/
getFilesSinceRoot: function(){
var result = [], filename, relativePath, file;
// ignore warning about unwanted properties because this.files is a null prototype object
/* eslint-disable-next-line guard-for-in */
for (filename in this.files) {
file = this.files[filename];
relativePath = filename.slice(this.root.length, filename.length);
if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root
result.push({relativePath:relativePath, file:file})
}
}
return result;
},
};
module.exports = out;