Skip to content

⬅️ Back to Table of Contents

📄 port

📊 Analysis Summary

Metric Count
🔧 Functions 1
📊 Variables & Constants 2

📚 Table of Contents

🛠️ File Location:

📂 packages/shared/utils/port.ts

Variables & Constants

Name Type Kind Value Exported
hyphenateRE RegExp const /\B([A-Z])/g
camelizeRE RegExp const /-(\w)/g

Functions

cacheStringFunction(fn: T): T

Parameters:

  • fn T

Returns: T

Calls:

  • Object.create
  • fn
Code
function cacheStringFunction<T extends (str: string) => string>(fn: T): T {
  const cache: Record<string, string> = Object.create(null)
  return ((str: string) => {
    const hit = cache[str]
    return hit || (cache[str] = fn(str))
  }) as T
}

Generated by Syntax Scribe