crud-object-diff
Version:
Helper utilities to compare objects or arrays for obtaining created, updated, & deleted values.
28 lines • 1.41 kB
TypeScript
/**
* Compare two arrays of objects, to get the created, updated, and deleted values
* @param {Array.<Object>} toCompareVals The first array item must be the original array of objects.
* [originalArray, stateUpdatedArray]
* @param {?string|Array.<string>} key The related key between the objects
* @returns {{createdVals: ?Array.<Object>, updatedVals: ?Array.<Object>, deletedVals: ?Array.<Object>}}
* Three objects with the corresponding created, updated, and deleted values
* respectively. Returns null for one of the corresponding values if it doesn't exist.
*/
declare function compareObjectVals<T extends object>(toCompareVals: [T[], T[]], key?: string | string[]): {
createdVals: T[] | null;
updatedVals: T[] | null;
deletedVals: T[] | null;
};
/**
* Compare two arrays, to get the created & deleted values
* @param {Array.<Array.<*>, Array.<*>>} toCompareVals The first array item must be the original array.
* [originalArray, stateUpdatedArray]
* @returns {{ createdVals: ?Array.<*>, deletedVals: ?Array.<*> }}
* Returns two arrays corresponding to the created and deleted values
* respectively. Returns null for one of the corresponding values if it doesn't exist.
*/
declare function compareArrayVals<T>(toCompareVals: [T[], T[]]): {
createdVals: T[] | null;
deletedVals: T[] | null;
};
export { compareObjectVals, compareArrayVals };
//# sourceMappingURL=main.d.ts.map