Skip to content

Commit 577e6b3

Browse files
committed
chore: linting and deps
1 parent a6f48f4 commit 577e6b3

File tree

4 files changed

+11
-31
lines changed

4 files changed

+11
-31
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@
162162
"docs": "aegir docs"
163163
},
164164
"dependencies": {
165-
"@chainsafe/is-ip": "^2.0.1",
166-
"@multiformats/multiaddr": "^12.0.0",
167-
"multiformats": "^13.0.0"
165+
"@multiformats/multiaddr": "^12.0.0"
168166
},
169167
"devDependencies": {
170168
"aegir": "^47.0.19"

src/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
* ```
3333
*/
3434

35-
import { isIPv4, isIPv6 } from '@chainsafe/is-ip'
36-
import { and, or, optional, fmt, func, code, value } from './utils.js'
37-
import { type Multiaddr, type Component, CODE_P2P, CODE_DNS4, CODE_DNS6, CODE_DNSADDR, CODE_DNS, CODE_IP4, CODE_IP6, CODE_TCP, CODE_UDP, CODE_QUIC, CODE_QUIC_V1, CODE_WS, CODE_WSS, CODE_TLS, CODE_SNI, CODE_WEBRTC_DIRECT, CODE_CERTHASH, CODE_WEBTRANSPORT, CODE_P2P_CIRCUIT, CODE_WEBRTC, CODE_HTTP, CODE_UNIX, CODE_HTTPS, CODE_MEMORY } from '@multiformats/multiaddr'
35+
import { CODE_P2P, CODE_DNS4, CODE_DNS6, CODE_DNSADDR, CODE_DNS, CODE_IP4, CODE_IP6, CODE_TCP, CODE_UDP, CODE_QUIC, CODE_QUIC_V1, CODE_WS, CODE_WSS, CODE_TLS, CODE_SNI, CODE_WEBRTC_DIRECT, CODE_CERTHASH, CODE_WEBTRANSPORT, CODE_P2P_CIRCUIT, CODE_WEBRTC, CODE_HTTP, CODE_UNIX, CODE_HTTPS, CODE_MEMORY } from '@multiformats/multiaddr'
36+
import { and, or, optional, fmt, code, value } from './utils.js'
37+
import type { Multiaddr, Component } from '@multiformats/multiaddr'
3838

3939
/**
4040
* A matcher accepts multiaddr components and either fails to match and returns
@@ -291,13 +291,12 @@ export const QUIC = fmt(_QUIC)
291291
*
292292
* ```ts
293293
* import { multiaddr } from '@multiformats/multiaddr'
294-
* import { QUICV1 } from '@multiformats/multiaddr-matcher'
294+
* import { QUIC_V1 } from '@multiformats/multiaddr-matcher'
295295
*
296-
* QUICV1.matches(multiaddr('/ip4/123.123.123.123/udp/1234/quic-v1')) // true
296+
* QUIC_V1.matches(multiaddr('/ip4/123.123.123.123/udp/1234/quic-v1')) // true
297297
* ```
298298
*/
299299
export const QUIC_V1 = fmt(_QUIC_V1)
300-
export const QUICV1 = QUIC_V1
301300

302301
const _WEB = or(
303302
_IP_OR_DOMAIN,
@@ -464,7 +463,7 @@ const _HTTPS = and(_IP_OR_DOMAIN, or(
464463
code(CODE_TLS),
465464
code(CODE_HTTPS)
466465
),
467-
optional(value(CODE_P2P))
466+
optional(value(CODE_P2P))
468467
)
469468

470469
/**

src/utils.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
import type { Matcher, MultiaddrMatcher } from './index.js'
2-
import { type Multiaddr, type Component, CODE_P2P, CODE_CERTHASH } from '@multiformats/multiaddr'
3-
4-
export const func = (fn: (val: Component) => boolean): Matcher => {
5-
return {
6-
match: (vals) => {
7-
if (vals.length < 1) {
8-
return false
9-
}
10-
11-
if (fn(vals[0])) {
12-
return vals.slice(1)
13-
}
14-
15-
return false
16-
},
17-
pattern: 'fn'
18-
}
19-
}
2+
import type { Multiaddr, Component } from '@multiformats/multiaddr'
203

214
export const code = (code: number): Matcher => {
225
return {

test/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ describe('multiaddr matcher', () => {
440440
})
441441

442442
it('QUICv1 addresses', () => {
443-
assertMatches(mafmt.QUICV1, goodQUICv1)
444-
assertExactMatches(mafmt.QUICV1, exactQUICv1)
445-
assertMismatches(mafmt.QUICV1, badQUICv1)
443+
assertMatches(mafmt.QUIC_V1, goodQUICv1)
444+
assertExactMatches(mafmt.QUIC_V1, exactQUICv1)
445+
assertMismatches(mafmt.QUIC_V1, badQUICv1)
446446
})
447447

448448
it('WebSockets addresses', () => {

0 commit comments

Comments
 (0)