filelist-utils
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -20,3 +20,5 @@ import { ExpandOptions } from './ExpandOptions'; | ||
size: number; | ||
}[], baseURL?: string | URL, options?: ExpandOptions & FilterOptions): Promise<FileCollection>; | ||
}[], options?: { | ||
baseURL?: string | URL; | ||
} & ExpandOptions & FilterOptions): Promise<FileCollection>; | ||
//# sourceMappingURL=fileCollectionFromFileArray.d.ts.map |
@@ -17,3 +17,4 @@ import fetch from 'cross-fetch'; | ||
*/ | ||
export async function fileCollectionFromFileArray(entries, baseURL, options = {}) { | ||
export async function fileCollectionFromFileArray(entries, options = {}) { | ||
const { baseURL } = options; | ||
let fileCollectionItems = []; | ||
@@ -38,10 +39,22 @@ /* | ||
text: async () => { | ||
const fileURL = new URL(entry.relativePath, baseURL).href; | ||
const response = await fetch(fileURL); | ||
return response.text(); | ||
if (baseURL) { | ||
const fileURL = new URL(entry.relativePath, baseURL); | ||
const response = await fetch(fileURL); | ||
return response.text(); | ||
} | ||
else { | ||
const response = await fetch(entry.relativePath); | ||
return response.text(); | ||
} | ||
}, | ||
arrayBuffer: async () => { | ||
const fileURL = new URL(entry.relativePath, baseURL).href; | ||
const response = await fetch(fileURL); | ||
return response.arrayBuffer(); | ||
if (baseURL) { | ||
const fileURL = new URL(entry.relativePath, baseURL); | ||
const response = await fetch(fileURL); | ||
return response.arrayBuffer(); | ||
} | ||
else { | ||
const response = await fetch(entry.relativePath); | ||
return response.arrayBuffer(); | ||
} | ||
}, | ||
@@ -48,0 +61,0 @@ stream: () => { |
@@ -18,4 +18,4 @@ import fetch from 'cross-fetch'; | ||
const baseURL = url; | ||
return fileCollectionFromFileArray(entries, baseURL, options); | ||
return fileCollectionFromFileArray(entries, { baseURL, ...options }); | ||
} | ||
//# sourceMappingURL=fileCollectionFromWebservice.js.map |
@@ -20,3 +20,5 @@ import { ExpandOptions } from './ExpandOptions'; | ||
size: number; | ||
}[], baseURL?: string | URL, options?: ExpandOptions & FilterOptions): Promise<FileCollection>; | ||
}[], options?: { | ||
baseURL?: string | URL; | ||
} & ExpandOptions & FilterOptions): Promise<FileCollection>; | ||
//# sourceMappingURL=fileCollectionFromFileArray.d.ts.map |
@@ -23,3 +23,4 @@ "use strict"; | ||
*/ | ||
async function fileCollectionFromFileArray(entries, baseURL, options = {}) { | ||
async function fileCollectionFromFileArray(entries, options = {}) { | ||
const { baseURL } = options; | ||
let fileCollectionItems = []; | ||
@@ -44,10 +45,22 @@ /* | ||
text: async () => { | ||
const fileURL = new URL(entry.relativePath, baseURL).href; | ||
const response = await (0, cross_fetch_1.default)(fileURL); | ||
return response.text(); | ||
if (baseURL) { | ||
const fileURL = new URL(entry.relativePath, baseURL); | ||
const response = await (0, cross_fetch_1.default)(fileURL); | ||
return response.text(); | ||
} | ||
else { | ||
const response = await (0, cross_fetch_1.default)(entry.relativePath); | ||
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(); | ||
if (baseURL) { | ||
const fileURL = new URL(entry.relativePath, baseURL); | ||
const response = await (0, cross_fetch_1.default)(fileURL); | ||
return response.arrayBuffer(); | ||
} | ||
else { | ||
const response = await (0, cross_fetch_1.default)(entry.relativePath); | ||
return response.arrayBuffer(); | ||
} | ||
}, | ||
@@ -54,0 +67,0 @@ stream: () => { |
@@ -24,5 +24,5 @@ "use strict"; | ||
const baseURL = url; | ||
return (0, fileCollectionFromFileArray_1.fileCollectionFromFileArray)(entries, baseURL, options); | ||
return (0, fileCollectionFromFileArray_1.fileCollectionFromFileArray)(entries, { baseURL, ...options }); | ||
} | ||
exports.fileCollectionFromWebservice = fileCollectionFromWebservice; | ||
//# sourceMappingURL=fileCollectionFromWebservice.js.map |
{ | ||
"name": "filelist-utils", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "Create a FileCollection from a path or a zip file", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -28,5 +28,6 @@ import fetch from 'cross-fetch'; | ||
}[], | ||
baseURL?: string | URL, | ||
options: ExpandOptions & FilterOptions = {}, | ||
options: { baseURL?: string | URL } & ExpandOptions & FilterOptions = {}, | ||
): Promise<FileCollection> { | ||
const { baseURL } = options; | ||
let fileCollectionItems: FileCollectionItem[] = []; | ||
@@ -51,10 +52,20 @@ /* | ||
text: async (): Promise<string> => { | ||
const fileURL = new URL(entry.relativePath, baseURL).href; | ||
const response = await fetch(fileURL); | ||
return response.text(); | ||
if (baseURL) { | ||
const fileURL = new URL(entry.relativePath, baseURL); | ||
const response = await fetch(fileURL); | ||
return response.text(); | ||
} else { | ||
const response = await fetch(entry.relativePath); | ||
return response.text(); | ||
} | ||
}, | ||
arrayBuffer: async (): Promise<ArrayBuffer> => { | ||
const fileURL = new URL(entry.relativePath, baseURL).href; | ||
const response = await fetch(fileURL); | ||
return response.arrayBuffer(); | ||
if (baseURL) { | ||
const fileURL = new URL(entry.relativePath, baseURL); | ||
const response = await fetch(fileURL); | ||
return response.arrayBuffer(); | ||
} else { | ||
const response = await fetch(entry.relativePath); | ||
return response.arrayBuffer(); | ||
} | ||
}, | ||
@@ -61,0 +72,0 @@ stream: (): ReadableStream => { |
@@ -27,3 +27,3 @@ import fetch from 'cross-fetch'; | ||
return fileCollectionFromFileArray(entries, baseURL, options); | ||
return fileCollectionFromFileArray(entries, { baseURL, ...options }); | ||
} |
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
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
155199
2427
6