se-runner
Version:
Selenium Test Runner
86 lines (69 loc) • 3.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Utils = function () {
function Utils() {
_classCallCheck(this, Utils);
}
_createClass(Utils, null, [{
key: 'enumerate',
value: function enumerate(obj, func) {
var prop = null,
result = null;
if ('function' === typeof func) {
for (prop in obj) {
if (!obj.hasOwnProperty(prop)) continue;
result = func(obj[prop], prop);
if (result) {
return result;
}
}
}
}
}, {
key: 'extend',
value: function extend() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var toStr = Object.prototype.toString,
arrayStr = toStr.call([]),
current = null,
newProperty = null,
i = 0,
_args = [].concat(args),
base = args[0];
for (i = 1; i < _args.length; i += 1) {
current = _args[i];
Utils.enumerate(current, function (val, arg) {
if (Utils.isObject(val) && Utils.isObject(base[arg]) && !(val instanceof Date)) {
newProperty = toStr.call(val) === arrayStr ? [] : {};
base[arg] = Utils.extend(base[arg] || newProperty, val);
} else {
base[arg] = 'undefined' !== typeof val ? val : base[arg];
}
});
}
return base;
}
}, {
key: 'guid',
value: function guid(format) {
return (format || 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx').replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0;
return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);
});
}
}, {
key: 'isObject',
value: function isObject(obj) {
return 'object' === (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) && null !== obj;
}
}]);
return Utils;
}();
exports.default = Utils;