Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typings #42

Open
matthieusieben opened this issue Jun 7, 2023 · 0 comments
Open

Add typings #42

matthieusieben opened this issue Jun 7, 2023 · 0 comments
Labels
feature New functionality or improvement

Comments

@matthieusieben
Copy link

I am currently using the following to type @hapi/b64. It would be nice if this module exported its own types. I d'ont have the time or resources to make a PR. Sorry about that.

declare module '@hapi/b64' {
  import { Transform } from 'node:stream'

  export class Decoder extends Transform {
    constructor()
  }
  export class Encoder extends Transform {
    constructor()
  }

  /**
   * @param buffer - A buffer containing the base64 encoded string
   * @returns A buffer containing the decoded bytes
   */
  export function decode(buffer: Buffer): Buffer

  /**
   * @params buffer - Buffer of bytes to encode
   * @returns A buffer containing a base64 encoded string
   */
  export function encode(buffer: Buffer): Buffer

  /**
   * Base64url (RFC 4648) encode
   */
  export function base64urlEncode(value: string | Buffer, encoding?: BufferEncoding): string

  /**
   * Base64url (RFC 4648) decode
   * @param encoding - defaults to 'binary'
   */
  export function base64urlDecode(value: string, encoding: 'buffer'): Buffer
  export function base64urlDecode(value: string, encoding?: BufferEncoding): string
}
@matthieusieben matthieusieben added the feature New functionality or improvement label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

1 participant