Comparing version 4.2.0 to 5.0.0
5.0.0 / 2019-10-07 | ||
================== | ||
* Avoid installing setImmediate in unsupported environments | ||
* fix #246: non-constructor Date() should return a string | ||
4.2.0 / 2019-08-04 | ||
@@ -3,0 +9,0 @@ ================== |
78
lolex.js
@@ -9,24 +9,2 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.lolex = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
var maxTimeout = Math.pow(2, 31) - 1; //see https://heycam.github.io/webidl/#abstract-opdef-converttoint | ||
// Make properties writable in IE, as per | ||
// http://www.adequatelygood.com/Replacing-setTimeout-Globally.html | ||
if (isRunningInIE) { | ||
_global.setTimeout = _global.setTimeout; | ||
_global.clearTimeout = _global.clearTimeout; | ||
_global.setInterval = _global.setInterval; | ||
_global.clearInterval = _global.clearInterval; | ||
_global.Date = _global.Date; | ||
} | ||
// setImmediate is not a standard function | ||
// avoid adding the prop to the window object if not present | ||
if (_global.setImmediate !== undefined) { | ||
_global.setImmediate = _global.setImmediate; | ||
_global.clearImmediate = _global.clearImmediate; | ||
} | ||
// node expects setTimeout/setInterval to return a fn object w/ .ref()/.unref() | ||
// browsers, a number. | ||
// see https://github.com/cjohansen/Sinon.JS/pull/436 | ||
var NOOP = function () { return undefined; }; | ||
@@ -54,3 +32,23 @@ var NOOP_ARRAY = function () { return []; }; | ||
); | ||
var setImmediatePresent = ( | ||
_global.setImmediate && typeof _global.setImmediate === "function" | ||
); | ||
// Make properties writable in IE, as per | ||
// http://www.adequatelygood.com/Replacing-setTimeout-Globally.html | ||
if (isRunningInIE) { | ||
_global.setTimeout = _global.setTimeout; | ||
_global.clearTimeout = _global.clearTimeout; | ||
_global.setInterval = _global.setInterval; | ||
_global.clearInterval = _global.clearInterval; | ||
_global.Date = _global.Date; | ||
} | ||
// setImmediate is not a standard function | ||
// avoid adding the prop to the window object if not present | ||
if (setImmediatePresent) { | ||
_global.setImmediate = _global.setImmediate; | ||
_global.clearImmediate = _global.clearImmediate; | ||
} | ||
_global.clearTimeout(timeoutResult); | ||
@@ -178,2 +176,9 @@ | ||
function ClockDate(year, month, date, hour, minute, second, ms) { | ||
// the Date constructor called as a function, ref Ecma-262 Edition 5.1, section 15.9.2. | ||
// This remains so in the 10th edition of 2019 as well. | ||
if (!(this instanceof ClockDate)) { | ||
return new NativeDate(ClockDate.clock.now).toString(); | ||
} | ||
// if Date is called as a constructor with 'new' keyword | ||
// Defensive and verbose to avoid potential harm in passing | ||
@@ -495,4 +500,2 @@ // explicit undefined when user does not pass argument | ||
clearTimeout: _global.clearTimeout, | ||
setImmediate: _global.setImmediate, | ||
clearImmediate: _global.clearImmediate, | ||
setInterval: _global.setInterval, | ||
@@ -503,2 +506,7 @@ clearInterval: _global.clearInterval, | ||
if (setImmediatePresent) { | ||
timers.setImmediate = _global.setImmediate; | ||
timers.clearImmediate = _global.clearImmediate; | ||
} | ||
if (hrtimePresent) { | ||
@@ -665,13 +673,15 @@ timers.hrtime = _global.process.hrtime; | ||
clock.setImmediate = function setImmediate(func) { | ||
return addTimer(clock, { | ||
func: func, | ||
args: Array.prototype.slice.call(arguments, 1), | ||
immediate: true | ||
}); | ||
}; | ||
if (setImmediatePresent) { | ||
clock.setImmediate = function setImmediate(func) { | ||
return addTimer(clock, { | ||
func: func, | ||
args: Array.prototype.slice.call(arguments, 1), | ||
immediate: true | ||
}); | ||
}; | ||
clock.clearImmediate = function clearImmediate(timerId) { | ||
return clearTimer(clock, timerId, "Immediate"); | ||
}; | ||
clock.clearImmediate = function clearImmediate(timerId) { | ||
return clearTimer(clock, timerId, "Immediate"); | ||
}; | ||
} | ||
@@ -678,0 +688,0 @@ clock.countTimers = function countTimers() { |
{ | ||
"name": "lolex", | ||
"description": "Fake JavaScript timers", | ||
"version": "4.2.0", | ||
"version": "5.0.0", | ||
"homepage": "http://github.com/sinonjs/lolex", | ||
@@ -36,14 +36,14 @@ "author": "Christian Johansen", | ||
"devDependencies": { | ||
"@sinonjs/referee-sinon": "4.1.0", | ||
"browserify": "16.2.0", | ||
"eslint": "6.1.0", | ||
"@sinonjs/referee-sinon": "5.0.0", | ||
"browserify": "16.5.0", | ||
"eslint": "6.5.1", | ||
"eslint-config-sinon": "1.0.3", | ||
"eslint-plugin-ie11": "1.0.0", | ||
"eslint-plugin-mocha": "4.11.0", | ||
"husky": "2.3.0", | ||
"eslint-plugin-mocha": "6.1.1", | ||
"husky": "3.0.8", | ||
"jsdom": "15.1.1", | ||
"lint-staged": "9.2.1", | ||
"mocha": "5.2.0", | ||
"mochify": "6.3.0", | ||
"npm-run-all": "4.1.2" | ||
"lint-staged": "9.4.1", | ||
"mocha": "6.2.1", | ||
"mochify": "6.5.0", | ||
"npm-run-all": "4.1.5" | ||
}, | ||
@@ -50,0 +50,0 @@ "eslintConfig": { |
@@ -7,24 +7,2 @@ "use strict"; | ||
var maxTimeout = Math.pow(2, 31) - 1; //see https://heycam.github.io/webidl/#abstract-opdef-converttoint | ||
// Make properties writable in IE, as per | ||
// http://www.adequatelygood.com/Replacing-setTimeout-Globally.html | ||
if (isRunningInIE) { | ||
_global.setTimeout = _global.setTimeout; | ||
_global.clearTimeout = _global.clearTimeout; | ||
_global.setInterval = _global.setInterval; | ||
_global.clearInterval = _global.clearInterval; | ||
_global.Date = _global.Date; | ||
} | ||
// setImmediate is not a standard function | ||
// avoid adding the prop to the window object if not present | ||
if (_global.setImmediate !== undefined) { | ||
_global.setImmediate = _global.setImmediate; | ||
_global.clearImmediate = _global.clearImmediate; | ||
} | ||
// node expects setTimeout/setInterval to return a fn object w/ .ref()/.unref() | ||
// browsers, a number. | ||
// see https://github.com/cjohansen/Sinon.JS/pull/436 | ||
var NOOP = function () { return undefined; }; | ||
@@ -52,3 +30,23 @@ var NOOP_ARRAY = function () { return []; }; | ||
); | ||
var setImmediatePresent = ( | ||
_global.setImmediate && typeof _global.setImmediate === "function" | ||
); | ||
// Make properties writable in IE, as per | ||
// http://www.adequatelygood.com/Replacing-setTimeout-Globally.html | ||
if (isRunningInIE) { | ||
_global.setTimeout = _global.setTimeout; | ||
_global.clearTimeout = _global.clearTimeout; | ||
_global.setInterval = _global.setInterval; | ||
_global.clearInterval = _global.clearInterval; | ||
_global.Date = _global.Date; | ||
} | ||
// setImmediate is not a standard function | ||
// avoid adding the prop to the window object if not present | ||
if (setImmediatePresent) { | ||
_global.setImmediate = _global.setImmediate; | ||
_global.clearImmediate = _global.clearImmediate; | ||
} | ||
_global.clearTimeout(timeoutResult); | ||
@@ -176,2 +174,9 @@ | ||
function ClockDate(year, month, date, hour, minute, second, ms) { | ||
// the Date constructor called as a function, ref Ecma-262 Edition 5.1, section 15.9.2. | ||
// This remains so in the 10th edition of 2019 as well. | ||
if (!(this instanceof ClockDate)) { | ||
return new NativeDate(ClockDate.clock.now).toString(); | ||
} | ||
// if Date is called as a constructor with 'new' keyword | ||
// Defensive and verbose to avoid potential harm in passing | ||
@@ -493,4 +498,2 @@ // explicit undefined when user does not pass argument | ||
clearTimeout: _global.clearTimeout, | ||
setImmediate: _global.setImmediate, | ||
clearImmediate: _global.clearImmediate, | ||
setInterval: _global.setInterval, | ||
@@ -501,2 +504,7 @@ clearInterval: _global.clearInterval, | ||
if (setImmediatePresent) { | ||
timers.setImmediate = _global.setImmediate; | ||
timers.clearImmediate = _global.clearImmediate; | ||
} | ||
if (hrtimePresent) { | ||
@@ -663,13 +671,15 @@ timers.hrtime = _global.process.hrtime; | ||
clock.setImmediate = function setImmediate(func) { | ||
return addTimer(clock, { | ||
func: func, | ||
args: Array.prototype.slice.call(arguments, 1), | ||
immediate: true | ||
}); | ||
}; | ||
if (setImmediatePresent) { | ||
clock.setImmediate = function setImmediate(func) { | ||
return addTimer(clock, { | ||
func: func, | ||
args: Array.prototype.slice.call(arguments, 1), | ||
immediate: true | ||
}); | ||
}; | ||
clock.clearImmediate = function clearImmediate(timerId) { | ||
return clearTimer(clock, timerId, "Immediate"); | ||
}; | ||
clock.clearImmediate = function clearImmediate(timerId) { | ||
return clearTimer(clock, timerId, "Immediate"); | ||
}; | ||
} | ||
@@ -676,0 +686,0 @@ clock.countTimers = function countTimers() { |
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
92755
1660