npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

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

install

npm i detect-and-shim

Downloadsweekly downloads

6

version

1.2.0

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability