@@ -65,59 +65,119 @@ const {
65
65
66
66
let internalDeepEqual ;
67
67
68
+ /**
69
+ * @deprecated since v4.0.0
70
+ * @param {any } arg
71
+ * @returns {arg is boolean }
72
+ */
68
73
function isBoolean ( arg ) {
69
74
return typeof arg === 'boolean' ;
70
75
}
71
76
77
+ /**
78
+ * @deprecated since v4.0.0
79
+ * @param {any } arg
80
+ * @returns {arg is null }
81
+ */
72
82
function isNull ( arg ) {
73
83
return arg === null ;
74
84
}
75
85
86
+ /**
87
+ * @deprecated since v4.0.0
88
+ * @param {any } arg
89
+ * @returns {arg is (null | undefined) }
90
+ */
76
91
function isNullOrUndefined ( arg ) {
77
92
return arg === null || arg === undefined ;
78
93
}
79
94
95
+ /**
96
+ * @deprecated since v4.0.0
97
+ * @param {any } arg
98
+ * @returns {arg is number }
99
+ */
80
100
function isNumber ( arg ) {
81
101
return typeof arg === 'number' ;
82
102
}
83
103
104
+ /**
105
+ * @param {any } arg
106
+ * @returns {arg is string }
107
+ */
84
108
function isString ( arg ) {
85
109
return typeof arg === 'string' ;
86
110
}
87
111
112
+ /**
113
+ * @deprecated since v4.0.0
114
+ * @param {any } arg
115
+ * @returns {arg is symbol }
116
+ */
88
117
function isSymbol ( arg ) {
89
118
return typeof arg === 'symbol' ;
90
119
}
91
120
121
+ /**
122
+ * @deprecated since v4.0.0
123
+ * @param {any } arg
124
+ * @returns {arg is undefined }
125
+ */
92
126
function isUndefined ( arg ) {
93
127
return arg === undefined ;
94
128
}
95
129
130
+ /**
131
+ * @deprecated since v4.0.0
132
+ * @param {any } arg
133
+ * @returns {a is NonNullable<object> }
134
+ */
96
135
function isObject ( arg ) {
97
136
return arg !== null && typeof arg === 'object' ;
98
137
}
99
138
139
+ /**
140
+ * @deprecated since v4.0.0
141
+ * @param {any } e
142
+ * @returns {arg is Error }
143
+ */
100
144
function isError ( e ) {
101
145
return ObjectPrototypeToString ( e ) === '[object Error]' || e instanceof Error ;
102
146
}
103
147
148
+ /**
149
+ * @deprecated since v4.0.0
150
+ * @param {any } arg
151
+ * @returns {arg is Function }
152
+ */
104
153
function isFunction ( arg ) {
105
154
return typeof arg === 'function' ;
106
155
}
107
156
157
+ /**
158
+ * @deprecated since v4.0.0
159
+ * @param {any } arg
160
+ * @returns {arg is (boolean | null | number | string | symbol | undefined) }
161
+ */
108
162
function isPrimitive ( arg ) {
109
163
return arg === null ||
110
164
( typeof arg !== 'object' && typeof arg !== 'function' ) ;
111
165
}
112
166
167
+ /**
168
+ * @param {number } n
169
+ * @returns {string }
170
+ */
113
171
function pad ( n ) {
114
172
return n . toString ( ) . padStart ( 2 , '0' ) ;
115
173
}
116
174
117
175
const months = [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' ,
118
176
'Oct' , 'Nov' , 'Dec' ] ;
119
177
120
- // 26 Feb 16:19:34
178
+ /**
179
+ * @returns {string } 26 Feb 16:19:34
180
+ */
121
181
function timestamp ( ) {
122
182
const d = new Date ( ) ;
123
183
const time = [ pad ( d . getHours ( ) ) ,
@@ -127,7 +187,11 @@ function timestamp() {
127
187
}
128
188
129
189
let console ;
130
- // Log is just a thin wrapper to console.log that prepends a timestamp
190
+ /**
191
+ * Log is just a thin wrapper to console.log that prepends a timestamp
192
+ * @deprecated since v6.0.0
193
+ * @type {(...args: any[]) => void }
194
+ */
131
195
function log ( ...args ) {
132
196
if ( ! console ) {
133
197
console = require ( 'internal/console/global' ) ;
@@ -144,9 +208,9 @@ function log(...args) {
144
208
* functions as prototype setup using normal JavaScript does not work as
145
209
* expected during bootstrapping (see mirror.js in r114903).
146
210
*
147
- * @param {function } ctor Constructor function which needs to inherit the
211
+ * @param {Function } ctor Constructor function which needs to inherit the
148
212
* prototype.
149
- * @param {function } superCtor Constructor function to inherit prototype from.
213
+ * @param {Function } superCtor Constructor function to inherit prototype from.
150
214
* @throws {TypeError } Will error if either constructor is null, or if
151
215
* the super constructor lacks a prototype.
152
216
*/
@@ -170,6 +234,14 @@ function inherits(ctor, superCtor) {
170
234
ObjectSetPrototypeOf ( ctor . prototype , superCtor . prototype ) ;
171
235
}
172
236
237
+ /**
238
+ * @deprecated since v6.0.0
239
+ * @template T
240
+ * @template S
241
+ * @param {T } target
242
+ * @param {S } source
243
+ * @returns {S extends null ? T : (T & S) }
244
+ */
173
245
function _extend ( target , source ) {
174
246
// Don't do anything if source isn't an object
175
247
if ( source === null || typeof source !== 'object' ) return target ;
@@ -193,6 +265,14 @@ const callbackifyOnRejected = hideStackFrames((reason, cb) => {
193
265
return cb ( reason ) ;
194
266
} ) ;
195
267
268
+ /**
269
+ * @template {(...args: any[]) => Promise<any>} T
270
+ * @param {T } original
271
+ * @returns {T extends (...args: infer TArgs) => Promise<infer TReturn> ?
272
+ * ((...params: [...TArgs, ((err: Error, ret: TReturn) => any)]) => void) :
273
+ * never
274
+ * }
275
+ */
196
276
function callbackify ( original ) {
197
277
if ( typeof original !== 'function' ) {
198
278
throw new ERR_INVALID_ARG_TYPE ( 'original' , 'Function' , original ) ;
@@ -227,6 +307,10 @@ function callbackify(original) {
227
307
return callbackified ;
228
308
}
229
309
310
+ /**
311
+ * @param {number } err
312
+ * @returns {string }
313
+ */
230
314
function getSystemErrorName ( err ) {
231
315
validateNumber ( err , 'err' ) ;
232
316
if ( err >= 0 || ! NumberIsSafeInteger ( err ) ) {
0 commit comments