UNPKG

amazon-route-53-dns-zone-file

Version:

Makes DNS Zone File easy. Parses and validates BIND zone files and can be extended for custom features. Functionality is modular. Features are made open for extension and closed for runtime mutation. Written in TypeScript.

30 lines (20 loc) 880 B
export const hasLetters = (x: string): boolean => /[a-z]/i.test(x); export const hasNumbers = (x: string): boolean => /\d/.test(x); export const trimDot = (x: string): string => x.replace(/\.$/, ''); export const withDot = (x: string): string => trimDot(x) + '.'; export const match = (pattern: RegExp, input: string): string[] => { if (typeof input === 'string') { return input.match(pattern) || []; } else { return []; } }; export const matchDigitWithNumber = /(\d+)([a-z]+)/gim; export const UNIX_NEW_LINE_CHAR = '\n'; export const unifyNewLine = (value: string): string => value .replace(/\\n/, UNIX_NEW_LINE_CHAR) .replace(/\r\n?/g, UNIX_NEW_LINE_CHAR); export const splitByNewLine = (value: string): string[] => unifyNewLine(value).split(UNIX_NEW_LINE_CHAR); export const newLinesIntoSpaces = (value: string) => value.replace(/\n/g, ' ');