11 lines
156 B
JavaScript
11 lines
156 B
JavaScript
|
export function thunk(fn) {
|
||
|
let value
|
||
|
let called
|
||
|
return () => {
|
||
|
if (!called) {
|
||
|
value = fn()
|
||
|
called = true
|
||
|
}
|
||
|
return value
|
||
|
}
|
||
|
}
|