{"version":3,"file":"createDoingHook.cjs","names":[],"sources":["../src/createDoingHook.ts"],"sourcesContent":["import type { Hooks, StoreKey } from './types';\n\n/**\n * Returns whether a hook is currently being executed.\n *\n */\nexport type DoingHook = (\n\t/**\n\t * The name of the hook to check for.\n\t * If omitted, will check for any hook being executed.\n\t */ hookName?: string\n) => boolean;\n\n/**\n * Returns a function which, when invoked, will return whether a hook is\n * currently being executed.\n *\n * @param hooks    Hooks instance.\n * @param storeKey\n *\n * @return Function that returns whether a hook is currently\n *                     being executed.\n */\nfunction createDoingHook( hooks: Hooks, storeKey: StoreKey ): DoingHook {\n\treturn function doingHook( hookName ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\t// If the hookName was not passed, check for any current hook.\n\t\tif ( 'undefined' === typeof hookName ) {\n\t\t\treturn hooksStore.__current.size > 0;\n\t\t}\n\n\t\t// Find if the `hookName` hook is in `__current`.\n\t\treturn Array.from( hooksStore.__current ).some(\n\t\t\t( hook ) => hook.name === hookName\n\t\t);\n\t};\n}\n\nexport default createDoingHook;\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,SAAS,gBAAiB,OAAc,UAAgC;CACvE,OAAO,SAAS,UAAW,UAAW;EACrC,MAAM,aAAa,MAAO;EAG1B,IAAK,gBAAgB,OAAO,UAC3B,OAAO,WAAW,UAAU,OAAO;EAIpC,OAAO,MAAM,KAAM,WAAW,SAAU,CAAC,CAAC,MACvC,SAAU,KAAK,SAAS,QAC3B;CACD;AACD"}