Skip to content

Commit 38774d3

Browse files
committed
chore: add docs
1 parent 27c27e4 commit 38774d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export const value = (code: number, value?: string): Matcher => {
4444
}
4545
}
4646

47+
/**
48+
* An optional matcher
49+
*/
4750
export const optional = (matcher: Matcher): Matcher => {
4851
return {
4952
match: (vals) => {
@@ -58,6 +61,9 @@ export const optional = (matcher: Matcher): Matcher => {
5861
}
5962
}
6063

64+
/**
65+
* Matches any one of the passed matches
66+
*/
6167
export const or = (...matchers: Matcher[]): Matcher => {
6268
return {
6369
match: (vals) => {
@@ -86,6 +92,9 @@ export const or = (...matchers: Matcher[]): Matcher => {
8692
}
8793
}
8894

95+
/**
96+
* Matches all of the passed matchers
97+
*/
8998
export const and = (...matchers: Matcher[]): Matcher => {
9099
return {
91100
match: (vals) => {
@@ -106,6 +115,9 @@ export const and = (...matchers: Matcher[]): Matcher => {
106115
}
107116
}
108117

118+
/**
119+
* Create a multiaddr matcher from the passed component matchers
120+
*/
109121
export function fmt (...matchers: Matcher[]): MultiaddrMatcher {
110122
function match (ma: Multiaddr): Component[] | false {
111123
let parts = ma.getComponents()

0 commit comments

Comments
 (0)