pinafore/routes/_utils/thunk.js

12 lines
158 B
JavaScript
Raw Normal View History

2018-02-22 01:57:49 +00:00
export function thunk (fn) {
2018-02-22 01:52:33 +00:00
let value
let called
return () => {
if (!called) {
value = fn()
called = true
}
return value
}
2018-02-22 01:57:49 +00:00
}