UNPKG

stringzy

Version:

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

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