Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComicParser

Hierarchy

Index

Constructors

constructor

  • new ComicParser(input: string, cryptoProvider: CryptoProvider, logLevel: { DEBUG: string; ERROR: string; INFO: string; SILENT: string; VERBOSE: string; WARN: string }): ComicParser
  • Create new ComicParser

    throws

    {Errors.ENOENT} no such file or directory

    throws

    {Errors.EINVAL} invalid input

    example

    new ComicParser('./foo/bar.zip' or './foo/bar');

    Parameters

    • input: string

      file or directory

    • cryptoProvider: CryptoProvider

      en/decrypto provider

    • logLevel: { DEBUG: string; ERROR: string; INFO: string; SILENT: string; VERBOSE: string; WARN: string }

      logging level

      • DEBUG: string

        "debug"

      • ERROR: string

        "error"

      • INFO: string

        "info"

      • SILENT: string

        "silent"

      • VERBOSE: string

        "verbose"

      • WARN: string

        "warn"

    Returns ComicParser

Accessors

cryptoProvider

input

  • get input(): string

logger

onProgress

  • get onProgress(): (step: number, totalStep: number, action: string) => void
  • set onProgress(arg: (step: number, totalStep: number, action: string) => void): any
  • Get onProgress callback

    Returns (step: number, totalStep: number, action: string) => void

      • (step: number, totalStep: number, action: string): void
      • Parameters

        • step: number
        • totalStep: number
        • action: string

        Returns void

  • Set callback that tells progress of parse and readItems.

    example

    parser.onProgress = (step, totalStep, action) => { console.log([${action}] ${step} / ${totalStep}); }

    see

    Parser.Action

    Parameters

    • arg: (step: number, totalStep: number, action: string) => void
        • (step: number, totalStep: number, action: string): void
        • Parameters

          • step: number
          • totalStep: number
          • action: string

          Returns void

    Returns any

Static parseDefaultOptions

  • get parseDefaultOptions(): { ext: string[]; overwrite: boolean; parseImageSize: boolean; unzipPath: string }
  • Get default values of parse options

    Returns { ext: string[]; overwrite: boolean; parseImageSize: boolean; unzipPath: string }

    • ext: string[]
    • overwrite: boolean
    • parseImageSize: boolean
    • unzipPath: string

Static parseOptionTypes

  • get parseOptionTypes(): { ext: string; overwrite: string; parseImageSize: string; unzipPath: string }
  • Get types of parse options

    Returns { ext: string; overwrite: string; parseImageSize: string; unzipPath: string }

    • ext: string
    • overwrite: string
    • parseImageSize: string
    • unzipPath: string

Static readDefaultOptions

  • get readDefaultOptions(): { force: boolean } & { base64: boolean }
  • Get default values of read options

    Returns { force: boolean } & { base64: boolean }

Static readOptionTypes

  • get readOptionTypes(): { force: string } & { base64: string }
  • Get types of read option

    Returns { force: string } & { base64: string }

Methods

Protected _createBook

Protected _getBookClass

  • _getBookClass(): {}

Protected _getParseContextClass

  • _getParseContextClass(): {}

Protected _getReadContextClass

  • _getReadContextClass(): {}

Protected _getReadItemClass

  • _getReadItemClass(): {}

_parse

  • extracts only necessary metadata from entries and create item list

    see

    ComicParser.parseDefaultOptions.ext

    see

    ComicParser.parseDefaultOptions.parseImageSize

    Parameters

    Returns Promise<ComicReadContext>

    return Context containing item list

Protected _parseAfterTasks

  • _parseAfterTasks(): Task[]

Protected _parseBeforeTasks

  • _parseBeforeTasks(): Task[]

_parseImageSize

  • _parseImageSize(entry: { entryPath: string; getFile: (options: { end: number; endocing: string }) => Promise<Buffer> | Buffer; size: number }, options: { ext: string[]; overwrite: boolean; parseImageSize: boolean; unzipPath: string }): Promise<{ height: number; width: number }>
  • parse image size from entry

    Parameters

    • entry: { entryPath: string; getFile: (options: { end: number; endocing: string }) => Promise<Buffer> | Buffer; size: number }

      image entry

      • entryPath: string
      • getFile: (options: { end: number; endocing: string }) => Promise<Buffer> | Buffer
          • (options: { end: number; endocing: string }): Promise<Buffer> | Buffer
          • Parameters

            • options: { end: number; endocing: string }
              • end: number
              • endocing: string

            Returns Promise<Buffer> | Buffer

      • size: number
    • options: { ext: string[]; overwrite: boolean; parseImageSize: boolean; unzipPath: string }

      parse options

      • ext: string[]
      • overwrite: boolean
      • parseImageSize: boolean
      • unzipPath: string

    Returns Promise<{ height: number; width: number }>

    return image size

Protected _parseTasks

  • _parseTasks(): Task[]

_prepareParse

_prepareRead

  • Validate read options and get entries from input

    async
    throws

    {Errors.EINVAL} invalid options or value type

    throws

    {Errors.ENOENT} no such file or directory

    throws

    {Errors.ENOFILE} no such file

    Parameters

    Returns Promise<BaseReadContext>

    returns Context containing target items, read options, entries

_read

  • _read(context: any): Promise<Array<string | Buffer>>
  • Contents is read using loader suitable for context

    async
    override
    throws

    {Errors.ENOFILE} no such file

    see

    Parser.readDefaultOptions.force

    Parameters

    • context: any

      properties required for reading

    Returns Promise<Array<string | Buffer>>

    reading results

Protected _readAfterTasks

  • _readAfterTasks(): Task[]

Protected _readBeforeTasks

  • _readBeforeTasks(): Task[]

Protected _readTasks

  • _readTasks(): Task[]

_unzipIfNeeded

parse

readItem

readItems

unzip

  • unzip(unzipPath: string, overwrite?: boolean): Promise<boolean>
  • Unzip

    async
    throws

    {Errors.EINVAL} invalid options or value type

    throws

    {Errors.ENOENT} no such file or directory

    throws

    {Errors.ENOFILE} no such file

    Parameters

    • unzipPath: string
    • Optional overwrite: boolean

    Returns Promise<boolean>

    success

Generated using TypeDoc