UNPKG

@zendesk/react-measure-timing-hooks

Version:

react hooks for measuring time to interactive and time to render of components

32 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ensureMatcherFn = ensureMatcherFn; exports.convertMatchersToFns = convertMatchersToFns; exports.convertLabelMatchersToFns = convertLabelMatchersToFns; const matchSpan_1 = require("./matchSpan"); function ensureMatcherFn(matcherFnOrDefinition) { return typeof matcherFnOrDefinition === 'function' ? matcherFnOrDefinition : (0, matchSpan_1.fromDefinition)(matcherFnOrDefinition); } function arrayHasAtLeastOneElement(arr) { return arr.length > 0; } function convertMatchersToFns(matchers) { const mapped = matchers?.map((m) => ensureMatcherFn(m)); if (mapped && arrayHasAtLeastOneElement(mapped)) { return mapped; } return undefined; } function convertLabelMatchersToFns(definitionLabelMatchers) { const matchers = {}; for (const key in definitionLabelMatchers) { // eslint-disable-next-line no-continue if (!definitionLabelMatchers?.[key]) continue; matchers[key] = ensureMatcherFn(definitionLabelMatchers[key]); } return matchers; } //# sourceMappingURL=ensureMatcherFn.js.map