UNPKG

stringzy

Version:

A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.

16 lines (15 loc) 464 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.camelCase = camelCase; function camelCase(text) { if (text == null) return ''; return text .trim() .toLowerCase() .replace(/[^\w\s]/g, ' ') .replace(/_/g, ' ') .replace(/\s+/g, ' ') .replace(/\s(.)/g, (_, character) => character.toUpperCase()) .replace(/^(.)/, (_, character) => character.toLowerCase()); }