@rdfx/serializer 0.0.53 → 0.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import type { SerializerOptions as JsonLdSerializerOptions } from "@rdfjs/serial
2
2
  import type { SerializerOptions as RdfjsSerializerOptions } from "@rdfjs/serializer-rdfjs";
3
3
  import type { SerializerOptions as TurtleSerializerOptions } from "@rdfjs/serializer-turtle";
4
4
  import type { Quad } from "@rdfjs/types";
5
+ import { type Either } from "purify-ts";
5
6
  import type { SerializerOptions as N3SerializerOptions } from "./N3Serializer.js";
6
7
  type SerializeOptions = ({
7
8
  format: "application/ld+json";
@@ -20,6 +21,6 @@ type SerializeOptions = ({
20
21
  } & N3SerializerOptions) | ({
21
22
  format: "text/turtle";
22
23
  } & TurtleSerializerOptions);
23
- export declare function serialize(input: Iterable<Quad>, options: SerializeOptions): Promise<import("purify-ts").Either<unknown, string>>;
24
+ export declare function serialize(input: Iterable<Quad>, options: SerializeOptions): Promise<Either<Error, string>>;
24
25
  export {};
25
26
  //# sourceMappingURL=serialize.d.ts.map
@@ -1,7 +1,13 @@
1
+ import { type SerializerOptions as TurtleSerializerOptions } from "@rdfjs/serializer-turtle";
1
2
  import type { Quad } from "@rdfjs/types";
2
- import type { UncompressedRdfFormat } from "@rdfx/format";
3
3
  import { Either } from "purify-ts";
4
- export declare function serializeSync(input: Iterable<Quad>, options: {
5
- format: Extract<UncompressedRdfFormat["mimeType"], "application/n-quads" | "application/n-triples">;
6
- }): Either<Error, string>;
4
+ type SerializeSyncOptions = {
5
+ format: "application/n-quads";
6
+ } | {
7
+ format: "application/n-triples";
8
+ } | ({
9
+ format: "text/turtle";
10
+ } & TurtleSerializerOptions);
11
+ export declare function serializeSync(input: Iterable<Quad>, options: SerializeSyncOptions): Either<Error, string>;
12
+ export {};
7
13
  //# sourceMappingURL=serializeSync.d.ts.map
@@ -1,13 +1,21 @@
1
+ import TurtleSerializer from "@rdfjs/serializer-turtle";
1
2
  import { Writer as N3Writer } from "n3";
2
3
  import { Either } from "purify-ts";
3
4
  export function serializeSync(input, options) {
4
5
  return Either.encase(() => {
5
- const ntriples = [];
6
- const n3Writer = new N3Writer(options);
7
- for (const quad of input) {
8
- ntriples.push(n3Writer.quadToString(quad.subject, quad.predicate, quad.object, quad.graph));
6
+ switch (options.format) {
7
+ case "application/n-quads":
8
+ case "application/n-triples": {
9
+ const ntriples = [];
10
+ const n3Writer = new N3Writer(options);
11
+ for (const quad of input) {
12
+ ntriples.push(n3Writer.quadToString(quad.subject, quad.predicate, quad.object, quad.graph));
13
+ }
14
+ return ntriples.join("\n");
15
+ }
16
+ case "text/turtle":
17
+ return new TurtleSerializer(options).transform(input);
9
18
  }
10
- return ntriples.join("\n");
11
19
  });
12
20
  }
13
21
  //# sourceMappingURL=serializeSync.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
- "@rdfx/format": "0.0.53",
4
- "@rdfx/stream": "0.0.53",
3
+ "@rdfx/format": "0.0.55",
4
+ "@rdfx/stream": "0.0.55",
5
5
  "@rdfjs/prefix-map": "~0.1.2",
6
6
  "@rdfjs/serializer-jsonld-ext": "~4.0.2",
7
7
  "@rdfjs/serializer-ntriples": "~2.0.1",
@@ -46,5 +46,5 @@
46
46
  },
47
47
  "type": "module",
48
48
  "types": "./dist/index.d.ts",
49
- "version": "0.0.53"
49
+ "version": "0.0.55"
50
50
  }