mirror of
https://github.com/fluencelabs/js-mafmt
synced 2025-04-25 17:42:27 +00:00
feat: add support for recursive addresses
This commit is contained in:
parent
c0d2d051b9
commit
2e28d27740
16
src/index.js
16
src/index.js
@ -62,15 +62,24 @@ let _IPFS = or(
|
||||
base('ipfs')
|
||||
)
|
||||
|
||||
const Circuit = or(
|
||||
const _Circuit = or(
|
||||
and(_IPFS, base('p2p-circuit'), _IPFS),
|
||||
and(_IPFS, base('p2p-circuit')),
|
||||
and(base('p2p-circuit'), _IPFS),
|
||||
and(Reliable, base('p2p-circuit')),
|
||||
and(base('p2p-circuit'), Reliable),
|
||||
base('p2p-circuit')
|
||||
)
|
||||
|
||||
const CircuitRecursive = () => or(
|
||||
and(_Circuit, CircuitRecursive),
|
||||
_Circuit
|
||||
)
|
||||
|
||||
const Circuit = CircuitRecursive()
|
||||
|
||||
const IPFS = or(
|
||||
and(Circuit, _IPFS, Circuit),
|
||||
and(_IPFS, Circuit),
|
||||
and(Circuit, _IPFS),
|
||||
Circuit,
|
||||
@ -116,7 +125,7 @@ function and () {
|
||||
return null
|
||||
}
|
||||
args.some(function (arg) {
|
||||
a = arg.partialMatch(a)
|
||||
a = typeof arg === 'function' ? arg().partialMatch(a) : arg.partialMatch(a)
|
||||
if (a === null) {
|
||||
return true
|
||||
}
|
||||
@ -149,7 +158,7 @@ function or () {
|
||||
function partialMatch (a) {
|
||||
let out = null
|
||||
args.some(function (arg) {
|
||||
const res = arg.partialMatch(a)
|
||||
const res = typeof arg === 'function' ? arg().partialMatch(a) : arg.partialMatch(a)
|
||||
if (res) {
|
||||
out = res
|
||||
return true
|
||||
@ -171,6 +180,7 @@ function or () {
|
||||
|
||||
function base (n) {
|
||||
const name = n
|
||||
|
||||
function matches (a) {
|
||||
if (typeof a === 'string') {
|
||||
a = multiaddr(a)
|
||||
|
Loading…
x
Reference in New Issue
Block a user