- siFunciona
-
All the siFunciona system functions for stringing together functions and simplifying logic.
- stringHelpers
-
Manage how strings are manipulated with these utilities.
- objectHelpers
-
Simplify working with object by providing array-like parsing. Also, provides cloning and merging along with accessors that always have a return value for optimal nesting.
- numberHelpers
-
Some number comparators and random number generators.
- functionHelpers
-
Manage how functions are called with these utilities.
- objectDescriptors
-
Create a format to standardize every object into a specific template.
- arrayHelpers
-
Some simple utility functions for generating arrays or performing work on arrays.
All the siFunciona system functions for stringing together functions and simplifying logic.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
Manage how strings are manipulated with these utilities.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
-
stringHelpers
-
.words(str) ⇒
array
-
.ucFirst(str) ⇒
string
-
.titleCase(str) ⇒
string
-
.strBeforeLast(str, search) ⇒
string
-
.strBefore(str, search) ⇒
string
-
.strAfterLast(str, search) ⇒
string
-
.strAfter(str, search) ⇒
string
-
.snakeCase(str) ⇒
string
-
.regexEscape(str) ⇒
string
-
.makeRelativePath(fromFile, toFile) ⇒
string
-
.makeFilepath(root, [append]) ⇒
string
-
.kabobCase(str) ⇒
string
-
.camelCase(str) ⇒
string
-
.words(str) ⇒
Split a string into sets of numbers or letters.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
Given a string, make the first character uppercase and the rest lowercase.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
Given a string in kebab-case, snake_case, camelCase or 'Sentence case', convert to 'Title Case'.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
Retrieve the string part after the last search match.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
search | string |
Retrieve the string part before the search match.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
search | string |
Retrieve the string part after the last search match.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
search | string |
Retrieve the string part after the search match.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
search | string |
Given a string in kebab-case, camelCase or 'Sentence case', convert to snake_case.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
Take a string and escape the regex characters.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
Compare two file paths and simplify them to a relative path.
Kind: static method of stringHelpers
Param | Type |
---|---|
fromFile | string |
toFile | string |
Format the given path so that it does not have trailing slashes and also correctly appends a path.
Kind: static method of stringHelpers
Param | Type | Default |
---|---|---|
root | string |
|
[append] | string |
"''" |
Given a string in snake_case, camelCase or 'Sentence case', convert to kabob-case.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
Given a string in kebab-case, snake_case or 'Sentence case', convert to camelCase.
Kind: static method of stringHelpers
Param | Type |
---|---|
str | string |
Simplify working with object by providing array-like parsing. Also, provides cloning and merging along with accessors that always have a return value for optimal nesting.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
-
objectHelpers
-
static
-
.mergeObjectsMutable ⇒
*
-
.mergeObjects ⇒
*
-
.setValue(key, value, item) ⇒
Object
|Array
-
.setAndReturnValue(item, key, value) ⇒
*
-
.reduceObject(obj, fn, [initialValue]) ⇒
*
-
.objectValues(object, [includeInherited]) ⇒
Array
-
.objectKeys(object, [includeInherited]) ⇒
Array.<(string|number)>
-
.mergeObjectsBase([options]) ⇒
module:objectHelpers~mergeObjectsCallback
|mergeObjectsCallback
-
.mapObject(obj, fn, [thisArg]) ⇒
Object
|Array
-
.isObject(object) ⇒
boolean
-
.isInstanceObject(object) ⇒
boolean
-
.isCloneable(value) ⇒
boolean
-
.filterObject(obj, fn, [thisArg]) ⇒
Object
|Array
-
.emptyObject(item) ⇒
boolean
-
.dotUnset(arrayObject, dotNotation) ⇒
Object
-
.dotSet(arrayObject, dotNotation, value) ⇒
Object
-
.dotNotate(arrayObject, [retainObjects]) ⇒
DotNotatedObject
-
.dotGet(arrayObject, dotNotation, [defaultValue]) ⇒
*
-
.cloneObject(object, [options]) ⇒
Object
-
.mergeObjectsMutable ⇒
-
inner
-
~handleRetainObjects([retainObjects]) ⇒
function
-
~performDotNotate(arrayObject, didRetain, [prepend], [results]) ⇒
DotNotatedObject
-
~handleRetainObjects([retainObjects]) ⇒
-
static
Uses mergeObjectsBase deep merge objects and arrays, merge by reference.
Kind: static constant of objectHelpers
See: module:objectHelpers~mergeObjectsCallback
Param | Type | Description |
---|---|---|
...objects | Object |
Provide a list of objects which will be merged starting from the end up into the first |
Uses mergeObjectsBase deep merge objects and arrays, merge by value.
Kind: static constant of objectHelpers
See: module:objectHelpers~mergeObjectsCallback
Param | Type | Description |
---|---|---|
...objects | Object |
Provide a list of objects which will be merged starting from the end up into the first |
Set a value on an item, then return the item. NOTE: Argument order designed for usage with pipe
Kind: static method of objectHelpers
Param | Type | Description |
---|---|---|
key |
string | number
|
The key on the item which will have its value set |
value | * |
Any value to be applied to the key |
item |
Object | Array
|
An object or array to be updated |
Set a value on an item, then return the value
Kind: static method of objectHelpers
Param | Type | Description |
---|---|---|
item |
Object | Array
|
An object or array to be updated |
key |
string | number
|
The key on the item which will have its value set |
value | * |
Any value to be applied to the key |
This function is intended to replicate behaviour of the Array.reduce() function but for Objects. If an array is passed in instead then it will perform standard reduce(). It is recommended to always use the standard reduce() function when it is known that the object is actually an array.
Kind: static method of objectHelpers
Param | Type | Description |
---|---|---|
obj |
Object | Array
|
The Object (or Array) to be filtered |
fn |
module:objectHelpers~reduceCallback | function | reduceCallback
|
The function to be processed for each filtered property |
[initialValue] |
Object | Array
|
Optional. Value to use as the first argument to the first call of the callback. If no initial value is supplied, the first element in the array will be used. Calling reduce on an empty array without an initial value is an error. |
Get an array of values from any object or array. Will return empty array when invalid or there are no values. Optional flag will include the inherited values from prototype chain when set.
Kind: static method of objectHelpers
Param | Type | Default |
---|---|---|
object |
Object | Array
|
|
[includeInherited] | boolean |
false |
Get an array of keys from any object or array. Will return empty array when invalid or there are no keys. Optional flag will include the inherited keys from prototype chain when set.
Kind: static method of objectHelpers
Param | Type | Default |
---|---|---|
object |
Object | Array
|
|
[includeInherited] | boolean |
false |
objectHelpers.mergeObjectsBase([options]) ⇒ module:objectHelpers~mergeObjectsCallback
| mergeObjectsCallback
Perform a deep merge of objects. This will return a function that will combine all objects and sub-objects. Objects having the same attributes will overwrite from last object to first. NOTE: Use the mapLimit and relevancyRange to resolve "too much recursion" when the object is large and is known to have circular references. A high mapLimit may lead to heavy memory usage and slow performance.
Kind: static method of objectHelpers
Param | Type | Default | Description |
---|---|---|---|
[options] | Object |
{} |
|
[options.mapLimit] | number |
100 |
Size of temporary reference array used in memory before assessing relevancy. |
[options.depthLimit] | number |
-1 |
Control how many nested levels deep will be used, -1 = no limit, >-1 = nth level limited. |
[options.relevancyRange] | number |
1000 |
Total reference map length subtract this range, any relevancy less than that amount at time of evaluation will be removed. |
[options.map] |
Iterable | array
|
[] |
A predetermined list of references gathered (to be passed to itself during recursion). |
[options.useClone] | boolean |
false |
This function is intended to replicate behaviour of the Array.map() function but for Objects. If an array is passed in instead then it will perform standard map(). It is recommended to always use the standard map() function when it is known that the object is actually an array.
Kind: static method of objectHelpers
Param | Type | Description |
---|---|---|
obj |
Object | Array
|
The Object (or Array) to be mapped |
fn |
module:objectHelpers~mapCallback | function
|
The function to be processed for each mapped property |
[thisArg] |
Object | Array
|
Optional. Value to use as this when executing callback. |
Check if the provided thing is an object / array.
Kind: static method of objectHelpers
Param | Type |
---|---|
object | * |
Check if the current object has inherited properties.
Kind: static method of objectHelpers
Param | Type |
---|---|
object |
Object | Array
|
Determine if the value is a reference instance
Kind: static method of objectHelpers
Param | Type |
---|---|
value |
Array | Object | *
|
This function is intended to replicate behaviour of the Array.filter() function but for Objects. If an array is passed in instead then it will perform standard filter(). It is recommended to always use the standard filter() function when it is known that the object is actually an array.
Kind: static method of objectHelpers
Param | Type | Description |
---|---|---|
obj |
Object | Array
|
The Object (or Array) to be filtered |
fn |
module:objectHelpers~filterCallback | function
|
The function to be processed for each filtered property |
[thisArg] |
Object | Array
|
Optional. Value to use as this when executing callback. |
Helper function for testing if the item is an Object or Array that does not have any properties
Kind: static method of objectHelpers
Param | Type | Description |
---|---|---|
item |
Object | Array
|
Object or Array to test |
Unset a nested property value an object.
Kind: static method of objectHelpers
Returns: Object
- The modified object
Param | Type | Description |
---|---|---|
arrayObject | Object |
The array or object to set the property on |
dotNotation | string |
The path for the property |
Set a nested property value an object.
Kind: static method of objectHelpers
Returns: Object
- The modified object
Param | Type | Description |
---|---|---|
arrayObject | Object |
The array or object to set the property on |
dotNotation | string |
The path for the property |
value | * |
The default value to return if the property is not found |
Convert an array or object to a single dimensional associative array with dot notation.
Kind: static method of objectHelpers
Returns: DotNotatedObject
- The dot-notated object
Param | Type | Default | Description |
---|---|---|---|
arrayObject | Object |
The array or object to dot-notate | |
[retainObjects] | Array.<DotNotationString> |
[] |
An array of keys to retain as objects |
Get a nested property value from an object.
Kind: static method of objectHelpers
Returns: *
- The value of the property
Param | Type | Default | Description |
---|---|---|---|
arrayObject | Object |
The array or object to get the property from | |
dotNotation | string |
The path to the property | |
[defaultValue] |
string | null
|
null |
The default value to return if the property is not found |
Clone objects for manipulation without data corruption, returns a copy of the provided object. NOTE: Use the mapLimit and relevancyRange to resolve "too much recursion" when the object is large and is known to have circular references. A high mapLimit may lead to heavy memory usage and slow performance.
Kind: static method of objectHelpers
Param | Type | Default | Description |
---|---|---|---|
object | Object |
The original object that is being cloned | |
[options] | Object |
{} |
|
[options.mapLimit] | number |
100 |
Size of temporary reference array used in memory before assessing relevancy. |
[options.depthLimit] | number |
-1 |
Control how many nested levels deep will be used, -1 = no limit, >-1 = nth level limited. |
[options.relevancyRange] | number |
1000 |
Total reference map length subtract this range, any relevancy less than that amount at time of evaluation will be removed. |
Convert an array of keys into a regex, return a function to test if incoming keys match.
Kind: inner method of objectHelpers
Returns: function
- The dot-notated array
Param | Type | Default | Description |
---|---|---|---|
[retainObjects] | Array.<DotNotationString> |
[] |
An array of keys to retain as objects |
The underlying logic function for converting arrays to dot-notation.
Kind: inner method of objectHelpers
Returns: DotNotatedObject
- The dot-notated object
Param | Type | Default | Description |
---|---|---|---|
arrayObject | Object |
The array or object to dot-notate | |
didRetain | function |
The test function to see if a key should be retained | |
[prepend] | DotNotationString |
'' |
The path for the property being processed |
[results] | DotNotatedObject |
{} |
The final array to return |
Some number comparators and random number generators.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
-
numberHelpers
-
.randomNumber(range, [offset], [interval]) ⇒
number
-
.randomInteger(range, [offset], [interval]) ⇒
number
-
.compare(val1, val2) ⇒
number
-
.absoluteMin(num1, num2) ⇒
number
-
.absoluteMax(num1, num2) ⇒
number
-
.randomNumber(range, [offset], [interval]) ⇒
Create a single random number within provided range. And with optional offset, The distance between the result numbers can be adjusted with interval.
Kind: static method of numberHelpers
Param | Type | Default | Description |
---|---|---|---|
range | number |
Choose the breadth of the random number (0-100 would be 100 for range) | |
[offset] | number |
0 |
Choose the starting number (1-10 would be 1 for offset, 9 for range) |
[interval] | number |
1 |
Choose the distance between numbers (~5, ~10, ~15 would be 5 for interval, 1 for offset, 2 for range) |
Create a single random integer within provide range. And with optional offset, The distance between the result numbers can be adjusted with interval.
Kind: static method of numberHelpers
Param | Type | Default | Description |
---|---|---|---|
range | number |
Choose the breadth of the random number (0-100 would be 100 for range) | |
[offset] | number |
0 |
Choose the starting number (1-10 would be 1 for offset, 9 for range) |
[interval] | number |
1 |
Choose the distance between numbers (5, 10, 15 would be 5 for interval, 1 for offset, 2 for range) |
Compare two numbers and return: -1 to indicate val1 is less than val2 0 to indicate both values are the equal 1 to indicate val1 is greater than val2
Kind: static method of numberHelpers
Param | Type | Description |
---|---|---|
val1 | number |
The first number to compare |
val2 | number |
The second number to compare |
Helper for returning the absolute min value
Kind: static method of numberHelpers
Param | Type | Description |
---|---|---|
num1 | number |
A number to compare |
num2 | number |
Another number to be compared against |
Helper for returning the absolute max value
Kind: static method of numberHelpers
Param | Type | Description |
---|---|---|
num1 | number |
A number to compare |
num2 | number |
Another number to be compared against |
Manage how functions are called with these utilities.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
-
functionHelpers
-
.trace(label, useClone) ⇒
function
-
.relevancyFilter(map, [options]) ⇒
relevanceMap
-
.queueTimeout([queueManagerHandle]) ⇒
module:functionHelpers~queueTimeoutHandle
-
.queueManager([queue]) ⇒
module:functionHelpers~queueManagerHandle
-
~makeQueuedRunnable(resolve, reject, fn, ...args) ⇒
queuedRunnable
-
~postRun(result) ⇒
*
-
~runNextItem() ⇒
IteratorYieldResult
|null
- ~pushAnother(fn, ...args) ⇒
-
~makeQueuedRunnable(resolve, reject, fn, ...args) ⇒
-
.preloadParams(fn, params, [unassignedParam]) ⇒
module:functionHelpers~callWithMissing
-
.pipe(...fns) ⇒
*
-
.onBodyLoad(callback, [reset]) ⇒
Array.<function()>
-
.makeBasicQueue(initialQueue) ⇒
IsQueue
-
.delay(time) ⇒
module:functionHelpers~delayHandler
-
.curry(fn) ⇒
function
|*
-
.callWithParams(fn, params, [minimum]) ⇒
*
-
.trace(label, useClone) ⇒
Output the value with label to the console and return the value to not interrupt the code.
Kind: static method of functionHelpers
Param | Type | Description |
---|---|---|
label | string |
Pass an identifying label of the value being output. |
useClone | Determines if the logged data should be a clone of the original to preserve state. |
Remove elements out of relevance range and update the max relevance.
Kind: static method of functionHelpers
Param | Type | Default |
---|---|---|
map | relevanceMap |
|
[options] | Object |
{} |
[options.mapLimit] | int |
1000 |
[options.relevancyRange] | int |
100 |
Manage functions to run sequentially with delays.
Kind: static method of functionHelpers
Param | Type | Default |
---|---|---|
[queueManagerHandle] | module:functionHelpers~queueManagerHandle |
|
Manage functions to run sequentially.
Kind: static method of functionHelpers
Param | Type | Default | Description |
---|---|---|---|
[queue] | IsQueue |
[] |
The iterable that can be used to store queued functions |
-
.queueManager([queue]) ⇒
module:functionHelpers~queueManagerHandle
-
~makeQueuedRunnable(resolve, reject, fn, ...args) ⇒
queuedRunnable
-
~postRun(result) ⇒
*
-
~runNextItem() ⇒
IteratorYieldResult
|null
- ~pushAnother(fn, ...args) ⇒
-
~makeQueuedRunnable(resolve, reject, fn, ...args) ⇒
Convert a function to a queueable object.
Kind: inner method of queueManager
Param | Type |
---|---|
resolve | Promise.resolve |
reject | Promise.reject |
fn | function |
...args | * |
After an item is run, THEN run this function to reset isRunning
Kind: inner method of queueManager
Param | Type |
---|---|
result | * |
When ready, runs the next queued runnable generator.
Kind: inner method of queueManager
Add a function into the queue to be run when ready.
Kind: inner method of queueManager
Returns: Promise
Param | Type | Description |
---|---|---|
fn | function |
The function to run when ready |
...args | * |
Optional arguments to apply when the function is ready to be run |
functionHelpers.preloadParams(fn, params, [unassignedParam]) ⇒ module:functionHelpers~callWithMissing
Provide an array of parameters to be used with a function, allow the function to be called later with the missing parameter.
Kind: static method of functionHelpers
Param | Type | Default | Description |
---|---|---|---|
fn | function |
The function to be called | |
params | Array |
The parameters to preload | |
[unassignedParam] | number |
0 |
Position of missing parameter (zero indexed) |
Take one or more function with a single parameter and return value. Pass a parameter and the value will be transformed by each function then returned.
Kind: static method of functionHelpers
Param | Type | Description |
---|---|---|
...fns | function |
Takes a series of functions having the same parameter |
Prepare functions to be called once the body is available.
Kind: static method of functionHelpers
Param | Type | Default |
---|---|---|
callback | function |
|
[reset] | boolean |
false |
Create an instance of a basic queue.
Kind: static method of functionHelpers
Param | Type |
---|---|
initialQueue | Array |
Provide a timeout which returns a promise.
Kind: static method of functionHelpers
Param | Type | Description |
---|---|---|
time | number |
Delay in milliseconds |
Return a curried version of the passed function. The returned function expects the same number of arguments minus the ones provided. fn is the name of the function being curried.
Kind: static method of functionHelpers
Param | Type | Description |
---|---|---|
fn | function |
Receives a function to be curried |
Given a function, call with the correct number of parameters from an array of possible parameters.
Kind: static method of functionHelpers
Param | Type | Default | Description |
---|---|---|---|
fn | function |
The function to be called | |
params | Array |
Array of possible function parameters | |
[minimum] | number |
2 |
Minimum number of parameters to use in the function |
Create a format to standardize every object into a specific template.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
-
objectDescriptors
-
.mappedDescriptorMap :
module:objectDescriptors~descriptorMap
-
.descriptorMapSample :
module:objectDescriptors~descriptorMap
-
.descriptorDetailSample :
module:objectDescriptors~descriptorDetail
-
.descriptorSample :
module:objectDescriptors~descriptor
-
.sameDescriptor(descriptor1, descriptor2) ⇒
boolean
-
.nextReference(descriptor, currentReference) ⇒
number
|undefined
-
.describeObjectMap(object, [options]) ⇒
module:objectDescriptors~descriptorMap
-
.describeObjectDetail(value, [key], [index]) ⇒
module:objectDescriptors~descriptorDetail
-
.describeObject(object) ⇒
module:objectDescriptors~descriptor
-
.compareDescriptor(descriptor1, descriptor2) ⇒
boolean
-
.cloneDescriptorDetail(originalDetail) ⇒
module:objectDescriptors~descriptorDetail
-
.cloneDescriptor(originalMap) ⇒
module:objectDescriptors~descriptor
-
.checkDescriptorComplete(descriptor) ⇒
module:objectDescriptors~descriptor
-
.checkClearValues(descriptor, [keepValues]) ⇒
module:objectDescriptors~descriptor
-
.assignDescriptorDetail(originalDetail, ...details) ⇒
module:objectDescriptors~descriptorDetail
-
.assignDescriptor(originalMap, ...descriptors) ⇒
module:objectDescriptors~descriptor
-
.mappedDescriptorMap :
Kind: static constant of objectDescriptors
Kind: static constant of objectDescriptors
Kind: static constant of objectDescriptors
Kind: static constant of objectDescriptors
Check if the two descriptors are the same.
Kind: static method of objectDescriptors
Param | Type |
---|---|
descriptor1 | module:objectDescriptors~descriptor |
descriptor2 | module:objectDescriptors~descriptor |
Find the index of the next module:objectDescriptors.descriptorDetail to build a resource for.
Kind: static method of objectDescriptors
Param | Type |
---|---|
descriptor | module:objectDescriptors~descriptor |
currentReference | number |
Trace out the entire object including nested objects.
Kind: static method of objectDescriptors
Param | Type | Default |
---|---|---|
object |
Object | Array
|
|
[options] | Object |
{} |
[options.mapLimit] | number |
1000000000 |
[options.depthLimit] | number |
-1 |
[options.keepValues] | boolean |
false |
objectDescriptors.describeObjectDetail(value, [key], [index]) ⇒ module:objectDescriptors~descriptorDetail
Trace an object's attribute and provide details about it.
Kind: static method of objectDescriptors
Param | Type | Default |
---|---|---|
value | * |
|
[key] |
string | number
|
0 |
[index] | number |
0 |
Trace an object and return the descriptor which defines the object's structure and attributes.
Kind: static method of objectDescriptors
Param | Type |
---|---|
object | Object |
Check if two descriptors are the same or similar in that they have similar keys and the associated types are the same.
Kind: static method of objectDescriptors
Param | Type |
---|---|
descriptor1 | module:objectDescriptors~descriptor |
descriptor2 | module:objectDescriptors~descriptor |
Get a new copy of an existing Descriptor Detail
Kind: static method of objectDescriptors
Param | Type |
---|---|
originalDetail | module:objectDescriptors~descriptorDetail |
Make a copy of an object descriptor so that the original will not be mutated.
Kind: static method of objectDescriptors
Param | Type |
---|---|
originalMap | module:objectDescriptors~descriptor |
Check if the descriptors references have all been built and set complete to true if they have.
Kind: static method of objectDescriptors
Param | Type |
---|---|
descriptor | module:objectDescriptors~descriptor |
Check if we should clear the values on this descriptor
Kind: static method of objectDescriptors
Param | Type | Default |
---|---|---|
descriptor | module:objectDescriptors~descriptor |
|
[keepValues] | boolean |
false |
objectDescriptors.assignDescriptorDetail(originalDetail, ...details) ⇒ module:objectDescriptors~descriptorDetail
Assign properties from other details onto an existing detail.
Kind: static method of objectDescriptors
Param | Type |
---|---|
originalDetail | module:objectDescriptors~descriptorDetail |
...details | module:objectDescriptors~descriptorDetail |
objectDescriptors.assignDescriptor(originalMap, ...descriptors) ⇒ module:objectDescriptors~descriptor
Apply one or more descriptors to an existing descriptor so that they represent a merged version of the descriptors.
Kind: static method of objectDescriptors
Param | Type |
---|---|
originalMap | module:objectDescriptors~descriptor |
...descriptors | module:objectDescriptors~descriptor |
Some simple utility functions for generating arrays or performing work on arrays.
Version: 1.0.0
Author: Joshua Heagle joshuaheagle@gmail.com
-
arrayHelpers
-
.BasicQueue
-
.dequeue() ⇒
queuedItem
|*
-
.empty() ⇒
boolean
-
.enqueue(data) ⇒
BasicQueue
-
.peek() ⇒
queuedItem
|*
-
.size() ⇒
number
-
.dequeue() ⇒
-
.uniqueArray(array) ⇒
Array
-
.mergeArrays(...arrays) ⇒
Array
-
.compareArrays(...arrays) ⇒
Array.<module:arrayHelpers~compareArrayResult>
-
.buildArrayOfReferences(item, length) ⇒
Array.<*>
-
.buildArray(item, length) ⇒
Array.<*>
-
.addUniqueToArray(item, array) ⇒
Array
-
.BasicQueue
Class BasicQueue is a functional example of a queue to be used with queueManager.
Kind: static class of arrayHelpers
-
.BasicQueue
-
.dequeue() ⇒
queuedItem
|*
-
.empty() ⇒
boolean
-
.enqueue(data) ⇒
BasicQueue
-
.peek() ⇒
queuedItem
|*
-
.size() ⇒
number
-
.dequeue() ⇒
Remove and return the next item in the queue
Kind: instance method of BasicQueue
Check if the queue is empty
Kind: instance method of BasicQueue
Add an item to the end of the queue
Kind: instance method of BasicQueue
Param | Type |
---|---|
data |
queuedItem | *
|
Retrieve the next item from the queue
Kind: instance method of BasicQueue
Get the quantity of items in the queue
Kind: instance method of BasicQueue
Remove duplicate values from an array. uniqueArray
Kind: static method of arrayHelpers
Param | Type | Description |
---|---|---|
array | Array |
The array to make unique |
Take multiple arrays and then filter all these into one unique array.
Kind: static method of arrayHelpers
Param | Type | Description |
---|---|---|
...arrays | Array |
Provide multiple arrays to create one unique array |
Compare two Arrays and return the Object where the value for each property is as follows: -1 to indicate val1 is less than val2 0 to indicate both values are the equal 1 to indicate val1 is greater than val2 The returned Object uses the element values as the property names This functions works by first creating a concatenated array of all unique values. Then for each unique values, convert to a string and use it as a new property name. Array filter each array checking if it has the unique value. Use the lengths of these filtered arrays to compare. So if the first array has the value and the second one doesn't the first length will be one or more and the second will be zero, if the both have the value then both will be one or more.
Kind: static method of arrayHelpers
Param | Type | Description |
---|---|---|
...arrays | Array |
The arrays to compare |
Example
// example of input and resulting output
compareArrays(
['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1'],
['match1', 'match2', 'secondMismatch1', 'badMatch1', 'badMatch1']
)
// unique array
['match1', 'firstMismatch1', 'match2', 'firstMismatch2', 'badMatch1', 'secondMismatch1']
// result object
[
{
value: 'match1',
keys: [[0], [0]],
result: [0, 0]
},
{
value: 'firstMismatch1',
keys: [[1], []],
result: [1, -1]
},
{
value: 'match2',
keys: [[2], [1]],
result: [0, 0]
},
{
value: 'firstMismatch2',
keys: [[3], []],
result: [1, -1]
},
{
value: 'badMatch1',
keys: [[4], [3, 4]],
result: [0, 0]
},
{
value: 'secondMismatch1',
keys: [[], [2]],
result: [-1, 1]
}
]
Leverage buildArrayBase to generate an array filled with references to the provided item. The length defines how long the array should be.
Kind: static method of arrayHelpers
Param | Type | Description |
---|---|---|
item | * |
The item to be used for each array element |
length | number |
The desired length of the array |
Leverage buildArrayBase to generate an array filled with a copy of the provided item. The length defines how long the array should be.
Kind: static method of arrayHelpers
Param | Type | Description |
---|---|---|
item | * |
The item to be used for each array element |
length | number |
The desired length of the array |
Having an array and a potential new array element, check if the element is in the array, if not append to array.
Kind: static method of arrayHelpers
Param | Type | Description |
---|---|---|
item | * |
An potential array element, possibly a DomItem |
array | Array |
An array where an element may be appended. |