Skip to content

Commit

Permalink
new TS compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jin committed Dec 16, 2024
1 parent 0bdc5ea commit ed47352
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion base64/decode/decode.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace $ {
export function $mol_base64_decode_node(base64Str: string): Uint8Array {
export function $mol_base64_decode_node(base64Str: string): Uint8Array< ArrayBuffer > {

base64Str = base64Str.replace( /-/g, '+' ).replace( /_/g, '/' )

Expand Down
2 changes: 1 addition & 1 deletion base64/decode/decode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace $ {
export function $mol_base64_decode(base64: string): Uint8Array {
export function $mol_base64_decode(base64: string): Uint8Array< ArrayBuffer > {
throw new Error('Not implemented')
}
}
2 changes: 1 addition & 1 deletion base64/decode/decode.web.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace $ {

export function $mol_base64_decode_web(base64Str: string): Uint8Array {
export function $mol_base64_decode_web(base64Str: string): Uint8Array< ArrayBuffer > {
return new Uint8Array($mol_dom_context.atob(base64Str).split('').map(c => c.charCodeAt(0)))
}

Expand Down
4 changes: 2 additions & 2 deletions buffer/buffer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace $ {
export class $mol_buffer extends DataView {
export class $mol_buffer extends DataView< ArrayBuffer > {

static from<
This extends typeof $mol_buffer
>(
this: This,
array: number | string | ArrayBufferView,
array: number | string | ArrayBufferView< ArrayBuffer >,
) {
if( typeof array === 'number' ) array = new Uint8Array( array )
if( typeof array === 'string' ) array = $mol_base64_ae_decode( array )
Expand Down
4 changes: 2 additions & 2 deletions crypto/key/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ namespace $ {

export class $mol_crypto_key extends $mol_buffer {

static from< This extends typeof $mol_crypto_key >( this: This, serial: number | string | ArrayBufferView ) {
static from< This extends typeof $mol_crypto_key >( this: This, serial: number | string | ArrayBufferView< ArrayBuffer > ) {

if( typeof serial === 'string' ) {
serial = new Uint8Array([
... $mol_base64_url_decode( serial.slice( 0, 43 ) ),
... $mol_base64_url_decode( serial.slice( 43, 86 ) ),
... $mol_base64_url_decode( serial.slice( 86, 129 ) ),
])
]) as Uint8Array< ArrayBuffer >
}

return super.from( serial ) as InstanceType< This >
Expand Down

0 comments on commit ed47352

Please sign in to comment.