I need to figure out a way to document the below function with JSDoc.
/**
* Return the collection from cache based on the hash, page and pagination count
* @param state
* @returns {function({hash: *, page: *, pagination?: *}): ([]|*)}
*/
export const collection = (state) => ({ hash, page, pagination = 60 }) => {
if (!state.models[hash]) return []
// deep copy the object because of the collection property array
const model = JSON.parse(JSON.stringify(state.models[hash]))
const end = page * pagination
const start = end - pagination
return model.collection.splice(start, end)
}
Edit
I have fixed the error I was receiving by changing the comment above to
/**
* Return the collection from cache based on the hash, page and pagination count
* @type {object}
* @param state
* @returns {function({hash: *, page: *, pagination: *}): Array}
*/
I receive this error:
ERROR: Unable to parse a tag's type expression for source file
/app/src/store/cache/getters.js in line 9 with tag title "returns"
and text "{function({hash: *, page: *, pagination?: *}): ([]|*)}":
Invalid type expression "function({hash: *, page: *, pagination?: *}):
([]|*)": Expected "#", "$", "(", ",", "-", ".", "/", "0", ":", "<",
"=", "@", "[]", "\\", "_", "}", "~", "", "", Unicode combining mark,
Unicode decimal number, Unicode letter number, Unicode lowercase letter,
Unicode modifier letter, Unicode other letter, Unicode punctuation
connector, Unicode titlecase letter, Unicode uppercase letter, or
[1-9] but "?" found.
package.json
"devDependencies": {
...
"jsdoc": "^3.6.5",
"jsdoc-vuejs": "^3.0.9",
"jsdoc-vuex-plugin": "^1.0.0",
...
},
https://github.com/Kocal/jsdoc-vuejs
https://github.com/martiensk/vuex-jsdoc