Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9582360
parse_primitives.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
723 B
Referenced Files
None
Subscribers
None
parse_primitives.ts
View Options
import
{
BlockPrimitive
}
from
"./block"
;
import
{
HeadingPrimitive
}
from
"./heading"
;
import
{
ImagePrimitive
}
from
"./image"
;
import
{
Primitive
}
from
"./primitive"
;
import
{
TextPrimitive
}
from
"./text"
;
// parses primitive json into classes
export
function
parse_primitives
(
primitive_json
:
Record
<
string
,
unknown
>
[]
)
:
Primitive
[]
{
const
ret
:
Primitive
[]
=
[];
for
(
const
p
of
primitive_json
)
{
if
(
p
[
"type"
]
===
"text"
)
{
ret
.
push
(
new
TextPrimitive
(
p
));
}
else
if
(
p
[
"type"
]
===
"heading"
)
{
ret
.
push
(
new
HeadingPrimitive
(
p
));
}
else
if
(
p
[
"type"
]
===
"image"
)
{
ret
.
push
(
new
ImagePrimitive
(
p
));
}
else
if
(
p
[
"type"
]
===
"block"
)
{
ret
.
push
(
new
BlockPrimitive
(
p
));
}
}
return
ret
;
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Oct 11, 06:40 (5 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
983903
Default Alt Text
parse_primitives.ts (723 B)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment