Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updateHash with string for batching #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/OriginalSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class OriginalSource extends Source {
constructor(value, name) {
super();
const isBuffer = Buffer.isBuffer(value);
this._valueIsBuffer = isBuffer
this._value = isBuffer ? undefined : value;
this._valueAsBuffer = isBuffer ? value : undefined;
this._name = name;
Expand Down Expand Up @@ -124,11 +125,8 @@ class OriginalSource extends Source {
}

updateHash(hash) {
if (this._valueAsBuffer === undefined) {
this._valueAsBuffer = Buffer.from(this._value, "utf-8");
}
hash.update("OriginalSource");
hash.update(this._valueAsBuffer);
hash.update(this._valueIsBuffer ? this._valueAsBuffer : this._value);
hash.update(this._name || "");
}
}
Expand Down
5 changes: 1 addition & 4 deletions lib/RawSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ class RawSource extends Source {
}

updateHash(hash) {
if (this._valueAsBuffer === undefined) {
this._valueAsBuffer = Buffer.from(this._value, "utf-8");
}
hash.update("RawSource");
hash.update(this._valueAsBuffer);
hash.update(this._valueIsBuffer ? this._valueAsBuffer : this._valueAsString);
}
}

Expand Down
6 changes: 4 additions & 2 deletions lib/SourceMapSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SourceMapSource extends Source {
) {
super();
const valueIsBuffer = Buffer.isBuffer(value);
this._valueIsBuffer = valueIsBuffer
this._valueAsString = valueIsBuffer ? undefined : value;
this._valueAsBuffer = valueIsBuffer ? value : undefined;

Expand All @@ -28,6 +29,7 @@ class SourceMapSource extends Source {
this._hasSourceMap = !!sourceMap;
const sourceMapIsBuffer = Buffer.isBuffer(sourceMap);
const sourceMapIsString = typeof sourceMap === "string";
this._sourceMapIsString = sourceMapIsString
this._sourceMapAsObject =
sourceMapIsBuffer || sourceMapIsString ? undefined : sourceMap;
this._sourceMapAsString = sourceMapIsString ? sourceMap : undefined;
Expand Down Expand Up @@ -228,9 +230,9 @@ class SourceMapSource extends Source {

hash.update("SourceMapSource");

hash.update(this._valueAsBuffer);
hash.update(this._valueIsBuffer ? this._valueAsBuffer : this._valueAsString);

hash.update(this._sourceMapAsBuffer);
hash.update(this._sourceMapIsString ? this._sourceMapAsString : this._sourceMapAsBuffer);

if (this._hasOriginalSource) {
hash.update(this._originalSourceAsBuffer);
Expand Down