- Numbers
- Arrays
- ArraysObjective
- ArraysNumerical
- Strings
- StringsCyrillic
- StringsLatin
- MockData
- Sort
- Stack
- Queue
Class for working with numbers and numerical data.
Get a random integer between the given range.
Returns Number The random integer between the min and max input.
Get a random float between the given range.
Returns Number The random float between the min and max input.
Normalize a number between 0 and 1 based on a known minimum and maximum value.
Returns Number The random float between the min and max input.
Normalize a number between a custom range (max,min) based on a known minimum and maximum value of the original dataset.
val
Number The value to normalize.minOriginal
Number The minimum extent in the original range.maxOriginal
Number The maximum extent in the original range.minNew
Number The minimum extent in the new, custom range.maxNew
Number The maximum extent in the new, custom range.
Returns Number
Class for working with arrays of any types
Find unique items within the array and count frequency of occurrence within the array.
array
Array A an array of values (string, number).
Returns Object Object containing the unique keys of the array, and counts of occurrence in the source array.
Chunk one flat array into a series of arrays of a certain size.
array
Array A an array of values (string, number, etc.).size
Number The size of chunks to split the array into.
Returns Array<Array> An array containing arrays of the specified size, containing the original data from the flat array.
Flattens n-nested arrays into one array of values.
array
Array A an array containing arrays nested to any amount (n).result
(optional, default[]
)
Returns Array A flat array of values/objects extracted from the nested arrays.
Class for working with arrays containing objects with key/value data.
Group an array of objects by similar properties.
array
Array<Object> An array of objects with similar properties.key
String The unique key to group by.
Returns Object Object containing child objects which contain the individual data points corresponding to the property key used for grouping.
Sort an array of objects with similar properties by a shared key's value.
array
Array<Object> An array of objects with similar properties.key
String The unique key to merge by.descending
Boolean Whether to merge descending (default), or ascending. (optional, defaulttrue
)
Returns Array<Object> Array of objects sorted by the key's value across occurrences.
Get the minimum value of a key in an array containing objects with that key.
array
Array A an array containing objects.key
String A key which exists in the objects in the array, with associated numerical values.
Returns Number The minimum value of all the keys in the object array.
Get the maximum value of a key in an array containing objects with that key.
array
Array A an array containing objects.key
String A key which exists in the objects in the array, with associated numerical values.
Returns Number The maximum value of all the keys in the object array.
Normalize the values in an object array associated with a specific key between 0 and 1 or a custom range based on the minimums and maximums contained in the object array by that key.
array
Array A an array containing objects.key
String A key which exists in the objects in the array, with associated numerical values.newMin
Number (Optional) A custom minimum value to normalize to. (optional, default0
)newMax
Number (Optional) A custom maximum value to normalize to. (optional, default1
)
Returns Array The modified object array.
Normalize the values in an object array associated with specific keys between 0 and 1 or a custom range based on the minimums and maximums contained in the object array by those keys.
array
Array A an array containing objects.keys
Array<String> An array of keys which exists in the objects in the array, with associated numerical values.newMin
Number (Optional) A custom minimum value to normalize to. (optional, default0
)newMax
Number (Optional) A custom maximum value to normalize to. (optional, default1
)
Returns Array The modified object array.
Normalize all the values in an object array associated with keys which have numerical value pairs between 0 and 1 or a custom range based on the minimums and maximums contained in the object array by those keys.
array
Array A an array containing objects.newMin
Number (Optional) A custom minimum value to normalize to. (optional, default0
)newMax
Number (Optional) A custom maximum value to normalize to. (optional, default1
)
Returns Array The modified object array.
Turn a flat array of objects containing common properties into a nested object hierarchy based on parent/child keys. ex. Folders, File Versions, etc.
array
Array<Object> A an array of objects.parentKey
String The common property of the objects to establish primary identity.childKey
String The common property of the objects to establish parent -> child relationships.
Returns Array<Object> An array of objects, nested using the .children accessor based on the parent -> child hierarchy established.
Class for working with arrays containing numbers and numerical data.
Sum the values of an array.
Returns Number The sum of values in the array.
Get the maximum value in the array.
Returns Number The maximum of the values in the array.
Get the minimum value in the array.
Returns Number The minimum of the values in the array.
Class for working with string data.
Check whether a string is null/empty and return a workable string.
str
String The string to check for null/empty.
Returns String A full or empty string.
Remove non-printable (non-ASCII) characters from a string.
str
String The string to clean of non-printable characters.
Returns String String without the non-ASCII characters.
Remove non-pathable characters from a string.
str
String The string to clean of non-pathable characters.
Returns String String without the path-breaking characters.
Create a random, unique identifier string.
Returns String A random string with alpha-numeric characters.
Class for working with Cyrillic string data.
Get an array of all the Cyrillic words from a monolithic string.
str
The string to break up into individual words.
Returns RegExpMatchArray An array of individual Cyrillic words.
Class for working with Latin string data.
Get an array of all the words from a monolithic string.
str
The string to break up into individual words.
Returns RegExpMatchArray An array of individual words.
Remove non-alpha-numeric characters from a string.
str
String The string to clean of non-alpha-numeric characters.
Returns String String without characters that aren't letters or numbers.
Remove non-alphabetic characters from a string.
str
String The string to clean of non-alphabetic characters.
Returns String String with characters which are only EN letters.
Class for creating mock data for algorithm/visualization testing.
Get a filled array of the corresponding size.
size
Number The amount of numbers in the array.
Returns Array<Number> A filled array the length of the specified size.
Create mock data for a circle-packing algorithm.
size
The amount of data points to create
Returns Array<{r: number, spaceType: (string), id: Number}> An array of objects which can be used as circles in circle-packing algorithm testing.
Create mock data for a network/graph algorithm.
size
The amount of data points to create
Returns {nodes: Array<{size: Number, x: null, y: null}>, links: Array<{source: number, target: number}>} An array of objects which can be used as nodes and connections in network/graph algorithm testing scenarios.
Class for sorting arrays containing numerical data.
Sort an array of numbers using the Bubble Sort algorithm. Iterating through all items in the array, we compare the current item with the next one in the array. If the current one is greater, the positions are swapped. This is repeated until there is no more swapping necessary.
Returns Array<Number> An array of sorted numbers.
Sort an array of numbers using the Insertion Sort algorithm. Insertion merge is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. The array elements are compared with each other sequentially and then arranged simultaneously in some particular order. The analogy can be understood from the style we arrange a deck of cards.
Returns Array<Number> An array of sorted numbers.
Sort an array of numbers using the Merge Sort algorithm. The MergeSort function repeatedly divides the array into two halves until we reach a stage where we try to perform MergeSort on a subarray of size 1 i.e. p == r. After that, the merge function comes into play and combines the sorted arrays into larger arrays until the whole array is merged.
Returns Array<Number> An array of sorted numbers.
Sort an array of numbers using the Quick Sort algorithm. QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot. There are many different versions of quickSort that pick pivot in different ways.
Returns Array<Number> An array of sorted numbers.
Stack data structure.
Get the count of the number of items in the stack.
Returns number The number of items in the stack.
Add an item to the top of the stack.
item
The item to add to the stack.
Returns number The new size of the stack.
Remove the top item from the stack.
Returns any
Get the item at the top of the stack, without removing it.
Returns any The item at the top of the stack.
Whether or not the stack is empty.
Returns boolean Whether or not the stack is empty.
Queue data structure.