UNPKG

@wordpress/hooks

Version:
31 lines (29 loc) 733 B
/** * Internal dependencies */ import validateHookName from './validateHookName'; /** * * Returns the number of times an action has been fired. * */ /** * Returns a function which, when invoked, will return the number of times a * hook has been called. * * @param hooks Hooks instance. * @param storeKey * * @return Function that returns a hook's call count. */ function createDidHook(hooks, storeKey) { return function didHook(hookName) { const hooksStore = hooks[storeKey]; if (!validateHookName(hookName)) { return; } return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0; }; } export default createDidHook; //# sourceMappingURL=createDidHook.js.map