7
7
* you may not use this file except in compliance with the License.
8
8
* You may obtain a copy of the License at
9
9
*
10
- * http://www.apache.org/licenses/LICENSE-2.0
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
11
*
12
12
* Unless required by applicable law or agreed to in writing, software
13
13
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -65,28 +65,34 @@ var DEFAULT_HTTPS_PORT = 443;
65
65
function factory ( options , clbk ) {
66
66
var opts ;
67
67
var err ;
68
+
68
69
opts = copy ( defaults ) ;
69
70
err = validate ( opts , options ) ;
70
71
if ( err ) {
71
72
throw err ;
72
73
}
73
74
if ( opts . port === null ) {
74
- if ( opts . protocol === 'https' ) {
75
- opts . port = DEFAULT_HTTPS_PORT ;
76
- } else {
77
- opts . port = DEFAULT_HTTP_PORT ;
78
- }
75
+ opts . port = ( opts . protocol === 'https' ) ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT ;
79
76
}
80
77
if ( ! isFunction ( clbk ) ) {
81
78
throw new TypeError ( format ( 'invalid argument. Callback argument must be a function. Value: `%s`.' , clbk ) ) ;
82
79
}
83
80
84
- function done ( error , data , info ) {
85
- error = error || null ;
86
- data = data || null ;
87
- info = info || null ;
88
- clbk ( error , data , info ) ;
89
- }
81
+ /**
82
+ * Callback invoked after receiving an API response.
83
+ *
84
+ * @private
85
+ * @param {(Error|null) } error - error object
86
+ * @param {Object } data - query data
87
+ * @param {Object } info - response info
88
+ * @returns {void }
89
+ */
90
+ function done ( error , data , info ) {
91
+ error = error || null ;
92
+ data = data || null ;
93
+ info = info || null ;
94
+ clbk ( error , data , info ) ;
95
+ }
90
96
91
97
/**
92
98
* Creates a GitHub repository.
@@ -101,11 +107,13 @@ function factory( options, clbk ) {
101
107
throw new TypeError ( format ( 'invalid argument. Repository name must be a string. Value: `%s`.' , name ) ) ;
102
108
}
103
109
query ( name , opts , done ) ;
104
- }
110
+ }
105
111
106
- return createRepo ;
112
+ return createRepo ;
107
113
}
108
114
115
+
116
+
109
117
// EXPORTS //
110
118
111
119
module . exports = factory ;
0 commit comments