@rdfx/serializer 0.0.54 → 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.
- package/dist/serializeSync.d.ts +10 -4
- package/dist/serializeSync.js +13 -5
- package/package.json +3 -3
package/dist/serializeSync.d.ts
CHANGED
|
@@ -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
|
-
|
|
5
|
-
format:
|
|
6
|
-
}
|
|
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
|
package/dist/serializeSync.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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.
|
|
4
|
-
"@rdfx/stream": "0.0.
|
|
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.
|
|
49
|
+
"version": "0.0.55"
|
|
50
50
|
}
|