UNPKG

@jscad/modeling

Version:

Constructive Solid Geometry (CSG) Library for JSCAD

21 lines (19 loc) 659 B
/** * Determine if the given object is a path2 geometry. * @param {Object} object - the object to interrogate * @returns {Boolean} true if the object matches a path2 * @alias module:modeling/geometries/path2.isA */ const isA = (object) => { if (object && typeof object === 'object') { // see create for the required attributes and types if ('points' in object && 'transforms' in object && 'isClosed' in object) { // NOTE: transforms should be a TypedArray, which has a read-only length if (Array.isArray(object.points) && 'length' in object.transforms) { return true } } } return false } module.exports = isA