aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils/common
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-04-14 09:57:37 +0200
committerChocobozzz <me@florianbigard.com>2023-04-14 10:14:40 +0200
commite7c89cc3f3e69776c6ad62e62a52f8d2f12a81c1 (patch)
tree88dcb15bd523af9fe42fa1fc1d380c3b8dfba089 /shared/core-utils/common
parent8b95440c8ac050594955926f18dab9f6d4a86e19 (diff)
downloadPeerTube-e7c89cc3f3e69776c6ad62e62a52f8d2f12a81c1.tar.gz
PeerTube-e7c89cc3f3e69776c6ad62e62a52f8d2f12a81c1.tar.zst
PeerTube-e7c89cc3f3e69776c6ad62e62a52f8d2f12a81c1.zip
Allow to update a live with untouched privacy
Diffstat (limited to 'shared/core-utils/common')
-rw-r--r--shared/core-utils/common/object.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/shared/core-utils/common/object.ts b/shared/core-utils/common/object.ts
index 7f1f147f4..9780b2594 100644
--- a/shared/core-utils/common/object.ts
+++ b/shared/core-utils/common/object.ts
@@ -45,10 +45,32 @@ function shallowCopy <T> (o: T): T {
45 return Object.assign(Object.create(Object.getPrototypeOf(o)), o) 45 return Object.assign(Object.create(Object.getPrototypeOf(o)), o)
46} 46}
47 47
48function simpleObjectsDeepEqual (a: any, b: any) {
49 if (a === b) return true
50
51 if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
52 return false
53 }
54
55 const keysA = Object.keys(a)
56 const keysB = Object.keys(b)
57
58 if (keysA.length !== keysB.length) return false
59
60 for (const key of keysA) {
61 if (!keysB.includes(key)) return false
62
63 if (!simpleObjectsDeepEqual(a[key], b[key])) return false
64 }
65
66 return true
67}
68
48export { 69export {
49 pick, 70 pick,
50 omit, 71 omit,
51 getKeys, 72 getKeys,
52 shallowCopy, 73 shallowCopy,
53 sortObjectComparator 74 sortObjectComparator,
75 simpleObjectsDeepEqual
54} 76}