Skip to content

Commit f8b49b8

Browse files
authored
chore: fix grammatical and spelling errors in comments and tests (#1490)
1 parent d1c9263 commit f8b49b8

16 files changed

+44
-40
lines changed

lib/application.js

+1
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,5 @@ function respond(ctx) {
278278
* Make HttpError available to consumers of the library so that consumers don't
279279
* have a direct dependency upon `http-errors`
280280
*/
281+
281282
module.exports.HttpError = HttpError;

lib/request.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ module.exports = {
146146
},
147147

148148
/**
149-
* Set pathname, retaining the query-string when present.
149+
* Set pathname, retaining the query string when present.
150150
*
151151
* @param {String} path
152152
* @api public
@@ -163,7 +163,7 @@ module.exports = {
163163
},
164164

165165
/**
166-
* Get parsed query-string.
166+
* Get parsed query string.
167167
*
168168
* @return {Object}
169169
* @api public
@@ -176,7 +176,7 @@ module.exports = {
176176
},
177177

178178
/**
179-
* Set query-string as an object.
179+
* Set query string as an object.
180180
*
181181
* @param {Object} obj
182182
* @api public
@@ -199,7 +199,7 @@ module.exports = {
199199
},
200200

201201
/**
202-
* Set querystring.
202+
* Set query string.
203203
*
204204
* @param {String} str
205205
* @api public
@@ -216,7 +216,7 @@ module.exports = {
216216
},
217217

218218
/**
219-
* Get the search string. Same as the querystring
219+
* Get the search string. Same as the query string
220220
* except it includes the leading ?.
221221
*
222222
* @return {String}
@@ -406,7 +406,7 @@ module.exports = {
406406
},
407407

408408
/**
409-
* Short-hand for:
409+
* Shorthand for:
410410
*
411411
* this.protocol == 'https'
412412
*
@@ -422,7 +422,7 @@ module.exports = {
422422
* When `app.proxy` is `true`, parse
423423
* the "X-Forwarded-For" ip address list.
424424
*
425-
* For example if the value were "client, proxy1, proxy2"
425+
* For example if the value was "client, proxy1, proxy2"
426426
* you would receive the array `["client", "proxy1", "proxy2"]`
427427
* where "proxy2" is the furthest down-stream.
428428
*
@@ -495,6 +495,7 @@ module.exports = {
495495
* @return {Object}
496496
* @api private
497497
*/
498+
498499
get accept() {
499500
return this._accept || (this._accept = accepts(this.req));
500501
},
@@ -505,6 +506,7 @@ module.exports = {
505506
* @param {Object}
506507
* @api private
507508
*/
509+
508510
set accept(obj) {
509511
this._accept = obj;
510512
},
@@ -607,7 +609,7 @@ module.exports = {
607609

608610
/**
609611
* Check if the incoming request contains the "Content-Type"
610-
* header field, and it contains any of the give mime `type`s.
612+
* header field and if it contains any of the given mime `type`s.
611613
* If there is no request body, `null` is returned.
612614
* If there is no content type, `false` is returned.
613615
* Otherwise, it returns the first `type` that matches.

lib/response.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ module.exports = {
433433
* @return {boolean}
434434
* @api public
435435
*/
436+
436437
has(field) {
437438
return typeof this.res.hasHeader === 'function'
438439
? this.res.hasHeader(field)
@@ -441,7 +442,7 @@ module.exports = {
441442
},
442443

443444
/**
444-
* Set header `field` to `val`, or pass
445+
* Set header `field` to `val` or pass
445446
* an object of header fields.
446447
*
447448
* Examples:
@@ -564,8 +565,9 @@ module.exports = {
564565
},
565566

566567
/**
567-
* Flush any set headers, and begin the body
568+
* Flush any set headers and begin the body
568569
*/
570+
569571
flushHeaders() {
570572
this.res.flushHeaders();
571573
}
@@ -577,6 +579,7 @@ module.exports = {
577579
* @return {Object}
578580
* @api public
579581
*/
582+
580583
/* istanbul ignore else */
581584
if (util.inspect.custom) {
582585
module.exports[util.inspect.custom] = module.exports.inspect;

test/application/onerror.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('app.onerror(err)', () => {
6666
assert(msg === '\n Foo\n');
6767
});
6868

69-
it('should use err.toString() instad of err.stack', () => {
69+
it('should use err.toString() instead of err.stack', () => {
7070
const app = new Koa();
7171
app.env = 'dev';
7272

test/application/respond.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ describe('app.respond', () => {
238238
});
239239
});
240240

241-
describe('when no middleware are present', () => {
241+
describe('when no middleware is present', () => {
242242
it('should 404', () => {
243243
const app = new Koa();
244244

test/application/use.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('app.use(fn)', () => {
9898
.expect('generator');
9999
});
100100

101-
it('should throw error for non function', () => {
101+
it('should throw error for non-function', () => {
102102
const app = new Koa();
103103

104104
[null, undefined, 0, false, 'not a function'].forEach(v => {

test/context/onerror.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ describe('ctx.onerror(err)', () => {
239239
});
240240

241241
describe('when non-error thrown', () => {
242-
it('should response non-error thrown message', () => {
242+
it('should respond with non-error thrown message', () => {
243243
const app = new Koa();
244244

245245
app.use((ctx, next) => {

test/request/accepts.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('ctx.accepts(types)', () => {
6262
});
6363
});
6464

65-
describe('when present in Accept as an exact match', () => {
65+
describe('when value present in Accept is an exact match', () => {
6666
it('should return the type', () => {
6767
const ctx = context();
6868
ctx.req.headers.accept = 'text/plain, text/html';
@@ -71,7 +71,7 @@ describe('ctx.accepts(types)', () => {
7171
});
7272
});
7373

74-
describe('when present in Accept as a type match', () => {
74+
describe('when value present in Accept is a type match', () => {
7575
it('should return the type', () => {
7676
const ctx = context();
7777
ctx.req.headers.accept = 'application/json, */*';
@@ -81,7 +81,7 @@ describe('ctx.accepts(types)', () => {
8181
});
8282
});
8383

84-
describe('when present in Accept as a subtype match', () => {
84+
describe('when value present in Accept is a subtype match', () => {
8585
it('should return the type', () => {
8686
const ctx = context();
8787
ctx.req.headers.accept = 'application/json, text/*';

test/request/fresh.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('ctx.fresh', () => {
3636
});
3737
});
3838

39-
describe('and etag do not match', () => {
39+
describe('and etag does not match', () => {
4040
it('should return false', () => {
4141
const ctx = context();
4242
ctx.status = 200;

test/request/hostname.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ describe('req.hostname', () => {
3131
assert.equal(req.hostname, '[::1]');
3232
});
3333

34-
it('should parse localhost with non special schema port', () => {
34+
it('should parse localhost with non-special schema port', () => {
3535
const req = request();
3636
req.header.host = '[::1]:1337';
3737
assert.equal(req.hostname, '[::1]');
3838
});
3939

40-
it('should reduce IPv6 with non special schema port, as hostname', () => {
40+
it('should reduce IPv6 with non-special schema port as hostname', () => {
4141
const req = request();
4242
req.header.host = '[2001:cdba:0000:0000:0000:0000:3257:9652]:1337';
4343
assert.equal(req.hostname, '[2001:cdba::3257:9652]');

test/request/length.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('ctx.length', () => {
1111
assert.equal(req.length, 10);
1212
});
1313

14-
it('with no content-length present', () => {
14+
it('should return undefined with no content-length present', () => {
1515
const req = request();
1616
assert.equal(req.length, undefined);
1717
});

test/request/query.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ describe('ctx.query', () => {
1818
});
1919
});
2020

21-
it('should return a parsed query-string', () => {
21+
it('should return a parsed query string', () => {
2222
const ctx = context({ url: '/?page=2' });
2323
assert.equal(ctx.query.page, '2');
2424
});
2525
});
2626

2727
describe('ctx.query=', () => {
28-
it('should stringify and replace the querystring and search', () => {
28+
it('should stringify and replace the query string and search', () => {
2929
const ctx = context({ url: '/store/shoes' });
3030
ctx.query = { page: 2, color: 'blue' };
3131
assert.equal(ctx.url, '/store/shoes?page=2&color=blue');

test/request/type.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('req.type', () => {
1111
assert.equal(req.type, 'text/html');
1212
});
1313

14-
it('with no host present', () => {
14+
it('should return empty string with no host present', () => {
1515
const req = request();
1616
assert.equal(req.type, '');
1717
});

test/request/whatwg-url.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ const request = require('../helpers/context').request;
55
const assert = require('assert');
66

77
describe('req.URL', () => {
8-
describe('should not throw when', () => {
9-
it('host is void', () => {
10-
// Accessing the URL should not throw.
11-
request().URL;
12-
});
8+
it('should not throw when host is void', () => {
9+
// Accessing the URL should not throw.
10+
request().URL;
11+
});
1312

14-
it('header.host is invalid', () => {
15-
const req = request();
16-
req.header.host = 'invalid host';
17-
// Accessing the URL should not throw.
18-
req.URL;
19-
});
13+
it('should not throw when header.host is invalid', () => {
14+
const req = request();
15+
req.header.host = 'invalid host';
16+
// Accessing the URL should not throw.
17+
req.URL;
2018
});
2119

2220
it('should return empty object when invalid', () => {

test/response/attachment.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('ctx.attachment([filename])', () => {
2424
});
2525
});
2626

27-
describe('when given a no-ascii filename', () => {
27+
describe('when given a non-ascii filename', () => {
2828
it('should set the encodeURI filename param', () => {
2929
const ctx = context();
3030
ctx.attachment('path/to/include-no-ascii-char-中文名-ok.png');
@@ -168,7 +168,7 @@ describe('contentDisposition(filename, options)', () => {
168168
'inline');
169169
});
170170

171-
it('should create a header with inline type & filename', () => {
171+
it('should create a header with inline type and filename', () => {
172172
const ctx = context();
173173
ctx.attachment('plans.pdf', { type: 'inline' });
174174
assert.equal(ctx.response.header['content-disposition'],

test/response/writable.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('res.writable', () => {
2121
setTimeout(() => client.end(), 100);
2222
}
2323

24-
it('should always writable and response all requests', done => {
24+
it('should always be writable and respond to all requests', done => {
2525
const app = new Koa();
2626
let count = 0;
2727
app.use(ctx => {
@@ -50,7 +50,7 @@ describe('res.writable', () => {
5050
});
5151
}
5252

53-
it('should not writable', done => {
53+
it('should not be writable', done => {
5454
const app = new Koa();
5555
app.use(ctx => {
5656
sleep(1000)
@@ -77,7 +77,7 @@ describe('res.writable', () => {
7777
}, 100);
7878
}
7979

80-
it('should not writable', done => {
80+
it('should not be writable', done => {
8181
const app = new Koa();
8282
app.use(ctx => {
8383
ctx.res.end();

0 commit comments

Comments
 (0)