UNPKG

@randsum/notation

Version:

A flexible, type-safe dice notation parser and validator

10 lines 452 B
import { completeRollPattern, coreNotationPattern } from './patterns'; export function isDiceNotation(argument) { const notAString = typeof argument !== 'string'; const basicTest = !!coreNotationPattern.test(String(argument)); if (!basicTest || notAString) return false; const cleanArg = argument.replace(/\s/g, ''); return cleanArg.replace(completeRollPattern, '').length === 0; } //# sourceMappingURL=isDiceNotation.js.map