@x-oasis/in-bounding-rect 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @x-oasis/in-bounding-rect
2
+
3
+ ## Installation
4
+
5
+ ```bash
6
+ $ npm i @x-oasis/in-bounding-rect
7
+ ```
8
+
9
+ ## How to use
10
+
11
+ ```typescript
12
+ import inBoundingRect from '@x-oasis/in-bounding-rect'
13
+ ```
14
+
15
+ ## How to run test
16
+
17
+ ```bash
18
+ $ pnpm test
19
+ ```
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index = (function (tl, br, p, included) {
6
+ if (included === void 0) {
7
+ included = false;
8
+ }
9
+ if (!included) return p.x > tl.x && p.x < br.x && p.y > tl.y && p.y < br.y;
10
+ return p.x >= tl.x && p.x <= br.x && p.y >= tl.y && p.y <= br.y;
11
+ });
12
+
13
+ exports.default = index;
14
+ //# sourceMappingURL=in-bounding-rect.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-bounding-rect.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["// https://stackoverflow.com/a/18295844\n\nexport type Coordinates = {\n x: number;\n y: number;\n};\n\n/**\n * tl: topLeftCoordinates\n * br: bottomRightCoordinates\n * p: point\n */\nexport default (\n tl: Coordinates,\n br: Coordinates,\n p: Coordinates,\n included = false\n) => {\n if (!included) return p.x > tl.x && p.x < br.x && p.y > tl.y && p.y < br.y;\n return p.x >= tl.x && p.x <= br.x && p.y >= tl.y && p.y <= br.y;\n};\n"],"names":["tl","br","p","included","x","y"],"mappings":";;;;AAYA,aAAe,UACbA,EAAe,EACfC,EAAe,EACfC,CAAc,EACdC,QAAQ;MAARA,QAAQ;IAARA,QAAQ,GAAG,KAAK;;EAEhB,IAAI,CAACA,QAAQ,EAAE,OAAOD,CAAC,CAACE,CAAC,GAAGJ,EAAE,CAACI,CAAC,IAAIF,CAAC,CAACE,CAAC,GAAGH,EAAE,CAACG,CAAC,IAAIF,CAAC,CAACG,CAAC,GAAGL,EAAE,CAACK,CAAC,IAAIH,CAAC,CAACG,CAAC,GAAGJ,EAAE,CAACI,CAAC;EAC1E,OAAOH,CAAC,CAACE,CAAC,IAAIJ,EAAE,CAACI,CAAC,IAAIF,CAAC,CAACE,CAAC,IAAIH,EAAE,CAACG,CAAC,IAAIF,CAAC,CAACG,CAAC,IAAIL,EAAE,CAACK,CAAC,IAAIH,CAAC,CAACG,CAAC,IAAIJ,EAAE,CAACI,CAAC;AACjE,CAAC;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e,x,t,y){return void 0===y&&(y=!1),y?t.x>=e.x&&t.x<=x.x&&t.y>=e.y&&t.y<=x.y:t.x>e.x&&t.x<x.x&&t.y>e.y&&t.y<x.y};
2
+ //# sourceMappingURL=in-bounding-rect.cjs.production.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-bounding-rect.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["// https://stackoverflow.com/a/18295844\n\nexport type Coordinates = {\n x: number;\n y: number;\n};\n\n/**\n * tl: topLeftCoordinates\n * br: bottomRightCoordinates\n * p: point\n */\nexport default (\n tl: Coordinates,\n br: Coordinates,\n p: Coordinates,\n included = false\n) => {\n if (!included) return p.x > tl.x && p.x < br.x && p.y > tl.y && p.y < br.y;\n return p.x >= tl.x && p.x <= br.x && p.y >= tl.y && p.y <= br.y;\n};\n"],"names":["tl","br","p","included","x","y"],"mappings":"6FAaEA,EACAC,EACAC,EACAC,GAEA,gBAFAA,IAAAA,GAAW,GAENA,EACED,EAAEE,GAAKJ,EAAGI,GAAKF,EAAEE,GAAKH,EAAGG,GAAKF,EAAEG,GAAKL,EAAGK,GAAKH,EAAEG,GAAKJ,EAAGI,EADxCH,EAAEE,EAAIJ,EAAGI,GAAKF,EAAEE,EAAIH,EAAGG,GAAKF,EAAEG,EAAIL,EAAGK,GAAKH,EAAEG,EAAIJ,EAAGI"}
@@ -0,0 +1,10 @@
1
+ var index = (function (tl, br, p, included) {
2
+ if (included === void 0) {
3
+ included = false;
4
+ }
5
+ if (!included) return p.x > tl.x && p.x < br.x && p.y > tl.y && p.y < br.y;
6
+ return p.x >= tl.x && p.x <= br.x && p.y >= tl.y && p.y <= br.y;
7
+ });
8
+
9
+ export default index;
10
+ //# sourceMappingURL=in-bounding-rect.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-bounding-rect.esm.js","sources":["../src/index.ts"],"sourcesContent":["// https://stackoverflow.com/a/18295844\n\nexport type Coordinates = {\n x: number;\n y: number;\n};\n\n/**\n * tl: topLeftCoordinates\n * br: bottomRightCoordinates\n * p: point\n */\nexport default (\n tl: Coordinates,\n br: Coordinates,\n p: Coordinates,\n included = false\n) => {\n if (!included) return p.x > tl.x && p.x < br.x && p.y > tl.y && p.y < br.y;\n return p.x >= tl.x && p.x <= br.x && p.y >= tl.y && p.y <= br.y;\n};\n"],"names":["tl","br","p","included","x","y"],"mappings":"AAYA,aAAe,UACbA,EAAe,EACfC,EAAe,EACfC,CAAc,EACdC,QAAQ;MAARA,QAAQ;IAARA,QAAQ,GAAG,KAAK;;EAEhB,IAAI,CAACA,QAAQ,EAAE,OAAOD,CAAC,CAACE,CAAC,GAAGJ,EAAE,CAACI,CAAC,IAAIF,CAAC,CAACE,CAAC,GAAGH,EAAE,CAACG,CAAC,IAAIF,CAAC,CAACG,CAAC,GAAGL,EAAE,CAACK,CAAC,IAAIH,CAAC,CAACG,CAAC,GAAGJ,EAAE,CAACI,CAAC;EAC1E,OAAOH,CAAC,CAACE,CAAC,IAAIJ,EAAE,CAACI,CAAC,IAAIF,CAAC,CAACE,CAAC,IAAIH,EAAE,CAACG,CAAC,IAAIF,CAAC,CAACG,CAAC,IAAIL,EAAE,CAACK,CAAC,IAAIH,CAAC,CAACG,CAAC,IAAIJ,EAAE,CAACI,CAAC;AACjE,CAAC;;;;"}
@@ -0,0 +1,6 @@
1
+ export declare type Coordinates = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ declare const _default: (tl: Coordinates, br: Coordinates, p: Coordinates, included?: boolean) => boolean;
6
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./in-bounding-rect.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./in-bounding-rect.cjs.development.js')
8
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@x-oasis/in-bounding-rect",
3
+ "version": "0.1.35",
4
+ "description": "in-bounding-rect function",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "module": "dist/in-bounding-rect.esm.js",
8
+ "files": [
9
+ "dist",
10
+ "index.ts",
11
+ "src"
12
+ ],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "devDependencies": {
16
+ "tsdx": "^0.14.1"
17
+ },
18
+ "scripts": {
19
+ "build": "tsdx build --tsconfig tsconfig.build.json",
20
+ "clean": "rimraf ./dist",
21
+ "test": "vitest",
22
+ "compile": "tsc -p tsconfig.build.json"
23
+ }
24
+ }
package/src/index.ts ADDED
@@ -0,0 +1,21 @@
1
+ // https://stackoverflow.com/a/18295844
2
+
3
+ export type Coordinates = {
4
+ x: number;
5
+ y: number;
6
+ };
7
+
8
+ /**
9
+ * tl: topLeftCoordinates
10
+ * br: bottomRightCoordinates
11
+ * p: point
12
+ */
13
+ export default (
14
+ tl: Coordinates,
15
+ br: Coordinates,
16
+ p: Coordinates,
17
+ included = false
18
+ ) => {
19
+ if (!included) return p.x > tl.x && p.x < br.x && p.y > tl.y && p.y < br.y;
20
+ return p.x >= tl.x && p.x <= br.x && p.y >= tl.y && p.y <= br.y;
21
+ };