Naivete Precedes Misrepresentation

    lazy-promise-loader

    1.0.0 • Public • Published

    lazy-promise-loader

    Like promise-loader, but with lazy promises (no invocation required).

    Promise is expected to be available in the global scope.

    Usage

    Documentation: Using loaders

    const _file = require('lazy-promise!./file.js')
     
    // file will not be loaded until `.then()` is invoked
    setTimeout(() => _file.then((file) => ...), 1000)
     
    // or in ES2017
    async function someHandler() {
      const file = await _file
    }

    Optionally specify a name for your chunk...

    const load = require("lazy-promise?editor!./editor.js")

    Why bother? For APIs that expect promises before the chunk is to be loaded. That's why.

    For example, say you have an API that accepts both functions, and promises that return functions, and these functions should not be invoked until some later time.

    With the regular 'ol promise-loader, there is no way to programatically tell which is which.

    Keywords

    none

    Install

    npm i lazy-promise-loader

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    WTFPL

    Last publish

    Collaborators

    • caseywebb