1.2.0 • Published 7 years ago

detect-and-shim v1.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

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