Skip to content

Commit bb6214d

Browse files
committed
save
1 parent 467e10e commit bb6214d

File tree

6 files changed

+90
-267
lines changed

6 files changed

+90
-267
lines changed

.eslintrc.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
{
22
"env": {
3-
"es6": true
3+
"es6": true,
4+
"node": true
45
},
56
"extends": ["airbnb-base", "plugin:prettier/recommended"],
67
"plugins": ["import", "prettier"],
78
"rules": {
9+
"array-element-newline": ["off"],
10+
"no-underscore-dangle" : ["off"],
11+
"no-void":["off"],
12+
"no-plusplus":["off"],
13+
"no-bitwise":["off"],
14+
"no-param-reassign":["off"],
815
"arrow-parens": ["error", "always"],
916
"no-console": "error",
1017
"prettier/prettier": [
1118
"error",
1219
{
1320
"semi": true,
14-
"printWidth": 90,
21+
"printWidth": 100,
1522
"singleQuote": true,
1623
"arrowParens": "always"
1724
}
1825
],
1926
"func-names": ["error", "always"],
2027
"comma-dangle": ["error", "never"],
21-
"max-len": ["error", 90, { "ignoreRegExpLiterals": true }]
28+
"max-len": ["error", 100, { "ignoreRegExpLiterals": true }]
2229
}
2330
}

packages/tiny/router.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@ const SEP = '/';
22
const [STYPE, PTYPE, ATYPE] = [0, 1, 2];
33
const [SLASH, COLON, ASTER] = [47, 58, 42, 63]; // / : *
44

5-
const METHODS = [
6-
'CONNECT',
7-
'DELETE',
8-
'GET',
9-
'HEAD',
10-
'OPTIONS',
11-
'PATCH',
12-
'POST',
13-
'PUT',
14-
'TRACE'
15-
];
5+
const METHODS = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
166

177
const EMPTY_ARRAY = [];
188
Object.freeze(EMPTY_ARRAY);
@@ -227,7 +217,7 @@ module.exports = class Router {
227217
[PARAM]: null
228218
};
229219

