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