1.0.6 • Published 1 year ago

@octoguide/array-utils v1.0.6

Weekly downloads
1
License
UNLICENSED
Repository
-
Last release
1 year ago

Constants

filterDuplicatesById

Remove entires from source that exist in duplicates

Kind: global constant

ParamTypeDescription
source*the list to remove duplicates from i.e. surveyQuestions
duplicates*the duplicates to check - assumes it is the id field i.e. the items already selected surveyGroups.questions - map to id field in the list

notDuplicateById

call using the array filter method - refer to filterDuplicatesById

Kind: global constant

ParamType
currentValue*

uniqueSymmetricDifference

take 2 arrays that have the key of id an return an array that has no common objects Handy for lists that don't require object that have already been selected.

Kind: global constant

ParamTypeDescription
array1*one array of objects
array2*another array of objects

unionWith

All array A items will end up in the result. array b items - Only NON duplicates from array A will be added using the comparator

Kind: global constant

ParamTypeDescription
aArray
bArray
compfunctionthe comparator to match items from array A with Array B

differenceBy

Returns items from array A that ARE NOT in array B (NOTE - If items from B are not in A - they will not be in the result)

Kind: global constant

ParamTypeDescription
aArray
bArray
compfunctionthe comparator that finds the difference in the 2 arrays

differenceById

Wrapper for differenceBy that uses the object id as the comparator

Kind: global constant

ParamType
a*
b*

sameBy

Returns items from array A that ARE NOT in array B (NOTE - If items from B are not in A - they will not be in the result)

Kind: global constant

ParamTypeDescription
aArray
bArray
compfunctionthe comparator that finds the difference in the 2 arrays

sameByIdValue

Wrapper for differenceBy that uses the object id as the comparator

Kind: global constant

ParamTypeDescription
aArrayobjects that have an id field {id: 'id1'}, {id: 'id3'}
bArrayArray of value that contain the id value to lookup 'id1', 'id2'

addOrUpdateEntry

update the entry in the list based on the id of the object

Kind: global constant

ParamTypeDescription
list*the list to update
payload*the payload to add or update

uniqByKeepFirst

find an object by its key, return the first instance in the list

Kind: global constant

ParamTypeDescription
a*the list of objects
key*the object key to return

uniqByKeepLast

find an object by its key, return the last instance in the list

Kind: global constant

ParamTypeDescription
a*the list of objects
key*the object key to return

removeDuplicatesById

remove array object duplicated by the 'id' field

Kind: global constant

ParamTypeDescription
array*the list of objects