Skip to content

Commit b6ed97c

Browse files
ShogunPandatargos
authored andcommitted
timers: document ref option for scheduler.wait
PR-URL: #54605 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
1 parent b8c06dc commit b6ed97c

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎doc/api/timers.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ added:
521521
*`delay` {number} The number of milliseconds to wait before resolving the
522522
promise.
523523
*`options` {Object}
524+
*`ref` {boolean} Set to `false` to indicate that the scheduled `Timeout`
525+
should not require the Node.js event loop to remain active.
526+
**Default:**`true`.
524527
*`signal` {AbortSignal} An optional `AbortSignal` that can be used to
525528
cancel waiting.
526529
* Returns: {Promise}

‎lib/timers/promises.js‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,18 @@ function setImmediate(value, options = kEmptyObject) {
131131
}
132132

133133
asyncfunction*setInterval(after,value,options=kEmptyObject){
134-
try{
135-
if(typeofafter!=='undefined'){
136-
validateNumber(after,'delay');
137-
}
134+
if(typeofafter!=='undefined'){
135+
validateNumber(after,'delay');
136+
}
138137

139-
validateObject(options,'options');
138+
validateObject(options,'options');
140139

141-
if(typeofoptions?.signal!=='undefined'){
142-
validateAbortSignal(options.signal,'options.signal');
143-
}
140+
if(typeofoptions?.signal!=='undefined'){
141+
validateAbortSignal(options.signal,'options.signal');
142+
}
144143

145-
if(typeofoptions?.ref!=='undefined'){
146-
validateBoolean(options.ref,'options.ref');
147-
}
148-
}catch(err){
149-
returnPromiseReject(err);
144+
if(typeofoptions?.ref!=='undefined'){
145+
validateBoolean(options.ref,'options.ref');
150146
}
151147

152148
const{ signal, ref =true}=options;

0 commit comments

Comments
 (0)