From a0220d19b15956841799e273d9410a889d1eb0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4r?= Date: Tue, 3 Mar 2015 22:07:48 +0100 Subject: [PATCH] Add setImmediate setTimeout, setInterval, setImmediate and their clear counterparts are globals in Node. Because set/clearImmediate are not available in all browsers, adding them here. --- index.js | 6 ++++++ readme.markdown | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 20e72df..d46325a 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,12 @@ var defaultVars = { Buffer: function () { return 'require("buffer").Buffer'; }, + setImmediate: function () { + return 'require("timers").setImmediate'; + }, + clearImmediate: function () { + return 'require("timers").clearImmediate'; + }, __filename: function (file, basedir) { var file = '/' + path.relative(basedir, file); return JSON.stringify(file); diff --git a/readme.markdown b/readme.markdown index 073273e..d77d19a 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,7 +1,7 @@ # insert-module-globals insert implicit module globals -(`__filename`, `__dirname`, `process`, `global`, and `Buffer`) +(`__filename`, `__dirname`, `process`, `global`, `setImmediate`, `clearImmediate` and `Buffer`) as a browserify-style transform [![build status](https://secure.travis-ci.org/substack/insert-module-globals.png)](http://travis-ci.org/substack/insert-module-globals)