Add log
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import {Result} from 'result'
|
||||
import logger from 'log'
|
||||
|
||||
const log = logger('misc')
|
||||
|
||||
export function a2str(buf: Uint8Array) : string {
|
||||
// @ts-ignore
|
||||
@@ -18,9 +21,14 @@ export function a2b64(buf: Uint8Array) : string {
|
||||
return btoa(a2str(buf))
|
||||
}
|
||||
export function b642a(b64: string) : Result<Uint8Array> {
|
||||
log.trace('b642a')
|
||||
|
||||
try {
|
||||
return Result.ok(str2a(atob(b64)))
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
log.warn('b64 decode failed')
|
||||
log.debug(`error : ${e}`)
|
||||
}
|
||||
|
||||
return Result.error([])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user