Pinafore-Web-Client-Frontend/routes/_utils/thunk.js

12 lines
158 B
JavaScript
Raw Normal View History

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