mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
add comments to everything potentially consumer facing (#3127)
* add comments to everything potentially consumer facing * rework smtp --------- Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* Computes the partial difference between two values.
|
||||
* Returns `undefined` if the values are equal, or `{ diff }` containing only the changed parts.
|
||||
* For arrays, the diff contains only items in `next` that have no deep-equal counterpart in `prev`.
|
||||
* For objects, the diff contains only keys whose values changed.
|
||||
*
|
||||
* @param prev - The original value
|
||||
* @param next - The updated value
|
||||
* @returns An object containing the diff, or `undefined` if the values are equal
|
||||
*/
|
||||
export function partialDiff<T>(
|
||||
prev: T,
|
||||
next: T,
|
||||
@@ -46,6 +56,14 @@ export function partialDiff<T>(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges multiple values together. Objects are merged key-by-key recursively.
|
||||
* Arrays are merged by appending items that are not already present (by deep equality).
|
||||
* Primitives are resolved by taking the last argument.
|
||||
*
|
||||
* @param args - The values to merge, applied left to right
|
||||
* @returns The merged result
|
||||
*/
|
||||
export function deepMerge(...args: unknown[]): unknown {
|
||||
const lastItem = (args as any)[args.length - 1]
|
||||
if (typeof lastItem !== 'object' || !lastItem) return lastItem
|
||||
|
||||
Reference in New Issue
Block a user