Skip to content

Commit

Permalink
PKG -- [util-address] Add JSDoc to util address (#1494)
Browse files Browse the repository at this point in the history
* PKG --  [util-address] Add JSDoc to util address

* PKG -- [util-address] Create changeset

Co-authored-by: Chase Fleming <1666730+chasefleming@users.noreply.github.com>
  • Loading branch information
chasefleming and chasefleming authored Nov 18, 2022
1 parent d09b4b8 commit 5bec557
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/seven-rules-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/util-address": minor
---

Add JSDoc to util-address package.
17 changes: 16 additions & 1 deletion packages/util-address/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
export function sansPrefix(address) {
/**
* Removes 0x from address if present
* @param {string} address
* @returns {string}
*/
export function sansPrefix(address) {
if (address == null) return null
return address.replace(/^0x/, "").replace(/^Fx/, "")
}

/**
* Adds 0x to address if not already present
* @param {string} address
* @returns {string}
*/
export function withPrefix(address) {
if (address == null) return null
return "0x" + sansPrefix(address)
}

/**
* Adds 0x to address if not already present
* @param {string} address
* @returns {string}
*/
export function display(address) {
return withPrefix(address)
}

0 comments on commit 5bec557

Please sign in to comment.