"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEdgeData = isEdgeData;
exports.isVector2 = isVector2;
exports.isVector3 = isVector3;
exports.isPoint = isPoint;
/**
* 判断是否为边数据
*
* judge whether the data is edge data
* @param data - 元素数据 | element data
* @returns - 是否为边数据 | whether the data is edge data
*/
function isEdgeData(data) {
if ('source' in data && 'target' in data)
return true;
return false;
}
/**
* 判断是否为二维向量
*
* Judge whether the vector is 2d
* @param vector - 向量 | vector
* @returns 是否为二维向量 | whether the vector is 2d
*/
function isVector2(vector) {
return vector.length === 2;
}
/**
* 判断是否为三维向量
*
* Judge whether the vector is 3d
* @param vector - 向量 | vector
* @returns 是否为三维向量 | whether the vector is 3d
*/
function isVector3(vector) {
return vector.length === 3;
}
/**
* 判断是否为点
*
* Judge whether the point is valid
* @param p - 点 | point
* @returns 是否为点 | whether the point is valid
*/
function isPoint(p) {
if (p instanceof Float32Array)
return true;
if (Array.isArray(p) && (p.length === 2 || p.length === 3)) {
return p.every((elem) => typeof elem === 'number');
}
return false;
}
//# sourceMappingURL=is.js.map