Skip to content

Instantly share code, notes, and snippets.

@codemile
Created January 2, 2025 16:51
Show Gist options
  • Save codemile/485efdcc4b7088bf42f31a610c922c44 to your computer and use it in GitHub Desktop.
Save codemile/485efdcc4b7088bf42f31a610c922c44 to your computer and use it in GitHub Desktop.
Utility function to trim a public key string to a specified size with ellipsis.
export function trimPublicKey(publicKey: string, size: number): string {
return publicKey.length <= size * 2
? publicKey
: `${publicKey.slice(0, size)}...${publicKey.slice(-size)}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment