shuffle

Shuffle array in place. Source: https://stackoverflow.com/a/6274381/616095

shuffle(a: array): array
Parameters
a (array)
Returns
array: Shuffled

unique

Filter array by unique values. Source: https://stackoverflow.com/a/14438954/616095

unique(a: array): array
Parameters
a (array)
Returns
array: Without duplicates

boundingRectsAreOverlapping

Return a boolean value that indicates the overlapping status between two DOMRect.

boundingRectsAreOverlapping(boundingRectA: DOMRect, boundingRectB: DOMRect): boolean
Parameters
boundingRectA (DOMRect) given by getBoundingClientRect
boundingRectB (DOMRect) given by getBoundingClientRect
Returns
boolean: Overlapping status

pointerInBoundingRect

Return a boolean value that indicates whether the pointer is in the given bounding rectangle.

pointerInBoundingRect(pointer: MouseEvent, boundingRect: DOMRect): boolean
Parameters
pointer (MouseEvent)
boundingRect (DOMRect) given by getBoundingClientRect
Returns
boolean: Pointer is in the given bounding rectangle

documentWidth

Get the viewport width.

documentWidth(): number
Returns
number: Viewport width

documentHeight

Get the viewport height.

documentHeight(): number
Returns
number: Viewport height

querySelectorAllAsArray

Consistent cross-browser querySelectorAll (on Edge you can’t use .forEach on a NodeList).

querySelectorAllAsArray($container: Element, selector: string): array
Parameters
$container (Element) any element
selector (string) used by querySelectorAll
Returns
array: Of elements

kebabCaseToPascalCase

kebab-case to PascalCase.

kebabCaseToPascalCase(string: string): string
Parameters
string (string)
Returns
string: PascalCase

numberFromString

Return the number included in a string.

numberFromString(string: string): number
Parameters
string (string)
Returns
number: Given string as a number

pascalCaseToKebabCase

PascalCase to kebab-case.

pascalCaseToKebabCase(string: string): string
Parameters
string (string)
Returns
string: kebab-case