mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
/**
|
|
* @namespace
|
|
*/
|
|
jasmine.util = {};
|
|
|
|
/**
|
|
* Declare that a child class inherit it's prototype from the parent class.
|
|
*
|
|
* @private
|
|
* @param {Function} childClass
|
|
* @param {Function} parentClass
|
|
*/
|
|
jasmine.util.inherit = function(childClass, parentClass) {
|
|
/**
|
|
* @private
|
|
*/
|
|
var subclass = function() {
|
|
};
|
|
subclass.prototype = parentClass.prototype;
|
|
childClass.prototype = new subclass;
|
|
};
|
|
|
|
jasmine.util.formatException = function(e) {
|
|
var lineNumber;
|
|
if (e.line) {
|
|
lineNumber = e.line;
|
|
}
|
|
else if (e.lineNumber) {
|
|
lineNumber = e.lineNumber;
|
|
}
|
|
|
|
var file;
|
|
|
|
if (e.sourceURL) {
|
|
file = e.sourceURL;
|
|
}
|
|
else if (e.fileName) {
|
|
file = e.fileName;
|
|
}
|
|
|
|
var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
|
|
|
|
if (file && lineNumber) {
|
|
message += ' in ' + file + ' (line ' + lineNumber + ')';
|
|
}
|
|
|
|
return message;
|
|
};
|
|
|
|
jasmine.util.htmlEscape = function(str) {
|
|
if (!str) return str;
|
|
return str.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>');
|
|
};
|
|
|
|
jasmine.util.argsToArray = function(args) {
|
|
var arrayOfArgs = [];
|
|
for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
|
|
return arrayOfArgs;
|
|
};
|
|
|
|
jasmine.util.extend = function(destination, source) {
|
|
for (var property in source) destination[property] = source[property];
|
|
return destination;
|
|
};
|
|
|