UNPKG

wechaty-puppet

Version:

Abstract Puppet for Wechaty

34 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateMixin = void 0; const interface_of_js_1 = require("../puppet/interface-of.js"); const validateMixin = (mixinBase) => { class ValidateMixin extends mixinBase { /** * Check if obj satisfy Puppet interface */ static validInterface(target) { return (0, interface_of_js_1.interfaceOfPuppet)(target); } /** * loose check instance of Puppet */ static validInstance(target) { return (0, interface_of_js_1.looseInstanceOfPuppet)(target); } /** * Huan(202110): I believe `valid()` will be a better performance than `validInterface()` * because it will check `instanceof` first, which I believe it will be the most case * and it will be faster than `interfaceOfPuppet()` */ static valid(target) { if (this.validInstance(target) || this.validInterface(target)) { return true; } return false; } } return ValidateMixin; }; exports.validateMixin = validateMixin; //# sourceMappingURL=validate-mixin.js.map