{"version":3,"file":"createDidHook.mjs","names":[],"sources":["../src/createDidHook.ts"],"sourcesContent":["import validateHookName from './validateHookName';\nimport type { Hooks, StoreKey } from './types';\n\n/**\n *\n * Returns the number of times an action has been fired.\n *\n */\nexport type DidHook = (\n\t/**\n\t * The hook name to check.\n\t */\n\thookName: string\n) => number | undefined;\n\n/**\n * Returns a function which, when invoked, will return the number of times a\n * hook has been called.\n *\n * @param hooks    Hooks instance.\n * @param storeKey\n *\n * @return  Function that returns a hook's call count.\n */\nfunction createDidHook( hooks: Hooks, storeKey: StoreKey ): DidHook {\n\treturn function didHook( hookName ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn hooksStore[ hookName ] && hooksStore[ hookName ].runs\n\t\t\t? hooksStore[ hookName ].runs\n\t\t\t: 0;\n\t};\n}\n\nexport default createDidHook;\n"],"mappings":";;;;;;;;;;;AAwBA,SAAS,cAAe,OAAc,UAA8B;CACnE,OAAO,SAAS,QAAS,UAAW;EACnC,MAAM,aAAa,MAAO;EAE1B,IAAK,CAAE,iBAAkB,QAAS,GACjC;EAGD,OAAO,WAAY,aAAc,WAAY,SAAU,CAAC,OACrD,WAAY,SAAU,CAAC,OACvB;CACJ;AACD"}