UNPKG

stringzy

Version:

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

16 lines (15 loc) 416 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.constantCase = constantCase; function constantCase(text) { if (text == null) return ''; return text .trim() .replace(/[\s-]+/g, '_') .replace(/([a-z])([A-Z])/g, '$1_$2') .replace(/[^\w_]/g, '_') .toUpperCase() .replace(/_+/g, '_') .replace(/^_+|_+$/g, ''); }