Skip to content

Commit bc17071

Browse files
jscissrgoto-bus-stop
authored andcommitted
Add setImmediate (#40)
setTimeout, setInterval, setImmediate and their clear counterparts are globals in Node. Because set/clearImmediate are not available in all browsers, adding them here.
1 parent a810104 commit bc17071

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ var defaultVars = {
4141
Buffer: function () {
4242
return 'require("buffer").Buffer';
4343
},
44+
setImmediate: function () {
45+
return 'require("timers").setImmediate';
46+
},
47+
clearImmediate: function () {
48+
return 'require("timers").clearImmediate';
49+
},
4450
__filename: function (file, basedir) {
4551
var relpath = path.relative(basedir, file);
4652
// standardize path separators, use slash in Windows too

readme.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# insert-module-globals
22

33
insert implicit module globals
4-
(`__filename`, `__dirname`, `process`, `global`, and `Buffer`)
4+
(`__filename`, `__dirname`, `process`, `global`, `setImmediate`, `clearImmediate` and `Buffer`)
55
as a browserify-style transform
66

77
[![build status](https://secure.travis-ci.org/browserify/insert-module-globals.png)](http://travis-ci.org/browserify/insert-module-globals)

0 commit comments

Comments
 (0)