detect-and-shim

1.2.0 • Public • Published

detect-and-shim Build Status

Easy to use asynchronous automatic shims

Installation

npm install -S detect-and-shim

Usage

import shim from 'detect-and-shim';
 
shim([
    'promise',
    // load 'promise.finally' only after 'promise'
    ['promise.finally', ['promise']],
    'object.assign'
], ()  => {
    // now you could work!
})

By default, all shims are loaded in parallel. If some shims should be loaded only after some other shims, it could be done by defining an array ['shim', [/* shim dependencies */]]

Additionally, you could pass your own shims:

import shim from 'detect-and-shim';
 
shim([{
    check() {
        return true; // if shim is needed;
    },
    shim(cb) {
        // shim and call cb()
    }
}], ()  => {
    // now you could work!
})

All included shims are loaded asynchronously using require.ensure([]). Custom shims could be loaded asynchronously as well.

List of included shims:

  • object.assign
  • promise
  • promise.finally

Package Sidebar

Install

npm i detect-and-shim

Weekly Downloads

1

Version

1.2.0

License

MIT

Last publish

Collaborators

  • jakwuh