UNPKG

ds-algo-study

Version:

Just experimenting with publishing a package

22 lines (16 loc) 560 B
export function reverse(value) { return value.split("").reverse().join(""); } export function camel(str) { return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) { if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces return index === 0 ? match.toLowerCase() : match.toUpperCase(); }); } export function camelToKebab(value) { return value.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); } /* - count(substring) Returns the count of the number of occurrences of the substring. */