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.

Readme

Keywords

none

Package Sidebar

Install

npm i lazy-promise-loader

Weekly Downloads

0

Version

1.0.0

License

WTFPL

Last publish

Collaborators

  • caseywebb