Sha256: 0b40401073f4babcbe4ad2e7eea91e870522d32ae847b108962db0c8a3bd4ad8

Contents?: true

Size: 1.37 KB

Versions: 8

Compression:

Stored size: 1.37 KB

Contents

try {
    // Old IE browsers that do not curry arguments
    if (!setTimeout.call) {
        var slicer = Array.prototype.slice;
        exports.setTimeout = function(fn) {
            var args = slicer.call(arguments, 1);
            return setTimeout(function() {
                return fn.apply(this, args);
            })
        };

        exports.setInterval = function(fn) {
            var args = slicer.call(arguments, 1);
            return setInterval(function() {
                return fn.apply(this, args);
            });
        };
    } else {
        exports.setTimeout = setTimeout;
        exports.setInterval = setInterval;
    }
    exports.clearTimeout = clearTimeout;
    exports.clearInterval = clearInterval;

    // Chrome and PhantomJS seems to depend on `this` pseudo variable being a
    // `window` and throws invalid invocation exception otherwise. If this code
    // runs in such JS runtime next line will throw and `catch` clause will
    // exported timers functions bound to a window.
    exports.setTimeout(function() {});
} catch (_) {
    function bind(f, context) {
        return function () { return f.apply(context, arguments) };
    }
    
    exports.setTimeout = bind(setTimeout, window);
    exports.setInterval = bind(setInterval, window);
    exports.clearTimeout = bind(clearTimeout, window);
    exports.clearInterval = bind(clearInterval, window);
}

Version data entries

8 entries across 6 versions & 3 rubygems

Version Path
snowball-0.1.22 node_modules/browserify/builtins/timers.js
sprockets-browserify-0.2.0 node_modules/browserify/node_modules/browser-resolve/builtin/timers.js
ruby-wisp-source-0.8.0 vendor/node_modules/browserify/node_modules/browser-resolve/builtin/timers.js
ruby-wisp-source-0.7.0 vendor/node_modules/browserify/node_modules/browser-resolve/builtin/timers.js
sprockets-browserify-0.1.2 node_modules/browserify/builtins/timers.js
sprockets-browserify-0.1.2 node_modules/module-deps/node_modules/browser-resolve/builtin/timers.js
sprockets-browserify-0.1.0 node_modules/module-deps/node_modules/browser-resolve/builtin/timers.js
sprockets-browserify-0.1.0 node_modules/browserify/builtins/timers.js