domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
21 lines (20 loc) • 788 B
TypeScript
/**
* a method which deduplicates objects by their identity from within an array
*
* note
* - when it operates on dobj instances, it extracts their identity via getUniqueIdentifier
* - when it operates on anything else, it simply serializes the object
*/
export declare const dedupe: <T>(objs: T[], options?: {
/**
* specifies what to do if more than one version of the same entity is found
*
* options
* - FAIL_FAST = throw an UnexpectedCodePathError to fail fast and prevent accidental data loss
* - CHOOSE_FIRST_OCCURRENCE = choose the first version of this entity found in the array
*
* note
* - default = FAIL_FAST, to create a pit-of-success
*/
onMultipleEntityVersions: 'FAIL_FAST' | 'CHOOSE_FIRST_OCCURRENCE';
}) => T[];