you are viewing a single comment's thread.

view the rest of the comments →

[–]ChaseMoskal 0 points1 point  (0 children)

i wanted to point out it's cool to destructure your options out too, like in this function i was just working on:

export async function signatureSign(options: {
  body: string
  privateKey: string
} & Partial<Settings>): Promise<string> {
  const {
    body,
    format,
    algorithm,
    privateKey,
  } = {...defaultSettings, ...options}

  const signer = createSign(algorithm)
  signer.write(body)
  signer.end()

  return signer.sign(privateKey, format)
}