1
1
package io .scalajs
2
2
3
3
import com .thoughtworks .enableIf
4
- import io .scalajs .nodejs .buffer .Buffer
5
4
import io .scalajs .nodejs .timers ._
6
5
7
6
import scala .concurrent .duration .FiniteDuration
@@ -54,10 +53,6 @@ package object nodejs {
54
53
// The handle object can be either a server, a socket (anything with an underlying _handle member), or an object with an fd member that is a valid file descriptor.
55
54
type Handle = js.Function | HasHandle | HasFileDescriptor
56
55
57
- type ReaddirArrays = js.Array [String ] | js.Array [Buffer ]
58
- @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
59
- type ReaddirArrays2 = ReaddirArrays | js.Array [fs.Dirent ]
60
-
61
56
// ///////////////////////////////////////////////////////////////////////////////
62
57
// Built-in Properties
63
58
// ///////////////////////////////////////////////////////////////////////////////
@@ -82,15 +77,18 @@ package object nodejs {
82
77
*/
83
78
def __filename : String = js.Dynamic .global.__filename.asInstanceOf [String ]
84
79
85
- /**
86
- * In browsers, the top-level scope is the global scope. That means that in browsers if you're in the global scope
87
- * var something will define a global variable. In Node.js this is different. The top-level scope is not the global
88
- * scope; var something inside a Node.js module will be local to that module.
89
- */
90
80
@ js.native
91
81
@ JSGlobal (" global" )
82
+ @ deprecated(" Use objects in io.scalajs.nodejs" , " 0.9.0" )
92
83
object global extends Global
93
84
85
+ @ js.native
86
+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs12)
87
+ @ JSGlobal (" queueMicrotask" )
88
+ object queueMicrotask extends js.Function1 [js.Function , Unit ] {
89
+ override def apply (arg1 : js.Function ): Unit = js.native
90
+ }
91
+
94
92
// ///////////////////////////////////////////////////////////////////////////////
95
93
// Timers
96
94
// ///////////////////////////////////////////////////////////////////////////////
@@ -107,10 +105,6 @@ package object nodejs {
107
105
@ JSGlobal (" clearTimeout" )
108
106
object clearTimeout extends ClearTimeout
109
107
110
- @ js.native
111
- @ JSGlobal (" ref" )
112
- object ref extends Ref
113
-
114
108
@ js.native
115
109
@ JSGlobal (" setImmediate" )
116
110
object setImmediate extends SetImmediate
@@ -123,10 +117,6 @@ package object nodejs {
123
117
@ JSGlobal (" setTimeout" )
124
118
object setTimeout extends SetTimeout
125
119
126
- @ js.native
127
- @ JSGlobal (" unref" )
128
- object unref extends UnRef
129
-
130
120
// ///////////////////////////////////////////////////////////////////////////////
131
121
// Implicit Conversions
132
122
// ///////////////////////////////////////////////////////////////////////////////
@@ -136,86 +126,23 @@ package object nodejs {
136
126
* @param duration the given [[FiniteDuration duration ]]
137
127
* @return the time in milliseconds as an integer
138
128
*/
129
+ @ deprecated(" Use io.scalajs.util.DurationHelper" , " 0.9.0" )
139
130
implicit def duration2Int (duration : FiniteDuration ): Int = duration.toMillis.toInt
140
131
141
132
/**
142
133
* Implicit conversion to translate durations into a double
143
134
* @param duration the given [[FiniteDuration duration ]]
144
135
* @return the time in milliseconds as a double
145
136
*/
137
+ @ deprecated(" Use io.scalajs.util.DurationHelper" , " 0.9.0" )
146
138
implicit def duration2Double (duration : FiniteDuration ): Double = duration.toMillis.toDouble
147
139
148
140
/**
149
141
* Implicit conversion to transform Node [[Error ]]s to [[Exception ]]s
150
142
* @param error the given [[Error ]]
151
143
* @return the resulting [[Exception ]]
152
144
*/
153
- implicit def error2Exception (error : Error ): Exception = js.JavaScriptException (error.message)
154
-
155
- // ///////////////////////////////////////////////////////////////////////////////
156
- // Exit Codes - Node.js will normally exit with a 0 status code when no more
157
- // async operations are pending. The following status codes are
158
- // used in other cases:
159
- // ///////////////////////////////////////////////////////////////////////////////
160
-
161
- type ExitCode = Int
162
-
163
- /**
164
- * There was an uncaught exception, and it was not handled by a domain or an 'uncaughtException' event handler.
165
- */
166
- val UncaughtFatalException : ExitCode = 1
167
-
168
- /**
169
- * The JavaScript source code internal in Node.js's bootstrapping process caused a parse error. This is extremely
170
- * rare, and generally can only happen during development of Node.js itself.
171
- */
172
- val InternalJavaScriptParseError : ExitCode = 3
173
-
174
- /**
175
- * The JavaScript source code internal in Node.js's bootstrapping process failed to return a function value when
176
- * evaluated. This is extremely rare, and generally can only happen during development of Node.js itself.
177
- */
178
- val InternalJavaScriptEvaluationFailure : ExitCode = 4
179
-
180
- /**
181
- * There was a fatal unrecoverable error in V8. Typically a message will be printed to stderr with the prefix FATAL ERROR.
182
- */
183
- val FatalError : ExitCode = 5
184
-
185
- /**
186
- * There was an uncaught exception, but the internal fatal exception handler function was somehow set to a non-function,
187
- * and could not be called.
188
- */
189
- val NonFunctionInternalExceptionHandler : ExitCode = 6
190
-
191
- /**
192
- * There was an uncaught exception, and the internal fatal exception handler function itself threw an error while
193
- * attempting to handle it. This can happen, for example, if a 'uncaughtException' or domain.on('error') handler
194
- * throws an error.
195
- */
196
- val InternalExceptionHandlerRunTimeFailure : ExitCode = 7
197
-
198
- /**
199
- * Either an unknown option was specified, or an option requiring a value was provided without a value.
200
- */
201
- val InvalidArgument : ExitCode = 8
202
-
203
- /**
204
- * The JavaScript source code internal in Node.js's bootstrapping process threw an error when the bootstrapping
205
- * function was called. This is extremely rare, and generally can only happen during development of Node.js itself.
206
- */
207
- val InternalJavaScriptRunTimeFailure : ExitCode = 10
208
-
209
- /**
210
- * The --debug and/or --debug-brk options were set, but an invalid port number was chosen.
211
- */
212
- val InvalidDebugArgument : ExitCode = 12
213
-
214
- /**
215
- * If Node.js receives a fatal signal such as SIGKILL or SIGHUP, then its exit code will be 128 plus the value of
216
- * the signal code. This is a standard Unix practice, since exit codes are defined to be 7-bit integers, and signal
217
- * exits set the high-order bit, and then contain the value of the signal code.
218
- */
219
- val SignalExits : ExitCode = 128
220
-
145
+ @ deprecated(" Use toException extension method from io.scalajs.util.NodeJSConverters._" , " 0.9.0" )
146
+ implicit def error2Exception (error : Error ): Exception =
147
+ io.scalajs.util.NodeJSConverters .ErrorExtension (error).toException()
221
148
}
0 commit comments