UNPKG

@autorest/openapi-to-typespec

Version:

Autorest plugin to scaffold a Typespec definition from an OpenAPI document

20 lines 716 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escapeRegex = exports.lastWordToSingular = void 0; const pluralize_1 = require("pluralize"); function lastWordToSingular(str) { const words = firstCharToUpperCase(str).split(/(?=[A-Z])/); const lastWord = words[words.length - 1]; return words.slice(0, -1).join("") + (0, pluralize_1.singular)(lastWord); } exports.lastWordToSingular = lastWordToSingular; function firstCharToUpperCase(str) { if (!str) return str; return str[0].toUpperCase() + str.substring(1); } function escapeRegex(str) { return str.replace(/\\/g, "\\\\"); } exports.escapeRegex = escapeRegex; //# sourceMappingURL=strings.js.map