mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Introduce TEXT_TURTLE constant
This commit is contained in:
committed by
Joachim Van Herwegen
parent
85e3117efe
commit
ee3b847033
@@ -1,2 +1,5 @@
|
||||
// Well-known content types
|
||||
export const TEXT_TURTLE = 'text/turtle';
|
||||
|
||||
// Internal (non-exposed) content types
|
||||
export const INTERNAL_QUADS = 'internal/quads';
|
||||
|
||||
@@ -4,6 +4,7 @@ import arrayifyStream from 'arrayify-stream';
|
||||
import { DataFactory, StreamParser, StreamWriter } from 'n3';
|
||||
import { NamedNode, Quad } from 'rdf-js';
|
||||
import streamifyArray from 'streamify-array';
|
||||
import { TEXT_TURTLE } from '../util/ContentTypes';
|
||||
import { LDP, RDF, STAT, TERMS, XML } from './Prefixes';
|
||||
|
||||
export const TYPE_PREDICATE = DataFactory.namedNode(`${RDF}type`);
|
||||
@@ -69,7 +70,7 @@ export class MetadataController {
|
||||
* @returns The Readable object.
|
||||
*/
|
||||
public generateReadableFromQuads(quads: Quad[]): Readable {
|
||||
return streamifyArray(quads).pipe(new StreamWriter({ format: 'text/turtle' }));
|
||||
return streamifyArray(quads).pipe(new StreamWriter({ format: TEXT_TURTLE }));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,6 +80,6 @@ export class MetadataController {
|
||||
* @returns A promise containing the array of quads.
|
||||
*/
|
||||
public async generateQuadsFromReadable(readable: Readable): Promise<Quad[]> {
|
||||
return arrayifyStream(readable.pipe(new StreamParser({ format: 'text/turtle' })));
|
||||
return arrayifyStream(readable.pipe(new StreamParser({ format: TEXT_TURTLE })));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user