@eclipse-glsp/protocol
Advanced tools
Comparing version 2.2.0-next.341 to 2.2.0-next.342
@@ -29,2 +29,9 @@ /******************************************************************************** | ||
/** | ||
* Type guard to check if a bound is valid. For a bound to be valid it needs to be defined and have valid | ||
* coordinates and dimensions. | ||
* | ||
* @param bounds the bounds to be checked for validity | ||
*/ | ||
function isValid(bounds?: Bounds): bounds is Bounds; | ||
/** | ||
* Checks whether the inner bounds are compeletely encompassed by the outer bounds. | ||
@@ -31,0 +38,0 @@ * |
@@ -36,2 +36,3 @@ "use strict"; | ||
(0, type_util_1.hasNumberProp)(bounds, 'height'); | ||
geometry_1.Bounds.isValid = (bounds) => bounds !== undefined && sprotty_geometry_dimension_1.Dimension.isValid(bounds) && sprotty_geometry_point_1.Point.isValid(bounds); | ||
geometry_1.Bounds.encompasses = (outer, inner) => geometry_1.Bounds.includes(outer, geometry_1.Bounds.topLeft(inner)) && geometry_1.Bounds.includes(outer, geometry_1.Bounds.bottomRight(inner)); | ||
@@ -38,0 +39,0 @@ geometry_1.Bounds.overlap = (one, other, touch) => { |
{ | ||
"name": "@eclipse-glsp/protocol", | ||
"version": "2.2.0-next.341+65b68e3", | ||
"version": "2.2.0-next.342+fb31fc2", | ||
"description": "The protocol definition for client-server communication in GLSP", | ||
@@ -61,3 +61,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "65b68e37b8d18852c6a8a4a81f5db5f716ef926b" | ||
"gitHead": "fb31fc22d9b5eb7244c7c0aa4a53f55d979e8d56" | ||
} |
@@ -35,2 +35,22 @@ /******************************************************************************** | ||
describe('isValid', () => { | ||
it('should return true if the bounds are valid', () => { | ||
const bounds: Bounds = { x: 0, y: 0, width: 100, height: 100 }; | ||
const result = Bounds.isValid(bounds); | ||
expect(result).to.be.true; | ||
}); | ||
it('should return false if a dimension is not valid', () => { | ||
const bounds = { x: 0, y: 0, width: 100, height: -1 }; | ||
const result = Bounds.isValid(bounds); | ||
expect(result).to.be.false; | ||
}); | ||
it('should return false if a coordinate is not valid', () => { | ||
const bounds = { x: 0, y: NaN, width: 100, height: 0 }; | ||
const result = Bounds.isValid(bounds); | ||
expect(result).to.be.false; | ||
}); | ||
}); | ||
describe('encompasses', () => { | ||
@@ -37,0 +57,0 @@ it('should return true if the outer bounds completely encompass the inner bounds', () => { |
@@ -37,2 +37,10 @@ /******************************************************************************** | ||
/** | ||
* Type guard to check if a bound is valid. For a bound to be valid it needs to be defined and have valid | ||
* coordinates and dimensions. | ||
* | ||
* @param bounds the bounds to be checked for validity | ||
*/ | ||
function isValid(bounds?: Bounds): bounds is Bounds; | ||
/** | ||
* Checks whether the inner bounds are compeletely encompassed by the outer bounds. | ||
@@ -276,2 +284,4 @@ * | ||
Bounds.isValid = (bounds?: Bounds): bounds is Bounds => bounds !== undefined && Dimension.isValid(bounds) && Point.isValid(bounds); | ||
Bounds.encompasses = (outer: Bounds, inner: Bounds): boolean => | ||
@@ -278,0 +288,0 @@ Bounds.includes(outer, Bounds.topLeft(inner)) && Bounds.includes(outer, Bounds.bottomRight(inner)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 7 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 7 instances in 1 package
1101098
19158