OptionaltoClone: FileCollectionThe collection to merge into this collection.
Optional subPath to prefix the relative paths of the files and sources.
this - The method is chainable.
This method will append a list of files to the collection.
pass a FileList (from dom input file element or similar) or an iterable of File objects.
This method can only be used from nodejs and will throw an error in the browser
The path to the file or directory to append.
Options for appending the path.
A promise that resolves when the path is appended.
Filter files of the collection based on a predicate function.
A new FileCollection containing only the files that match the predicate (and sources attached to these files).
Save an object to the collection. This method will convert typed arrays to normal arrays and will replace a potentially existing file with the same name.
The key is the relative path of the file in the collection.
The value is the object to save. It will be serialized using JSON.stringify.
A promise that resolves when the file is saved.
This method will generate a new FileCollection. It filters files and sources from this collection based on the subPath. The files and sources will have the subPath removed from their relative paths.
Think of this method like a cd command. Only with a relative path, and no possibility to go up.
The subPath to filter the files and sources by.
A new FileCollection with the filtered files and sources with subPath as root.
const collection = new FileCollection();
collection.appendText('a/b/c.txt', 'hello');
collection.appendText('a/b/d.txt', 'world');
collection.appendText('a/e.txt', 'hello world');
const subCollection = collection.subroot('a');
expect(subCollection.files.map((f) => f.relativePath)).toStrictEqual([
'b/c.txt',
'b/d.txt',
'e.txt',
]);
expect(subCollection.sources.map((s) => s.relativePath)).toStrictEqual([
'b/c.txt',
'b/d.txt',
'e.txt',
]);
This method will zip the file collection and return the zip as an ArrayBuffer
OptionalfinalPaths: Map<ExtendedSourceItem, string>toZip will fill this map with the final paths of the sources
Zip as an Uint8Array
StaticfromOptionaloptions: OptionsStaticfromStaticfromStaticfromStaticfromStaticisFast check if the buffer is a valid ium container. Check the mimetype if provided. The check assume the first entry:
the buffer to check
Optionalmimetype: stringthe mimetype to check as the first file in zip named "mimetype"
boolean
StaticisFast check if the buffer is a zip file, checks are:
the buffer to check
boolean
This method will merge the files and sources of another collection into this collection. Sources and files will be appended to this collection. The relative paths of the files and sources will be prefixed with the subPath.