mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-09 19:01:41 +00:00
more notifications
This commit is contained in:
parent
04ba949182
commit
9e28ee036f
5 changed files with 99 additions and 39 deletions
26
server/utils/objectUtils.js
Normal file
26
server/utils/objectUtils.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
function flattenAny(obj, prefix = '', result = {}) {
|
||||
const entries =
|
||||
obj instanceof Map
|
||||
? obj.entries()
|
||||
: Object.entries(obj);
|
||||
|
||||
for (const [key, value] of entries) {
|
||||
const newKey = prefix ? `${prefix}.${key}` : `${key}`;
|
||||
if (
|
||||
value instanceof Map ||
|
||||
(typeof value === 'object' &&
|
||||
value !== null &&
|
||||
!Array.isArray(value))
|
||||
) {
|
||||
flattenAny(value, newKey, result);
|
||||
} else {
|
||||
result[newKey] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
flattenAny
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue