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>}
|
* @returns {Promise<number>}
|
||||||
*/
|
*/
|
||||||
const getWallTotalPages = () =>
|
const getWallTotalPages = async () => {
|
||||||
/** @type {Promise<number>} */ (Utils.tryAndWait(
|
const totalPages = await Utils.tryAndWait(
|
||||||
(_, user) =>
|
(_, user) =>
|
||||||
user
|
user
|
||||||
.get(Key.WALL)
|
.get(Key.WALL)
|
||||||
.get(Key.NUM_OF_PAGES)
|
.get(Key.NUM_OF_PAGES)
|
||||||
.then(),
|
.then(),
|
||||||
v => typeof v !== 'number'
|
v => typeof v !== 'number'
|
||||||
)) || 0
|
)
|
||||||
|
|
||||||
|
return typeof totalPages === 'number' ? totalPages : 0
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Won't fail if given an invalid page, will return an empty set.
|
* Won't fail if given an invalid page, will return an empty set.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue