No Description

Sven Slootweg 99cfa7e688 0.1.1 3 weeks ago
.gitignore 000ac8c49c Initial commit 3 months ago
README.md 000ac8c49c Initial commit 3 months ago
example.js 260258342f Migrate to error-chain 3 weeks ago
index.js 260258342f Migrate to error-chain 3 weeks ago
package.json 99cfa7e688 0.1.1 3 weeks ago
yarn.lock 260258342f Migrate to error-chain 3 weeks ago

README.md

@ppstreams/end-of-stream-marker

A simple custom error type for marking the end of a ppstreams stream. You'd usually only need this module when you're implementing a source stream.

Example

An example of producing an EndOfStream marker, from the range-numbers module, which is a source stream that produces numbers within a range:

"use strict";

const simpleSource = require("@ppstreams/simple-source");
const EndOfStream = require("@ppstreams/end-of-stream");

module.exports = function rangeNumbers(start, end, step = 1) {
	let i = start;

	return simpleSource({
		onRequest: () => {
			if (i >= end) {
				throw new EndOfStream();
			} else {
				let number = i;
				i += step;
				return number;
			}
		}
	});
}

API

EndOfStream()

A custom Error constructor, that produces an 'end of stream' marker; that is, a special kind of error to signal that the end of the source stream has been reached, and no further values should be requested.

Takes no arguments.