diff --git a/types/ip-subnet-calculator/index.d.ts b/types/ip-subnet-calculator/index.d.ts new file mode 100644 index 0000000000..e3158233b3 --- /dev/null +++ b/types/ip-subnet-calculator/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for ip-subnet-calculator 1.1 +// Project: https://github.com/franksrevenge/IPSubnetCalculator +// Definitions by: dahool +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace IpSubnetCalculator; + +export function calculate(ipStart: string|number, ipEnd: string|number): SubnetResult[]; +export function calculateSubnetMask(ip: string|number, prefixSize: number): SubnetResult; +export function calculateCIDRPrefix(ip: string|number, subnetMask: string|number): SubnetResult; + +export function isIp(ipStr: string): boolean; +export function isDecimalIp(ipNum: number): boolean; + +export function toDecimal(ip: string|number): number; +export function toString(num: string|number): string; + +export interface SubnetResult { + ipLow: number; + ipLowStr: string; + ipHigh: number; + ipHighStr: string; + prefixMask: number; + prefixMaskStr: string; + prefixSize: number; + invertedMask: number; + invertedMaskStr: string; + invertedSize: number; +} diff --git a/types/ip-subnet-calculator/ip-subnet-calculator-tests.ts b/types/ip-subnet-calculator/ip-subnet-calculator-tests.ts new file mode 100644 index 0000000000..6f3229b379 --- /dev/null +++ b/types/ip-subnet-calculator/ip-subnet-calculator-tests.ts @@ -0,0 +1,11 @@ +import * as IpSubnetCalculator from "ip-subnet-calculator"; + +IpSubnetCalculator.calculate("", ""); // $ExpectType SubnetResult[] +IpSubnetCalculator.calculateSubnetMask("", 1); // $ExpectType SubnetResult +IpSubnetCalculator.calculateCIDRPrefix("", 1); // $ExpectType SubnetResult + +IpSubnetCalculator.isIp(""); // $ExpectType boolean +IpSubnetCalculator.isDecimalIp(0); // $ExpectType boolean + +IpSubnetCalculator.toDecimal(""); // $ExpectType number +IpSubnetCalculator.toString(0); // $ExpectType string diff --git a/types/ip-subnet-calculator/tsconfig.json b/types/ip-subnet-calculator/tsconfig.json new file mode 100644 index 0000000000..74284388ce --- /dev/null +++ b/types/ip-subnet-calculator/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ip-subnet-calculator-tests.ts" + ] +} diff --git a/types/ip-subnet-calculator/tslint.json b/types/ip-subnet-calculator/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ip-subnet-calculator/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }