Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F8922835
transform-object.ts
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
530 B
Referenced Files
None
Subscribers
None
transform-object.ts
View Options
export
default
function
transformObject
<
T
>
(
obj
:
T
,
prop_tranformer
:
(
prop
:
string
)
=>
keyof
T
,
value_transformer
:
(
prop
:
string
,
obj
:
Object
)
=>
any
)
{
const
new_obj
=
Array
.
isArray
(
obj
)
?
(([]
as
unknown
)
as
T
)
:
({}
as
T
);
for
(
const
prop
in
obj
)
{
let
new_prop
=
prop_tranformer
(
prop
);
new_obj
[
new_prop
]
=
typeof
obj
[
prop
]
===
"object"
?
transformObject
(
(
obj
[
prop
]
as
unknown
)
as
T
,
prop_tranformer
,
value_transformer
)
:
value_transformer
(
prop
,
obj
[
prop
]);
}
return
new_obj
;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 20, 14:58 (20 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
926883
Default Alt Text
transform-object.ts (530 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment