Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Parser

Hierarchy

Index

References

Action

Re-exports Action

Constructors

constructor

  • Create new Parser

    throws

    {Errors.ENOENT} no such file or directory

    throws

    {Errors.EINVAL} invalid input

    example

    class FooParser extends Parser { ... } new FooParser('./foo/bar.zip' or './foo/bar');

    Parameters

    • input: string

      file or directory

    • Optional cryptoProvider: CryptoProvider
    • Optional loggerOptions: { logLevel: LogLevel; namespace: string }

    Returns Parser

Properties

Private _unzipTasks

_unzipTasks: any
returns

return tasks

Accessors

cryptoProvider

  • Get en/decrypto provider

    Returns CryptoProvider

input

  • get input(): string
  • Get file or directory

    Returns string

logger

  • Get logger

    Returns 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(): { overwrite: boolean; unzipPath: string }
  • Get default values of parse options

    static

    Returns { overwrite: boolean; unzipPath: string }

    • overwrite: boolean

      If true, overwrite to unzipPath when unzip. (only using if unzipPath specified.)

    • unzipPath: string

      If specified, unzip to that path.

Static parseOptionTypes

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

    static

    Returns { overwrite: string; unzipPath: string }

    • overwrite: string

      /

      /**

    • unzipPath: string

Static readDefaultOptions

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

    static

    Returns void | { force: boolean }

Static readOptionTypes

  • get readOptionTypes(): void | { force: string }
  • Get types of read option

    static

    Returns void | { force: string }

Methods

Protected _createBook

  • Create new Book from context

    Parameters

    Returns Promise<BaseBook>

    return Book

Protected _getBookClass

  • _getBookClass(): {}
  • virtual

    Returns {}

Protected _getParseContextClass

  • _getParseContextClass(): {}
  • virtual

    Returns {}

Protected _getReadContextClass

  • _getReadContextClass(): {}
  • virtual

    Returns {}

Protected _getReadItemClass

  • _getReadItemClass(): {}
  • virtual

    Returns {}

Protected _parseAfterTasks

  • _parseAfterTasks(): Task[]
  • Returns Task[]

    return after tasks

Protected _parseBeforeTasks

  • _parseBeforeTasks(): Task[]
  • Returns Task[]

    return before tasks

Protected _parseTasks

  • _parseTasks(): Task[]
  • Returns Task[]

    return tasks

_prepareParse

  • Validate parse 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<BaseParseContext>

    return Context containing parse options, entries

_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[]
  • Returns Task[]

    return after tasks

Protected _readBeforeTasks

  • _readBeforeTasks(): Task[]
  • Returns Task[]

    return before tasks

Protected _readTasks

  • _readTasks(): Task[]
  • Returns Task[]

    return tasks

_unzipIfNeeded

  • Unzipping if zip source and unzipPath option specified

    async
    throws

    {Errors.ENOENT} no such file or directory

    throws

    {Errors.EEXIST} file or directory already exists

    Parameters

    Returns Promise<BaseParseContext>

    return Context (no change at this step)

parse

  • Parse the input

    async
    see

    Parser.parseDefaultOptions

    see

    Parser.parseOptionTypes

    Parameters

    Returns Promise<BaseBook>

    return Book

readItem

  • Reading contents of Item

    see

    Parser.readDefaultOptions

    see

    Parser.readOptionTypes

    Parameters

    Returns string | Buffer

    reading result

readItems

  • Reading contents of Items

    async
    see

    Parser.readDefaultOptions

    see

    Parser.readOptionTypes

    Parameters

    Returns (string | Buffer)[]

    reading results

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