UNPKG

convert2base

Version:

Project developed to perform basic binary conversions involving binary, octal, decimal and hexadecimal numbers.

8 lines (7 loc) 249 B
export const validateBinaryNumber = (binaryNumber: string) => { if (!/^[01]+$/.test(String(binaryNumber))) { throw new Error( 'The provided binary number is invalid. Make sure it contains only 0s and 1s.' ); } };