Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7860267
flatten-object-to-dot-notation.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
532 B
Referenced Files
None
Subscribers
None
flatten-object-to-dot-notation.js
View Options
module
.
exports
=
function
(
context
,
obj
)
{
const
prefix
=
typeof
context
===
"string"
?
context
+
"."
:
""
;
return
flattenObjectToDotNotation
(
prefix
,
obj
);
};
function
flattenObjectToDotNotation
(
prefix
,
obj
)
{
return
Object
.
keys
(
obj
).
reduce
((
flattened
,
prop
)
=>
{
const
new_prop
=
prefix
+
prop
;
if
(
obj
[
prop
]
&&
typeof
obj
[
prop
]
===
"object"
)
{
Object
.
assign
(
flattened
,
flattenObjectToDotNotation
(
new_prop
+
"."
,
obj
[
prop
])
);
}
else
{
flattened
[
new_prop
]
=
obj
[
prop
];
}
return
flattened
;
},
{});
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 13, 17:19 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
872833
Default Alt Text
flatten-object-to-dot-notation.js (532 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment