Serialise data from any iterable set of quads.
import { Quad, Store, DataFactory } from 'n3';
import serialize from '@jeswr/rdf-serialize-store';
const { namedNode, literal, quad } = DataFactory;
const quads = [
quad(namedNode('http://example.org/subject'), namedNode('http://example.org/predicate'), namedNode('http://example.org/object')),
quad(namedNode('http://example.org/subject'), namedNode('http://example.org/predicate'), literal('object')),
];
// <http://example.org/subject> <http://example.org/predicate> <http://example.org/object>, "object".
await serialize(quads, { contentType: 'text/turtle' });
await serialize(new Store(quads), { contentType: 'text/turtle' });
// @prefix ex: <http://example.org/> .
// ex:subject ex:predicate ex:object, "object".
await serialize(quads, { contentType: 'text/turtle', prefixes: { ex: "http://example.org/" } });
©2024–present Jesse Wright, MIT License.