Removed obsolete and unused utility fns

This commit is contained in:
Steve Gravrock
2022-06-11 11:17:16 -07:00
parent 135ff20123
commit e2e2275d41
7 changed files with 36 additions and 118 deletions

View File

@@ -169,10 +169,6 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
};
getJasmineRequireObj().base = function(j$, jasmineGlobal) {
j$.unimplementedMethod_ = function() {
throw new Error('unimplemented method');
};
/**
* 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.
@@ -600,34 +596,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
getJasmineRequireObj().util = function(j$) {
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) {
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) {
if (Object.prototype.toString.apply(obj) === '[object Array]') {
return obj.slice();
@@ -644,22 +616,19 @@ getJasmineRequireObj().util = function(j$) {
};
util.cloneArgs = function(args) {
const clonedArgs = [];
const argsAsArray = j$.util.argsToArray(args);
for (let i = 0; i < argsAsArray.length; i++) {
const str = Object.prototype.toString.apply(argsAsArray[i]),
return Array.from(args).map(function(arg) {
const str = Object.prototype.toString.apply(arg),
primitives = /^\[object (Boolean|String|RegExp|Number)/;
// All falsey values are either primitives, `null`, or `undefined.
if (!argsAsArray[i] || str.match(primitives)) {
clonedArgs.push(argsAsArray[i]);
if (!arg || str.match(primitives)) {
return arg;
} else if (str === '[object Date]') {
clonedArgs.push(new Date(argsAsArray[i].valueOf()));
return new Date(arg.valueOf());
} else {
clonedArgs.push(j$.util.clone(argsAsArray[i]));
return j$.util.clone(arg);
}
}
return clonedArgs;
});
};
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) {
// Timeouts are implemented with setTimeout, which only supports a limited
// 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) {
tickDate = tickDate || function() {};
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
@@ -3818,19 +3777,19 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
delete scheduledFunctions[currentTime];
forEachFunction(funcsToRun, function(funcToRun) {
if (funcToRun.recurring) {
reschedule(funcToRun);
for (const fn of funcsToRun) {
if (fn.recurring) {
reschedule(fn);
}
});
}
forEachFunction(funcsToRun, function(funcToRun) {
if (j$.util.arrayContains(deletedKeys, funcToRun.timeoutKey)) {
for (const fn of funcsToRun) {
if (deletedKeys.includes(fn.timeoutKey)) {
// skip a timeoutKey deleted whilst we were running
return;
}
funcToRun.funcToCall.apply(null, funcToRun.params || []);
});
fn.funcToCall.apply(null, fn.params || []);
}
deletedKeys = [];
} while (
scheduledLookup.length > 0 &&
@@ -4038,7 +3997,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
let empty = true;
for (const prop in error) {
if (j$.util.arrayContains(ignoredProperties, prop)) {
if (ignoredProperties.includes(prop)) {
continue;
}
result[prop] = error[prop];
@@ -7611,7 +7570,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} catch (e) {
this.emitScalar('has-invalid-toString-method');
}
} else if (j$.util.arrayContains(this.seen, value)) {
} else if (this.seen.includes(value)) {
this.emitScalar(
'<circular reference: ' +
(j$.isArray_(value) ? 'Array' : 'Object') +
@@ -8234,7 +8193,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
reporters.push(fallbackReporter);
}
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 = [];
for (const reporter of reporters) {
addFn(fns, reporter, method, args);

View File

@@ -119,12 +119,6 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
);
}
function forEachFunction(funcsToRun, callback) {
for (const f of funcsToRun) {
callback(f);
}
}
function runScheduledFunctions(endTime, tickDate) {
tickDate = tickDate || function() {};
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
@@ -147,19 +141,19 @@ getJasmineRequireObj().DelayedFunctionScheduler = function(j$) {
delete scheduledFunctions[currentTime];
forEachFunction(funcsToRun, function(funcToRun) {
if (funcToRun.recurring) {
reschedule(funcToRun);
for (const fn of funcsToRun) {
if (fn.recurring) {
reschedule(fn);
}
});
}
forEachFunction(funcsToRun, function(funcToRun) {
if (j$.util.arrayContains(deletedKeys, funcToRun.timeoutKey)) {
for (const fn of funcsToRun) {
if (deletedKeys.includes(fn.timeoutKey)) {
// skip a timeoutKey deleted whilst we were running
return;
}
funcToRun.funcToCall.apply(null, funcToRun.params || []);
});
fn.funcToCall.apply(null, fn.params || []);
}
deletedKeys = [];
} while (
scheduledLookup.length > 0 &&

View File

@@ -83,7 +83,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
let empty = true;
for (const prop in error) {
if (j$.util.arrayContains(ignoredProperties, prop)) {
if (ignoredProperties.includes(prop)) {
continue;
}
result[prop] = error[prop];

View File

@@ -61,7 +61,7 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
} catch (e) {
this.emitScalar('has-invalid-toString-method');
}
} else if (j$.util.arrayContains(this.seen, value)) {
} else if (this.seen.includes(value)) {
this.emitScalar(
'<circular reference: ' +
(j$.isArray_(value) ? 'Array' : 'Object') +

View File

@@ -32,7 +32,7 @@ getJasmineRequireObj().ReportDispatcher = function(j$) {
reporters.push(fallbackReporter);
}
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 = [];
for (const reporter of reporters) {
addFn(fns, reporter, method, args);

View File

@@ -1,8 +1,4 @@
getJasmineRequireObj().base = function(j$, jasmineGlobal) {
j$.unimplementedMethod_ = function() {
throw new Error('unimplemented method');
};
/**
* 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.

View File

@@ -1,34 +1,10 @@
getJasmineRequireObj().util = function(j$) {
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) {
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) {
if (Object.prototype.toString.apply(obj) === '[object Array]') {
return obj.slice();
@@ -45,22 +21,19 @@ getJasmineRequireObj().util = function(j$) {
};
util.cloneArgs = function(args) {
const clonedArgs = [];
const argsAsArray = j$.util.argsToArray(args);
for (let i = 0; i < argsAsArray.length; i++) {
const str = Object.prototype.toString.apply(argsAsArray[i]),
return Array.from(args).map(function(arg) {
const str = Object.prototype.toString.apply(arg),
primitives = /^\[object (Boolean|String|RegExp|Number)/;
// All falsey values are either primitives, `null`, or `undefined.
if (!argsAsArray[i] || str.match(primitives)) {
clonedArgs.push(argsAsArray[i]);
if (!arg || str.match(primitives)) {
return arg;
} else if (str === '[object Date]') {
clonedArgs.push(new Date(argsAsArray[i].valueOf()));
return new Date(arg.valueOf());
} else {
clonedArgs.push(j$.util.clone(argsAsArray[i]));
return j$.util.clone(arg);
}
}
return clonedArgs;
});
};
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) {
// Timeouts are implemented with setTimeout, which only supports a limited
// range of values. The limit is unspecified, as is the behavior when it's