funtool
Version:
A modern, efficient, and modular JavaScript utility library designed to enhance developer productivity.
3 lines (2 loc) • 2.8 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).funtool={})}(this,(function(e){"use strict";function t(e){return e.replace(/[_\-\s]+/g," ").trim().split(/\s+/).flatMap((e=>e.match(/[A-Z]{2,}(?=[A-Z][a-z]|[0-9]|$)|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/g)||[]))}e.capitalizeFirstLetter=function(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""},e.count=function(e,t){return(e.match(new RegExp(t,"g"))||[]).length},e.findIndex=function(e,t){return e.indexOf(t)},e.insertAfter=function(e,t,n){const r="number"==typeof n?n:e.indexOf(n);return r<0||r>=e.length?e:e.slice(0,r+1)+t+e.slice(r+1)},e.insertBefore=function(e,t,n){const r="number"==typeof n?n:e.indexOf(n);return r<0||r>e.length?e:e.slice(0,r)+t+e.slice(r)},e.lowercaseFirstLetter=function(e){return e?e.charAt(0).toLowerCase()+e.slice(1):""},e.padEnd=function(e,t,n=" "){return e.padEnd(t,n)},e.padStart=function(e,t,n=" "){return e.padStart(t,n)},e.removeAfter=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(0,n+1):e},e.removeAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e.slice(n+1)},e.removeBefore=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(n):e},e.repeat=function(e,t){return e.repeat(t)},e.replaceAll=function(e,t,n){return e.split(t).join(n)},e.reverse=function(e){return e.split("").reverse().join("")},e.substring=function(e,t,n){return e.substring(t,n)},e.toCamelCase=function(e){if(!e)return"";const[n,...r]=t(e);return[n.toLowerCase(),...r.map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))].join("")},e.toKebabCase=function(e){return t(e).map((e=>e.toLowerCase())).join("-")},e.toLowerAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e[n].toLowerCase()+e.slice(n+1)},e.toLowerCase=function(e){return e.toString().toLowerCase()},e.toPascalCase=function(e){return t(e).map((e=>/^[A-Z0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join("")},e.toSnakeCase=function(e){return t(e).map((e=>e.toLowerCase())).join("_")},e.toTitleCase=function(e){return e.toLowerCase().replace(/[_\-]+/g," ").replace(/\b([a-z])([a-z]*)/g,((e,t,n)=>t.toUpperCase()+n))},e.toUpperAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e[n].toUpperCase()+e.slice(n+1)},e.toUpperCase=function(e){return e.toString().toUpperCase()},e.trim=function(e){return e.toString().replace(/^\s+|\s+$/g,"")},e.trimEnd=function(e){return e.toString().replace(/\s+$/g,"")},e.trimStart=function(e){return e.toString().replace(/^\s+/g,"")},e.words=t}));
//# sourceMappingURL=index.umd.js.map