cabbie-sync
Version:
A synchronous webdriver client
96 lines (69 loc) • 4.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
var _assert = require('assert');
var assert = _interopRequireWildcard(_assert);
var _util = require('util');
var _flowRuntime = require('flow-runtime');
var _flowRuntime2 = _interopRequireDefault(_flowRuntime);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var inspectKey = _util.inspect.custom || 'inspect'; /**
*
* This file is generated automatically, run npm run build to re-generate.
**/
function addLogging(cls /*: any*/) {
var options /*: { baseClass?: boolean; inspect?: (obj: any, depth: number, options: Object) => string; }*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { baseClass: false };
var _clsType = _flowRuntime2.default.any();
var _optionsType = _flowRuntime2.default.object(_flowRuntime2.default.property('baseClass', _flowRuntime2.default.boolean(), true), _flowRuntime2.default.property('inspect', _flowRuntime2.default.function(_flowRuntime2.default.param('obj', _flowRuntime2.default.any()), _flowRuntime2.default.param('depth', _flowRuntime2.default.number()), _flowRuntime2.default.param('options', _flowRuntime2.default.object()), _flowRuntime2.default.return(_flowRuntime2.default.string())), true));
_flowRuntime2.default.param('cls', _clsType).assert(cls);
_flowRuntime2.default.param('options', _optionsType).assert(options);
var proto = cls.prototype;
(0, _getOwnPropertyNames2.default)(proto).forEach(function (name) {
if (typeof proto[name] !== 'function') {
return;
}
if (name[0] === '_') {
return;
}
var fun = proto[name];
proto[name] = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var start = Date.now();
var result = void 0;
try {
result = fun.call.apply(fun, [this].concat(args));
} catch (err) {
this.debug.onCall({ obj: this, name: name, args: args, duration: Date.now() - start, success: false, err: err });
throw err;
}
this.debug.onCall({ obj: this, name: name, args: args, duration: Date.now() - start, success: true, result: result });
return result;
};
});
if (options.inspect) {
var ins = options.inspect;
assert.equal((0, _typeof3.default)(options.inspect), 'function');
proto[inspectKey] = _flowRuntime2.default.annotate(function (depth /*: number*/, options /*: Object*/) /*: string*/ {
var _depthType = _flowRuntime2.default.number();
var _optionsType2 = _flowRuntime2.default.object();
var _returnType = _flowRuntime2.default.return(_flowRuntime2.default.string());
_flowRuntime2.default.param('depth', _depthType).assert(depth);
_flowRuntime2.default.param('options', _optionsType2).assert(options);
return _returnType.assert(ins(this, depth, options));
}, _flowRuntime2.default.function(_flowRuntime2.default.param('depth', _flowRuntime2.default.number()), _flowRuntime2.default.param('options', _flowRuntime2.default.object()), _flowRuntime2.default.return(_flowRuntime2.default.string())));
} else if (!proto[inspectKey] && !options.baseClass) {
proto[inspectKey] = function () {
return cls.name;
};
}
}
_flowRuntime2.default.annotate(addLogging, _flowRuntime2.default.function(_flowRuntime2.default.param('cls', _flowRuntime2.default.any()), _flowRuntime2.default.param('options', _flowRuntime2.default.object(_flowRuntime2.default.property('baseClass', _flowRuntime2.default.boolean(), true), _flowRuntime2.default.property('inspect', _flowRuntime2.default.function(_flowRuntime2.default.param('obj', _flowRuntime2.default.any()), _flowRuntime2.default.param('depth', _flowRuntime2.default.number()), _flowRuntime2.default.param('options', _flowRuntime2.default.object()), _flowRuntime2.default.return(_flowRuntime2.default.string())), true)))));
exports.default = addLogging;