* Create a cached version of a pure function.
(fn)
| 79 | * Create a cached version of a pure function. |
| 80 | */ |
| 81 | function cached (fn) { |
| 82 | var cache = Object.create(null); |
| 83 | return (function cachedFn (str) { |
| 84 | var hit = cache[str]; |
| 85 | return hit || (cache[str] = fn(str)) |
| 86 | }) |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Camelize a hyphen-delimited string. |