Removed obsolete and unused utility fns
This commit is contained in:
+18
-59
@@ -169,10 +169,6 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||||
j$.unimplementedMethod_ = function() {
|
|
||||||
throw new Error('unimplemented method');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum object depth the pretty printer will print to.
|
* Maximum object depth the pretty printer will print to.
|
||||||
* Set this to a lower value to speed up pretty printing if you have large objects.
|
* Set this to a lower value to speed up pretty printing if you have large objects.
|
||||||
@@ -600,34 +596,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
getJasmineRequireObj().util = function(j$) {
|
getJasmineRequireObj().util = function(j$) {
|
||||||
const util = {};
|
const util = {};
|
||||||
|
|
||||||
util.inherit = function(childClass, parentClass) {
|
|
||||||
const Subclass = function() {};
|
|
||||||
Subclass.prototype = parentClass.prototype;
|
|
||||||
childClass.prototype = new Subclass();
|
|
||||||
};
|
|
||||||
|
|
||||||
util.argsToArray = function(args) {
|
|
||||||
const arrayOfArgs = [];
|
|
||||||
for (let i = 0; i < args.length; i++) {
|
|
||||||
arrayOfArgs.push(args[i]);
|
|
||||||
}
|
|
||||||
return arrayOfArgs;
|
|
||||||
};
|
|
||||||
|
|
||||||
util.isUndefined = function(obj) {
|
util.isUndefined = function(obj) {
|
||||||
return obj === void 0;
|
return obj === void 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.arrayContains = function(array, search) {
|
|
||||||
let i = array.length;
|
|
||||||
while (i--) {
|
|
||||||
if (array[i] === search) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
util.clone = function(obj) {
|
util.clone = function(obj) {
|
||||||
if (Object.prototype.toString.apply(obj) === '[object Array]') {
|
if (Object.prototype.toString.apply(obj) === '[object Array]') {
|
||||||
return obj.slice();
|
return obj.slice();
|
||||||
@@ -644,22 +616,19 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
util.cloneArgs = function(args) {
|
util.cloneArgs = function(args) {
|
||||||
const clonedArgs = [];
|
return Array.from(args).map(function(arg) {
|
||||||
const argsAsArray = j$.util.argsToArray(args);
|
const str = Object.prototype.toString.apply(arg),
|
||||||
for (let i = 0; i < argsAsArray.length; i++) {
|
|
||||||
const str = Object.prototype.toString.apply(argsAsArray[i]),
|
|
||||||
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
||||||
|
|
||||||
// All falsey values are either primitives, `null`, or `undefined.
|
// All falsey values are either primitives, `null`, or `undefined.
|
||||||
if (!argsAsArray[i] || str.match(primitives)) {
|
if (!arg || str.match(primitives)) {
|
||||||
clonedArgs.push(argsAsArray[i]);
|
return arg;
|
||||||
} else if (str === '[object Date]') {
|
} else if (str === '[object Date]') {
|
||||||
clonedArgs.push(new Date(argsAsArray[i].valueOf()));
|
return new Date(arg.valueOf());
|
||||||
} else {
|
} else {
|
||||||
clonedArgs.push(j$.util.clone(argsAsArray[i]));
|
return j$.util.clone(arg);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return clonedArgs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
util.getPropertyDescriptor = function(obj, methodName) {
|
util.getPropertyDescriptor = function(obj, methodName) {
|
||||||
@@ -702,10 +671,6 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function StopIteration() {}
|
|
||||||
StopIteration.prototype = Object.create(Error.prototype);
|
|
||||||
StopIteration.prototype.constructor = StopIteration;
|
|
||||||
|
|
||||||
util.validateTimeout = function(timeout, msgPrefix) {
|
util.validateTimeout = function(timeout, msgPrefix) {
|
||||||
// Timeouts are implemented with setTimeout, which only supports a limited
|
// Timeouts are implemented with setTimeout, which only supports a limited
|
||||||
// range of values. The limit is unspecified, as is the behavior when it's
|
// range of values. The limit is unspecified, as is the behavior when it's
|
||||||
@@ -3790,12 +3755,6 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function forEachFunction(funcsToRun, callback) {
|
|
||||||
for (const f of funcsToRun) {
|
|
||||||
callback(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function runScheduledFunctions(endTime, tickDate) {
|
function runScheduledFunctions(endTime, tickDate) {
|
||||||
tickDate = tickDate || function() {};
|
tickDate = tickDate || function() {};
|
||||||
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
||||||
@@ -3818,19 +3777,19 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|||||||
|
|
||||||
delete scheduledFunctions[currentTime];
|
delete scheduledFunctions[currentTime];
|
||||||
|
|
||||||
forEachFunction(funcsToRun, function(funcToRun) {
|
for (const fn of funcsToRun) {
|
||||||
if (funcToRun.recurring) {
|
if (fn.recurring) {
|
||||||
reschedule(funcToRun);
|
reschedule(fn);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
forEachFunction(funcsToRun, function(funcToRun) {
|
for (const fn of funcsToRun) {
|
||||||
if (j$.util.arrayContains(deletedKeys, funcToRun.timeoutKey)) {
|
if (deletedKeys.includes(fn.timeoutKey)) {
|
||||||
// skip a timeoutKey deleted whilst we were running
|
// skip a timeoutKey deleted whilst we were running
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
fn.funcToCall.apply(null, fn.params || []);
|
||||||
});
|
}
|
||||||
deletedKeys = [];
|
deletedKeys = [];
|
||||||
} while (
|
} while (
|
||||||
scheduledLookup.length > 0 &&
|
scheduledLookup.length > 0 &&
|
||||||
@@ -4038,7 +3997,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
|||||||
let empty = true;
|
let empty = true;
|
||||||
|
|
||||||
for (const prop in error) {
|
for (const prop in error) {
|
||||||
if (j$.util.arrayContains(ignoredProperties, prop)) {
|
if (ignoredProperties.includes(prop)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result[prop] = error[prop];
|
result[prop] = error[prop];
|
||||||
@@ -7611,7 +7570,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.emitScalar('has-invalid-toString-method');
|
this.emitScalar('has-invalid-toString-method');
|
||||||
}
|
}
|
||||||
} else if (j$.util.arrayContains(this.seen, value)) {
|
} else if (this.seen.includes(value)) {
|
||||||
this.emitScalar(
|
this.emitScalar(
|
||||||
'<circular reference: ' +
|
'<circular reference: ' +
|
||||||
(j$.isArray_(value) ? 'Array' : 'Object') +
|
(j$.isArray_(value) ? 'Array' : 'Object') +
|
||||||
@@ -8234,7 +8193,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
reporters.push(fallbackReporter);
|
reporters.push(fallbackReporter);
|
||||||
}
|
}
|
||||||
const onComplete = args[args.length - 1];
|
const onComplete = args[args.length - 1];
|
||||||
args = j$.util.argsToArray(args).splice(0, args.length - 1);
|
args = Array.from(args).splice(0, args.length - 1);
|
||||||
const fns = [];
|
const fns = [];
|
||||||
for (const reporter of reporters) {
|
for (const reporter of reporters) {
|
||||||
addFn(fns, reporter, method, args);
|
addFn(fns, reporter, method, args);
|
||||||
|
|||||||
@@ -119,12 +119,6 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function forEachFunction(funcsToRun, callback) {
|
|
||||||
for (const f of funcsToRun) {
|
|
||||||
callback(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function runScheduledFunctions(endTime, tickDate) {
|
function runScheduledFunctions(endTime, tickDate) {
|
||||||
tickDate = tickDate || function() {};
|
tickDate = tickDate || function() {};
|
||||||
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
||||||
@@ -147,19 +141,19 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
|
|||||||
|
|
||||||
delete scheduledFunctions[currentTime];
|
delete scheduledFunctions[currentTime];
|
||||||
|
|
||||||
forEachFunction(funcsToRun, function(funcToRun) {
|
for (const fn of funcsToRun) {
|
||||||
if (funcToRun.recurring) {
|
if (fn.recurring) {
|
||||||
reschedule(funcToRun);
|
reschedule(fn);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
forEachFunction(funcsToRun, function(funcToRun) {
|
for (const fn of funcsToRun) {
|
||||||
if (j$.util.arrayContains(deletedKeys, funcToRun.timeoutKey)) {
|
if (deletedKeys.includes(fn.timeoutKey)) {
|
||||||
// skip a timeoutKey deleted whilst we were running
|
// skip a timeoutKey deleted whilst we were running
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
fn.funcToCall.apply(null, fn.params || []);
|
||||||
});
|
}
|
||||||
deletedKeys = [];
|
deletedKeys = [];
|
||||||
} while (
|
} while (
|
||||||
scheduledLookup.length > 0 &&
|
scheduledLookup.length > 0 &&
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
|||||||
let empty = true;
|
let empty = true;
|
||||||
|
|
||||||
for (const prop in error) {
|
for (const prop in error) {
|
||||||
if (j$.util.arrayContains(ignoredProperties, prop)) {
|
if (ignoredProperties.includes(prop)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result[prop] = error[prop];
|
result[prop] = error[prop];
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.emitScalar('has-invalid-toString-method');
|
this.emitScalar('has-invalid-toString-method');
|
||||||
}
|
}
|
||||||
} else if (j$.util.arrayContains(this.seen, value)) {
|
} else if (this.seen.includes(value)) {
|
||||||
this.emitScalar(
|
this.emitScalar(
|
||||||
'<circular reference: ' +
|
'<circular reference: ' +
|
||||||
(j$.isArray_(value) ? 'Array' : 'Object') +
|
(j$.isArray_(value) ? 'Array' : 'Object') +
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
|
|||||||
reporters.push(fallbackReporter);
|
reporters.push(fallbackReporter);
|
||||||
}
|
}
|
||||||
const onComplete = args[args.length - 1];
|
const onComplete = args[args.length - 1];
|
||||||
args = j$.util.argsToArray(args).splice(0, args.length - 1);
|
args = Array.from(args).splice(0, args.length - 1);
|
||||||
const fns = [];
|
const fns = [];
|
||||||
for (const reporter of reporters) {
|
for (const reporter of reporters) {
|
||||||
addFn(fns, reporter, method, args);
|
addFn(fns, reporter, method, args);
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
||||||
j$.unimplementedMethod_ = function() {
|
|
||||||
throw new Error('unimplemented method');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum object depth the pretty printer will print to.
|
* Maximum object depth the pretty printer will print to.
|
||||||
* Set this to a lower value to speed up pretty printing if you have large objects.
|
* Set this to a lower value to speed up pretty printing if you have large objects.
|
||||||
|
|||||||
+7
-38
@@ -1,34 +1,10 @@
|
|||||||
getJasmineRequireObj().util = function(j$) {
|
getJasmineRequireObj().util = function(j$) {
|
||||||
const util = {};
|
const util = {};
|
||||||
|
|
||||||
util.inherit = function(childClass, parentClass) {
|
|
||||||
const Subclass = function() {};
|
|
||||||
Subclass.prototype = parentClass.prototype;
|
|
||||||
childClass.prototype = new Subclass();
|
|
||||||
};
|
|
||||||
|
|
||||||
util.argsToArray = function(args) {
|
|
||||||
const arrayOfArgs = [];
|
|
||||||
for (let i = 0; i < args.length; i++) {
|
|
||||||
arrayOfArgs.push(args[i]);
|
|
||||||
}
|
|
||||||
return arrayOfArgs;
|
|
||||||
};
|
|
||||||
|
|
||||||
util.isUndefined = function(obj) {
|
util.isUndefined = function(obj) {
|
||||||
return obj === void 0;
|
return obj === void 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
util.arrayContains = function(array, search) {
|
|
||||||
let i = array.length;
|
|
||||||
while (i--) {
|
|
||||||
if (array[i] === search) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
util.clone = function(obj) {
|
util.clone = function(obj) {
|
||||||
if (Object.prototype.toString.apply(obj) === '[object Array]') {
|
if (Object.prototype.toString.apply(obj) === '[object Array]') {
|
||||||
return obj.slice();
|
return obj.slice();
|
||||||
@@ -45,22 +21,19 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
util.cloneArgs = function(args) {
|
util.cloneArgs = function(args) {
|
||||||
const clonedArgs = [];
|
return Array.from(args).map(function(arg) {
|
||||||
const argsAsArray = j$.util.argsToArray(args);
|
const str = Object.prototype.toString.apply(arg),
|
||||||
for (let i = 0; i < argsAsArray.length; i++) {
|
|
||||||
const str = Object.prototype.toString.apply(argsAsArray[i]),
|
|
||||||
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
||||||
|
|
||||||
// All falsey values are either primitives, `null`, or `undefined.
|
// All falsey values are either primitives, `null`, or `undefined.
|
||||||
if (!argsAsArray[i] || str.match(primitives)) {
|
if (!arg || str.match(primitives)) {
|
||||||
clonedArgs.push(argsAsArray[i]);
|
return arg;
|
||||||
} else if (str === '[object Date]') {
|
} else if (str === '[object Date]') {
|
||||||
clonedArgs.push(new Date(argsAsArray[i].valueOf()));
|
return new Date(arg.valueOf());
|
||||||
} else {
|
} else {
|
||||||
clonedArgs.push(j$.util.clone(argsAsArray[i]));
|
return j$.util.clone(arg);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return clonedArgs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
util.getPropertyDescriptor = function(obj, methodName) {
|
util.getPropertyDescriptor = function(obj, methodName) {
|
||||||
@@ -103,10 +76,6 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function StopIteration() {}
|
|
||||||
StopIteration.prototype = Object.create(Error.prototype);
|
|
||||||
StopIteration.prototype.constructor = StopIteration;
|
|
||||||
|
|
||||||
util.validateTimeout = function(timeout, msgPrefix) {
|
util.validateTimeout = function(timeout, msgPrefix) {
|
||||||
// Timeouts are implemented with setTimeout, which only supports a limited
|
// Timeouts are implemented with setTimeout, which only supports a limited
|
||||||
// range of values. The limit is unspecified, as is the behavior when it's
|
// range of values. The limit is unspecified, as is the behavior when it's
|
||||||
|
|||||||
Reference in New Issue
Block a user