* Create a cached version of a pure function.
(fn)
| 85 | * Create a cached version of a pure function. |
| 86 | */ |
| 87 | function cached (fn) { |
| 88 | var cache = Object.create(null); |
| 89 | return (function cachedFn (str) { |
| 90 | var hit = cache[str]; |
| 91 | return hit || (cache[str] = fn(str)) |
| 92 | }) |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Camelize a hyphen-delimited string. |