Page MenuHomeSealhub

parse_primitives.ts
No OneTemporary

parse_primitives.ts

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

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)

Event Timeline