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 1.2.0 to 1.3.0

lib-esm/fileCollectionFromFileArray.d.ts

43

lib-esm/fileCollectionFromWebservice.js
import fetch from 'cross-fetch';
import { FileCollection } from './FileCollection';
import { maybeExpand } from './utilities/maybeExpand';
import { maybeFilter } from './utilities/maybeFilter';
import { fileCollectionFromFileArray } from './fileCollectionFromFileArray';
/**

@@ -18,41 +16,6 @@ * Creates a FileCollection from a webservice. This webservice should return an array of objects containing the properties:

const response = await fetch(url.toString());
const entries = await response.json();
const baseURL = url;
const entries = await response.json();
let fileCollectionItems = [];
/*
Answer should contain:
- relativePath
- name
- lastModified
- size
And we need to add those async functions:
- stream
- text
- arrayBuffer
*/
for (const entry of entries) {
fileCollectionItems.push({
name: entry.name,
size: entry.size,
relativePath: entry.relativePath,
lastModified: entry.lastModified,
text: async () => {
const fileURL = new URL(entry.relativePath, baseURL).href;
const response = await fetch(fileURL);
return response.text();
},
arrayBuffer: async () => {
const fileURL = new URL(entry.relativePath, baseURL).href;
const response = await fetch(fileURL);
return response.arrayBuffer();
},
stream: () => {
throw new Error('stream not yet implemented');
},
});
}
fileCollectionItems = await maybeExpand(fileCollectionItems, options);
fileCollectionItems = await maybeFilter(fileCollectionItems, options);
return new FileCollection(fileCollectionItems);
return fileCollectionFromFileArray(entries, baseURL, options);
}
//# sourceMappingURL=fileCollectionFromWebservice.js.map
import { FileCollection } from './FileCollection';
import { FileCollectionItem } from './FileCollectionItem';
export declare type StringObject = Record<string, string>;
declare type GroupByOption = 'baseDir' | 'extension' | 'filename' | ((file?: FileCollectionItem, fileInfo?: StringObject) => string);
declare type GroupByOption = 'baseDir' | 'extension' | 'filename' | ((file?: FileCollectionItem, fileInfo?: ReturnType<typeof getFileInfo>) => string);
interface GroupOfFileCollection {

@@ -22,3 +22,8 @@ meta: StringObject;

export declare function groupFiles(fileCollection: FileCollection, options?: GroupFilesOptions): GroupOfFileCollection[];
declare function getFileInfo(file: FileCollectionItem): {
baseDir: string;
extension: string;
filename: string;
};
export {};
//# sourceMappingURL=groupFiles.d.ts.map
export * from './fileCollectionFromPath';
export * from './fileCollectionFromPaths';
export * from './fileCollectionFromZip';
export * from './fileCollectionFromZipURL';
export * from './fileCollectionFromWebservice';
export * from './fileCollectionFromFileList';
export * from './fileCollectionFromFileArray';
export * from './fileCollectionFromFiles';

@@ -7,0 +9,0 @@ export * from './groupFiles';

export * from './fileCollectionFromPath';
export * from './fileCollectionFromPaths';
export * from './fileCollectionFromZip';
export * from './fileCollectionFromZipURL';
export * from './fileCollectionFromWebservice';
export * from './fileCollectionFromFileList';
export * from './fileCollectionFromFileArray';
export * from './fileCollectionFromFiles';

@@ -7,0 +9,0 @@ export * from './groupFiles';

@@ -8,5 +8,3 @@ "use strict";

const cross_fetch_1 = __importDefault(require("cross-fetch"));
const FileCollection_1 = require("./FileCollection");
const maybeExpand_1 = require("./utilities/maybeExpand");
const maybeFilter_1 = require("./utilities/maybeFilter");
const fileCollectionFromFileArray_1 = require("./fileCollectionFromFileArray");
/**

@@ -25,42 +23,7 @@ * Creates a FileCollection from a webservice. This webservice should return an array of objects containing the properties:

const response = await (0, cross_fetch_1.default)(url.toString());
const entries = await response.json();
const baseURL = url;
const entries = await response.json();
let fileCollectionItems = [];
/*
Answer should contain:
- relativePath
- name
- lastModified
- size
And we need to add those async functions:
- stream
- text
- arrayBuffer
*/
for (const entry of entries) {
fileCollectionItems.push({
name: entry.name,
size: entry.size,
relativePath: entry.relativePath,
lastModified: entry.lastModified,
text: async () => {
const fileURL = new URL(entry.relativePath, baseURL).href;
const response = await (0, cross_fetch_1.default)(fileURL);
return response.text();
},
arrayBuffer: async () => {
const fileURL = new URL(entry.relativePath, baseURL).href;
const response = await (0, cross_fetch_1.default)(fileURL);
return response.arrayBuffer();
},
stream: () => {
throw new Error('stream not yet implemented');
},
});
}
fileCollectionItems = await (0, maybeExpand_1.maybeExpand)(fileCollectionItems, options);
fileCollectionItems = await (0, maybeFilter_1.maybeFilter)(fileCollectionItems, options);
return new FileCollection_1.FileCollection(fileCollectionItems);
return (0, fileCollectionFromFileArray_1.fileCollectionFromFileArray)(entries, baseURL, options);
}
exports.fileCollectionFromWebservice = fileCollectionFromWebservice;
//# sourceMappingURL=fileCollectionFromWebservice.js.map
import { FileCollection } from './FileCollection';
import { FileCollectionItem } from './FileCollectionItem';
export declare type StringObject = Record<string, string>;
declare type GroupByOption = 'baseDir' | 'extension' | 'filename' | ((file?: FileCollectionItem, fileInfo?: StringObject) => string);
declare type GroupByOption = 'baseDir' | 'extension' | 'filename' | ((file?: FileCollectionItem, fileInfo?: ReturnType<typeof getFileInfo>) => string);
interface GroupOfFileCollection {

@@ -22,3 +22,8 @@ meta: StringObject;

export declare function groupFiles(fileCollection: FileCollection, options?: GroupFilesOptions): GroupOfFileCollection[];
declare function getFileInfo(file: FileCollectionItem): {
baseDir: string;
extension: string;
filename: string;
};
export {};
//# sourceMappingURL=groupFiles.d.ts.map
export * from './fileCollectionFromPath';
export * from './fileCollectionFromPaths';
export * from './fileCollectionFromZip';
export * from './fileCollectionFromZipURL';
export * from './fileCollectionFromWebservice';
export * from './fileCollectionFromFileList';
export * from './fileCollectionFromFileArray';
export * from './fileCollectionFromFiles';

@@ -7,0 +9,0 @@ export * from './groupFiles';

@@ -20,4 +20,6 @@ "use strict";

__exportStar(require("./fileCollectionFromZip"), exports);
__exportStar(require("./fileCollectionFromZipURL"), exports);
__exportStar(require("./fileCollectionFromWebservice"), exports);
__exportStar(require("./fileCollectionFromFileList"), exports);
__exportStar(require("./fileCollectionFromFileArray"), exports);
__exportStar(require("./fileCollectionFromFiles"), exports);

@@ -24,0 +26,0 @@ __exportStar(require("./groupFiles"), exports);

{
"name": "filelist-utils",
"version": "1.2.0",
"version": "1.3.0",
"description": "Create a FileCollection from a path or a zip file",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -5,5 +5,4 @@ import fetch from 'cross-fetch';

import { FileCollection } from './FileCollection';
import { FileCollectionItem } from './FileCollectionItem';
import { maybeExpand } from './utilities/maybeExpand';
import { FilterOptions, maybeFilter } from './utilities/maybeFilter';
import { fileCollectionFromFileArray } from './fileCollectionFromFileArray';
import { FilterOptions } from './utilities/maybeFilter';

@@ -26,40 +25,6 @@ /**

const response = await fetch(url.toString());
const entries = await response.json();
const baseURL = url;
const entries = await response.json();
let fileCollectionItems: FileCollectionItem[] = [];
/*
Answer should contain:
- relativePath
- name
- lastModified
- size
And we need to add those async functions:
- stream
- text
- arrayBuffer
*/
for (const entry of entries) {
fileCollectionItems.push({
name: entry.name,
size: entry.size,
relativePath: entry.relativePath,
lastModified: entry.lastModified,
text: async (): Promise<string> => {
const fileURL = new URL(entry.relativePath, baseURL).href;
const response = await fetch(fileURL);
return response.text();
},
arrayBuffer: async (): Promise<ArrayBuffer> => {
const fileURL = new URL(entry.relativePath, baseURL).href;
const response = await fetch(fileURL);
return response.arrayBuffer();
},
stream: (): ReadableStream => {
throw new Error('stream not yet implemented');
},
});
}
fileCollectionItems = await maybeExpand(fileCollectionItems, options);
fileCollectionItems = await maybeFilter(fileCollectionItems, options);
return new FileCollection(fileCollectionItems);
return fileCollectionFromFileArray(entries, baseURL, options);
}

@@ -10,3 +10,6 @@ import { FileCollection } from './FileCollection';

| 'filename'
| ((file?: FileCollectionItem, fileInfo?: StringObject) => string);
| ((
file?: FileCollectionItem,
fileInfo?: ReturnType<typeof getFileInfo>,
) => string);

@@ -13,0 +16,0 @@ interface GroupOfFileCollection {

export * from './fileCollectionFromPath';
export * from './fileCollectionFromPaths';
export * from './fileCollectionFromZip';
export * from './fileCollectionFromZipURL';
export * from './fileCollectionFromWebservice';
export * from './fileCollectionFromFileList';
export * from './fileCollectionFromFileArray';
export * from './fileCollectionFromFiles';

@@ -7,0 +9,0 @@ export * from './groupFiles';

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