-
Notifications
You must be signed in to change notification settings - Fork 63
/
Node.hx
181 lines (156 loc) · 5.69 KB
/
Node.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
* Copyright (C)2014-2020 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package js;
import haxe.Constraints.Function;
import haxe.extern.Rest;
import js.node.Module;
import js.node.Process;
import js.node.Timers.Immediate;
import js.node.Timers.Timeout;
import js.node.console.Console;
#if haxe4
import js.Syntax.code;
#end
/**
Node.js globals
**/
@:native("global")
extern class Node {
/**
This variable may appear to be global but is not. See [__dirname](https://nodejs.org/api/modules.html#modules_dirname).
**/
static var __dirname(get, never):String;
private static inline function get___dirname():String {
#if haxe4
return code("__dirname");
#else
return untyped __js__("__dirname");
#end
}
/**
This variable may appear to be global but is not. See [__filename](https://nodejs.org/api/modules.html#modules_filename).
**/
static var __filename(get, never):String;
private static inline function get___filename():String {
#if haxe4
return code("__filename");
#else
return untyped __js__("__filename");
#end
}
/**
`clearImmediate` is described in the [timers](https://nodejs.org/api/timers.html) section.
**/
static function clearImmediate(immediate:Immediate):Void;
/**
`clearInterval` is described in the [timers](https://nodejs.org/api/timers.html) section.
**/
static function clearInterval(timeout:Timeout):Void;
/**
`clearTimeout` is described in the [timers](https://nodejs.org/api/timers.html) section.
**/
static function clearTimeout(timeout:Timeout):Void;
/**
Used to print to stdout and stderr. See the [console](https://nodejs.org/api/console.html) section.
**/
static var console(get, never):Console;
private static inline function get_console():Console {
#if haxe4
return code("console");
#else
return untyped __js__("console");
#end
}
/**
This variable may appear to be global but is not. See [exports](https://nodejs.org/api/modules.html#modules_exports).
**/
static var exports(get, never):Dynamic<Dynamic>;
private static inline function get_exports():Dynamic<Dynamic> {
#if haxe4
return code("exports");
#else
return untyped __js__("exports");
#end
}
/**
In browsers, the top-level scope is the global scope.
This means that within the browser `var something` will define a new global variable.
In Node.js this is different. The top-level scope is not the global scope; `var something` inside a Node.js module
will be local to that module.
**/
static inline var global:Dynamic<Dynamic> = cast Node;
/**
This variable may appear to be global but is not. See [module](https://nodejs.org/api/modules.html#modules_module).
**/
static var module(get, never):Module;
private static inline function get_module():Module {
#if haxe4
return code("module");
#else
return untyped __js__("module");
#end
}
/**
The process object. See the [process object](https://nodejs.org/api/process.html#process_process) section.
**/
static var process(get, never):Process;
private static inline function get_process():Process {
#if haxe4
return code("process");
#else
return untyped __js__("process");
#end
}
/**
The `queueMicrotask()` method queues a microtask to invoke `callback`.
If `callback` throws an exception, the [process object](https://nodejs.org/api/process.html#process_process) 'uncaughtException' event will be emitted.
The microtask queue is managed by V8 and may be used in a similar manner to the `Process.nextTick()` queue,
which is managed by Node.js.
The `Process.nextTick()` queue is always processed before the microtask queue within each turn of the Node.js event loop.
**/
static function queueMicrotask(callback:Void->Void):Void;
/**
This variable may appear to be global but is not. See [require()](https://nodejs.org/api/modules.html#modules_require_id).
**/
static inline function require(module:String):Dynamic {
#if haxe4
return code("require({0})", module);
#else
return untyped __js__("require({0})", module);
#end
}
/**
`setImmediate` is described in the [timers](https://nodejs.org/api/timers.html) section.
**/
static function setImmediate(callback:Function, args:Rest<Dynamic>):Immediate;
/**
`setInterval` is described in the [timers](https://nodejs.org/api/timers.html) section.
**/
static function setInterval(callback:Function, delay:Int, args:Rest<Dynamic>):Timeout;
/**
`setTimeout` is described in the [timers](https://nodejs.org/api/timers.html) section.
**/
static function setTimeout(callback:Function, delay:Int, args:Rest<Dynamic>):Timeout;
}
@:deprecated typedef TimeoutObject = js.node.Timers.Timeout;
@:deprecated typedef IntervalObject = js.node.Timers.Timeout;
@:deprecated typedef ImmediateObject = js.node.Timers.Immediate;