Skip to content

Commit e486aa6

Browse files
authored
Merge branch 'main' into soundtrack-type-title-detection
2 parents 798161a + 70c806f commit e486aa6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

harmonizer/properties.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { HarmonyRelease, HarmonyTrack } from './types.ts';
22

33
/** Release properties which can be combined from data of multiple providers. */
4-
export const combinableReleaseProperties: Array<keyof HarmonyRelease> = [
4+
export const combinableReleaseProperties = [
55
'externalLinks',
66
'availableIn',
77
'excludedFrom',
88
'info',
9-
];
9+
] as const satisfies Array<keyof HarmonyRelease>;
1010

1111
/**
1212
* Release properties which have to be taken from one provider and can not be combined from data of multiple providers.
@@ -27,15 +27,15 @@ export const immutableReleaseProperties = [
2727
'images', // TODO: make images combinable? combine if not only front covers?
2828
'copyright',
2929
'credits',
30-
] as const;
30+
] as const satisfies Array<keyof HarmonyRelease>;
3131

3232
/** Track properties which have to be taken from one provider and can not be combined from data of multiple providers. */
3333
export const immutableTrackProperties = [
3434
'isrc',
3535
'length',
36-
] as const;
36+
] as const satisfies Array<keyof HarmonyTrack>;
3737

3838
/** Track properties which can be combined from data of multiple providers. */
39-
export const combinableTrackProperties: Array<keyof HarmonyTrack> = [
39+
export const combinableTrackProperties = [
4040
'recording',
41-
];
41+
] as const satisfies Array<keyof HarmonyTrack>;

utils/record.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/** Clones properties between records of the same type. Creates a deep copy if necessary. */
22
export function cloneInto<T>(target: T, source: T, property: keyof T) {
33
let value = source[property];
4+
if (value === undefined) {
5+
return value;
6+
}
47
if (typeof value === 'object' && value !== null) {
58
value = structuredClone(value);
69
}
@@ -9,7 +12,11 @@ export function cloneInto<T>(target: T, source: T, property: keyof T) {
912

1013
/** Copies properties between records of the same type. Helper to prevent type errors. */
1114
export function copyTo<T>(target: T, source: T, property: keyof T) {
12-
return target[property] = source[property];
15+
const value = source[property];
16+
if (value === undefined) {
17+
return value;
18+
}
19+
return target[property] = value;
1320
}
1421

1522
/** Filters the error entires of the given record and creates a new error-free record. */

0 commit comments

Comments
 (0)