Skip to content

Commit caea960

Browse files
committed
✨feature: add custom tag @case to create a runnable environment
1 parent 6463bbc commit caea960

File tree

5 files changed

+104
-16
lines changed

5 files changed

+104
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ npm-debug.log
55
test/*.js
66
test/integration/*.js
77
!test/ts-node-register.js
8+
docs

package-lock.json

Lines changed: 96 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"bech32": "^2.0.0",
5555
"bip174": "^2.1.1",
5656
"bs58check": "^3.0.1",
57+
"typedoc-plugin-bitcoinjs-runcase": "^1.0.1",
5758
"typeforce": "^1.11.3",
5859
"varuint-bitcoin": "^1.1.2"
5960
},

ts_src/address.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,12 @@ function _toFutureSegwitAddress(output: Buffer, network: Network): string {
7171

7272
/**
7373
* decode address with base58 specification, return address version and address hash if valid
74-
* @example
74+
* @case
7575
* ```ts
76-
* // valid case
77-
* fromBase58Check('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')
78-
* // => {version: 0, hash: <Buffer 75 1e 76 e8 19 91 96 d4 54 94 1c 45 d1 b3 a3 23 f1 43 3b d6>}
79-
*
80-
* // invalid case: address is too short
81-
* fromBase58Check('7SeEnXWPaCCALbVrTnszCVGfRU8cGfx')
82-
* // => throw new TypeError('7SeEnXWPaCCALbVrTnszCVGfRU8cGfx is too short')
83-
*
84-
* // invalid case: address is too long
85-
* fromBase58Check('j9ywUkWg2fTQrouxxh5rSZhRvrjMkEUfuiKe')
86-
* // => throw new TypeError('j9ywUkWg2fTQrouxxh5rSZhRvrjMkEUfuiKe is too long')
76+
* // You can test it here and find more case in test/address.spec.ts
77+
* const result = address.fromBase58Check('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')
78+
* console.log(JSON.stringify(result))
79+
* // => {"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]}}
8780
* ```
8881
*/
8982
export function fromBase58Check(address: string): Base58CheckResult {

typedoc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"searchGroupBoosts": {
1111
"Classes": 1.5
1212
},
13+
"plugin": ["typedoc-plugin-bitcoinjs-runcase"],
1314
"visibilityFilters": {},
1415
"hideGenerator": true,
1516
"excludePrivate": true,

0 commit comments

Comments
 (0)