-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PKG -- [util-address] Add JSDoc to util address (#1494)
* 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
1 parent
d09b4b8
commit 5bec557
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@onflow/util-address": minor | ||
--- | ||
|
||
Add JSDoc to util-address package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |