| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2270285 commit fe922f0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | const { | |
| 25 | 25 | MathTrunc, | |
| 26 | 26 | ObjectDefineProperty, | |
| 27 | + ObjectDefineProperties, | ||
| 27 | 28 | SymbolDispose, | |
| 28 | 29 | SymbolToPrimitive, | |
| 29 | 30 | } = primordials; | |
@@ -62,6 +63,7 @@ let debug = require('internal/util/debuglog').debuglog('timer', (fn) => { | |||
| 62 | 63 | const { validateFunction } = require('internal/validators'); | |
| 63 | 64 | ||
| 64 | 65 | let timersPromises; | |
| 66 | + let timers; | ||
| 65 | 67 | ||
| 66 | 68 | const { | |
| 67 | 69 | destroyHooksExist, | |
@@ -347,7 +349,7 @@ Immediate.prototype[SymbolDispose] = function() { | |||
| 347 | 349 | clearImmediate(this); | |
| 348 | 350 | }; | |
| 349 | 351 | ||
| 350 | - module.exports = { | ||
| 352 | + module.exports = timers = { | ||
| 351 | 353 | setTimeout, | |
| 352 | 354 | clearTimeout, | |
| 353 | 355 | setImmediate, | |
@@ -372,3 +374,15 @@ module.exports = { | |||
| 372 | 374 | 'timers.enroll() is deprecated. Please use setTimeout instead.', | |
| 373 | 375 | 'DEP0095'), | |
| 374 | 376 | }; | |
| 377 | + | ||
| 378 | + ObjectDefineProperties(timers, { | ||
| 379 | + promises: { | ||
| 380 | + __proto__: null, | ||
| 381 | + configurable: true, | ||
| 382 | + enumerable: true, | ||
| 383 | + get() { | ||
| 384 | + timersPromises ??= require('timers/promises'); | ||
| 385 | + return timersPromises; | ||
| 386 | + }, | ||
| 387 | + }, | ||
| 388 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,12 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + | ||
| 5 | + const timer = require('node:timers'); | ||
| 6 | + const timerPromises = require('node:timers/promises'); | ||
| 7 | + const assert = require('assert'); | ||
| 8 | + const { test } = require('node:test'); | ||
| 9 | + | ||
| 10 | + test('(node:timers/promises) is equal to (node:timers).promises', common.mustCall(() => { | ||
| 11 | + assert.deepStrictEqual(timerPromises, timer.promises); | ||
| 12 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments