Skip to content

Commit 12c7e19

Browse files
docs(targets) add jsdocs/typedefs
1 parent 8c1297e commit 12c7e19

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

packages/@httpsnippet/httpsnippet/targets.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
const clients = require('./clients')
44

5+
/**
6+
* @typedef {Object} ClientInfo
7+
* @prop {string} key - e.g. "curl"
8+
* @prop {string} title - e.g. "cURL"
9+
* @prop {string} link - href linking to client website.
10+
* @prop {string} description
11+
* @prop {string} target - {Target}.key
12+
*/
13+
14+
/**
15+
* @typedef {Object} Client
16+
* @prop {Function} - code building function
17+
* @prop {ClientInfo} info - info about client
18+
*/
19+
20+
/**
21+
* @typedef {Object} Target
22+
* @prop {string} key - e.g. "javascript"
23+
* @prop {string} title - e.g. "Javascript"
24+
* @prop {string} extname - extension name, e.g. .js, .sh, .py
25+
* @prop {string} default - default {Client}.info.key
26+
* @prop {Array<Client>} clients
27+
*/
28+
529
module.exports = (function () {
630
const baseTargets = {
731
shell: { key: 'shell', title: 'Shell', extname: '.sh', default: 'curl' },
@@ -57,6 +81,10 @@ module.exports = (function () {
5781
match
5882
}
5983

84+
/**
85+
* Includes client files with their code building functions + infos
86+
* @returns {Object.<string, { clients: Object.<string, Client>, key, title, extname,default }>}
87+
*/
6088
function all () {
6189
const targets = Object.keys(clients).reduce((acc, client) => {
6290
const info = clients[client] && clients[client].info
@@ -83,6 +111,9 @@ module.exports = (function () {
83111
})
84112
}
85113

114+
/**
115+
* @returns {Array<Target>}
116+
*/
86117
function available () {
87118
return all().map(target => {
88119
return {

0 commit comments

Comments
 (0)