Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/utils

Package Overview
Dependencies
Maintainers
22
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/utils - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

5

CHANGELOG.md

@@ -6,2 +6,7 @@ # Changelog

## 1.2.1 - 2021/8/3
- fix overload order
- fix `gt` and `gte` properties behavior in `isNumber` argument guard
## 1.2.0 - 2021/5/23

@@ -8,0 +13,0 @@

30

dist/src/geometry.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.divide = exports.equals = exports.contains = exports.isIntersected = exports.intersect = exports.offsetNegative = exports.offset = exports.scale = exports.isEmpty = exports.region = exports.size = exports.location = void 0;
exports.divide = exports.equals = exports.contains = exports.isIntersected = exports.subtraction = exports.intersect = exports.offsetNegative = exports.offset = exports.scale = exports.isEmpty = exports.region = exports.size = exports.location = void 0;
const types = require("./types");

@@ -62,2 +62,13 @@ const guard = require("./guard");

exports.intersect = intersect;
function subtraction(region1, region2) {
if (!isIntersected(region1, region2))
return { x: 0, y: 0, width: 0, height: 0 };
const result = {};
result.x = Math.max(region1.x - region2.x, 0);
result.y = Math.max(region1.y - region2.y, 0);
result.width = Math.min(region1.x + region1.width, region2.x + region2.width) - (result.x + region2.x);
result.height = Math.min(region1.y + region1.height, region2.y + region2.height) - (result.y + region2.y);
return result;
}
exports.subtraction = subtraction;
function isIntersected(region1, region2) {

@@ -107,3 +118,4 @@ return (((region1.x <= region2.x && region2.x <= region1.x + region1.width) ||

exports.equals = equals;
function divide(region, size) {
function divide(region, size, padding = {}) {
var _a, _b;
guard.notNull(region, { name: 'region' });

@@ -113,12 +125,22 @@ guard.notNull(size, { name: 'size' });

guard.isNumber(size.height, { name: 'size.height', gt: 0 });
(_a = padding.top) !== null && _a !== void 0 ? _a : (padding.top = 0);
(_b = padding.bottom) !== null && _b !== void 0 ? _b : (padding.bottom = 0);
const subRegions = [];
const maxX = region.x + region.width;
const maxY = region.y + region.height;
const stepX = size.width;
const stepY = padding.top + padding.bottom < size.height ? size.height - (padding.top + padding.bottom) : size.height;
let currentY = region.y;
while (currentY < maxY) {
const nextY = Math.min(currentY + size.height, maxY);
let nextY = Math.min(currentY + stepY, maxY);
// first region
if (currentY === region.y)
nextY += padding.top;
// last region
else if (nextY + padding.bottom >= maxY)
nextY += padding.bottom;
const currentHeight = nextY - currentY;
let currentX = region.x;
while (currentX < maxX) {
const nextX = Math.min(currentX + size.width, maxX);
const nextX = Math.min(currentX + stepX, maxX);
const currentWidth = nextX - currentX;

@@ -125,0 +147,0 @@ subRegions.push({ x: currentX, y: currentY, width: currentWidth, height: currentHeight });

4

dist/src/guard.js

@@ -26,5 +26,5 @@ "use strict";

else if (!types.isNull(gt))
isGreaterThenOrEqual(value, gt, { name });
isGreaterThen(value, gt, { name });
else if (!types.isNull(gte))
isGreaterThen(value, gte, { name });
isGreaterThenOrEqual(value, gte, { name });
}

@@ -31,0 +31,0 @@ exports.isNumber = isNumber;

{
"name": "@applitools/utils",
"version": "1.2.0",
"version": "1.2.1",
"keywords": [

@@ -5,0 +5,0 @@ "applitools",

@@ -20,18 +20,22 @@ declare type Location = {

export declare function isEmpty(region: Region): boolean;
export declare function scale(region: Region, scaleRatio: number): Region;
export declare function scale(size: RectangleSize, scaleRatio: number): RectangleSize;
export declare function scale(location: Location, scaleRatio: number): Location;
export declare function scale(size: RectangleSize, scaleRatio: number): RectangleSize;
export declare function scale(region: Region, scaleRatio: number): Region;
export declare function offset(region: Region, offset: Location): Region;
export declare function offset(location: Location, offset: Location): Location;
export declare function offset(region: Region, offset: Location): Region;
export declare function offsetNegative(region: Region, offset: Location): Region;
export declare function offsetNegative(location: Location, offset: Location): Location;
export declare function offsetNegative(region: Region, offset: Location): Region;
export declare function intersect(region1: Region, region2: Region): Region;
export declare function subtraction(region1: Region, region2: Region): Region;
export declare function isIntersected(region1: Region, region2: Region): boolean;
export declare function contains(region: Region, location: Location): boolean;
export declare function contains(region: Region, innerRegion: Region): boolean;
export declare function equals(region1: Region, region2: Region): boolean;
export declare function equals(location1: Location, location2: Location): boolean;
export declare function equals(size1: RectangleSize, size2: RectangleSize): boolean;
export declare function equals(region1: Region, region2: Region): boolean;
export declare function divide(region: Region, size: RectangleSize): Region[];
export declare function divide(region: Region, size: RectangleSize, padding?: {
top?: number;
bottom?: number;
}): Region[];
export {};
//# sourceMappingURL=geometry.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc