@mehmetb/rollup-plugin-node-builtins 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +101 -0
  2. package/dist/constants.js +474 -0
  3. package/dist/rollup-plugin-node-builtins.cjs.js +77 -0
  4. package/dist/rollup-plugin-node-builtins.es6.js +75 -0
  5. package/package.json +42 -0
  6. package/src/es6/assert.js +488 -0
  7. package/src/es6/console.js +13 -0
  8. package/src/es6/domain.js +100 -0
  9. package/src/es6/empty.js +1 -0
  10. package/src/es6/events.js +475 -0
  11. package/src/es6/http-lib/capability.js +52 -0
  12. package/src/es6/http-lib/request.js +278 -0
  13. package/src/es6/http-lib/response.js +185 -0
  14. package/src/es6/http-lib/to-arraybuffer.js +30 -0
  15. package/src/es6/http.js +167 -0
  16. package/src/es6/inherits.js +25 -0
  17. package/src/es6/os.js +113 -0
  18. package/src/es6/path.js +234 -0
  19. package/src/es6/punycode.js +475 -0
  20. package/src/es6/qs.js +147 -0
  21. package/src/es6/readable-stream/buffer-list.js +59 -0
  22. package/src/es6/readable-stream/duplex.js +45 -0
  23. package/src/es6/readable-stream/passthrough.js +15 -0
  24. package/src/es6/readable-stream/readable.js +896 -0
  25. package/src/es6/readable-stream/transform.js +174 -0
  26. package/src/es6/readable-stream/writable.js +483 -0
  27. package/src/es6/setimmediate.js +185 -0
  28. package/src/es6/stream.js +110 -0
  29. package/src/es6/string-decoder.js +220 -0
  30. package/src/es6/timers.js +76 -0
  31. package/src/es6/tty.js +20 -0
  32. package/src/es6/url.js +745 -0
  33. package/src/es6/util.js +598 -0
  34. package/src/es6/vm.js +202 -0
  35. package/src/es6/zlib-lib/LICENSE +21 -0
  36. package/src/es6/zlib-lib/adler32.js +31 -0
  37. package/src/es6/zlib-lib/binding.js +269 -0
  38. package/src/es6/zlib-lib/crc32.js +40 -0
  39. package/src/es6/zlib-lib/deflate.js +1862 -0
  40. package/src/es6/zlib-lib/inffast.js +325 -0
  41. package/src/es6/zlib-lib/inflate.js +1650 -0
  42. package/src/es6/zlib-lib/inftrees.js +329 -0
  43. package/src/es6/zlib-lib/messages.js +11 -0
  44. package/src/es6/zlib-lib/trees.js +1220 -0
  45. package/src/es6/zlib-lib/utils.js +73 -0
  46. package/src/es6/zlib-lib/zstream.js +28 -0
  47. package/src/es6/zlib.js +635 -0
  48. package/src/index.js +73 -0
@@ -0,0 +1,185 @@
1
+ /*
2
+ MIT Licence
3
+ Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola
4
+ https://github.com/YuzuJS/setImmediate/blob/f1ccbfdf09cb93aadf77c4aa749ea554503b9234/LICENSE.txt
5
+ */
6
+
7
+ var nextHandle = 1; // Spec says greater than zero
8
+ var tasksByHandle = {};
9
+ var currentlyRunningATask = false;
10
+ var doc = global.document;
11
+ var registerImmediate;
12
+
13
+ export function setImmediate(callback) {
14
+ // Callback can either be a function or a string
15
+ if (typeof callback !== "function") {
16
+ callback = new Function("" + callback);
17
+ }
18
+ // Copy function arguments
19
+ var args = new Array(arguments.length - 1);
20
+ for (var i = 0; i < args.length; i++) {
21
+ args[i] = arguments[i + 1];
22
+ }
23
+ // Store and register the task
24
+ var task = { callback: callback, args: args };
25
+ tasksByHandle[nextHandle] = task;
26
+ registerImmediate(nextHandle);
27
+ return nextHandle++;
28
+ }
29
+
30
+ export function clearImmediate(handle) {
31
+ delete tasksByHandle[handle];
32
+ }
33
+
34
+ function run(task) {
35
+ var callback = task.callback;
36
+ var args = task.args;
37
+ switch (args.length) {
38
+ case 0:
39
+ callback();
40
+ break;
41
+ case 1:
42
+ callback(args[0]);
43
+ break;
44
+ case 2:
45
+ callback(args[0], args[1]);
46
+ break;
47
+ case 3:
48
+ callback(args[0], args[1], args[2]);
49
+ break;
50
+ default:
51
+ callback.apply(undefined, args);
52
+ break;
53
+ }
54
+ }
55
+
56
+ function runIfPresent(handle) {
57
+ // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
58
+ // So if we're currently running a task, we'll need to delay this invocation.
59
+ if (currentlyRunningATask) {
60
+ // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
61
+ // "too much recursion" error.
62
+ setTimeout(runIfPresent, 0, handle);
63
+ } else {
64
+ var task = tasksByHandle[handle];
65
+ if (task) {
66
+ currentlyRunningATask = true;
67
+ try {
68
+ run(task);
69
+ } finally {
70
+ clearImmediate(handle);
71
+ currentlyRunningATask = false;
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+ function installNextTickImplementation() {
78
+ registerImmediate = function(handle) {
79
+ process.nextTick(function () { runIfPresent(handle); });
80
+ };
81
+ }
82
+
83
+ function canUsePostMessage() {
84
+ // The test against `importScripts` prevents this implementation from being installed inside a web worker,
85
+ // where `global.postMessage` means something completely different and can't be used for this purpose.
86
+ if (global.postMessage && !global.importScripts) {
87
+ var postMessageIsAsynchronous = true;
88
+ var oldOnMessage = global.onmessage;
89
+ global.onmessage = function() {
90
+ postMessageIsAsynchronous = false;
91
+ };
92
+ global.postMessage("", "*");
93
+ global.onmessage = oldOnMessage;
94
+ return postMessageIsAsynchronous;
95
+ }
96
+ }
97
+
98
+ function installPostMessageImplementation() {
99
+ // Installs an event handler on `global` for the `message` event: see
100
+ // * https://developer.mozilla.org/en/DOM/window.postMessage
101
+ // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
102
+
103
+ var messagePrefix = "setImmediate$" + Math.random() + "$";
104
+ var onGlobalMessage = function(event) {
105
+ if (event.source === global &&
106
+ typeof event.data === "string" &&
107
+ event.data.indexOf(messagePrefix) === 0) {
108
+ runIfPresent(+event.data.slice(messagePrefix.length));
109
+ }
110
+ };
111
+
112
+ if (global.addEventListener) {
113
+ global.addEventListener("message", onGlobalMessage, false);
114
+ } else {
115
+ global.attachEvent("onmessage", onGlobalMessage);
116
+ }
117
+
118
+ registerImmediate = function(handle) {
119
+ global.postMessage(messagePrefix + handle, "*");
120
+ };
121
+ }
122
+
123
+ function installMessageChannelImplementation() {
124
+ var channel = new MessageChannel();
125
+ channel.port1.onmessage = function(event) {
126
+ var handle = event.data;
127
+ runIfPresent(handle);
128
+ };
129
+
130
+ registerImmediate = function(handle) {
131
+ channel.port2.postMessage(handle);
132
+ };
133
+ }
134
+
135
+ function installReadyStateChangeImplementation() {
136
+ var html = doc.documentElement;
137
+ registerImmediate = function(handle) {
138
+ // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
139
+ // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
140
+ var script = doc.createElement("script");
141
+ script.onreadystatechange = function () {
142
+ runIfPresent(handle);
143
+ script.onreadystatechange = null;
144
+ html.removeChild(script);
145
+ script = null;
146
+ };
147
+ html.appendChild(script);
148
+ };
149
+ }
150
+
151
+ function installSetTimeoutImplementation() {
152
+ registerImmediate = function(handle) {
153
+ setTimeout(runIfPresent, 0, handle);
154
+ };
155
+ }
156
+
157
+ // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
158
+ var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
159
+ attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
160
+
161
+ // Don't get fooled by e.g. browserify environments.
162
+ if ({}.toString.call(global.process) === "[object process]") {
163
+ // For Node.js before 0.9
164
+ installNextTickImplementation();
165
+
166
+ } else if (canUsePostMessage()) {
167
+ // For non-IE10 modern browsers
168
+ installPostMessageImplementation();
169
+
170
+ } else if (global.MessageChannel) {
171
+ // For web workers, where supported
172
+ installMessageChannelImplementation();
173
+
174
+ } else if (doc && "onreadystatechange" in doc.createElement("script")) {
175
+ // For IE 6–8
176
+ installReadyStateChangeImplementation();
177
+
178
+ } else {
179
+ // For older browsers
180
+ installSetTimeoutImplementation();
181
+ }
182
+ export default {
183
+ setTimeout: setTimeout,
184
+ clearTimeout: clearTimeout
185
+ }
@@ -0,0 +1,110 @@
1
+ import EE from 'events';
2
+ import {inherits} from 'util';
3
+
4
+ import {Duplex} from './readable-stream/duplex.js';
5
+ import {Readable} from './readable-stream/readable.js';
6
+ import {Writable} from './readable-stream/writable.js';
7
+ import {Transform} from './readable-stream/transform.js';
8
+ import {PassThrough} from './readable-stream/passthrough.js';
9
+ inherits(Stream, EE);
10
+ Stream.Readable = Readable;
11
+ Stream.Writable = Writable;
12
+ Stream.Duplex = Duplex;
13
+ Stream.Transform = Transform;
14
+ Stream.PassThrough = PassThrough;
15
+
16
+ // Backwards-compat with node 0.4.x
17
+ Stream.Stream = Stream;
18
+
19
+ export default Stream;
20
+ export {Readable,Writable,Duplex,Transform,PassThrough,Stream}
21
+
22
+ // old-style streams. Note that the pipe method (the only relevant
23
+ // part of this class) is overridden in the Readable class.
24
+
25
+ function Stream() {
26
+ EE.call(this);
27
+ }
28
+
29
+ Stream.prototype.pipe = function(dest, options) {
30
+ var source = this;
31
+
32
+ function ondata(chunk) {
33
+ if (dest.writable) {
34
+ if (false === dest.write(chunk) && source.pause) {
35
+ source.pause();
36
+ }
37
+ }
38
+ }
39
+
40
+ source.on('data', ondata);
41
+
42
+ function ondrain() {
43
+ if (source.readable && source.resume) {
44
+ source.resume();
45
+ }
46
+ }
47
+
48
+ dest.on('drain', ondrain);
49
+
50
+ // If the 'end' option is not supplied, dest.end() will be called when
51
+ // source gets the 'end' or 'close' events. Only dest.end() once.
52
+ if (!dest._isStdio && (!options || options.end !== false)) {
53
+ source.on('end', onend);
54
+ source.on('close', onclose);
55
+ }
56
+
57
+ var didOnEnd = false;
58
+ function onend() {
59
+ if (didOnEnd) return;
60
+ didOnEnd = true;
61
+
62
+ dest.end();
63
+ }
64
+
65
+
66
+ function onclose() {
67
+ if (didOnEnd) return;
68
+ didOnEnd = true;
69
+
70
+ if (typeof dest.destroy === 'function') dest.destroy();
71
+ }
72
+
73
+ // don't leave dangling pipes when there are errors.
74
+ function onerror(er) {
75
+ cleanup();
76
+ if (EE.listenerCount(this, 'error') === 0) {
77
+ throw er; // Unhandled stream error in pipe.
78
+ }
79
+ }
80
+
81
+ source.on('error', onerror);
82
+ dest.on('error', onerror);
83
+
84
+ // remove all the event listeners that were added.
85
+ function cleanup() {
86
+ source.removeListener('data', ondata);
87
+ dest.removeListener('drain', ondrain);
88
+
89
+ source.removeListener('end', onend);
90
+ source.removeListener('close', onclose);
91
+
92
+ source.removeListener('error', onerror);
93
+ dest.removeListener('error', onerror);
94
+
95
+ source.removeListener('end', cleanup);
96
+ source.removeListener('close', cleanup);
97
+
98
+ dest.removeListener('close', cleanup);
99
+ }
100
+
101
+ source.on('end', cleanup);
102
+ source.on('close', cleanup);
103
+
104
+ dest.on('close', cleanup);
105
+
106
+ dest.emit('pipe', source);
107
+
108
+ // Allow for unix-like usage: A.pipe(B).pipe(C)
109
+ return dest;
110
+ };
@@ -0,0 +1,220 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ import {Buffer} from 'buffer';
23
+ var isBufferEncoding = Buffer.isEncoding
24
+ || function(encoding) {
25
+ switch (encoding && encoding.toLowerCase()) {
26
+ case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
27
+ default: return false;
28
+ }
29
+ }
30
+
31
+
32
+ function assertEncoding(encoding) {
33
+ if (encoding && !isBufferEncoding(encoding)) {
34
+ throw new Error('Unknown encoding: ' + encoding);
35
+ }
36
+ }
37
+
38
+ // StringDecoder provides an interface for efficiently splitting a series of
39
+ // buffers into a series of JS strings without breaking apart multi-byte
40
+ // characters. CESU-8 is handled as part of the UTF-8 encoding.
41
+ //
42
+ // @TODO Handling all encodings inside a single object makes it very difficult
43
+ // to reason about this code, so it should be split up in the future.
44
+ // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
45
+ // points as used by CESU-8.
46
+ export function StringDecoder(encoding) {
47
+ this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
48
+ assertEncoding(encoding);
49
+ switch (this.encoding) {
50
+ case 'utf8':
51
+ // CESU-8 represents each of Surrogate Pair by 3-bytes
52
+ this.surrogateSize = 3;
53
+ break;
54
+ case 'ucs2':
55
+ case 'utf16le':
56
+ // UTF-16 represents each of Surrogate Pair by 2-bytes
57
+ this.surrogateSize = 2;
58
+ this.detectIncompleteChar = utf16DetectIncompleteChar;
59
+ break;
60
+ case 'base64':
61
+ // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
62
+ this.surrogateSize = 3;
63
+ this.detectIncompleteChar = base64DetectIncompleteChar;
64
+ break;
65
+ default:
66
+ this.write = passThroughWrite;
67
+ return;
68
+ }
69
+
70
+ // Enough space to store all bytes of a single character. UTF-8 needs 4
71
+ // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
72
+ this.charBuffer = new Buffer(6);
73
+ // Number of bytes received for the current incomplete multi-byte character.
74
+ this.charReceived = 0;
75
+ // Number of bytes expected for the current incomplete multi-byte character.
76
+ this.charLength = 0;
77
+ };
78
+
79
+
80
+ // write decodes the given buffer and returns it as JS string that is
81
+ // guaranteed to not contain any partial multi-byte characters. Any partial
82
+ // character found at the end of the buffer is buffered up, and will be
83
+ // returned when calling write again with the remaining bytes.
84
+ //
85
+ // Note: Converting a Buffer containing an orphan surrogate to a String
86
+ // currently works, but converting a String to a Buffer (via `new Buffer`, or
87
+ // Buffer#write) will replace incomplete surrogates with the unicode
88
+ // replacement character. See https://codereview.chromium.org/121173009/ .
89
+ StringDecoder.prototype.write = function(buffer) {
90
+ var charStr = '';
91
+ // if our last write ended with an incomplete multibyte character
92
+ while (this.charLength) {
93
+ // determine how many remaining bytes this buffer has to offer for this char
94
+ var available = (buffer.length >= this.charLength - this.charReceived) ?
95
+ this.charLength - this.charReceived :
96
+ buffer.length;
97
+
98
+ // add the new bytes to the char buffer
99
+ buffer.copy(this.charBuffer, this.charReceived, 0, available);
100
+ this.charReceived += available;
101
+
102
+ if (this.charReceived < this.charLength) {
103
+ // still not enough chars in this buffer? wait for more ...
104
+ return '';
105
+ }
106
+
107
+ // remove bytes belonging to the current character from the buffer
108
+ buffer = buffer.slice(available, buffer.length);
109
+
110
+ // get the character that was split
111
+ charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
112
+
113
+ // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
114
+ var charCode = charStr.charCodeAt(charStr.length - 1);
115
+ if (charCode >= 0xD800 && charCode <= 0xDBFF) {
116
+ this.charLength += this.surrogateSize;
117
+ charStr = '';
118
+ continue;
119
+ }
120
+ this.charReceived = this.charLength = 0;
121
+
122
+ // if there are no more bytes in this buffer, just emit our char
123
+ if (buffer.length === 0) {
124
+ return charStr;
125
+ }
126
+ break;
127
+ }
128
+
129
+ // determine and set charLength / charReceived
130
+ this.detectIncompleteChar(buffer);
131
+
132
+ var end = buffer.length;
133
+ if (this.charLength) {
134
+ // buffer the incomplete character bytes we got
135
+ buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
136
+ end -= this.charReceived;
137
+ }
138
+
139
+ charStr += buffer.toString(this.encoding, 0, end);
140
+
141
+ var end = charStr.length - 1;
142
+ var charCode = charStr.charCodeAt(end);
143
+ // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
144
+ if (charCode >= 0xD800 && charCode <= 0xDBFF) {
145
+ var size = this.surrogateSize;
146
+ this.charLength += size;
147
+ this.charReceived += size;
148
+ this.charBuffer.copy(this.charBuffer, size, 0, size);
149
+ buffer.copy(this.charBuffer, 0, 0, size);
150
+ return charStr.substring(0, end);
151
+ }
152
+
153
+ // or just emit the charStr
154
+ return charStr;
155
+ };
156
+
157
+ // detectIncompleteChar determines if there is an incomplete UTF-8 character at
158
+ // the end of the given buffer. If so, it sets this.charLength to the byte
159
+ // length that character, and sets this.charReceived to the number of bytes
160
+ // that are available for this character.
161
+ StringDecoder.prototype.detectIncompleteChar = function(buffer) {
162
+ // determine how many bytes we have to check at the end of this buffer
163
+ var i = (buffer.length >= 3) ? 3 : buffer.length;
164
+
165
+ // Figure out if one of the last i bytes of our buffer announces an
166
+ // incomplete char.
167
+ for (; i > 0; i--) {
168
+ var c = buffer[buffer.length - i];
169
+
170
+ // See http://en.wikipedia.org/wiki/UTF-8#Description
171
+
172
+ // 110XXXXX
173
+ if (i == 1 && c >> 5 == 0x06) {
174
+ this.charLength = 2;
175
+ break;
176
+ }
177
+
178
+ // 1110XXXX
179
+ if (i <= 2 && c >> 4 == 0x0E) {
180
+ this.charLength = 3;
181
+ break;
182
+ }
183
+
184
+ // 11110XXX
185
+ if (i <= 3 && c >> 3 == 0x1E) {
186
+ this.charLength = 4;
187
+ break;
188
+ }
189
+ }
190
+ this.charReceived = i;
191
+ };
192
+
193
+ StringDecoder.prototype.end = function(buffer) {
194
+ var res = '';
195
+ if (buffer && buffer.length)
196
+ res = this.write(buffer);
197
+
198
+ if (this.charReceived) {
199
+ var cr = this.charReceived;
200
+ var buf = this.charBuffer;
201
+ var enc = this.encoding;
202
+ res += buf.slice(0, cr).toString(enc);
203
+ }
204
+
205
+ return res;
206
+ };
207
+
208
+ function passThroughWrite(buffer) {
209
+ return buffer.toString(this.encoding);
210
+ }
211
+
212
+ function utf16DetectIncompleteChar(buffer) {
213
+ this.charReceived = buffer.length % 2;
214
+ this.charLength = this.charReceived ? 2 : 0;
215
+ }
216
+
217
+ function base64DetectIncompleteChar(buffer) {
218
+ this.charReceived = buffer.length % 3;
219
+ this.charLength = this.charReceived ? 3 : 0;
220
+ }
@@ -0,0 +1,76 @@
1
+ // License https://jryans.mit-license.org/
2
+
3
+ import {setImmediate, clearImmediate} from './setimmediate';
4
+ export {setImmediate, clearImmediate};
5
+ // DOM APIs, for completeness
6
+ var apply = Function.prototype.apply;
7
+
8
+ export function clearInterval(timeout) {
9
+ if (typeof timeout === 'number' && typeof global.clearInterval === 'function') {
10
+ global.clearInterval(timeout);
11
+ } else {
12
+ clearFn(timeout)
13
+ }
14
+ }
15
+ export function clearTimeout(timeout) {
16
+ if (typeof timeout === 'number' && typeof global.clearTimeout === 'function') {
17
+ global.clearTimeout(timeout);
18
+ } else {
19
+ clearFn(timeout)
20
+ }
21
+ }
22
+ function clearFn(timeout) {
23
+ if (timeout && typeof timeout.close === 'function') {
24
+ timeout.close();
25
+ }
26
+ }
27
+ export function setTimeout() {
28
+ return new Timeout(apply.call(global.setTimeout, window, arguments), clearTimeout);
29
+ }
30
+ export function setInterval() {
31
+ return new Timeout(apply.call(global.setInterval, window, arguments), clearInterval);
32
+ }
33
+
34
+ function Timeout(id) {
35
+ this._id = id;
36
+ }
37
+ Timeout.prototype.unref = Timeout.prototype.ref = function() {};
38
+ Timeout.prototype.close = function() {
39
+ clearFn(this._id);
40
+ }
41
+
42
+ // Does not start the time, just sets up the members needed.
43
+ export function enroll(item, msecs) {
44
+ clearTimeout(item._idleTimeoutId);
45
+ item._idleTimeout = msecs;
46
+ }
47
+
48
+ export function unenroll(item) {
49
+ clearTimeout(item._idleTimeoutId);
50
+ item._idleTimeout = -1;
51
+ }
52
+ export var _unrefActive = active;
53
+ export function active(item) {
54
+ clearTimeout(item._idleTimeoutId);
55
+
56
+ var msecs = item._idleTimeout;
57
+ if (msecs >= 0) {
58
+ item._idleTimeoutId = setTimeout(function onTimeout() {
59
+ if (item._onTimeout)
60
+ item._onTimeout();
61
+ }, msecs);
62
+ }
63
+ }
64
+
65
+ export default {
66
+ setImmediate: setImmediate,
67
+ clearImmediate: clearImmediate,
68
+ setTimeout: setTimeout,
69
+ clearTimeout: clearTimeout,
70
+ setInterval: setInterval,
71
+ clearInterval: clearInterval,
72
+ active: active,
73
+ unenroll: unenroll,
74
+ _unrefActive: _unrefActive,
75
+ enroll: enroll
76
+ };
package/src/es6/tty.js ADDED
@@ -0,0 +1,20 @@
1
+ // MIT lisence
2
+ // from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js
3
+
4
+ export function isatty() {
5
+ return false;
6
+ }
7
+
8
+ export function ReadStream() {
9
+ throw new Error('tty.ReadStream is not implemented');
10
+ }
11
+
12
+ export function WriteStream() {
13
+ throw new Error('tty.ReadStream is not implemented');
14
+ }
15
+
16
+ export default {
17
+ isatty: isatty,
18
+ ReadStream: ReadStream,
19
+ WriteStream: WriteStream
20
+ }