New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

browser-fs-readdir

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-fs-readdir - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

6

lib/index.d.ts

@@ -26,3 +26,6 @@ /**

*/
declare function getFiles(dirHandle: FileSystemDirectoryHandle, recursive?: boolean, path?: string, skipDirectory?: (entry: FileSystemDirectoryHandle) => boolean): Promise<FileWithDirectoryAndFileHandle[]>;
declare function getFiles(dirHandle: FileSystemDirectoryHandle, recursive?: boolean, path?: string, skipDirectory?: (entry: FileSystemDirectoryHandle) => boolean, progress?: {
loaded: number;
total: number;
}, onProgress?: (event: ProgressEvent) => void): Promise<FileWithDirectoryAndFileHandle[]>;

@@ -41,4 +44,5 @@ /**

skipDirectory?: (entry: FileSystemDirectoryHandle) => boolean;
onProgress?: (event: ProgressEvent) => void;
}): Promise<FileWithDirectoryAndFileHandle[]>;
export { type FileWithDirectoryAndFileHandle, readdir as default, getFiles, readdir };
// src/lib/fs.ts
async function getFiles(dirHandle, recursive = false, path = dirHandle.name, skipDirectory) {
async function getFiles(dirHandle, recursive = false, path = dirHandle.name, skipDirectory, progress, onProgress) {
const dirs = [];
const files = [];
progress = progress || { loaded: 0, total: 0 };
for await (const entry of dirHandle.values()) {
const nestedPath = `${path}/${entry.name}`;
if (entry.kind === "file") {
progress.total += 1;
files.push(

@@ -13,2 +15,4 @@ entry.getFile().then((f) => {

file.handle = entry;
progress.loaded += 1;
onProgress?.(new ProgressEvent("progress", { lengthComputable: true, ...progress }));
return Object.defineProperty(file, "webkitRelativePath", {

@@ -22,3 +26,3 @@ configurable: true,

} else if (entry.kind === "directory" && recursive && (!skipDirectory || !skipDirectory(entry))) {
dirs.push(getFiles(entry, recursive, nestedPath, skipDirectory));
dirs.push(getFiles(entry, recursive, nestedPath, skipDirectory, progress, onProgress));
}

@@ -31,3 +35,10 @@ }

async function readdir(dirHandle, options) {
return await getFiles(dirHandle, options?.recursive, void 0, options?.skipDirectory);
return await getFiles(
dirHandle,
options?.recursive,
void 0,
options?.skipDirectory,
void 0,
options?.onProgress
);
}

@@ -34,0 +45,0 @@ var lib_default = readdir;

5

package.json
{
"name": "browser-fs-readdir",
"description": "Read contents of a directory with the File System Access API.",
"version": "0.0.2",
"version": "0.0.3",
"author": "prin <hi@prin.studio>",

@@ -23,3 +23,4 @@ "license": "MIT",

"prepare": "husky",
"commitlint": "commitlint --edit"
"commitlint": "commitlint --edit",
"prepublishOnly": "npm run build:lib"
},

@@ -26,0 +27,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc