Skip to content

Commit 13d221e

Browse files
committed
fix: improve JSDoc
1 parent b8f50cb commit 13d221e

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- Default value for `option` parameters.
1717
- Optimizations for single responsibility principle (SRP).
18+
- Improved JSDoc.
1819

1920
## [0.2.0] - 2023-04-17
2021

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ Creates a client.
126126
| Parameter | Required? | Type | Default | Description |
127127
|:-------------------------|:----------|:--------------------|:---------------------------|:----------------------------------------------------------------------|
128128
| `options` | No | `Object` | `{}` | The options for the client. |
129-
| `options.basePath` | No | `string` | `/api` | The base path of the API. |
130-
| `options.baseUrl` | No | `string` | `window.location.pathname` | The base URL of the API. |
129+
| `options.basePath` | No | `String` | `/api` | The base path of the API. |
130+
| `options.baseUrl` | No | `String` | `window.location.pathname` | The base URL of the API. |
131131
| `options.fetchClient` | No | `Function` | `fetch` | The fetch client to use. Tested with `fetch` and `axios`. |
132-
| `options.fetchOptions` | No | `Object` | `{}` | The fetch client options. |
133-
| `options.locale` | No | `string` | `''` | The locale for every request. |
134-
| `options.onError` | No | `Function(error)` | `() => {}` | The function to call on error. |
135-
| `options.onResponse` | No | `Function(reponse)` | `(r) => r` | The function to call on response. |
136-
| `options.removeEmbedded` | No | `boolean` | `false` | Whether to remove the `_embedded` layer from the response if present. |
132+
| `options.fetchOptions` | No | `Object` | `{}` | The options for the fetch client. |
133+
| `options.locale` | No | `String` | `''` | The locale for every request. |
134+
| `options.onError` | No | `Function(Error)` | `() => {}` | The function to call on error. |
135+
| `options.onResponse` | No | `Function(Reponse)` | `(r) => r` | The function to call on response. |
136+
| `options.removeEmbedded` | No | `Boolean` | `false` | Whether to remove the `_embedded` layer from the response if present. |
137137

138138
## Instance methods
139139

@@ -145,7 +145,7 @@ Retrieves page data from the given path.
145145

146146
| Parameter | Required? | Type | Default | Description |
147147
|:----------|:----------|:---------|:--------|:----------------------------------|
148-
| `path` | Yes | `string` | - | The path of the page to retrieve. |
148+
| `path` | Yes | `String` | - | The path of the page to retrieve. |
149149

150150
#### Return value
151151

@@ -159,11 +159,11 @@ Retrieves navigation data with the given key and optional query parameters.
159159

160160
| Parameter | Required? | Type | Default | Description |
161161
|:-----------------|:----------|:----------|:--------|:-------------------------------------------|
162-
| `key` | Yes | `string` | - | The key of the navigation to retrieve. |
162+
| `key` | Yes | `String` | - | The key of the navigation to retrieve. |
163163
| `params` | No | `Object` | - | The query parameters for the request. |
164-
| `params.depth` | No | `number` | `1` | The maximum depth of the navigation. |
165-
| `params.excerpt` | No | `boolean` | `false` | Whether to include excerpt data. |
166-
| `params.flat` | No | `boolean` | `false` | Whether to return as list instead of tree. |
164+
| `params.depth` | No | `Number` | `1` | The maximum depth of the navigation. |
165+
| `params.excerpt` | No | `Boolean` | `false` | Whether to include excerpt data. |
166+
| `params.flat` | No | `Boolean` | `false` | Whether to return as list instead of tree. |
167167

168168
#### Return value
169169

@@ -177,9 +177,9 @@ Retrieves snippet data with the given area name and optional query parameters.
177177

178178
| Parameter | Required? | Type | Default | Description |
179179
|:--------------------------|:----------|:----------|:--------|:------------------------------------------|
180-
| `area` | Yes | `string` | - | The name of the snippet area to retrieve. |
180+
| `area` | Yes | `String` | - | The name of the snippet area to retrieve. |
181181
| `params` | No | `Object` | - | The query parameters for the request. |
182-
| `params.includeExtension` | No | `boolean` | `false` | Whether to include extension data. |
182+
| `params.includeExtension` | No | `Boolean` | `false` | Whether to include extension data. |
183183

184184
#### Return value
185185

