18 lines
414 B
JavaScript
18 lines
414 B
JavaScript
|
'use strict';
|
||
|
|
||
|
exports.test = function () {
|
||
|
if (global.setImmediate) {
|
||
|
// we can only get here in IE10
|
||
|
// which doesn't handel postMessage well
|
||
|
return false;
|
||
|
}
|
||
|
return typeof global.MessageChannel !== 'undefined';
|
||
|
};
|
||
|
|
||
|
exports.install = function (func) {
|
||
|
var channel = new global.MessageChannel();
|
||
|
channel.port1.onmessage = func;
|
||
|
return function () {
|
||
|
channel.port2.postMessage(0);
|
||
|
};
|
||
|
};
|