MCPcopy
hub / github.com/tinyhttp/tinyhttp / compile

Function compile

packages/proxy-addr/src/index.ts:46–63  ·  view source on GitHub ↗

* Compile argument into trust function. * * @param val

(val: string | string[] | number[])

Source from the content-addressed store, hash-verified

44 * @param val
45 */
46function compile(val: string | string[] | number[]) {
47 let trust
48 if (typeof val === 'string') trust = [val]
49 else if (Array.isArray(val)) trust = val.slice()
50 else throw new TypeError('unsupported trust argument')
51
52 for (let i = 0; i < trust.length; i++) {
53 val = trust[i]
54 if (!Object.prototype.hasOwnProperty.call(IP_RANGES, val)) continue
55
56 // Splice in pre-defined range
57 val = IP_RANGES[val as string]
58 // eslint-disable-next-line prefer-spread
59 trust.splice.apply(trust, [i, 1].concat(val as number[]))
60 i += val.length - 1
61 }
62 return compileTrust(compileRangeSubnets(trust))
63}
64/**
65 * Compile `arr` elements into range subnets.
66 */

Callers 2

trustRemoteAddressFunction · 0.90
alladdrsFunction · 0.85

Calls 2

compileTrustFunction · 0.85
compileRangeSubnetsFunction · 0.85

Tested by

no test coverage detected