UNPKG

1.29 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.validateStartFromProps = void 0;
4const validateStartFromProps = (startFrom, endAt) => {
5 if (typeof startFrom !== 'undefined') {
6 if (typeof startFrom !== 'number') {
7 throw new TypeError(`type of startFrom prop must be a number, instead got type ${typeof startFrom}.`);
8 }
9 if (isNaN(startFrom) || startFrom === Infinity) {
10 throw new TypeError('startFrom prop can not be NaN or Infinity.');
11 }
12 if (startFrom < 0) {
13 throw new TypeError(`startFrom must be greater than equal to 0 instead got ${startFrom}.`);
14 }
15 }
16 if (typeof endAt !== 'undefined') {
17 if (typeof endAt !== 'number') {
18 throw new TypeError(`type of endAt prop must be a number, instead got type ${typeof endAt}.`);
19 }
20 if (isNaN(endAt)) {
21 throw new TypeError('endAt prop can not be NaN.');
22 }
23 if (endAt <= 0) {
24 throw new TypeError(`endAt must be a positive number, instead got ${endAt}.`);
25 }
26 }
27 if (endAt < startFrom) {
28 throw new TypeError('endAt prop must be greater than startFrom prop.');
29 }
30};
31exports.validateStartFromProps = validateStartFromProps;