@jest/fake-timers
Advanced tools
Comparing version 24.9.0 to 25.0.0
@@ -8,3 +8,3 @@ 'use strict'; | ||
enumerable: true, | ||
get: function get() { | ||
get: function() { | ||
return _jestFakeTimers.default; | ||
@@ -11,0 +11,0 @@ } |
@@ -16,3 +16,2 @@ /** | ||
export default class FakeTimers<TimerRef> { | ||
private _cancelledImmediates; | ||
private _cancelledTicks; | ||
@@ -19,0 +18,0 @@ private _config; |
@@ -11,3 +11,3 @@ 'use strict'; | ||
_jestMessageUtil = function _jestMessageUtil() { | ||
_jestMessageUtil = function() { | ||
return data; | ||
@@ -42,4 +42,2 @@ }; | ||
constructor({global, moduleMocker, timerConfig, config, maxLoops}) { | ||
_defineProperty(this, '_cancelledImmediates', void 0); | ||
_defineProperty(this, '_cancelledTicks', void 0); | ||
@@ -95,5 +93,3 @@ | ||
clearAllTimers() { | ||
this._immediates.forEach(immediate => | ||
this._fakeClearImmediate(immediate.uuid) | ||
); | ||
this._immediates = []; | ||
@@ -110,3 +106,2 @@ this._timers.clear(); | ||
this._cancelledTicks = {}; | ||
this._cancelledImmediates = {}; | ||
this._now = 0; | ||
@@ -174,6 +169,6 @@ this._ticks = []; | ||
_runImmediate(immediate) { | ||
if (!this._cancelledImmediates.hasOwnProperty(immediate.uuid)) { | ||
// Callback may throw, so update the map prior calling. | ||
this._cancelledImmediates[immediate.uuid] = true; | ||
try { | ||
immediate.callback(); | ||
} finally { | ||
this._fakeClearImmediate(immediate.uuid); | ||
} | ||
@@ -408,3 +403,5 @@ } | ||
_fakeClearImmediate(uuid) { | ||
this._cancelledImmediates[uuid] = true; | ||
this._immediates = this._immediates.filter( | ||
immediate => immediate.uuid !== uuid | ||
); | ||
} | ||
@@ -420,13 +417,3 @@ | ||
this._ticks.push({ | ||
callback: (function(_callback) { | ||
function callback() { | ||
return _callback.apply(this, arguments); | ||
} | ||
callback.toString = function() { | ||
return _callback.toString(); | ||
}; | ||
return callback; | ||
})(() => callback.apply(null, args)), | ||
callback: () => callback.apply(null, args), | ||
uuid | ||
@@ -451,26 +438,16 @@ }); | ||
const uuid = this._uuidCounter++; | ||
const uuid = String(this._uuidCounter++); | ||
this._immediates.push({ | ||
callback: (function(_callback2) { | ||
function callback() { | ||
return _callback2.apply(this, arguments); | ||
} | ||
callback.toString = function() { | ||
return _callback2.toString(); | ||
}; | ||
return callback; | ||
})(() => callback.apply(null, args)), | ||
uuid: String(uuid) | ||
callback: () => callback.apply(null, args), | ||
uuid | ||
}); | ||
const cancelledImmediates = this._cancelledImmediates; | ||
this._timerAPIs.setImmediate(() => { | ||
if (!cancelledImmediates.hasOwnProperty(uuid)) { | ||
// Callback may throw, so update the map prior calling. | ||
cancelledImmediates[String(uuid)] = true; | ||
callback.apply(null, args); | ||
if (this._immediates.find(x => x.uuid === uuid)) { | ||
try { | ||
callback.apply(null, args); | ||
} finally { | ||
this._fakeClearImmediate(uuid); | ||
} | ||
} | ||
@@ -494,13 +471,3 @@ }); | ||
this._timers.set(String(uuid), { | ||
callback: (function(_callback3) { | ||
function callback() { | ||
return _callback3.apply(this, arguments); | ||
} | ||
callback.toString = function() { | ||
return _callback3.toString(); | ||
}; | ||
return callback; | ||
})(() => callback.apply(null, args)), | ||
callback: () => callback.apply(null, args), | ||
expiry: this._now + intervalDelay, | ||
@@ -523,13 +490,3 @@ interval: intervalDelay, | ||
this._timers.set(String(uuid), { | ||
callback: (function(_callback4) { | ||
function callback() { | ||
return _callback4.apply(this, arguments); | ||
} | ||
callback.toString = function() { | ||
return _callback4.toString(); | ||
}; | ||
return callback; | ||
})(() => callback.apply(null, args)), | ||
callback: () => callback.apply(null, args), | ||
expiry: this._now + delay, | ||
@@ -536,0 +493,0 @@ interval: undefined, |
{ | ||
"name": "@jest/fake-timers", | ||
"version": "24.9.0", | ||
"version": "25.0.0", | ||
"repository": { | ||
@@ -13,8 +13,8 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/types": "^24.9.0", | ||
"jest-message-util": "^24.9.0", | ||
"jest-mock": "^24.9.0" | ||
"@jest/types": "^25.0.0", | ||
"jest-message-util": "^25.0.0", | ||
"jest-mock": "^25.0.0" | ||
}, | ||
"engines": { | ||
"node": ">= 6" | ||
"node": ">= 8" | ||
}, | ||
@@ -24,3 +24,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "9ad0f4bc6b8bdd94989804226c28c9960d9da7d1" | ||
"gitHead": "ff9269be05fd8316e95232198fce3463bf2f270e" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19875
502
+ Added@jest/types@25.5.0(transitive)
+ Added@types/yargs@15.0.19(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchalk@3.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedjest-message-util@25.5.0(transitive)
+ Addedjest-mock@25.5.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
- Removed@jest/console@24.9.0(transitive)
- Removed@jest/source-map@24.9.0(transitive)
- Removed@jest/test-result@24.9.0(transitive)
- Removed@jest/types@24.9.0(transitive)
- Removed@types/yargs@13.0.12(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedcallsites@3.1.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedjest-message-util@24.9.0(transitive)
- Removedjest-mock@24.9.0(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedslash@2.0.0(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.70.6.1(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
Updated@jest/types@^25.0.0
Updatedjest-message-util@^25.0.0
Updatedjest-mock@^25.0.0