3c2057d4500bcc8d8f96e5a00ee11a18ad4e8abdc9f9538f0743dc3eb0bf6d2fa3841a7357c8a401bad95694dcbe0299487a407b771de8888ea45bd60615c9 296 B

123456789101112
  1. function cached(fn) {
  2. const cache = Object.create(null);
  3. return function cachedFn(str) {
  4. const hit = cache[str];
  5. return hit || (cache[str] = fn(str));
  6. };
  7. }
  8. const regex = /-(\w)/g;
  9. const camelize = cached(str => str.replace(regex, (_, c) => c.toUpperCase()));
  10. export { camelize };