Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@jest/fake-timers

Package Overview
Dependencies
99
Maintainers
7
Versions
116
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 24.5.0 to 24.6.0

tsconfig.tsbuildinfo

105

build/jestFakeTimers.js

@@ -18,20 +18,2 @@ 'use strict';

function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(
Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
})
);
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _defineProperty(obj, key, value) {

@@ -60,2 +42,32 @@ if (key in obj) {

constructor({global, moduleMocker, timerConfig, config, maxLoops}) {
_defineProperty(this, '_cancelledImmediates', void 0);
_defineProperty(this, '_cancelledTicks', void 0);
_defineProperty(this, '_config', void 0);
_defineProperty(this, '_disposed', void 0);
_defineProperty(this, '_fakeTimerAPIs', void 0);
_defineProperty(this, '_global', void 0);
_defineProperty(this, '_immediates', void 0);
_defineProperty(this, '_maxLoops', void 0);
_defineProperty(this, '_moduleMocker', void 0);
_defineProperty(this, '_now', void 0);
_defineProperty(this, '_ticks', void 0);
_defineProperty(this, '_timerAPIs', void 0);
_defineProperty(this, '_timers', void 0);
_defineProperty(this, '_uuidCounter', void 0);
_defineProperty(this, '_timerConfig', void 0);
this._global = global;

@@ -87,5 +99,3 @@ this._timerConfig = timerConfig;

for (const uuid in this._timers) {
delete this._timers[uuid];
}
this._timers.clear();
}

@@ -104,3 +114,3 @@

this._immediates = [];
this._timers = {};
this._timers = new Map();
}

@@ -211,3 +221,6 @@

runOnlyPendingTimers() {
const timers = _objectSpread({}, this._timers);
// We need to hold the current shape of `this._timers` because existing
// timers can add new ones to the map and hence would run more than necessary.
// See https://github.com/facebook/jest/pull/4608 for details
const timerEntries = Array.from(this._timers.entries());

@@ -218,5 +231,5 @@ this._checkFakeTimers();

Object.keys(timers)
.sort((left, right) => timers[left].expiry - timers[right].expiry)
.forEach(this._runTimerHandle, this);
timerEntries
.sort(([, left], [, right]) => left.expiry - right.expiry)
.forEach(([timerHandle]) => this._runTimerHandle(timerHandle));
}

@@ -237,4 +250,10 @@

const nextTimerExpiry = this._timers[timerHandle].expiry;
const timerValue = this._timers.get(timerHandle);
if (timerValue === undefined) {
break;
}
const nextTimerExpiry = timerValue.expiry;
if (this._now + msToRun < nextTimerExpiry) {

@@ -322,3 +341,3 @@ // There are no timers between now and the target we're running to, so

return Object.keys(this._timers).length;
return this._timers.size + this._immediates.length + this._ticks.length;
}

@@ -367,4 +386,4 @@

if (uuid && this._timers.hasOwnProperty(uuid)) {
delete this._timers[String(uuid)];
if (uuid) {
this._timers.delete(String(uuid));
}

@@ -455,3 +474,4 @@ }

const uuid = this._uuidCounter++;
this._timers[String(uuid)] = {
this._timers.set(String(uuid), {
callback: (function(_callback3) {

@@ -471,3 +491,4 @@ function callback() {

type: 'interval'
};
});
return this._timerConfig.idToRef(uuid);

@@ -483,3 +504,4 @@ }

const uuid = this._uuidCounter++;
this._timers[String(uuid)] = {
this._timers.set(String(uuid), {
callback: (function(_callback4) {

@@ -499,3 +521,4 @@ function callback() {

type: 'timeout'
};
});
return this._timerConfig.idToRef(uuid);

@@ -506,9 +529,5 @@ }

let nextTimerHandle = null;
let uuid;
let soonestTime = MS_IN_A_YEAR;
let timer;
for (uuid in this._timers) {
timer = this._timers[uuid];
this._timers.forEach((timer, uuid) => {
if (timer.expiry < soonestTime) {

@@ -518,3 +537,3 @@ soonestTime = timer.expiry;

}
}
});

@@ -525,3 +544,3 @@ return nextTimerHandle;

_runTimerHandle(timerHandle) {
const timer = this._timers[timerHandle];
const timer = this._timers.get(timerHandle);

@@ -535,3 +554,5 @@ if (!timer) {

const callback = timer.callback;
delete this._timers[timerHandle];
this._timers.delete(timerHandle);
callback();

@@ -538,0 +559,0 @@ break;

11

package.json
{
"name": "@jest/fake-timers",
"version": "24.5.0",
"version": "24.6.0",
"repository": {

@@ -13,6 +13,5 @@ "type": "git",

"dependencies": {
"@jest/types": "^24.5.0",
"@types/node": "*",
"jest-message-util": "^24.5.0",
"jest-mock": "^24.5.0"
"@jest/types": "^24.6.0",
"jest-message-util": "^24.6.0",
"jest-mock": "^24.6.0"
},

@@ -25,3 +24,3 @@ "engines": {

},
"gitHead": "800533020f5b2f153615c821ed7cb12fd868fa6f"
"gitHead": "04e6a66d2ba8b18bee080bb28547db74a255d2c7"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc