UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

26 lines (20 loc) 518 B
'use strict'; /*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ // src/cacheStringFunc.ts function cacheStringFunction(fn) { const cache = /* @__PURE__ */ Object.create(null); return (str) => { const hit = cache[str]; return hit || (cache[str] = fn(str)); }; } // src/hyphenate.ts var hyphenateRE = /\B([A-Z])/g; var hyphenate = cacheStringFunction( (str) => str.replace(hyphenateRE, "-$1").toLowerCase() ); exports.hyphenate = hyphenate;