Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filelist-utils

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filelist-utils - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

20

lib-esm/fileListFromPath.d.ts
import { PartialFileList } from './PartialFile';
/**
* Generate a FileList from a directory path
* By default this method will expand all zip and gzip files
* @param path
* @returns
*/
export declare function fileListFromPath(path: string): PartialFileList;
export declare function fileListFromPath(path: string, options?: {
/**
* Expand all zip files
* Set this value to undefined to prevent unzip
* @default ()
*/
unzip?: {
zipExtensions?: string[];
};
/**
* Expand all gzip files
* Set this value to undefined to prevent ungzip
* @default ()
*/
ungzip?: {
gzipExtensions?: string[];
};
}): Promise<PartialFileList>;
//# sourceMappingURL=fileListFromPath.d.ts.map

@@ -1,12 +0,18 @@

import { readdirSync, statSync } from 'fs';
import { readdirSync, statSync, createReadStream } from 'fs';
import { readFile } from 'fs/promises';
import { join } from 'path';
import { fileListUngzip } from './fileListUngzip';
import { fileListUnzip } from './fileListUnzip';
/**
* Generate a FileList from a directory path
* By default this method will expand all zip and gzip files
* @param path
* @returns
*/
export function fileListFromPath(path) {
const fileList = [];
export async function fileListFromPath(path, options = {}) {
const { unzip = {}, ungzip = {} } = options;
let fileList = [];
appendFiles(fileList, path);
fileList = await fileListUnzip(fileList, unzip);
fileList = await fileListUngzip(fileList, ungzip);
return fileList;

@@ -36,2 +42,7 @@ }

},
//@ts-expect-error wrong type script definition ?
stream: () => {
//@ts-expect-error typescript definition not correct
return createReadStream(join(currentDir, entry));
},
});

@@ -38,0 +49,0 @@ }

@@ -15,3 +15,4 @@ import JSZip from 'jszip';

arrayBuffer: () => Promise<ArrayBuffer>;
stream: () => ReadableStream<any>;
}[]>;
//# sourceMappingURL=fileListFromZip.d.ts.map

@@ -27,2 +27,12 @@ import JSZip from 'jszip';

},
stream: () => {
return new ReadableStream({
start(controller) {
void entry.async('arraybuffer').then((arrayBuffer) => {
controller.enqueue(arrayBuffer);
controller.close();
});
},
});
},
});

@@ -29,0 +39,0 @@ }

@@ -39,2 +39,16 @@ import { ungzip } from 'pako';

},
//@ts-expect-error should be ok
stream: () => {
return new ReadableStream({
start(controller) {
void file
.arrayBuffer()
.then((arrayBuffer) => ungzip(new Uint8Array(arrayBuffer)))
.then((arrayBuffer) => {
controller.enqueue(arrayBuffer);
controller.close();
});
},
});
},
});

@@ -41,0 +55,0 @@ fileList.splice(i, 1);

@@ -26,2 +26,3 @@ import { fileListFromZip } from './fileListFromZip';

zipEntry.webkitRelativePath = `${file.webkitRelativePath}/${zipEntry.webkitRelativePath}`;
//@ts-expect-error should be correct
fileList.push(zipEntry);

@@ -28,0 +29,0 @@ }

2

lib-esm/PartialFile.d.ts
/** subset for File */
export declare type PartialFile = Omit<File, 'stream' | 'slice' | 'type'>;
export declare type PartialFile = Omit<File, 'slice' | 'type'>;
export declare type PartialFileList = PartialFile[];
//# sourceMappingURL=PartialFile.d.ts.map
import { PartialFileList } from './PartialFile';
/**
* Generate a FileList from a directory path
* By default this method will expand all zip and gzip files
* @param path
* @returns
*/
export declare function fileListFromPath(path: string): PartialFileList;
export declare function fileListFromPath(path: string, options?: {
/**
* Expand all zip files
* Set this value to undefined to prevent unzip
* @default ()
*/
unzip?: {
zipExtensions?: string[];
};
/**
* Expand all gzip files
* Set this value to undefined to prevent ungzip
* @default ()
*/
ungzip?: {
gzipExtensions?: string[];
};
}): Promise<PartialFileList>;
//# sourceMappingURL=fileListFromPath.d.ts.map

@@ -7,10 +7,16 @@ "use strict";

const path_1 = require("path");
const fileListUngzip_1 = require("./fileListUngzip");
const fileListUnzip_1 = require("./fileListUnzip");
/**
* Generate a FileList from a directory path
* By default this method will expand all zip and gzip files
* @param path
* @returns
*/
function fileListFromPath(path) {
const fileList = [];
async function fileListFromPath(path, options = {}) {
const { unzip = {}, ungzip = {} } = options;
let fileList = [];
appendFiles(fileList, path);
fileList = await (0, fileListUnzip_1.fileListUnzip)(fileList, unzip);
fileList = await (0, fileListUngzip_1.fileListUngzip)(fileList, ungzip);
return fileList;

@@ -41,2 +47,7 @@ }

},
//@ts-expect-error wrong type script definition ?
stream: () => {
//@ts-expect-error typescript definition not correct
return (0, fs_1.createReadStream)((0, path_1.join)(currentDir, entry));
},
});

@@ -43,0 +54,0 @@ }

@@ -15,3 +15,4 @@ import JSZip from 'jszip';

arrayBuffer: () => Promise<ArrayBuffer>;
stream: () => ReadableStream<any>;
}[]>;
//# sourceMappingURL=fileListFromZip.d.ts.map

