type-initializr
Version:
Uma ferramenta para instanciar classes existentes baseasas em modelos com valores padrões
20 lines (19 loc) • 819 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class TypeUtils {
static isInitializable(type) {
if (type) {
const typeName = this.getTypeName(type);
return !this.getWellKnownJsTypes().some(t => t.toLowerCase() === (typeName === null || typeName === void 0 ? void 0 : typeName.toLowerCase()));
}
return false;
}
static getWellKnownJsTypes() {
return ['boolean', 'number', 'string', 'object', 'undefined', 'function', 'null', 'symbol'].map(t => t.toLowerCase());
}
static getTypeName(prototype) {
var _a;
return (_a = prototype === null || prototype === void 0 ? void 0 : prototype.constructor) === null || _a === void 0 ? void 0 : _a.name;
}
}
exports.TypeUtils = TypeUtils;