0.4.0 • Published 1 year ago

ldes-consumer v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ldes-consumer

This package provides a wrapper around https://github.com/TREEcg/event-stream-client/tree/main/packages/actor-init-ldes-client. It allows you to consume a time-based fragmented LDES stream given its URL.

Using this package

An example of using this package is included below:

const consumer = new Consumer({
	endpoint,
	initialState,
});
consumer.listen(async (member) => {
	// Do something with the member
});

You can instatiate an object of class Consumer with an object of type ConsumerArgs:

  const consumer = new Consumer({
    endpoint, // the endpoint to consumer from, e.g. http://example.com/ldes/0
    state, // you can pass a specific state to the consumer which it can use to skip already processed fragments and members
    requestHeaders // custom HTTP headers which should be sent when sending HTTP calls to the LDES endpoint
  });

The listen-method of the consumer allows you to consume the stream and pass a callback to process each member of the stream.

  consumer.listen(async (member: Member){
    // Do something with the member and state
  }, () => console.log('Stream has been consumed'))

You can pass two callbacks to the listen-method:

  • The first callback receives a member object, it is called for each incoming member. The member-object includes an id and a list of quads.
  • The second callback takes a state parameter, it is called when the whole stream has been consumed and passes along a state representation.
0.4.0

1 year ago

0.3.0

2 years ago

0.2.0

2 years ago

0.3.5

2 years ago

0.3.2

2 years ago

0.1.4

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago