utils.d.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import { Dictionary } from './types/interfaces/Dictionary';
  2. import FilterItem from './FilterItem';
  3. /**
  4. * A function to check that all elements of an array are found within another array.
  5. * @param {Array} arr1 is the array of strings to be checked
  6. * @param {Array} arr2 is the array of strings to check against
  7. * @return {Boolean} whether all string of arr1 are contained in arr2
  8. */
  9. declare const allStringsOfArray1InArray2: (arr1: string[], arr2: string[]) => boolean;
  10. export { allStringsOfArray1InArray2 };
  11. /**
  12. * Given a CSS prop it will normalize the syntax for JS
  13. * e.g. transform background-color to backgroundColor
  14. * @param {String} cssProp prop name
  15. * @return {String} normalized name
  16. */
  17. declare const getNormalizedCssPropName: (cssProp: string) => string;
  18. export { getNormalizedCssPropName };
  19. /**
  20. * Set inline styles on an HTML node
  21. * @param {HTMLElement} node - HTML node
  22. * @param {Object} styles - object with styles
  23. * @returns {undefined}
  24. */
  25. declare function setStylesOnHTMLNode(node: Element, styles: any): void;
  26. export { setStylesOnHTMLNode };
  27. /**
  28. * Returns an object with value/key pairs of all data
  29. * attributes on an HTML element, disregarding the
  30. * two data attributes that are reserved for internal
  31. * usage by Filterizr
  32. * @param {Object} node - HTML node
  33. * @returns {Object} map of data attributes / values
  34. */
  35. declare function getDataAttributesOfHTMLNode(node: Element): Dictionary;
  36. export { getDataAttributesOfHTMLNode };
  37. /**
  38. * Check that a DOM element has a data-attribute present
  39. * @param {Object} node element
  40. * @param {String} dataAttributeName name of data attribute
  41. * @return {Boolean} data attribute exists
  42. */
  43. declare function checkDataAttributeExists(node: Element, dataAttributeName: string): boolean;
  44. export { checkDataAttributeExists };
  45. /**
  46. * A very simple function to perform a basic
  47. * deep clone of an object.
  48. * @param {Object} o is the object to perform the deep clone on
  49. * @return {Object} deep clone
  50. */
  51. declare const makeShallowClone: (o: any) => Dictionary;
  52. export { makeShallowClone };
  53. /**
  54. * A function to recursively merge an object, copying over all
  55. * properties of the old object missing from the target object.
  56. * In case a prop in is an object, the method is called recursively.
  57. * This is a non-mutating method.
  58. * @param {Object} old is the old object from which the missing props are copied.
  59. * @param {Object} target is the target object with the updated values.
  60. */
  61. declare const merge: (old: any, target: any) => Dictionary;
  62. export { merge };
  63. /**
  64. * A function get the intersection of two arrays. IE9+.
  65. * @param {Array} arr1 is the first array of which to get the intersection
  66. * @param {Array} arr2 is the second array of which to get the intersection
  67. */
  68. declare const intersection: (arr1: any[], arr2: any[]) => any;
  69. export { intersection };
  70. /**
  71. * Debounce of Underscore.js
  72. */
  73. declare const debounce: (func: Function, wait: number, immediate: boolean) => Function;
  74. export { debounce };
  75. /**
  76. * Fisher-Yates shuffle ES6 non-mutating implementation.
  77. * @param {Array} array the array to shuffle
  78. * @return {Array} shuffled array without mutating the initial array.
  79. */
  80. declare const shuffle: (array: any[]) => any[];
  81. export { shuffle };
  82. /**
  83. * Simple method to check if two arrays of FilterItems
  84. * are sorted in the same manner or not.
  85. * @param {Array} arr1 the first array of FilterItems
  86. * @param {Array} arr2 the second array of FilterItems
  87. * @return {Boolean} equality
  88. */
  89. declare const filterItemArraysHaveSameSorting: (filterItemsA: FilterItem[], filterItemsB: FilterItem[]) => boolean;
  90. export { filterItemArraysHaveSameSorting };
  91. /**
  92. * Simple non-mutating sorting function for arrays of objects by a property
  93. * @param {Array} array to sort
  94. * @param {Function} propFn fetches the property by which to sort
  95. * @return {Array} a new sorted array
  96. */
  97. declare const sortBy: (array: any[], propFn: Function) => any[];
  98. export { sortBy };
  99. /**
  100. * Error checking method to restrict a prop to some allowed values
  101. * @param {String} name of the option key in the options object
  102. * @param {String|Number|Object|Function|Array|Boolean} value of the option
  103. * @param {String} type of the property
  104. * @param {Array} allowed accepted values for option
  105. * @param {String} furtherHelpLink a link to docs for further help
  106. */
  107. declare const checkOptionForErrors: (name: string, value: string | number | boolean | object | Function | any[], type?: string, allowed?: RegExp | any[], furtherHelpLink?: string) => void;
  108. export { checkOptionForErrors };
  109. /**
  110. * Wrapper around document.querySelector, will function as
  111. * an identity function if an HTML element is passed in
  112. * @param {HTMLElement|string} nodeOrSelector
  113. */
  114. declare const getHTMLElement: (selectorOrNode: string | HTMLElement) => HTMLElement;
  115. export { getHTMLElement };
  116. /**
  117. * A Regexp to validate potential values for the CSS easing property of transitions.
  118. */
  119. declare const cssEasingValuesRegexp: RegExp;
  120. export { cssEasingValuesRegexp };
  121. /**
  122. * Possible animation states for Filterizr
  123. */
  124. declare const FILTERIZR_STATE: {
  125. IDLE: string;
  126. FILTERING: string;
  127. SORTING: string;
  128. SHUFFLING: string;
  129. };
  130. export { FILTERIZR_STATE };
  131. /**
  132. * Transition end events with vendor prefixing
  133. */
  134. declare const TRANSITION_END_EVENTS: string[];
  135. export { TRANSITION_END_EVENTS };
  136. /**
  137. * A no-operation function
  138. */
  139. declare const noop: () => void;
  140. export { noop };