convconv
Version:
Naming Conventions Converter
43 lines (42 loc) • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FROM_OPERATIONS = void 0;
const camel_1 = require("./adapters/camel");
const adapter_1 = require("./adapters/adapter");
const convconv_1 = require("./convconv");
const is_operations_1 = require("./is.operations");
const get_convention_1 = require("./get.convention");
const errors_1 = require("./errors");
function assertConvention(convention, name) {
if (!is_operations_1.IS_OPERATIONS.isConvention(convention, name)) {
throw new errors_1.ConventionViolationError(convention, name);
}
}
exports.FROM_OPERATIONS = {
autoFrom(name) {
return this.fromConvention((0, get_convention_1.getConvention)(name), name);
},
fromConvention(convention, name) {
assertConvention(convention, name);
const adapter = adapter_1.Adapters[camel_1.Camel.fromKebab(convention)];
return new convconv_1.ConvConvImpl(name, adapter);
},
fromKebab(name) {
return this.fromConvention("kebab", name);
},
fromCamel(name) {
return this.fromConvention("camel", name);
},
fromSnake(name) {
return this.fromConvention("snake", name);
},
fromPascal(name) {
return this.fromConvention("pascal", name);
},
fromScreamingKebab(name) {
return this.fromConvention("screaming-kebab", name);
},
fromScreamingSnake(name) {
return this.fromConvention("screaming-snake", name);
},
};