@zip.js/zip.js
    Preparing search index...

    Class ZipFileEntry<ReaderType, WriterType>

    Represents a file entry in the zip (Filesystem API).

    A {@link ZipFileEntry}#replace*() method describes the entry with the content it is given: it updates ZipEntry#uncompressedSize and clears the pass-through state of an entry imported with the ZipReaderOptions#passThrough option, since the bytes copied verbatim are gone. Replacing the content of an entry therefore keeps ZipFS#getExportedSize exact.

    Type Parameters

    • ReaderType
    • WriterType

    Hierarchy (View Summary)

    Index
    children: ZipEntry[]

    The children of the entry.

    The underlying EntryMetaData instance.

    directory: void

    void for ZipFileEntry instances.

    id: number

    The ID of the instance.

    name: string

    The relative filename of the entry.

    The options applied to the entry when the zip file is exported.

    These are the options passed when the entry was added to the filesystem, updated by ZipEntry#setOptions. An entry imported from a zip file has none until ZipEntry#setOptions is called.

    parent?: ZipEntry

    The parent directory of the entry.

    reader:
        | ReadableStream<any>
        | ReadableStream<any>[]
        | ReadableReader
        | Reader<unknown>[]
        | ReadableReader[]
        | Reader<ReaderType>

    The Reader instance used to read the content of the entry.

    uncompressedSize: number

    The uncompressed size of the content.

    It is the size of the raw compressed content when the entry has been imported with the passThrough option set to true, since the entry holds the compressed data in that case. The uncompressed size of the original entry remains available in ZipEntry#data.

    It is updated by the {@link ZipFileEntry}#replace*() methods, and it is 0 for an entry holding a ReadableStream instance, whose size is only known once the entry has been read.

    writer:
        | WritableStream<any>
        | WritableWriter
        | Writer<WriterType>
        | AsyncGenerator<
            WritableStream<any>
            | WritableWriter
            | Writer<unknown>,
            any,
            any,
        >

    The Writer instance used to write the content of the entry.

    • Retrieves the content of the entry as an ArrayBuffer instance

      Parameters

      Returns Promise<ArrayBuffer>

      A promise resolving to an ArrayBuffer instance.

    • Retrieves the content of the entry as a Blob instance

      Parameters

      • OptionalmimeType: string

        The MIME type of the content.

      • Optionaloptions: EntryGetDataOptions

        The options.

      Returns Promise<Blob>

      A promise resolving to a Blob instance.

    • Retrieves the content of the entry via a Writer instance

      Type Parameters

      • Type

      Parameters

      • writer:
            | WritableStream<any>
            | WritableWriter
            | Writer<unknown>
            | AsyncGenerator<
                WritableStream<any>
                | WritableWriter
                | Writer<unknown>,
                any,
                any,
            >

        The Writer instance.

      • Optionaloptions: EntryGetDataOptions

        The options.

      Returns Promise<Type>

      A promise resolving to data associated to the Writer instance.

    • Retrieves the content of the entry as as a Data URI string encoded in Base64

      Parameters

      • OptionalmimeType: string

        The MIME type of the content.

      • Optionaloptions: EntryGetDataOptions

        The options.

      Returns Promise<string>

      A promise resolving to a Data URI string encoded in Base64.

    • Retrieves the text content of the entry as a string

      Parameters

      • Optionalencoding: string

        The encoding of the text.

      • Optionaloptions: EntryGetDataOptions

        The options.

      Returns Promise<string>

      A promise resolving to a string.

    • Retrieves the content of the entry as a Uint8Array instance

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

      A promise resolving to a Uint8Array instance.

    • Retrieves the content of the entry via a WritableStream instance

      Parameters

      • Optionalwritable: WritableStream<any>

        The WritableStream instance.

      • Optionaloptions: EntryGetDataOptions

        The options.

      Returns Promise<WritableStream<any>>

      A promise resolving to the WritableStream instance.

    • Set the name of the entry

      Parameters

      • name: string

        The new name of the entry.

      Returns void

      A name holding "/" is split into path components, like the name passed to a {@link ZipDirectoryEntry}#add*() method, so it moves the entry into the directories it names, creating them when they do not exist. Renaming an entry to the name it already has does nothing. Renaming it onto an existing sibling throws an ERR_ENTRY_EXISTS error, and renaming it into itself or into one of its descendants throws.

    • Replaces the content of the entry with a Blob instance

      Parameters

      • blob: Blob

        The Blob instance.

      Returns void

    • Replaces the content of the entry with a Data URI string encoded in Base64

      Parameters

      • dataURI: string

        The Data URI string encoded in Base64.

      Returns void

    • Replaces the content of the entry with a ReadableStream instance

      Parameters

      • readable: ReadableStream

        The ReadableStream instance.

      Returns void

      The size of a ReadableStream instance is unknown, so the entry reports an undetermined size, like an entry added with ZipDirectoryEntry#addReadable. ZipFS#getExportedSize then throws an ERR_UNDETERMINED_SIZE error instead of returning a size it cannot predict.

    • Replaces the content of the entry with a string

      Parameters

      • text: string

        The string.

      Returns void

    • Replaces the content of the entry with a Uint8Array instance

      Parameters

      • array: Uint8Array

        The Uint8Array instance.

      Returns void