@octoguide/array-utils
v1.0.6
Published
<dl> <dt><a href="#filterDuplicatesById">filterDuplicatesById</a></dt> <dd><p>Remove entires from source that exist in duplicates</p> </dd> <dt><a href="#notDuplicateById">notDuplicateById</a></dt> <dd><p>call using the array filter method - refer to filt
Downloads
2
Readme
Constants
filterDuplicatesById
Remove entires from source that exist in duplicates
Kind: global constant
| Param | Type | Description | | --- | --- | --- | | 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
| Param | Type | | --- | --- | | 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
| Param | Type | Description | | --- | --- | --- | | 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
| Param | Type | Description | | --- | --- | --- | | a | Array | | | b | Array | | | comp | function | the 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
| Param | Type | Description | | --- | --- | --- | | a | Array | | | b | Array | | | comp | function | the comparator that finds the difference in the 2 arrays |
differenceById
Wrapper for differenceBy that uses the object id as the comparator
Kind: global constant
| Param | Type | | --- | --- | | 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
| Param | Type | Description | | --- | --- | --- | | a | Array | | | b | Array | | | comp | function | the comparator that finds the difference in the 2 arrays |
sameByIdValue
Wrapper for differenceBy that uses the object id as the comparator
Kind: global constant
| Param | Type | Description | | --- | --- | --- | | a | Array | objects that have an id field [{id: 'id1'}, {id: 'id3'}] | | b | Array | Array 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
| Param | Type | Description | | --- | --- | --- | | 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
| Param | Type | Description | | --- | --- | --- | | 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
| Param | Type | Description | | --- | --- | --- | | a | * | the list of objects | | key | * | the object key to return |
removeDuplicatesById
remove array object duplicated by the 'id' field
Kind: global constant
| Param | Type | Description | | --- | --- | --- | | array | * | the list of objects |