Skip to content

Commit

Permalink
prettier --write '**/*.js'
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed May 25, 2021
1 parent be93aea commit bd1ea8b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 93 deletions.
20 changes: 8 additions & 12 deletions lib/Headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ Headers.prototype.set = function (headerName, valueOrValues, valueNumber) {
Array.isArray(this.valuesByName[headerNameLowerCase]) &&
valueNumber < this.valuesByName[headerNameLowerCase].length
) {
this.valuesByName[headerNameLowerCase][
valueNumber
] = this.parseHeaderValue(valueOrValues);
this.valuesByName[headerNameLowerCase][valueNumber] =
this.parseHeaderValue(valueOrValues);
} else {
(this.valuesByName[headerNameLowerCase] =
this.valuesByName[headerNameLowerCase] || []).push(
Expand Down Expand Up @@ -433,9 +432,8 @@ Headers.prototype.toCanonicalObject = function () {
const canonicalObject = {};
const lowerCaseHeaderNames = this.getNamesLowerCase();
lowerCaseHeaderNames.forEach(function (lowerCaseHeaderName) {
canonicalObject[formatHeaderName(lowerCaseHeaderName)] = this.getAll(
lowerCaseHeaderName
);
canonicalObject[formatHeaderName(lowerCaseHeaderName)] =
this.getAll(lowerCaseHeaderName);
}, this);
return canonicalObject;
};
Expand All @@ -446,13 +444,11 @@ Headers.prototype.toJSON = function () {
lowerCaseHeaderNames.forEach(function (lowerCaseHeaderName) {
const values = this.getAll(lowerCaseHeaderName);
if (values.length === 1) {
obj[formatHeaderName(lowerCaseHeaderName)] = this.get(
lowerCaseHeaderName
);
obj[formatHeaderName(lowerCaseHeaderName)] =
this.get(lowerCaseHeaderName);
} else {
obj[formatHeaderName(lowerCaseHeaderName)] = this.getAll(
lowerCaseHeaderName
);
obj[formatHeaderName(lowerCaseHeaderName)] =
this.getAll(lowerCaseHeaderName);
}
}, this);
return obj;
Expand Down
5 changes: 2 additions & 3 deletions lib/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ Message.prototype.populateFromBuffer = function (buffer) {
};

Message.prototype.populateFromString = function (str) {
const bodyStartIndex = this.headers.populateFromStringAndReturnBodyStartIndex(
str
);
const bodyStartIndex =
this.headers.populateFromStringAndReturnBodyStartIndex(str);
if (bodyStartIndex < str.length) {
this.rawBody = str.substr(bodyStartIndex);
}
Expand Down
87 changes: 9 additions & 78 deletions test/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -1095,32 +1095,9 @@ describe('Message', function () {
'ascii'
),
Buffer.from([
0x1f,
0x8b,
0x08,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x03,
0x4b,
0xcb,
0xcf,
0x4f,
0x4a,
0x2c,
0x02,
0x00,
0x95,
0x1f,
0xf6,
0x9e,
0x06,
0x00,
0x00,
0x00,
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x4b, 0xcb, 0xcf, 0x4f, 0x4a, 0x2c, 0x02, 0x00, 0x95, 0x1f,
0xf6, 0x9e, 0x06, 0x00, 0x00, 0x00,
]),
])
).body,
Expand Down Expand Up @@ -1229,32 +1206,9 @@ describe('Message', function () {
'ascii'
),
Buffer.from([
0x1f,
0x8b,
0x08,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x03,
0x4b,
0xcb,
0xcf,
0x4f,
0x4a,
0x2c,
0x02,
0x00,
0x95,
0x1f,
0xf6,
0x9e,
0x06,
0x00,
0x00,
0x00,
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4b,
0xcb, 0xcf, 0x4f, 0x4a, 0x2c, 0x02, 0x00, 0x95, 0x1f, 0xf6, 0x9e,
0x06, 0x00, 0x00, 0x00,
]),
])
);
Expand All @@ -1264,32 +1218,9 @@ describe('Message', function () {
message.rawBody,
'to equal',
Buffer.from([
0x1f,
0x8b,
0x08,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x03,
0x4b,
0x4a,
0x2c,
0x4a,
0xcb,
0xcf,
0x07,
0x00,
0x2b,
0x85,
0xa8,
0xe2,
0x06,
0x00,
0x00,
0x00,
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x4b,
0x4a, 0x2c, 0x4a, 0xcb, 0xcf, 0x07, 0x00, 0x2b, 0x85, 0xa8, 0xe2,
0x06, 0x00, 0x00, 0x00,
])
);
expect(message.body, 'to equal', 'barfoo');
Expand Down

0 comments on commit bd1ea8b

Please sign in to comment.