Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-util

Package Overview
Dependencies
Maintainers
5
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-util - npm Package Compare versions

Comparing version 13.1.2 to 13.2.1

128

build/FakeTimers.js

@@ -16,2 +16,3 @@ /**

const fn = impl => mocks.getMockFn().mockImpl(impl);

@@ -43,2 +44,3 @@

const MS_IN_A_YEAR = 31536000000;

@@ -69,3 +71,3 @@

// Store original timer APIs for future reference
this._originalTimerAPIs = {
this._timerAPIs = {
clearImmediate: global.clearImmediate,

@@ -80,22 +82,10 @@ clearInterval: global.clearInterval,

this._fakeTimerAPIs = {
setTimeout: mocks.getMockFn().mockImpl(
this._fakeSetTimeout.bind(this)),
clearImmediate: fn(this._fakeClearImmediate.bind(this)),
clearInterval: fn(this._fakeClearTimer.bind(this)),
clearTimeout: fn(this._fakeClearTimer.bind(this)),
setImmediate: fn(this._fakeSetImmediate.bind(this)),
setInterval: fn(this._fakeSetInterval.bind(this)),
setTimeout: fn(this._fakeSetTimeout.bind(this)) };
clearTimeout: mocks.getMockFn().mockImpl(
this._fakeClearTimer.bind(this)),
setInterval: mocks.getMockFn().mockImpl(
this._fakeSetInterval.bind(this)),
clearInterval: mocks.getMockFn().mockImpl(
this._fakeClearTimer.bind(this)),
setImmediate: mocks.getMockFn().mockImpl(
this._fakeSetImmediate.bind(this)),
clearImmediate: mocks.getMockFn().mockImpl(
this._fakeClearImmediate.bind(this)) };
// If there's a process.nextTick on the global, mock it out

@@ -105,8 +95,6 @@ // (only applicable to node/node-emulating environments)

typeof global.process.nextTick === 'function') {
this._originalTimerAPIs.nextTick = global.process.nextTick;
this._fakeTimerAPIs.nextTick = mocks.getMockFn().mockImpl(
this._fakeNextTick.bind(this));}
this._timerAPIs.nextTick = global.process.nextTick;
this._fakeTimerAPIs.nextTick = fn(this._fakeNextTick.bind(this));}
this.useFakeTimers();

@@ -134,2 +122,7 @@

dispose() {
this._disposed = true;
this.clearAllTimers();}
reset() {

@@ -281,21 +274,11 @@ this._cancelledTicks = {};

const hasSetImmediate = typeof this._global.setImmediate === 'function';
const prevClearImmediate = this._global.clearImmediate;
const prevClearInterval = this._global.clearInterval;
const prevClearTimeout = this._global.clearTimeout;
const prevSetImmediate = this._global.setImmediate;
const prevSetInterval = this._global.setInterval;
const prevSetTimeout = this._global.setTimeout;
const prevSetInterval = this._global.setInterval;
const prevClearTimeout = this._global.clearTimeout;
const prevClearInterval = this._global.clearInterval;
let prevNextTick;
let prevSetImmediate;
let prevClearImmediate;
const prevNextTick = hasNextTick ? this._global.process.nextTick : null;
if (hasNextTick) {
prevNextTick = this._global.process.nextTick;}
if (hasSetImmediate) {
prevSetImmediate = this._global.setImmediate;
prevClearImmediate = this._global.clearImmediate;}
this.useRealTimers();

@@ -312,14 +295,12 @@

this._global.clearImmediate = prevClearImmediate;
this._global.clearInterval = prevClearInterval;
this._global.clearTimeout = prevClearTimeout;
this._global.setImmediate = prevSetImmediate;
this._global.setInterval = prevSetInterval;
this._global.setTimeout = prevSetTimeout;
this._global.setInterval = prevSetInterval;
this._global.clearTimeout = prevClearTimeout;
this._global.clearInterval = prevClearInterval;
if (hasNextTick) {
this._global.process.nextTick = prevNextTick;}
if (hasSetImmediate) {
this._global.setImmediate = prevSetImmediate;
this._global.clearImmediate = prevClearImmediate;}
if (errThrown) {

@@ -335,17 +316,13 @@ throw cbErr;}}

const hasSetImmediate = typeof this._global.setImmediate === 'function';
this._global.setTimeout = this._originalTimerAPIs.setTimeout;
this._global.setInterval = this._originalTimerAPIs.setInterval;
this._global.clearTimeout = this._originalTimerAPIs.clearTimeout;
this._global.clearInterval = this._originalTimerAPIs.clearInterval;
this._global.clearImmediate = this._timerAPIs.clearImmediate;
this._global.clearInterval = this._timerAPIs.clearInterval;
this._global.clearTimeout = this._timerAPIs.clearTimeout;
this._global.setImmediate = this._timerAPIs.setImmediate;
this._global.setInterval = this._timerAPIs.setInterval;
this._global.setTimeout = this._timerAPIs.setTimeout;
if (hasNextTick) {
this._global.process.nextTick = this._originalTimerAPIs.nextTick;}
this._global.process.nextTick = this._timerAPIs.nextTick;}}
if (hasSetImmediate) {
this._global.setImmediate = this._originalTimerAPIs.setImmediate;
this._global.clearImmediate = this._originalTimerAPIs.clearImmediate;}}
useFakeTimers() {

@@ -356,17 +333,13 @@ const hasNextTick =

const hasSetImmediate = typeof this._global.setImmediate === 'function';
this._global.clearImmediate = this._fakeTimerAPIs.clearImmediate;
this._global.clearInterval = this._fakeTimerAPIs.clearInterval;
this._global.clearTimeout = this._fakeTimerAPIs.clearTimeout;
this._global.setImmediate = this._fakeTimerAPIs.setImmediate;
this._global.setInterval = this._fakeTimerAPIs.setInterval;
this._global.setTimeout = this._fakeTimerAPIs.setTimeout;
this._global.setInterval = this._fakeTimerAPIs.setInterval;
this._global.clearTimeout = this._fakeTimerAPIs.clearTimeout;
this._global.clearInterval = this._fakeTimerAPIs.clearInterval;
if (hasNextTick) {
this._global.process.nextTick = this._fakeTimerAPIs.nextTick;}
this._global.process.nextTick = this._fakeTimerAPIs.nextTick;}}
if (hasSetImmediate) {
this._global.setImmediate = this._fakeTimerAPIs.setImmediate;
this._global.clearImmediate = this._fakeTimerAPIs.clearImmediate;}}
_fakeClearTimer(uuid) {

@@ -383,2 +356,6 @@ if (this._timers.hasOwnProperty(uuid)) {

_fakeNextTick(callback) {
if (this._disposed) {
return;}
const args = [];

@@ -397,3 +374,4 @@ for (let ii = 1, ll = arguments.length; ii < ll; ii++) {

const cancelledTicks = this._cancelledTicks;
this._originalTimerAPIs.nextTick && this._originalTimerAPIs.nextTick(() => {
this._timerAPIs.nextTick && this._timerAPIs.nextTick(() => {
if (this._blocked) {return;}
if (!cancelledTicks.hasOwnProperty(uuid)) {

@@ -408,2 +386,6 @@ // Callback may throw, so update the map prior calling.

_fakeSetImmediate(callback) {
if (this._disposed) {
return null;}
const args = [];

@@ -422,3 +404,3 @@ for (let ii = 1, ll = arguments.length; ii < ll; ii++) {

const cancelledImmediates = this._cancelledImmediates;
this._originalTimerAPIs.setImmediate(() => {
this._timerAPIs.setImmediate(() => {
if (!cancelledImmediates.hasOwnProperty(uuid)) {

@@ -435,2 +417,6 @@ // Callback may throw, so update the map prior calling.

_fakeSetInterval(callback, intervalDelay) {
if (this._disposed) {
return null;}
if (intervalDelay == null) {

@@ -458,2 +444,6 @@ intervalDelay = 0;}

_fakeSetTimeout(callback, delay) {
if (this._disposed) {
return null;}
if (delay == null) {

@@ -460,0 +450,0 @@ delay = 0;}

{
"name": "jest-util",
"version": "13.1.2",
"version": "13.2.1",
"repository": {

@@ -15,3 +15,3 @@ "type": "git",

"mkdirp": "^0.5.1",
"jest-mock": "^13.1.1"
"jest-mock": "^13.2.1"
},

@@ -18,0 +18,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc