Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd committed Jan 27, 2024
1 parent 10a0854 commit d23c58f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client/class/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export function get_fetcher (
// Initialize the options object.
if (token !== undefined) {
init.headers = {
...init.headers,
'Authorization' :'Token ' + token
...init.headers,
'Authorization' :'Bearer ' + token
}
}
// Run the fetcher method.
Expand Down
19 changes: 19 additions & 0 deletions src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ export function is_literal (value : unknown) : value is Literal {
return false
}

export function is_uint (
value : unknown,
max_val = Number.MAX_SAFE_INTEGER
) : value is Number {
if (typeof value === 'string') {
value = Number(value)
}
if (typeof value !== 'number') {
return false
}
return (
typeof value === 'number' &&
!isNaN(value) &&
value >= 0 &&
value <= max_val &&
Math.floor(value) === value
)
}

export function now () {
return Math.floor(Date.now() / 1000)
}
Expand Down

0 comments on commit d23c58f

Please sign in to comment.