UNPKG

step-sequence-generator

Version:

A step sequence generator for figure skating programs

68 lines (67 loc) 2.68 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.createCoordinates = createCoordinates; exports.createVectorCursor = createVectorCursor; exports.createCoord = createCoord; exports.createCursor = createCursor; const Utils = __importStar(require("./utils")); const custom_errors_1 = require("../../errors/custom-errors"); function createCoordinates(x, y) { const xC = Utils.createCoord('x', x); const yC = Utils.createCoord('y', y); return { x: xC, y: yC }; } function createCoord(axis, coord) { let max = axis === 'x' ? 59 : 29; if (coord < 1 || coord > max) { throw new custom_errors_1.CoordinatesError(`${axis.toUpperCase()} coordinate must be between 1 and ${max}. Got: ${coord}`, 'OUTSIDE_BOUNDS'); } else { return coord; } } function createVectorCursor(x, y) { const xC = Utils.createCursor(x); const yC = Utils.createCursor(y); return { x: xC, y: yC }; } function createCursor(n) { if ([1, 0, -1].includes(n)) { return n; } console.debug('createCursor: Не допустимое значение для cursor'); throw new custom_errors_1.VectorCursorError(`Не допустимое значение для cursor. Должно быть (1, 0, -1), получил ${n}`, 'WRONG_CURSOR_VALUE'); }