Skip to content

Commit 36b65b8

Browse files
committed
minor refactor
1 parent 060eb30 commit 36b65b8

File tree

5 files changed

+39
-77
lines changed

5 files changed

+39
-77
lines changed

bin/cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import commandLineArgs from 'command-line-args'
33
import commandLineUsage from 'command-line-usage'
44
import jsdoc2md from 'jsdoc-to-markdown'
5-
import omit from 'lodash.omit'
65
import assert from 'assert'
76
import fs from 'fs'
87
import loadConfig from 'config-master'
@@ -33,7 +32,8 @@ if (options.help) {
3332

3433
/* jsdoc2md --config */
3534
if (options.config) {
36-
console.log(JSON.stringify(omit(options, 'config'), null, ' '))
35+
delete options.config
36+
console.log(JSON.stringify(options, null, ' '))
3737
process.exit(0)
3838
}
3939

dist/index.cjs

+16-19
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ class JsdocToMarkdown {
111111
* @returns {Promise}
112112
* @category async
113113
*/
114-
clear () {
115-
return jsdocApi.cache.clear().then(() => dmd.cache.clear())
114+
async clear () {
115+
await jsdocApi.cache.clear();
116+
await dmd.cache.clear();
116117
}
117118

118119
/**
@@ -121,23 +122,19 @@ class JsdocToMarkdown {
121122
* @returns {object}
122123
* @category async
123124
*/
124-
getNamepaths (options) {
125-
return this.getTemplateData(options)
126-
.then(data => {
127-
const namepaths = {};
128-
const kinds = [
129-
'module', 'class', 'constructor', 'mixin', 'member',
130-
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
131-
];
132-
kinds.forEach(kind => {
133-
namepaths[kind] = data
134-
.filter(identifier => {
135-
return identifier.kind === kind
136-
})
137-
.map(identifier => identifier.longname);
138-
});
139-
return namepaths
140-
})
125+
async getNamepaths (options) {
126+
const data = await this.getTemplateData(options);
127+
const namepaths = {};
128+
const kinds = [
129+
'module', 'class', 'constructor', 'mixin', 'member',
130+
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
131+
];
132+
for (const kind of kinds) {
133+
namepaths[kind] = data
134+
.filter(identifier => identifier.kind === kind)
135+
.map(identifier => identifier.longname);
136+
}
137+
return namepaths
141138
}
142139
}
143140

index.js

+16-19
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ class JsdocToMarkdown {
9090
* @returns {Promise}
9191
* @category async
9292
*/
93-
clear () {
94-
return jsdocApi.cache.clear().then(() => dmd.cache.clear())
93+
async clear () {
94+
await jsdocApi.cache.clear()
95+
await dmd.cache.clear()
9596
}
9697

9798
/**
@@ -100,23 +101,19 @@ class JsdocToMarkdown {
100101
* @returns {object}
101102
* @category async
102103
*/
103-
getNamepaths (options) {
104-
return this.getTemplateData(options)
105-
.then(data => {
106-
const namepaths = {}
107-
const kinds = [
108-
'module', 'class', 'constructor', 'mixin', 'member',
109-
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
110-
]
111-
kinds.forEach(kind => {
112-
namepaths[kind] = data
113-
.filter(identifier => {
114-
return identifier.kind === kind
115-
})
116-
.map(identifier => identifier.longname)
117-
})
118-
return namepaths
119-
})
104+
async getNamepaths (options) {
105+
const data = await this.getTemplateData(options)
106+
const namepaths = {}
107+
const kinds = [
108+
'module', 'class', 'constructor', 'mixin', 'member',
109+
'namespace', 'constant', 'function', 'event', 'typedef', 'external'
110+
]
111+
for (const kind of kinds) {
112+
namepaths[kind] = data
113+
.filter(identifier => identifier.kind === kind)
114+
.map(identifier => identifier.longname)
115+
}
116+
return namepaths
120117
}
121118
}
122119

package-lock.json

+4-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"command-line-args": "^6.0.0",
4040
"command-line-usage": "^7.0.3",
4141
"config-master": "^3.1.0",
42-
"dmd": "next",
42+
"dmd": "^7.0.0",
4343
"jsdoc-api": "^9.3.0",
4444
"jsdoc-parse": "^6.2.3",
4545
"walk-back": "^5.1.1"

0 commit comments

Comments
 (0)