50 lines
989 B
JavaScript
50 lines
989 B
JavaScript
getJasmineRequireObj().util = function() {
|
|
|
|
var util = {};
|
|
|
|
util.inherit = function(childClass, parentClass) {
|
|
var Subclass = function() {
|
|
};
|
|
Subclass.prototype = parentClass.prototype;
|
|
childClass.prototype = new Subclass();
|
|
};
|
|
|
|
util.htmlEscape = function(str) {
|
|
if (!str) {
|
|
return str;
|
|
}
|
|
return str.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>');
|
|
};
|
|
|
|
util.argsToArray = function(args) {
|
|
var arrayOfArgs = [];
|
|
for (var i = 0; i < args.length; i++) {
|
|
arrayOfArgs.push(args[i]);
|
|
}
|
|
return arrayOfArgs;
|
|
};
|
|
|
|
util.isUndefined = function(obj) {
|
|
return obj === void 0;
|
|
};
|
|
|
|
util.clone = function(obj) {
|
|
if (Object.prototype.toString.apply(obj) === '[object Array]') {
|
|
return obj.slice();
|
|
}
|
|
|
|
var cloned = {};
|
|
for (var prop in obj) {
|
|
if (obj.hasOwnProperty(prop)) {
|
|
cloned[prop] = obj[prop];
|
|
}
|
|
}
|
|
|
|
return cloned;
|
|
};
|
|
|
|
return util;
|
|
};
|