230-
if (out[TYPE] != src[TYPE]) {
220+
if (out[TYPE] !== src[TYPE]) {
231221
throw new Error('type missmatch');
232222
}
233223

@@ -314,10 +304,9 @@ module.exports = class Router {
314304
const more = Object.keys(child.childs).length;
315305
const prefix_ = `${prefix + (last ? ' ' : '│')} `;
316306
317-
return `${prefix + (last ? '└' : '├')}${more ? '┬' : '─'} ${print(
318-
child,
319-
prefix_
320-
).slice(prefix.length + 2)}`;
307+
return `${prefix + (last ? '└' : '├')}${more ? '┬' : '─'} ${print(child, prefix_).slice(
308+
prefix.length + 2
309+
)}`;
321310
})
322311
.join('')}`;
323312
};

test/assets/github-api.js

Lines changed: 35 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ module.exports = [
66
['PUT', '/authorizations/clients/:client_id', '/authorizations/clients/12345'],
77
['PATCH', '/authorizations/:id', '/authorizations/233'],
88
['DELETE', '/authorizations/:id', '/authorizations/377'],
9-
[
10-
'GET',
11-
'/applications/:client_id/tokens/:access_token',
12-
'/applications/233/tokens/12345tokens'
13-
],
9+
['GET', '/applications/:client_id/tokens/:access_token', '/applications/233/tokens/12345tokens'],
1410
['DELETE', '/applications/:client_id/tokens', '/applications/377/tokens'],
1511
[
1612
'DELETE',
@@ -35,21 +31,9 @@ module.exports = [
3531
['PUT', '/repos/:owner/:repo/notifications', '/repos/tinyio/router/notifications'],
3632
['GET', '/notifications/threads/:id', '/notifications/threads/233'],
3733
['PATCH', '/notifications/threads/:id', '/notifications/threads/233'],
38-
[
39-
'GET',
40-
'/notifications/threads/:id/subscription',
41-
'/notifications/threads/377/subscription'
42-
],
43-
[
44-
'PUT',
45-
'/notifications/threads/:id/subscription',
46-
'/notifications/threads/610/subscription'
47-
],
48-
[
49-
'DELETE',
50-
'/notifications/threads/:id/subscription',
51-
'/notifications/threads/233/subscription'
52-
],
34+
['GET', '/notifications/threads/:id/subscription', '/notifications/threads/377/subscription'],
35+
['PUT', '/notifications/threads/:id/subscription', '/notifications/threads/610/subscription'],
36+
['DELETE', '/notifications/threads/:id/subscription', '/notifications/threads/233/subscription'],
5337
['GET', '/repos/:owner/:repo/stargazers', '/repos/tinyio/tiny/stargazers'],
5438
['GET', '/users/:user/starred', '/users/fundon/starred'],
5539
['GET', '/user/starred', '/user/starred'],
@@ -61,11 +45,7 @@ module.exports = [
6145
['GET', '/user/subscriptions', '/user/subscriptions'],
6246
['GET', '/repos/:owner/:repo/subscription', '/repos/tinyio/router-mapper/subscription'],
6347
['PUT', '/repos/:owner/:repo/subscription', '/repos/tinyio/router-mapper/subscription'],
64-
[
65-
'DELETE',
66-
'/repos/:owner/:repo/subscription',
67-
'/repos/tinyio/router-mapper/subscription'
68-
],
48+
['DELETE', '/repos/:owner/:repo/subscription', '/repos/tinyio/router-mapper/subscription'],
6949
['GET', '/user/subscriptions/:owner/:repo', '/user/subscriptions/tinyio/tiny'],
7050
['PUT', '/user/subscriptions/:owner/:repo', '/user/subscriptions/tinyio/tiny'],
7151
['DELETE', '/user/subscriptions/:owner/:repo', '/user/subscriptions/tinyio/tiny'],
@@ -87,11 +67,7 @@ module.exports = [
8767
// Git Data
8868
['GET', '/repos/:owner/:repo/git/blobs/:sha', '/repos/tinyio/tiny/git/blobs/abcdefgh'],
8969
['POST', '/repos/:owner/:repo/git/blobs', '/repos/tinyio/tiny/git/blobs'],
90-
[
91-
'GET',
92-
'/repos/:owner/:repo/git/commits/:sha',
93-
'/repos/tinyio/tiny/git/commits/abcdefgh'
94-
],
70+
['GET', '/repos/:owner/:repo/git/commits/:sha', '/repos/tinyio/tiny/git/commits/abcdefgh'],
9571
['POST', '/repos/:owner/:repo/git/commits', '/repos/tinyio/tiny/git/commits'],
9672
['GET', '/repos/:owner/:repo/git/refs/*ref', '/repos/tinyio/tiny/git/refs/asdf'],
9773
['GET', '/repos/:owner/:repo/git/refs', '/repos/tinyio/tiny/git/refs'],
@@ -112,78 +88,30 @@ module.exports = [
11288
['POST', '/repos/:owner/:repo/issues', '/repos/tinyio/tiny/issues'],
11389
['PATCH', '/repos/:owner/:repo/issues/:number', '/repos/tinyio/tiny/issues/377'],
11490
['GET', '/repos/:owner/:repo/assignees', '/repos/tinyio/tiny/assignees'],
115-
[
116-
'GET',
117-
'/repos/:owner/:repo/assignees/:assignee',
118-
'/repos/tinyio/tiny/assignees/31231'
119-
],
120-
[
121-
'GET',
122-
'/repos/:owner/:repo/issues/:number/comments',
123-
'/repos/tinyio/tiny/issues/610/comments'
124-
],
91+
['GET', '/repos/:owner/:repo/assignees/:assignee', '/repos/tinyio/tiny/assignees/31231'],
92+
['GET', '/repos/:owner/:repo/issues/:number/comments', '/repos/tinyio/tiny/issues/610/comments'],
12593
['GET', '/repos/:owner/:repo/issues/comments', '/repos/tinyio/tiny/issues/comments'],
126-
[
127-
'GET',
128-
'/repos/:owner/:repo/issues/comments/:id',
129-
'/repos/tinyio/tiny/issues/comments/233'
130-
],
131-
[
132-
'POST',
133-
'/repos/:owner/:repo/issues/:number/comments',
134-
'/repos/tinyio/tiny/issues/377/comments'
135-
],
136-
[
137-
'PATCH',
138-
'/repos/:owner/:repo/issues/comments/:id',
139-
'/repos/tinyio/tiny/issues/comments/233'
140-
],
141-
[
142-
'DELETE',
143-
'/repos/:owner/:repo/issues/comments/:id',
144-
'/repos/tinyio/tiny/issues/comments/233'
145-
],
146-
[
147-
'GET',
148-
'/repos/:owner/:repo/issues/:number/events',
149-
'/repos/tinyio/tiny/issues/233/events'
150-
],
94+
['GET', '/repos/:owner/:repo/issues/comments/:id', '/repos/tinyio/tiny/issues/comments/233'],
95+
['POST', '/repos/:owner/:repo/issues/:number/comments', '/repos/tinyio/tiny/issues/377/comments'],
96+
['PATCH', '/repos/:owner/:repo/issues/comments/:id', '/repos/tinyio/tiny/issues/comments/233'],
97+
['DELETE', '/repos/:owner/:repo/issues/comments/:id', '/repos/tinyio/tiny/issues/comments/233'],
98+
['GET', '/repos/:owner/:repo/issues/:number/events', '/repos/tinyio/tiny/issues/233/events'],
15199
['GET', '/repos/:owner/:repo/issues/events', '/repos/tinyio/tiny/issues/events'],
152-
[
153-
'GET',
154-
'/repos/:owner/:repo/issues/events/:id',
155-
'/repos/tinyio/tiny/issues/events/233'
156-
],
100+
['GET', '/repos/:owner/:repo/issues/events/:id', '/repos/tinyio/tiny/issues/events/233'],
157101
['GET', '/repos/:owner/:repo/labels', '/repos/tinyio/tiny/labels'],
158102
['GET', '/repos/:owner/:repo/labels/:name', '/repos/tinyio/tiny/labels/help'],
159103
['POST', '/repos/:owner/:repo/labels', '/repos/tinyio/tiny/labels'],
160104
['PATCH', '/repos/:owner/:repo/labels/:name', '/repos/tinyio/tiny/labels/hello'],
161105
['DELETE', '/repos/:owner/:repo/labels/:name', '/repos/tinyio/tiny/labels/iojs'],
162-
[
163-
'GET',
164-
'/repos/:owner/:repo/issues/:number/labels',
165-
'/repos/tinyio/tiny/issues/388/labels'
166-
],
167-
[
168-
'POST',
169-
'/repos/:owner/:repo/issues/:number/labels',
170-
'/repos/tinyio/tiny/issues/388/labels'
171-
],
106+
['GET', '/repos/:owner/:repo/issues/:number/labels', '/repos/tinyio/tiny/issues/388/labels'],
107+
['POST', '/repos/:owner/:repo/issues/:number/labels', '/repos/tinyio/tiny/issues/388/labels'],
172108
[
173109
'DELETE',
174110
'/repos/:owner/:repo/issues/:number/labels/:name',
175111
'/repos/tinyio/tiny/issues/233/labels/help'
176112
],
177-
[
178-
'PUT',
179-
'/repos/:owner/:repo/issues/:number/labels',
180-
'/repos/tinyio/tiny/issues/233/labels'
181-
],
182-
[
183-
'DELETE',
184-
'/repos/:owner/:repo/issues/:number/labels',
185-
'/repos/tinyio/tiny/issues/399/labels'
186-
],
113+
['PUT', '/repos/:owner/:repo/issues/:number/labels', '/repos/tinyio/tiny/issues/233/labels'],
114+
['DELETE', '/repos/:owner/:repo/issues/:number/labels', '/repos/tinyio/tiny/issues/399/labels'],
187115
[
188116
'GET',
189117
'/repos/:owner/:repo/milestones/:number/labels',
@@ -192,16 +120,8 @@ module.exports = [
192120
['GET', '/repos/:owner/:repo/milestones', '/repos/tinyio/tiny/milestones'],
193121
['GET', '/repos/:owner/:repo/milestones/:number', '/repos/tinyio/tiny/milestones/1024'],
194122
['POST', '/repos/:owner/:repo/milestones', '/repos/tinyio/tiny/milestones'],
195-
[
196-
'PATCH',
197-
'/repos/:owner/:repo/milestones/:number',
198-
'/repos/tinyio/tiny/milestones/1024'
199-
],
200-
[
201-
'DELETE',
202-
'/repos/:owner/:repo/milestones/:number',
203-
'/repos/tinyio/tiny/milestones/233'
204-
],
123+
['PATCH', '/repos/:owner/:repo/milestones/:number', '/repos/tinyio/tiny/milestones/1024'],
124+
['DELETE', '/repos/:owner/:repo/milestones/:number', '/repos/tinyio/tiny/milestones/233'],
205125

206126
// Miscellaneous
207127
['GET', '/emojis', '/emojis'],
@@ -244,42 +164,14 @@ module.exports = [
244164
['GET', '/repos/:owner/:repo/pulls/:number', '/repos/tinyio/tiny/pulls/233'],
245165
['POST', '/repos/:owner/:repo/pulls', '/repos/tinyio/tiny/pulls'],
246166
['PATCH', '/repos/:owner/:repo/pulls/:number', '/repos/tinyio/tiny/pulls/233'],
247-
[
248-
'GET',
249-
'/repos/:owner/:repo/pulls/:number/commits',
250-
'/repos/tinyio/tiny/pulls/233/commits'
251-
],
252-
[
253-
'GET',
254-
'/repos/:owner/:repo/pulls/:number/files',
255-
'/repos/tinyio/tiny/pulls/233/files'
256-
],
257-
[
258-
'GET',
259-
'/repos/:owner/:repo/pulls/:number/merge',
260-
'/repos/tinyio/tiny/pulls/233/merge'
261-
],
262-
[
263-
'PUT',
264-
'/repos/:owner/:repo/pulls/:number/merge',
265-
'/repos/tinyio/tiny/pulls/233/merge'
266-
],
267-
[
268-
'GET',
269-
'/repos/:owner/:repo/pulls/:number/comments',
270-
'/repos/tinyio/tiny/pulls/233/comments'
271-
],
167+
['GET', '/repos/:owner/:repo/pulls/:number/commits', '/repos/tinyio/tiny/pulls/233/commits'],
168+
['GET', '/repos/:owner/:repo/pulls/:number/files', '/repos/tinyio/tiny/pulls/233/files'],
169+
['GET', '/repos/:owner/:repo/pulls/:number/merge', '/repos/tinyio/tiny/pulls/233/merge'],
170+
['PUT', '/repos/:owner/:repo/pulls/:number/merge', '/repos/tinyio/tiny/pulls/233/merge'],
171+
['GET', '/repos/:owner/:repo/pulls/:number/comments', '/repos/tinyio/tiny/pulls/233/comments'],
272172
['GET', '/repos/:owner/:repo/pulls/comments', '/repos/tinyio/tiny/pulls/comments'],
273-
[
274-
'GET',
275-
'/repos/:owner/:repo/pulls/comments/:number',
276-
'/repos/tinyio/tiny/pulls/comments/233'
277-
],
278-
[
279-
'PUT',
280-
'/repos/:owner/:repo/pulls/:number/comments',
281-
'/repos/tinyio/tiny/pulls/233/comments'
282-
],
173+
['GET', '/repos/:owner/:repo/pulls/comments/:number', '/repos/tinyio/tiny/pulls/comments/233'],
174+
['PUT', '/repos/:owner/:repo/pulls/:number/comments', '/repos/tinyio/tiny/pulls/233/comments'],
283175
[
284176
'PATCH',
285177
'/repos/:owner/:repo/pulls/comments/:number',
@@ -308,21 +200,9 @@ module.exports = [
308200
['GET', '/repos/:owner/:repo/branches/:branch', '/repos/tinyio/tiny/branches/master'],
309201
['DELETE', '/repos/:owner/:repo', '/repos/tinyio/tiny'],
310202
['GET', '/repos/:owner/:repo/collaborators', '/repos/tinyio/tiny/collaborators'],
311-
[
312-
'GET',
313-
'/repos/:owner/:repo/collaborators/:user',
314-
'/repos/tinyio/tiny/collaborators/fundon'
315-
],
316-
[
317-
'PUT',
318-
'/repos/:owner/:repo/collaborators/:user',
319-
'/repos/tinyio/tiny/collaborators/fundon'
320-
],
321-
[
322-
'DELETE',
323-
'/repos/:owner/:repo/collaborators/:user',
324-
'/repos/tinyio/tiny/collaborators/fundon'
325-
],
203+
['GET', '/repos/:owner/:repo/collaborators/:user', '/repos/tinyio/tiny/collaborators/fundon'],
204+
['PUT', '/repos/:owner/:repo/collaborators/:user', '/repos/tinyio/tiny/collaborators/fundon'],
205+
['DELETE', '/repos/:owner/:repo/collaborators/:user', '/repos/tinyio/tiny/collaborators/fundon'],
326206
['GET', '/repos/:owner/:repo/comments', '/repos/tinyio/tiny/comments'],
327207
[
328208
'GET',
@@ -366,31 +246,11 @@ module.exports = [
366246
['POST', '/repos/:owner/:repo/releases', '/repos/trejs/tiny/releases'],
367247
['PATCH', '/repos/:owner/:repo/releases/:id', '/repos/tinyio/tiny/releases/231'],
368248
['DELETE', '/repos/:owner/:repo/releases/:id', '/repos/tinyio/tiny/releases/231'],
369-
[
370-
'GET',
371-
'/repos/:owner/:repo/releases/:id/assets',
372-
'/repos/tinyio/tiny/releases/233/assets'
373-
],
374-
[
375-
'GET',
376-
'/repos/:owner/:repo/stats/contributors',
377-
'/repos/tinyio/tiny/stats/contributors'
378-
],
379-
[
380-
'GET',
381-
'/repos/:owner/:repo/stats/commit_activity',
382-
'/repos/trejs/tiny/stats/commit_activity'
383-
],
384-
[
385-
'GET',
386-
'/repos/:owner/:repo/stats/code_frequency',
387-
'/repos/tinyio/tiny/stats/code_frequency'
388-
],
389-
[
390-
'GET',
391-
'/repos/:owner/:repo/stats/participation',
392-
'/repos/tinyio/tiny/stats/participation'
393-
],
249+
['GET', '/repos/:owner/:repo/releases/:id/assets', '/repos/tinyio/tiny/releases/233/assets'],
250+
['GET', '/repos/:owner/:repo/stats/contributors', '/repos/tinyio/tiny/stats/contributors'],
251+
['GET', '/repos/:owner/:repo/stats/commit_activity', '/repos/trejs/tiny/stats/commit_activity'],
252+
['GET', '/repos/:owner/:repo/stats/code_frequency', '/repos/tinyio/tiny/stats/code_frequency'],
253+
['GET', '/repos/:owner/:repo/stats/participation', '/repos/tinyio/tiny/stats/participation'],
394254
['GET', '/repos/:owner/:repo/stats/punch_card', '/repos/tinyio/tiny/stats/punch_card'],
395255
['GET', '/repos/:owner/:repo/statuses/:ref', '/repos/tinyio/tiny/statuses/dev'],
396256
['POST', '/repos/:owner/:repo/statuses/:ref', '/repos/tinyio/tiny/statuses/master'],

test/benchmarks/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const nap = require('pancho');
99
const Table = require('cli-table');
1010
const { fork } = require('child_process');
1111

12-
const files = fs
13-
.readdirSync(`${__dirname}/cases`)
14-
.filter((file) => file.match(/(.+)\.js$/));
12+
const files = fs.readdirSync(`${__dirname}/cases`).filter((file) => file.match(/(.+)\.js$/));
1513

1614
const argv = minimist(process.argv.slice(2));
1715
const cannon = (title = null) =>

0 commit comments

Comments
 (0)