12 lines
168 B
JavaScript
12 lines
168 B
JavaScript
|
export function thunk (func) {
|
||
|
let cached
|
||
|
let runOnce
|
||
|
return () => {
|
||
|
if (!runOnce) {
|
||
|
cached = func()
|
||
|
runOnce = true
|
||
|
}
|
||
|
return cached
|
||
|
}
|
||
|
}
|