Skip to content

Commit

Permalink
Use global object detection from @sinonjs/commons
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Dec 19, 2019
1 parent e8cb75c commit f34a13e
Show file tree
Hide file tree
Showing 5 changed files with 1,865 additions and 2,477 deletions.
4 changes: 2 additions & 2 deletions lib/sinon/assert.js
Expand Up @@ -7,8 +7,8 @@ var orderByFirstCall = require("@sinonjs/commons").orderByFirstCall;
var timesInWords = require("./util/core/times-in-words");
var format = require("./util/core/format");
var stringSlice = require("@sinonjs/commons").prototypes.string.slice;
var globalObject = require("@sinonjs/commons").global;

var globalContext = typeof global !== "undefined" ? global : window;
var arraySlice = arrayProto.slice;
var concat = arrayProto.concat;
var forEach = arrayProto.forEach;
Expand Down Expand Up @@ -61,7 +61,7 @@ function verifyIsValidAssertion(assertionMethod, assertionArgs) {
}

function failAssertion(object, msg) {
var obj = object || globalContext;
var obj = object || globalObject;
var failMethod = obj.fail || assert.fail;
failMethod.call(obj, msg);
}
Expand Down
6 changes: 2 additions & 4 deletions lib/sinon/util/core/next-tick.js
@@ -1,8 +1,6 @@
"use strict";

var globalObject = require("@sinonjs/commons").global;
var getNextTick = require("./get-next-tick");

/* istanbul ignore next */
var root = typeof window !== "undefined" ? window : global;

module.exports = getNextTick(root.process, root.setImmediate);
module.exports = getNextTick(globalObject.process, globalObject.setImmediate);
4 changes: 2 additions & 2 deletions lib/sinon/util/fake-timers.js
Expand Up @@ -2,7 +2,7 @@

var extend = require("./core/extend");
var llx = require("lolex");
var globalContext = typeof global !== "undefined" ? global : window;
var globalObject = require("@sinonjs/commons").global;

function createClock(config, globalCtx) {
var llxCtx = llx;
Expand All @@ -15,7 +15,7 @@ function createClock(config, globalCtx) {
}

function addIfDefined(obj, globalPropName) {
var globalProp = globalContext[globalPropName];
var globalProp = globalObject[globalPropName];
if (typeof globalProp !== "undefined") {
obj[globalPropName] = globalProp;
}
Expand Down

0 comments on commit f34a13e

Please sign in to comment.