UNPKG

spaceship-sprites

Version:

Spaceship Sprite is a random ship sprite generator in typescript.

35 lines (34 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const validateInteger = (value, name) => { if (!Number.isInteger(value)) { throw new Error(`[Validator] Expected integer for ${name} but found ${value}`); } }; const validatePositive = (value, name) => { if (value < 0.0) { throw new Error(`[Validator] Expected positive value for ${name} but found ${value}`); } }; const validatePercentage = (value, name) => { if (value < 0.0 || value > 1.0) { throw new Error(`[Validator] Expected percentage value for ${name} but found ${value}`); } }; const validatePositiveNonZero = (value, name) => { if (value <= 0.0) { throw new Error(`[Validator] Expected positive non-zero value for ${name} but found ${value}`); } }; const validatePositiveInteger = (value, name) => { validateInteger(value, name); validatePositive(value, name); }; class Validator { } Validator.integer = validateInteger; Validator.positive = validatePositive; Validator.positiveInteger = validatePositiveInteger; Validator.percentage = validatePercentage; Validator.positiveNonZero = validatePositiveNonZero; exports.default = Validator;