Options
All
  • Public
  • Public/Protected
  • All
Menu

pinus-loader

Index

Functions

checkFileType

  • checkFileType(fn: string, suffix: string): boolean
  • Check file suffix

    Parameters

    • fn: string

      file name

    • suffix: string

      suffix string, such as .js, etc.

    Returns boolean

getFileName

  • getFileName(fp: string, suffixLength: number): string
  • Parameters

    • fp: string
    • suffixLength: number

    Returns string

isDir

  • isDir(path: string): boolean
  • Parameters

    • path: string

    Returns boolean

isFile

  • isFile(path: string): boolean
  • Parameters

    • path: string

    Returns boolean

load

  • load(mpath: string, context: any, reload: boolean): object
  • Load modules under the path. If the module is a function, loader would treat it as a factory function and invoke it with the context parameter to get a instance of the module. Else loader would just require the module. Module instance can specify a name property and it would use file name as the default name if there is no name property. All loaded modules under the path would be add to an empty root object with the name as the key.

    Parameters

    • mpath: string

      the path of modules. Load all the files under the path, but not recursively if the path contain any sub-directory.

    • context: any

      the context parameter that would be pass to the module factory function.

    • reload: boolean

    Returns object

    module that has loaded.

    • [key: string]: any

loadFile

  • loadFile(fp: string, context: any, reload: boolean): any
  • Parameters

    • fp: string
    • context: any
    • reload: boolean

    Returns any

loadPath

  • loadPath(path: string, context: any, reload: boolean): object
  • Parameters

    • path: string
    • context: any
    • reload: boolean

    Returns object

    • [key: string]: any

requireUncached

  • requireUncached(module: string): any