Skip to content

Commit

Permalink
Stream: Replace assert() with explicit throw to not pull in unneces…
Browse files Browse the repository at this point in the history
…sary dependency (for browser).
  • Loading branch information
poelstra committed Feb 11, 2021
1 parent e09515a commit e5c5eab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

/* istanbul ignore next */ // ignores Typescript's __extend() function

import * as assert from "assert";

import BaseError from "./BaseError";
import { filter, map, Transform } from "./Transform";
import {
Expand Down Expand Up @@ -1579,7 +1577,9 @@ export class Stream<T> implements ReadableStream<T>, WritableStream<T> {
if (writer.value instanceof Eof) {
const eof = writer.value;
// EOF, with or without error
assert(!this._ended && !this._endPending);
if (this._ended || this._endPending) {
throw new Error("assertion failed");
}
this._endPending = eof;
const ender = this._ender!; // Ensure calling without `this`
this._ender = undefined; // Prevent calling again
Expand Down

0 comments on commit e5c5eab

Please sign in to comment.