always return a number
This commit is contained in:
parent
d139a6a052
commit
4a80fe5caf
1 changed files with 6 additions and 3 deletions
|
|
@ -8,15 +8,18 @@ const Key = require('../key')
|
|||
/**
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
const getWallTotalPages = () =>
|
||||
/** @type {Promise<number>} */ (Utils.tryAndWait(
|
||||
const getWallTotalPages = async () => {
|
||||
const totalPages = await Utils.tryAndWait(
|
||||
(_, user) =>
|
||||
user
|
||||
.get(Key.WALL)
|
||||
.get(Key.NUM_OF_PAGES)
|
||||
.then(),
|
||||
v => typeof v !== 'number'
|
||||
)) || 0
|
||||
)
|
||||
|
||||
return typeof totalPages === 'number' ? totalPages : 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Won't fail if given an invalid page, will return an empty set.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue