ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

feat: improve utility of isAddress

Open zzmp opened this issue 3 years ago • 0 comments

Improves the utility of isAddress:

  • allows it to check any type (unknown), instead of restricting it to string
  • returns string | false, so that an unknown type passed in can then be narrowed to a string without coercion

This will not break usages in conditionals, as string is truthy, so string | false can still be used eg in if (isAddress(addr)). This will break usages where true/false are explicitly checked, such as isAddress(addr) === true/!== false.

zzmp avatar Aug 13 '22 00:08 zzmp