All files / utils dom.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40        94x       94x   94x             94x   15x             94x 11x           94x            
/**
 * @module Utils
 */
 
import * as MC from "@lisn/globals/minification-constants";
 
import { MutationCategory } from "@lisn/globals/types";
 
import { isValidStrList } from "@lisn/utils/validation";
 
import { newBitSpaces, createBitSpace } from "@lisn/modules/bit-spaces";
 
/**
 * Returns true if the given string is a valid category.
 *
 * @category Validation
 */
export const isValidMutationCategory = (
  category: string,
): category is MutationCategory => DOM_CATEGORIES_SPACE.has(category);
 
/**
 * Returns true if the given string or array is a list of valid categories.
 *
 * @category Validation
 */
export const isValidMutationCategoryList = (categories: string | string[]) =>
  isValidStrList(categories, isValidMutationCategory, false);
 
/**
 * @ignore
 * @internal
 */
export const DOM_CATEGORIES_SPACE = createBitSpace<MutationCategory>(
  newBitSpaces(),
  MC.S_ADDED,
  MC.S_REMOVED,
  MC.S_ATTRIBUTE,
);