shell-ahk
Version:
`Lodash`/`jQuery` for `AHK`.
21 lines (13 loc) • 372 B
text/coffeescript
# @ts-check
$cacheOnce = {}
$indexOnce = 0
###* @type import('../type/module').Once ###
export default (callback) ->
$i = $indexOnce
$indexOnce++
$cacheOnce[$i] = [false, '']
return (args...) ->
if $cacheOnce[$i][0] then return $cacheOnce[$i][1]
$result = callback args...
$cacheOnce[$i] = [true, $result]
return $result