@@ -193,7 +193,7 @@ Performs a search with the given query.
193193

194194
| Parameter | Required? | Type | Default | Description |
195195
|:----------|:----------|:---------|:--------|:------------------|
196-
| `query` | Yes | `string` | - | The search query. |
196+
| `query` | Yes | `String` | - | The search query. |
197197

198198
#### Return value
199199

src/client.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export default class Client {
1717
* Creates a client.
1818
*
1919
* @param {Object} [options={}] - The options for the client.
20-
* @param {string} [options.baseUrl='/api'] - The base path of the API.
21-
* @param {string} [options.baseUrl=window.location.origin] - The base URL of the API.
22-
* @param {function} [options.fetchClient=fetch.bind(window)] - The fetch client to use.
23-
* @param {Object} [options.fetchOptions={}] - The fetch client options.
24-
* @param {string} [options.locale=''] - The locale for every request.
25-
* @param {function} [options.onError=() => {}] - The function to call on error.
26-
* @param {function} [options.onResponse=(r) => r] - The function to call on response.
27-
* @param {boolean} [options.removeEmbedded=false] - Whether to remove the _embedded layer from the response if present.
20+
* @param {String} [options.baseUrl='/api'] - The base path of the API.
21+
* @param {String} [options.baseUrl=window.location.origin] - The base URL of the API.
22+
* @param {Function} [options.fetchClient=fetch.bind(window)] - The fetch client to use.
23+
* @param {Object} [options.fetchOptions={}] - The options for the fetch client.
24+
* @param {String} [options.locale=''] - The locale for every request.
25+
* @param {Function} [options.onError=() => {}] - The function to call on error.
26+
* @param {Function} [options.onResponse=(r) => r] - The function to call on response.
27+
* @param {Boolean} [options.removeEmbedded=false] - Whether to remove the _embedded layer from the response if present.
2828
*/
2929
constructor({
3030
basePath = '/api',
@@ -49,11 +49,11 @@ export default class Client {
4949
/**
5050
* Builds a URL with the given path and optional query parameters.
5151
*
52-
* @param {string} path - The path for the URL.
52+
* @param {String} path - The path for the URL.
5353
* @param {Object} [options={}] - The options for building the URL.
5454
* @param {Object} [options.params={}] - The query parameters for the URL.
55-
* @param {boolean} [options.withBasePath=true] - Whether to apply the base path.
56-
* @param {boolean} [options.withLocale=true] - Whether to prepend locale to path.
55+
* @param {Boolean} [options.withBasePath=true] - Whether to apply the base path.
56+
* @param {Boolean} [options.withLocale=true] - Whether to prepend locale to path.
5757
* @returns {URL} The built URL.
5858
*/
5959
buildUrl(
@@ -115,7 +115,7 @@ export default class Client {
115115
/**
116116
* Retrieves page data from the given path.
117117
*
118-
* @param {string} path - The path of the page to retrieve.
118+
* @param {String} path - The path of the page to retrieve.
119119
* @returns {Promise<Object>} A Promise that resolves to the page data.
120120
*/
121121
getPageByPath(path) {
@@ -130,7 +130,7 @@ export default class Client {
130130
/**
131131
* Retrieves navigation data with the given key and optional query parameters.
132132
*
133-
* @param {string} key - The key of the navigation to retrieve.
133+
* @param {String} key - The key of the navigation to retrieve.
134134
* @param {Object} [params] - The query parameters for the request.
135135
* @returns {Promise<Object>} A Promise that resolves to the navigation data.
136136
*/
@@ -145,7 +145,7 @@ export default class Client {
145145
/**
146146
* Retrieves snippet data with the given area name and optional query parameters.
147147
*
148-
* @param {string} area - The name of the snippet area to retrieve.
148+
* @param {String} area - The name of the snippet area to retrieve.
149149
* @param {Object} [params] - The query parameters for the request.
150150
* @returns {Promise<Object>} A Promise that resolves to the snippet area data.
151151
*/
@@ -160,7 +160,7 @@ export default class Client {
160160
/**
161161
* Performs a search with the given query.
162162
*
163-
* @param {string} query - The search query.
163+
* @param {String} query - The search query.
164164
* @returns {Promise<Object>} A Promise that resolves to the search results.
165165
*/
166166
search(query) {

0 commit comments

Comments
 (0)