From 4e84e0f4ff4a553bce13fb8ce6f3a97240ef1bc2 Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Wed, 20 Dec 2023 15:44:58 +0100 Subject: [PATCH] refactor: remove unsued code This was only used in namespace logic and is no longer required --- src/types/ip-address.ts | 15 --------------- test/test-ip-address.ts | 28 ---------------------------- 2 files changed, 43 deletions(-) delete mode 100644 src/types/ip-address.ts delete mode 100644 test/test-ip-address.ts diff --git a/src/types/ip-address.ts b/src/types/ip-address.ts deleted file mode 100644 index 5a9de148..00000000 --- a/src/types/ip-address.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Brand } from "ts-brand"; -import net from "node:net"; - -/** - * A string that is either a valid v4 or v6 ip-address - */ -export type IpAddress = Brand; - -/** - * Checks if a string is valid {@link IpAddress} - * @param s The string - */ -export function isIpAddress(s: string): s is IpAddress { - return net.isIPv4(s) || net.isIPv6(s); -} diff --git a/test/test-ip-address.ts b/test/test-ip-address.ts deleted file mode 100644 index 49e28d4b..00000000 --- a/test/test-ip-address.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { describe } from "mocha"; -import { isIpAddress } from "../src/types/ip-address"; -import should from "should"; - -describe("ip-address", function () { - describe("validate", function () { - [ - "10.20.30.40", - "64.233.160.0", - "2001:0db8:85a3:0000:0000:8a2e:0370:7334", - ].forEach((s) => - it(`"${s}" should be ip-address`, () => should(isIpAddress(s)).be.true()) - ); - - [ - "", - " ", - "hello", - // Missing 4th segment - "64.233.160", - // Deleted some colons - "2001:0db8:85a30000:0000:8a2e0370:7334", - ].forEach((s) => - it(`"${s}" should not be ip-address`, () => - should(isIpAddress(s)).be.false()) - ); - }); -});