Skip to content

Commit

Permalink
✨feature: add custom tag @case to create a runnable environment
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonandjay committed Nov 2, 2023
1 parent 6463bbc commit caea960
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ npm-debug.log
test/*.js
test/integration/*.js
!test/ts-node-register.js
docs
100 changes: 96 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"bech32": "^2.0.0",
"bip174": "^2.1.1",
"bs58check": "^3.0.1",
"typedoc-plugin-bitcoinjs-runcase": "^1.0.1",
"typeforce": "^1.11.3",
"varuint-bitcoin": "^1.1.2"
},
Expand Down
17 changes: 5 additions & 12 deletions ts_src/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,12 @@ function _toFutureSegwitAddress(output: Buffer, network: Network): string {

/**
* decode address with base58 specification, return address version and address hash if valid
* @example
* @case
* ```ts
* // valid case
* fromBase58Check('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')
* // => {version: 0, hash: <Buffer 75 1e 76 e8 19 91 96 d4 54 94 1c 45 d1 b3 a3 23 f1 43 3b d6>}
*
* // invalid case: address is too short
* fromBase58Check('7SeEnXWPaCCALbVrTnszCVGfRU8cGfx')
* // => throw new TypeError('7SeEnXWPaCCALbVrTnszCVGfRU8cGfx is too short')
*
* // invalid case: address is too long
* fromBase58Check('j9ywUkWg2fTQrouxxh5rSZhRvrjMkEUfuiKe')
* // => throw new TypeError('j9ywUkWg2fTQrouxxh5rSZhRvrjMkEUfuiKe is too long')
* // You can test it here and find more case in test/address.spec.ts
* const result = address.fromBase58Check('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')
* console.log(JSON.stringify(result))
* // => {"version":0,"hash":{"type":"Buffer","data":[117,30,118,232,25,145,150,212,84,148,28,69,209,179,163,35,241,67,59,214]}}
* ```
*/
export function fromBase58Check(address: string): Base58CheckResult {
Expand Down
1 change: 1 addition & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"searchGroupBoosts": {
"Classes": 1.5
},
"plugin": ["typedoc-plugin-bitcoinjs-runcase"],
"visibilityFilters": {},
"hideGenerator": true,
"excludePrivate": true,
Expand Down

0 comments on commit caea960

Please sign in to comment.