Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Jun 26, 2020
1 parent 199bf06 commit 36b912e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ class Resource {
birthtime: new Date()
};

this._createStream = createStream || null;
this._stream = stream || null;
this._buffer = buffer || null;
if (typeof string === "string" || string instanceof String) {
if (createStream) {
this._createStream = createStream;
} else if (stream) {
this._stream = stream;
} else if (buffer) {
this.setBuffer(buffer);
} else if (typeof string === "string" || string instanceof String) {
this.setString(string);
} else if (this._buffer) {
this.setBuffer(this._buffer);
}

// Tracing:
Expand Down Expand Up @@ -119,7 +120,7 @@ class Resource {
this._buffer = buffer;
this._contentDrained = false;
this._streamDrained = false;
this._setSize(Buffer.byteLength(this._buffer));
this._setSize(this._buffer.byteLength);
}

/**
Expand Down

0 comments on commit 36b912e

Please sign in to comment.