@comunica/bus-query-operation 3.2.1 → 3.2.2

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.
@@ -0,0 +1,108 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-operation/^3.0.0/components/context.jsonld"
4
+ ],
5
+ "@id": "npmd:@comunica/bus-query-operation",
6
+ "components": [
7
+ {
8
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator",
9
+ "@type": "Class",
10
+ "requireElement": "ClosableIterator",
11
+ "extends": [
12
+ {
13
+ "@type": "GenericComponentExtension",
14
+ "component": "urn:npm:asynciterator:AsyncIterator",
15
+ "genericTypeInstances": [
16
+ {
17
+ "@type": "ParameterRangeGenericTypeReference",
18
+ "parameterRangeGenericType": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__generic_S"
19
+ }
20
+ ]
21
+ }
22
+ ],
23
+ "comment": "An AsyncIterator with a callback for when this iterator is closed in any way. In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.",
24
+ "genericTypeParameters": [
25
+ {
26
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__generic_S"
27
+ }
28
+ ],
29
+ "parameters": [
30
+ {
31
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_options_onClose",
32
+ "range": {
33
+ "@type": "ParameterRangeWildcard"
34
+ }
35
+ },
36
+ {
37
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_source",
38
+ "range": {
39
+ "@type": "ParameterRangeGenericComponent",
40
+ "component": "urn:npm:asynciterator:AsyncIterator",
41
+ "genericTypeInstances": [
42
+ {
43
+ "@type": "ParameterRangeGenericTypeReference",
44
+ "parameterRangeGenericType": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__generic_S"
45
+ }
46
+ ]
47
+ }
48
+ }
49
+ ],
50
+ "memberFields": [
51
+ {
52
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member__source",
53
+ "memberFieldName": "_source",
54
+ "range": {
55
+ "@type": "ParameterRangeIntersection",
56
+ "parameterRangeElements": [
57
+ {
58
+ "@type": "ParameterRangeGenericComponent",
59
+ "component": "urn:npm:asynciterator:AsyncIterator",
60
+ "genericTypeInstances": [
61
+ {
62
+ "@type": "ParameterRangeGenericTypeReference",
63
+ "parameterRangeGenericType": "cbqo:components/ClosableIterator.jsonld#InternalSource__generic_T"
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "@type": "ParameterRangeWildcard"
69
+ }
70
+ ]
71
+ }
72
+ },
73
+ {
74
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member_onClose",
75
+ "memberFieldName": "onClose"
76
+ },
77
+ {
78
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member_constructor",
79
+ "memberFieldName": "constructor"
80
+ },
81
+ {
82
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member_read",
83
+ "memberFieldName": "read"
84
+ },
85
+ {
86
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator__member__end",
87
+ "memberFieldName": "_end"
88
+ }
89
+ ],
90
+ "constructorArguments": [
91
+ {
92
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_source"
93
+ },
94
+ {
95
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_options__constructorArgument",
96
+ "fields": [
97
+ {
98
+ "keyRaw": "onClose",
99
+ "value": {
100
+ "@id": "cbqo:components/ClosableIterator.jsonld#ClosableIterator_options_onClose"
101
+ }
102
+ }
103
+ ]
104
+ }
105
+ ]
106
+ }
107
+ ]
108
+ }
@@ -0,0 +1,18 @@
1
+ import { AsyncIterator, DESTINATION } from 'asynciterator';
2
+ type InternalSource<T> = AsyncIterator<T> & {
3
+ [DESTINATION]?: AsyncIterator<any>;
4
+ };
5
+ /**
6
+ * An AsyncIterator with a callback for when this iterator is closed in any way.
7
+ * In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.
8
+ */
9
+ export declare class ClosableIterator<S> extends AsyncIterator<S> {
10
+ protected readonly _source: InternalSource<S>;
11
+ private readonly onClose;
12
+ constructor(source: AsyncIterator<S>, options: {
13
+ onClose: () => void;
14
+ });
15
+ read(): S | null;
16
+ protected _end(destroy: boolean): void;
17
+ }
18
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClosableIterator = void 0;
4
+ const asynciterator_1 = require("asynciterator");
5
+ /**
6
+ * An AsyncIterator with a callback for when this iterator is closed in any way.
7
+ * In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.
8
+ */
9
+ class ClosableIterator extends asynciterator_1.AsyncIterator {
10
+ constructor(source, options) {
11
+ super();
12
+ this.onClose = options.onClose;
13
+ this._source = source;
14
+ // Wire up the source for reading
15
+ this._source[asynciterator_1.DESTINATION] = this;
16
+ this._source.on('end', destinationClose);
17
+ this._source.on('error', destinationEmitError);
18
+ this._source.on('readable', destinationSetReadable);
19
+ this.readable = this._source.readable;
20
+ }
21
+ read() {
22
+ const ret = this._source.read();
23
+ if (!ret) {
24
+ // Mark as non-readable if ret was null
25
+ this.readable = false;
26
+ // Close this iterator if the source is empty
27
+ if (this._source.done) {
28
+ this.close();
29
+ }
30
+ }
31
+ return ret;
32
+ }
33
+ _end(destroy) {
34
+ this.onClose();
35
+ this._source.removeListener('end', destinationClose);
36
+ this._source.removeListener('error', destinationEmitError);
37
+ this._source.removeListener('readable', destinationSetReadable);
38
+ delete this._source[asynciterator_1.DESTINATION];
39
+ this._source.destroy();
40
+ super._end(destroy);
41
+ }
42
+ }
43
+ exports.ClosableIterator = ClosableIterator;
44
+ // Helpers below are copied from AsyncIterator, as they are not exported from there.
45
+ function destinationSetReadable() {
46
+ this[asynciterator_1.DESTINATION].readable = true;
47
+ }
48
+ function destinationEmitError(error) {
49
+ this[asynciterator_1.DESTINATION].emit('error', error);
50
+ }
51
+ function destinationClose() {
52
+ this[asynciterator_1.DESTINATION].close();
53
+ }
54
+ //# sourceMappingURL=ClosableIterator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClosableIterator.js","sourceRoot":"","sources":["ClosableIterator.ts"],"names":[],"mappings":";;;AAAA,iDAA2D;AAK3D;;;GAGG;AACH,MAAa,gBAAoB,SAAQ,6BAAgB;IAIvD,YAAmB,MAAwB,EAAE,OAAgC;QAC3E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAuB,MAAM,CAAC;QAE1C,iCAAiC;QACjC,IAAI,CAAC,OAAO,CAAC,2BAAW,CAAC,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACxC,CAAC;IAEe,IAAI;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,uCAAuC;YACvC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YAEtB,6CAA6C;YAC7C,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAEkB,IAAI,CAAC,OAAgB;QACtC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,2BAAW,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAzCD,4CAyCC;AAED,oFAAoF;AAEpF,SAAS,sBAAsB;IAC7B,IAAI,CAAC,2BAAW,CAAE,CAAC,QAAQ,GAAG,IAAI,CAAC;AACrC,CAAC;AACD,SAAS,oBAAoB,CAA6B,KAAY;IACpE,IAAI,CAAC,2BAAW,CAAE,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC;AACD,SAAS,gBAAgB;IACvB,IAAI,CAAC,2BAAW,CAAE,CAAC,KAAK,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import { AsyncIterator, DESTINATION } from 'asynciterator';\n\ntype InternalSource<T> =\n AsyncIterator<T> & { [DESTINATION]?: AsyncIterator<any> };\n\n/**\n * An AsyncIterator with a callback for when this iterator is closed in any way.\n * In contrast to ClosableTransformIterator, this does not add the overhead of a TransformIterator.\n */\nexport class ClosableIterator<S> extends AsyncIterator<S> {\n protected readonly _source: InternalSource<S>;\n private readonly onClose: () => void;\n\n public constructor(source: AsyncIterator<S>, options: { onClose: () => void }) {\n super();\n this.onClose = options.onClose;\n this._source = <InternalSource<S>> source;\n\n // Wire up the source for reading\n this._source[DESTINATION] = this;\n this._source.on('end', destinationClose);\n this._source.on('error', destinationEmitError);\n this._source.on('readable', destinationSetReadable);\n this.readable = this._source.readable;\n }\n\n public override read(): S | null {\n const ret = this._source.read();\n if (!ret) {\n // Mark as non-readable if ret was null\n this.readable = false;\n\n // Close this iterator if the source is empty\n if (this._source.done) {\n this.close();\n }\n }\n return ret;\n }\n\n protected override _end(destroy: boolean): void {\n this.onClose();\n\n this._source.removeListener('end', destinationClose);\n this._source.removeListener('error', destinationEmitError);\n this._source.removeListener('readable', destinationSetReadable);\n delete this._source[DESTINATION];\n this._source.destroy();\n super._end(destroy);\n }\n}\n\n// Helpers below are copied from AsyncIterator, as they are not exported from there.\n\nfunction destinationSetReadable<S>(this: InternalSource<S>): void {\n this[DESTINATION]!.readable = true;\n}\nfunction destinationEmitError<S>(this: InternalSource<S>, error: Error): void {\n this[DESTINATION]!.emit('error', error);\n}\nfunction destinationClose<S>(this: InternalSource<S>): void {\n this[DESTINATION]!.close();\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from './ActorQueryOperationTyped';
3
3
  export * from './ActorQueryOperationTypedMediated';
4
4
  export * from './Bindings';
5
5
  export * from './BusQueryOperation';
6
+ export * from './ClosableIterator';
6
7
  export * from './ClosableTransformIterator';
package/lib/index.js CHANGED
@@ -19,5 +19,6 @@ __exportStar(require("./ActorQueryOperationTyped"), exports);
19
19
  __exportStar(require("./ActorQueryOperationTypedMediated"), exports);
20
20
  __exportStar(require("./Bindings"), exports);
21
21
  __exportStar(require("./BusQueryOperation"), exports);
22
+ __exportStar(require("./ClosableIterator"), exports);
22
23
  __exportStar(require("./ClosableTransformIterator"), exports);
23
24
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,6DAA2C;AAC3C,qEAAmD;AACnD,6CAA2B;AAC3B,sDAAoC;AACpC,8DAA4C","sourcesContent":["export * from './ActorQueryOperation';\nexport * from './ActorQueryOperationTyped';\nexport * from './ActorQueryOperationTypedMediated';\nexport * from './Bindings';\nexport * from './BusQueryOperation';\nexport * from './ClosableTransformIterator';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,6DAA2C;AAC3C,qEAAmD;AACnD,6CAA2B;AAC3B,sDAAoC;AACpC,qDAAmC;AACnC,8DAA4C","sourcesContent":["export * from './ActorQueryOperation';\nexport * from './ActorQueryOperationTyped';\nexport * from './ActorQueryOperationTypedMediated';\nexport * from './Bindings';\nexport * from './BusQueryOperation';\nexport * from './ClosableIterator';\nexport * from './ClosableTransformIterator';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/bus-query-operation",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "A comunica bus for query-operation events.",
5
5
  "lsd:module": true,
6
6
  "license": "MIT",
@@ -49,5 +49,5 @@
49
49
  "rdf-terms": "^1.11.0",
50
50
  "sparqlalgebrajs": "^4.3.7"
51
51
  },
52
- "gitHead": "f558377c3cefbd1606c51ede80440b862e7dda4f"
52
+ "gitHead": "fbcc3a81f87738633ddf69ede5ca504236f7edd9"
53
53
  }