This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 5 files changed +47
-51
lines changed
5 files changed +47
-51
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const promisify = require ( 'promisify-es6 ' )
3
+ const configure = require ( '../lib/configure ' )
4
4
5
- module . exports = ( send ) => {
6
- return promisify ( ( opts , callback ) => {
7
- if ( typeof ( opts ) === 'function' ) {
8
- callback = opts
9
- opts = { }
10
- }
5
+ module . exports = configure ( ( { ky } ) => {
6
+ return options => {
7
+ options = options || { }
11
8
12
- send ( {
13
- path : 'diag/cmds' ,
14
- qs : opts
15
- } , callback )
16
- } )
17
- }
9
+ const searchParams = new URLSearchParams ( options . searchParams )
10
+ if ( options . verbose != null ) searchParams . set ( 'verbose' , options . verbose )
11
+
12
+ return ky . get ( 'diag/cmds' , {
13
+ timeout : options . timeout ,
14
+ signal : options . signal ,
15
+ headers : options . headers ,
16
+ searchParams
17
+ } ) . json ( )
18
+ }
19
+ } )
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const moduleConfig = require ( '../utils/module-config ' )
3
+ const callbackify = require ( 'callbackify ' )
4
4
5
- module . exports = ( arg ) => {
6
- const send = moduleConfig ( arg )
7
-
8
- return {
9
- net : require ( './net' ) ( send ) ,
10
- sys : require ( './sys' ) ( send ) ,
11
- cmds : require ( './cmds' ) ( send )
12
- }
13
- }
5
+ module . exports = config => ( {
6
+ net : callbackify . variadic ( require ( './net' ) ( config ) ) ,
7
+ sys : callbackify . variadic ( require ( './sys' ) ( config ) ) ,
8
+ cmds : callbackify . variadic ( require ( './cmds' ) ( config ) )
9
+ } )
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const promisify = require ( 'promisify-es6 ' )
3
+ const configure = require ( '../lib/configure ' )
4
4
5
- module . exports = ( send ) => {
6
- return promisify ( ( opts , callback ) => {
7
- if ( typeof ( opts ) === 'function' ) {
8
- callback = opts
9
- opts = { }
10
- }
5
+ module . exports = configure ( ( { ky } ) => {
6
+ return options => {
7
+ options = options || { }
11
8
12
- send ( {
13
- path : 'diag/net' ,
14
- qs : opts
15
- } , callback )
16
- } )
17
- }
9
+ return ky . get ( 'diag/net' , {
10
+ timeout : options . timeout ,
11
+ signal : options . signal ,
12
+ headers : options . headers ,
13
+ searchParams : options . searchParams
14
+ } ) . json ( )
15
+ }
16
+ } )
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const promisify = require ( 'promisify-es6 ' )
3
+ const configure = require ( '../lib/configure ' )
4
4
5
- module . exports = ( send ) => {
6
- return promisify ( ( opts , callback ) => {
7
- if ( typeof ( opts ) === 'function' ) {
8
- callback = opts
9
- opts = { }
10
- }
5
+ module . exports = configure ( ( { ky } ) => {
6
+ return options => {
7
+ options = options || { }
11
8
12
- send ( {
13
- path : 'diag/sys' ,
14
- qs : opts
15
- } , callback )
16
- } )
17
- }
9
+ return ky . get ( 'diag/sys' , {
10
+ timeout : options . timeout ,
11
+ signal : options . signal ,
12
+ headers : options . headers ,
13
+ searchParams : options . searchParams
14
+ } ) . json ( )
15
+ }
16
+ } )
Original file line number Diff line number Diff line change @@ -94,7 +94,8 @@ function requireCommands (send, config) {
94
94
bootstrap : require ( '../bootstrap' ) ( config ) ,
95
95
config : require ( '../config' ) ( config ) ,
96
96
dag : require ( '../dag' ) ( config ) ,
97
- dht : require ( '../dht' ) ( config )
97
+ dht : require ( '../dht' ) ( config ) ,
98
+ diag : require ( '../diag' ) ( config )
98
99
}
99
100
100
101
Object . assign ( cmds . refs , {
@@ -123,7 +124,6 @@ function requireCommands (send, config) {
123
124
124
125
// Miscellaneous
125
126
commands : require ( '../commands' ) ,
126
- diag : require ( '../diag' ) ,
127
127
id : require ( '../id' ) ,
128
128
key : require ( '../key' ) ,
129
129
log : require ( '../log' ) ,
You can’t perform that action at this time.
0 commit comments