16 lines
410 B
JavaScript
16 lines
410 B
JavaScript
|
export default function (point) {
|
||
|
checkCoord(point.x);
|
||
|
checkCoord(point.y);
|
||
|
}
|
||
|
function checkCoord(num) {
|
||
|
if (typeof Number.isFinite === 'function') {
|
||
|
if (Number.isFinite(num)) {
|
||
|
return;
|
||
|
}
|
||
|
throw new TypeError('coordinates must be finite numbers');
|
||
|
}
|
||
|
if (typeof num !== 'number' || num !== num || !isFinite(num)) {
|
||
|
throw new TypeError('coordinates must be finite numbers');
|
||
|
}
|
||
|
}
|