Use basic types in JSDoc rather than object types (#1178)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by GitHub · parent 28b649d · Browse files · 1 file·+57 added−57 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+57 added−57 removed
- other:+57 added−57 removed
Provenance
- Commit
31f1878- Tree
5f92e1c- Author
John Gee <john@ruru.gen.nz>- Committer
GitHub <noreply@github.com>- Parent
28b649d
1 file changed+57 added−57 removed
modified:index.js+57 added-57 removed
9 unmodified lines10 class Option {11 /**12 * Initialize a new `Option` with the given `flags` and `description`.13 *14- * @param {String} flags15- * @param {String} description14+ * @param {string} flags15+ * @param {string} description16 * @api public17 */18 19 constructor(flags, description) {10 unmodified lines30 31 /**32 * Return option name.33 *34- * @return {String}34+ * @return {string}35 * @api private36 */37 38 name() {3 unmodified lines42 /**43 * Return option name, in a camelcase format that can be used44 * as a object attribute key.45 *46- * @return {String}46+ * @return {string}47 * @api private48 */49 50 attributeName() {2 unmodified lines53 54 /**55 * Check if `arg` matches the short or long flag.56 *57- * @param {String} arg58- * @return {Boolean}57+ * @param {string} arg58+ * @return {boolean}59 * @api private60 */61 62 is(arg) {7 unmodified lines70 */71 class CommanderError extends Error {72 /**73 * Constructs the CommanderError class74- * @param {Number} exitCode suggested exit code which could be used with process.exit75- * @param {String} code an id string representing the error76- * @param {String} message human-readable description of the error74+ * @param {number} exitCode suggested exit code which could be used with process.exit75+ * @param {string} code an id string representing the error76+ * @param {string} message human-readable description of the error77 * @constructor78 */79 constructor(exitCode, code, message) {80 super(message);8 unmodified lines89 class Command extends EventEmitter {90 /**91 * Initialize a new `Command`.92 *93- * @param {String} [name]93+ * @param {string} [name]94 * @api public95 */96 97 constructor(name) {236 unmodified lines334 335 /**336 * Call process.exit, and _exitCallback if defined.337 *338- * @param {Number} exitCode exit code for using with process.exit339- * @param {String} code an id string representing the error340- * @param {String} message human-readable description of the error338+ * @param {number} exitCode exit code for using with process.exit339+ * @param {string} code an id string representing the error340+ * @param {string} message human-readable description of the error341 * @return never342 * @api private343 */344 52 unmodified lines397 /**398 * Internal implementation shared by .option() and .requiredOption()399 *400 * @param {Object} config401- * @param {String} flags402- * @param {String} description401+ * @param {string} flags402+ * @param {string} description403 * @param {Function|*} [fn] - custom option processing function or default vaue404 * @param {*} [defaultValue]405 * @return {Command} for chaining406 * @api private108 unmodified lines515 *516 * // optional argument517 * program.option('-c, --cheese [type]', 'add cheese [marble]');518 *519- * @param {String} flags520- * @param {String} description519+ * @param {string} flags520+ * @param {string} description521 * @param {Function|*} [fn] - custom option processing function or default vaue522 * @param {*} [defaultValue]523 * @return {Command} for chaining524 * @api public8 unmodified lines533 * the option must be specified on the command line. (Otherwise the same as .option().)534 *535 * The `flags` string should contain both the short and long flags, separated by comma, a pipe or space.536 *537- * @param {String} flags538- * @param {String} description537+ * @param {string} flags538+ * @param {string} description539 * @param {Function|*} [fn] - custom option processing function or default vaue540 * @param {*} [defaultValue]541 * @return {Command} for chaining542 * @api public5 unmodified lines548 549 /**550 * Allow unknown options on the command line.551 *552- * @param {Boolean} arg if `true` or omitted, no error will be thrown552+ * @param {Boolean} [arg] - if `true` or omitted, no error will be thrown553 * for unknown options.554 * @api public555 */556 allowUnknownOption(arg) {34 unmodified lines591 592 /**593 * Store option value594 *595- * @param {String} key595+ * @param {string} key596 * @param {Object} value597 * @api private598 */599 7 unmodified lines607 608 /**609 * Retrieve option value610 *611- * @param {String} key611+ * @param {string} key612 * @return {Object} value613 * @api private614 */615 293 unmodified lines909 910 /**911 * Return an option matching `arg` if any.912 *913- * @param {String} arg913+ * @param {string} arg914 * @return {Option}915 * @api private916 */917 141 unmodified lines1059 1060 /**1061 * Argument `name` is missing.1062 *1063- * @param {String} name1063+ * @param {string} name1064 * @api private1065 */1066 1067 missingArgument(name) {5 unmodified lines1073 /**1074 * `Option` is missing an argument, but received `flag` or nothing.1075 *1076 * @param {Option} option1077- * @param {String} [flag]1077+ * @param {string} [flag]1078 * @api private1079 */1080 1081 optionMissingArgument(option, flag) {22 unmodified lines1104 1105 /**1106 * Unknown option `flag`.1107 *1108- * @param {String} flag1108+ * @param {string} flag1109 * @api private1110 */1111 1112 unknownOption(flag) {5 unmodified lines1118 1119 /**1120 * Unknown command.1121 *1122- * @param {String} flag1122+ * @param {string} flag1123 * @api private1124 */1125 1126 unknownCommand() {14 unmodified lines1141 * which will print the version number when passed.1142 *1143 * You can optionally supply the flags and description to override the defaults.1144 *1145- * @param {String} str1146- * @param {String} [flags]1147- * @param {String} [description]1145+ * @param {string} str1146+ * @param {string} [flags]1147+ * @param {string} [description]1148 * @return {Command} for chaining1149 * @api public1150 */1151 14 unmodified lines1166 1167 /**1168 * Set the description to `str`.1169 *1170- * @param {String} str1170+ * @param {string} str1171 * @param {Object} [argsDescription]1172 * @return {String|Command}1173 * @api public1174 */7 unmodified lines1182 1183 /**1184 * Set an alias for the command1185 *1186- * @param {String} alias1186+ * @param {string} alias1187 * @return {String|Command}1188 * @api public1189 */1190 13 unmodified lines1204 1205 /**1206 * Set / get the command usage `str`.1207 *1208- * @param {String} [str]1208+ * @param {string} [str]1209 * @return {String|Command}1210 * @api public1211 */1212 14 unmodified lines1227 1228 /**1229 * Get or set the name of the command1230 *1231- * @param {String} [str]1231+ * @param {string} [str]1232 * @return {String|Command}1233 * @api public1234 */1235 35 unmodified lines1271 1272 /**1273 * Return the largest command length.1274 *1275- * @return {Number}1275+ * @return {number}1276 * @api private1277 */1278 1279 largestCommandLength() {5 unmodified lines1285 1286 /**1287 * Return the largest option length.1288 *1289- * @return {Number}1289+ * @return {number}1290 * @api private1291 */1292 1293 largestOptionLength() {9 unmodified lines1303 1304 /**1305 * Return the largest arg length.1306 *1307- * @return {Number}1307+ * @return {number}1308 * @api private1309 */1310 1311 largestArgLength() {4 unmodified lines1316 1317 /**1318 * Return the pad width.1319 *1320- * @return {Number}1320+ * @return {number}1321 * @api private1322 */1323 1324 padWidth() {15 unmodified lines1340 1341 /**1342 * Return help for options.1343 *1344- * @return {String}1344+ * @return {string}1345 * @api private1346 */1347 1348 optionHelp() {13 unmodified lines1362 1363 /**1364 * Return command help documentation.1365 *1366- * @return {String}1366+ * @return {string}1367 * @api private1368 */1369 1370 commandHelp() {17 unmodified lines1388 1389 /**1390 * Return program help documentation.1391 *1392- * @return {String}1392+ * @return {string}1393 * @api public1394 */1395 1396 helpInformation() {74 unmodified lines1471 /**1472 * You can pass in flags and a description to override the help1473 * flags and help description for your command.1474 *1475- * @param {String} [flags]1476- * @param {String} [description]1475+ * @param {string} [flags]1476+ * @param {string} [description]1477 * @return {Command}1478 * @api public1479 */1480 53 unmodified lines1534 1535 /**1536 * Camel-case the given `flag`1537 *1538- * @param {String} flag1539- * @return {String}1538+ * @param {string} flag1539+ * @return {string}1540 * @api private1541 */1542 1543 function camelcase(flag) {4 unmodified lines1548 1549 /**1550 * Pad `str` to `width`.1551 *1552- * @param {String} str1553- * @param {Number} width1554- * @return {String}1552+ * @param {string} str1553+ * @param {number} width1554+ * @return {string}1555 * @api private1556 */1557 1558 function pad(str, width) {4 unmodified lines1563 /**1564 * Wraps the given string with line breaks at the specified width while breaking1565 * words and indenting every but the first line on the left.1566 *1567- * @param {String} str1568- * @param {Number} width1569- * @param {Number} indent1570- * @return {String}1567+ * @param {string} str1568+ * @param {number} width1569+ * @param {number} indent1570+ * @return {string}1571 * @api private1572 */1573 function wrap(str, width, indent) {1574 const regex = new RegExp('.{1,' + (width - 1) + '}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)', 'g');10 unmodified lines1585 * Optionally wrap the given str to a max width of width characters per line1586 * while indenting with indent spaces. Do not wrap if insufficient width or1587 * string is manually formatted.1588 *1589- * @param {String} str1590- * @param {Number} width1591- * @param {Number} indent1592- * @return {String}1589+ * @param {string} str1590+ * @param {number} width1591+ * @param {number} indent1592+ * @return {string}1593 * @api private1594 */1595 function optionalWrap(str, width, indent) {1596 // Detect manually wrapped and indented strings by searching for line breaks26 unmodified lines1623 /**1624 * Takes an argument and returns its human readable equivalent for help usage.1625 *1626 * @param {Object} arg1627- * @return {String}1627+ * @return {string}1628 * @api private1629 */1630 1631 function humanReadableArgName(arg) {53 unmodified lines