UNPKG

@spec2ts/openapi-client

Version:

Utility to convert OpenAPI v3 specifications to Typescript HTTP client using TypeScript native compiler

22 lines (21 loc) 663 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.camelCase = void 0; function camelCase(str) { const regex = /[A-Z\xC0-\xD6\xD8-\xDE_$]?[a-z\xDF-\xF6\xF8-\xFF_$]+|[A-Z\xC0-\xD6\xD8-\xDE_$]+(?![a-z\xDF-\xF6\xF8-\xFF_$])|\d+/g; const words = str.match(regex); if (!words) return ""; let result = ""; const len = words.length; for (let i = 0; i < len; i++) { const word = words[i]; let tmp = word.toLowerCase(); if (i !== 0) { tmp = tmp[0].toUpperCase() + tmp.substr(1); } result += tmp; } return result; } exports.camelCase = camelCase;