Skip to content

Commit 2112bf8

Browse files
committed
chore: clean up code
1 parent 560fcd6 commit 2112bf8

File tree

1 file changed

+22
-14
lines changed
  • lib/node_modules/@stdlib/_tools/github/create-repo/lib

1 file changed

+22
-14
lines changed

lib/node_modules/@stdlib/_tools/github/create-repo/lib/factory.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* you may not use this file except in compliance with the License.
88
* You may obtain a copy of the License at
99
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
10+
* http://www.apache.org/licenses/LICENSE-2.0
1111
*
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -65,28 +65,34 @@ var DEFAULT_HTTPS_PORT = 443;
6565
function factory( options, clbk ) {
6666
var opts;
6767
var err;
68+
6869
opts = copy( defaults );
6970
err = validate( opts, options );
7071
if ( err ) {
7172
throw err;
7273
}
7374
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;
7976
}
8077
if ( !isFunction( clbk ) ) {
8178
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
8279
}
8380

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+
}
9096

9197
/**
9298
* Creates a GitHub repository.
@@ -101,11 +107,13 @@ function factory( options, clbk ) {
101107
throw new TypeError( format( 'invalid argument. Repository name must be a string. Value: `%s`.', name ) );
102108
}
103109
query( name, opts, done );
104-
}
110+
}
105111

106-
return createRepo;
112+
return createRepo;
107113
}
108114

115+
116+
109117
// EXPORTS //
110118

111119
module.exports = factory;

0 commit comments

Comments
 (0)