Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions types/n3/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,12 @@ export interface ParserOptions {
baseIRI?: string | undefined;
blankNodePrefix?: string | undefined;
isImpliedBy?: boolean | undefined;
emptyFormulaAsTrue?: boolean | undefined;
}

export interface StreamParserOptions extends ParserOptions {
options?: boolean | undefined;
comments?: boolean | undefined;
}

export type ParseCallback<Q extends BaseQuad = Quad> = (error: Error, quad: Q, prefixes: Prefixes) => void;
Expand Down Expand Up @@ -237,6 +239,8 @@ export interface WriterOptions {
format?: string | MimeFormat | undefined;
prefixes?: Prefixes<RDF.NamedNode | string> | undefined;
end?: boolean | undefined;
baseIRI?: string | undefined;
writeBase?: boolean | undefined;
}

export class Writer<Q extends RDF.BaseQuad = RDF.Quad> {
Expand Down
15 changes: 15 additions & 0 deletions types/n3/n3-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,16 @@ function test_parser_options() {
format: "text/Turtle*",
blankNodePrefix: "",
});
const parser7 = new N3.Parser({
baseIRI: "http://example.org/",
factory: N3.DataFactory,
format: "text/n3",
blankNodePrefix: "",
emptyFormulaAsTrue: true,
});
const streamParser = new N3.StreamParser({
comments: true,
});
}

function test_term_to_and_from_id() {
Expand Down Expand Up @@ -638,5 +648,10 @@ function test_get_rules_from_dataset() {
const rules: N3.Rule[] = N3.getRulesFromDataset(store);
}

function test_writer_base_iri() {
const writer1 = new N3.Writer({ baseIRI: "http://example.org/" });
const writer2 = new N3.Writer({ baseIRI: "http://example.org/", writeBase: true });
}

export const namedNode: ReturnType<RDF.DataFactory["namedNode"]> = N3.DataFactory.namedNode("hello world");
export const df: RDF.DataFactory = N3.DataFactory;