@rdfx/stream 0.0.49 → 0.0.50

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./iterableToStream.js";
2
2
  export * from "./streamToArray.js";
3
+ export * from "./streamToString.js";
3
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./iterableToStream.js";
2
2
  export * from "./streamToArray.js";
3
+ export * from "./streamToString.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ import type { EventEmitter } from "events";
2
+ import { Either } from "purify-ts";
3
+ /**
4
+ * Convert an EventEmitter returned by an RDF/JS Stream serializer .import to a string by collecting the output.
5
+ */
6
+ export declare function streamToString(stream: EventEmitter): Promise<Either<Error, string>>;
7
+ //# sourceMappingURL=streamToString.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { Either, Left } from "purify-ts";
2
+ /**
3
+ * Convert an EventEmitter returned by an RDF/JS Stream serializer .import to a string by collecting the output.
4
+ */
5
+ export function streamToString(stream) {
6
+ return new Promise((resolve) => {
7
+ let result = "";
8
+ let settled = false;
9
+ stream.on("data", (chunk) => {
10
+ result += String(chunk);
11
+ });
12
+ stream.on("end", () => {
13
+ if (!settled) {
14
+ settled = true;
15
+ resolve(Either.of(result));
16
+ }
17
+ });
18
+ stream.on("error", (error) => {
19
+ if (!settled) {
20
+ settled = true;
21
+ resolve(Left(error));
22
+ }
23
+ });
24
+ });
25
+ }
26
+ //# sourceMappingURL=streamToString.js.map
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "readable-stream": "^4.7.0"
7
7
  },
8
8
  "devDependencies": {
9
- "@rdfx/parsers": "0.0.49"
9
+ "@rdfx/parsers": "0.0.50"
10
10
  },
11
11
  "files": [
12
12
  "LICENSE",
@@ -29,5 +29,5 @@
29
29
  },
30
30
  "type": "module",
31
31
  "types": "./dist/index.d.ts",
32
- "version": "0.0.49"
32
+ "version": "0.0.50"
33
33
  }