File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ export const value = (code: number, value?: string): Matcher => {
4444 }
4545}
4646
47+ /**
48+ * An optional matcher
49+ */
4750export 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+ */
6167export 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+ */
8998export 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+ */
109121export function fmt ( ...matchers : Matcher [ ] ) : MultiaddrMatcher {
110122 function match ( ma : Multiaddr ) : Component [ ] | false {
111123 let parts = ma . getComponents ( )
You can’t perform that action at this time.
0 commit comments