Skip to content

Commit

Permalink
annotate all return values
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Jul 23, 2024
1 parent 3104d58 commit 7bb7ce9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function parseCidr(str: Network): ParsedCidr {
}

// returns whether networks fully or partially overlap
function doNetsOverlap(a: ParsedCidr, b: ParsedCidr) {
function doNetsOverlap(a: ParsedCidr, b: ParsedCidr): boolean {
// aaa
// bbb
if (a.start > b.end) return false; // a starts after b
Expand All @@ -125,7 +125,7 @@ function doNetsOverlap(a: ParsedCidr, b: ParsedCidr) {
}

// returns whether network a fully contains network b;
function netContains(a: ParsedCidr, b: ParsedCidr) {
function netContains(a: ParsedCidr, b: ParsedCidr): boolean {
// aaa
// bbbb
if (b.start < a.start) return false; // a starts after b
Expand Down Expand Up @@ -259,7 +259,7 @@ function subparts(part: Part): Part[] {
return parts;
}

function diff(a: bigint, b: bigint) {
function diff(a: bigint, b: bigint): bigint {
a += 1n;
return a - b;
}
Expand Down Expand Up @@ -349,7 +349,7 @@ export function mergeCidr(nets: Networks): Network[] {
return [...merged[4].sort(compare), ...merged[6].sort(compare)];
}

export function excludeCidr(base: Networks, excl: Networks) {
export function excludeCidr(base: Networks, excl: Networks): Network[] {
const basenets: Network[] = mergeCidr(uniq(Array.isArray(base) ? base : [base]));
const exclnets: Network[] = mergeCidr(uniq(Array.isArray(excl) ? excl : [excl]));

Expand Down Expand Up @@ -383,7 +383,7 @@ export function excludeCidr(base: Networks, excl: Networks) {
return bases[4].concat(bases[6]).sort(compare);
}

export function expandCidr(nets: Networks) {
export function expandCidr(nets: Networks): Network[] {
const arr: Network[] = uniq(Array.isArray(nets) ? nets : [nets]);
const ips: Network[] = [];

Expand All @@ -396,7 +396,7 @@ export function expandCidr(nets: Networks) {
return ips.map(ip => normalizeCidr(ip));
}

export function overlapCidr(a: Networks, b: Networks) {
export function overlapCidr(a: Networks, b: Networks): boolean {
const aNets: Network[] = uniq(Array.isArray(a) ? a : [a]);
const bNets: Network[] = uniq(Array.isArray(b) ? b : [b]);

Expand All @@ -419,7 +419,7 @@ export function overlapCidr(a: Networks, b: Networks) {
return false;
}

export function containsCidr(a: Networks, b: Networks) {
export function containsCidr(a: Networks, b: Networks): boolean {
const aNets: Network[] = uniq(Array.isArray(a) ? a : [a]);
const bNets: Network[] = uniq(Array.isArray(b) ? b : [b]);

Expand Down

0 comments on commit 7bb7ce9

Please sign in to comment.