@@ -33,2 +33,12 @@ "use strict";

},
stream: () => {
return new ReadableStream({
start(controller) {
void entry.async('arraybuffer').then((arrayBuffer) => {
controller.enqueue(arrayBuffer);
controller.close();
});
},
});
},
});

@@ -35,0 +45,0 @@ }

@@ -42,2 +42,16 @@ "use strict";

},
//@ts-expect-error should be ok
stream: () => {
return new ReadableStream({
start(controller) {
void file
.arrayBuffer()
.then((arrayBuffer) => (0, pako_1.ungzip)(new Uint8Array(arrayBuffer)))
.then((arrayBuffer) => {
controller.enqueue(arrayBuffer);
controller.close();
});
},
});
},
});

@@ -44,0 +58,0 @@ fileList.splice(i, 1);

@@ -29,2 +29,3 @@ "use strict";

zipEntry.webkitRelativePath = `${file.webkitRelativePath}/${zipEntry.webkitRelativePath}`;
//@ts-expect-error should be correct
fileList.push(zipEntry);

@@ -31,0 +32,0 @@ }

/** subset for File */
export declare type PartialFile = Omit<File, 'stream' | 'slice' | 'type'>;
export declare type PartialFile = Omit<File, 'slice' | 'type'>;
export declare type PartialFileList = PartialFile[];
//# sourceMappingURL=PartialFile.d.ts.map
{
"name": "filelist-utils",
"version": "0.5.0",
"version": "0.6.0",
"description": "Create a FileList from a path or a zip file",

@@ -42,16 +42,16 @@ "main": "./lib/index.js",

"devDependencies": {
"@types/jest": "^27.4.1",
"@types/pako": "^1.0.3",
"eslint": "^8.12.0",
"@types/jest": "^27.5.1",
"@types/pako": "^2.0.0",
"eslint": "^8.16.0",
"eslint-config-cheminfo-typescript": "^10.4.0",
"jest": "^27.5.1",
"prettier": "^2.6.1",
"jest": "^28.1.0",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
"ts-jest": "^28.0.3",
"typescript": "^4.7.2"
},
"dependencies": {
"jszip": "^3.7.1",
"jszip": "^3.10.0",
"pako": "^2.0.4"
}
}

@@ -1,2 +0,2 @@

import { readdirSync, statSync } from 'fs';
import { readdirSync, statSync, createReadStream } from 'fs';
import { readFile } from 'fs/promises';

@@ -6,11 +6,38 @@ import { join } from 'path';

import { PartialFileList } from './PartialFile';
import { fileListUngzip } from './fileListUngzip';
import { fileListUnzip } from './fileListUnzip';
/**
* Generate a FileList from a directory path
* By default this method will expand all zip and gzip files
* @param path
* @returns
*/
export function fileListFromPath(path: string) {
const fileList: PartialFileList = [];
export async function fileListFromPath(
path: string,
options: {
/**
* Expand all zip files
* Set this value to undefined to prevent unzip
* @default ()
*/
unzip?: {
zipExtensions?: string[];
};
/**
* Expand all gzip files
* Set this value to undefined to prevent ungzip
* @default ()
*/
ungzip?: {
gzipExtensions?: string[];
};
} = {},
) {
const { unzip = {}, ungzip = {} } = options;
let fileList: PartialFileList = [];
appendFiles(fileList, path);
fileList = await fileListUnzip(fileList, unzip);
fileList = await fileListUngzip(fileList, ungzip);
return fileList;

@@ -24,2 +51,3 @@ }

const stat = statSync(current);
if (stat.isDirectory()) {

@@ -41,2 +69,7 @@ appendFiles(fileList, current);

},
//@ts-expect-error wrong type script definition ?
stream: (): ReadableStream => {
//@ts-expect-error typescript definition not correct
return createReadStream(join(currentDir, entry));
},
});

@@ -43,0 +76,0 @@ }

@@ -30,2 +30,12 @@ import JSZip from 'jszip';

},
stream: () => {
return new ReadableStream({
start(controller) {
void entry.async('arraybuffer').then((arrayBuffer) => {
controller.enqueue(arrayBuffer);
controller.close();
});
},
});
},
});

@@ -32,0 +42,0 @@ }

import { ungzip } from 'pako';
import { PartialFileList, PartialFile } from './PartialFile';
/**

@@ -54,2 +55,16 @@ * Some files in the fileList may actually be gzip. This method will ungzip those files.

},
//@ts-expect-error should be ok
stream: () => {
return new ReadableStream({
start(controller) {
void file
.arrayBuffer()
.then((arrayBuffer) => ungzip(new Uint8Array(arrayBuffer)))
.then((arrayBuffer) => {
controller.enqueue(arrayBuffer);
controller.close();
});
},
});
},
});

@@ -56,0 +71,0 @@

@@ -40,2 +40,3 @@ import { PartialFileList, PartialFile } from './PartialFile';

zipEntry.webkitRelativePath = `${file.webkitRelativePath}/${zipEntry.webkitRelativePath}`;
//@ts-expect-error should be correct
fileList.push(zipEntry);

@@ -42,0 +43,0 @@ }

/** subset for File */
export type PartialFile = Omit<File, 'stream' | 'slice' | 'type'>;
export type PartialFile = Omit<File, 'slice' | 'type'>;
export type PartialFileList = PartialFile[];

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

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

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

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

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