1- import { assertUint8 , assertEmptyRest } from './assert.js'
1+ import { assertEmptyRest } from './assert.js'
22import { typedView } from './array.js'
3- import { E_STRING } from './fallback/_utils.js'
3+ import { assertU8 , E_STRING } from './fallback/_utils.js'
44import { isHermes } from './fallback/platform.js'
55import { decodeLatin1 , encodeLatin1 } from './fallback/latin1.js'
66import * as js from './fallback/base64.js'
@@ -38,7 +38,7 @@ const toUrl = (x) => x.replaceAll('+', '-').replaceAll('/', '_')
3838const haveWeb = ( x ) => web64 && x . toBase64 === web64
3939
4040export function toBase64 ( x , { padding = true } = { } ) {
41- assertUint8 ( x )
41+ assertU8 ( x )
4242 if ( haveWeb ( x ) ) return padding ? x . toBase64 ( ) : x . toBase64 ( { omitPadding : ! padding } ) // Modern, optionless is slightly faster
4343 if ( haveNativeBuffer ) return maybeUnpad ( toBuffer ( x ) . base64Slice ( 0 , x . byteLength ) , padding ) // Older Node.js
4444 if ( shouldUseBtoa ) return maybeUnpad ( btoa ( decodeLatin1 ( x ) ) , padding )
@@ -47,7 +47,7 @@ export function toBase64(x, { padding = true } = {}) {
4747
4848// NOTE: base64url omits padding by default
4949export function toBase64url ( x , { padding = false } = { } ) {
50- assertUint8 ( x )
50+ assertU8 ( x )
5151 if ( haveWeb ( x ) ) return x . toBase64 ( { alphabet : 'base64url' , omitPadding : ! padding } ) // Modern
5252 if ( haveNativeBuffer ) return maybePad ( toBuffer ( x ) . base64urlSlice ( 0 , x . byteLength ) , padding ) // Older Node.js
5353 if ( shouldUseBtoa ) return maybeUnpad ( toUrl ( btoa ( decodeLatin1 ( x ) ) ) , padding )
0 commit comments