@scratching-platypus/coordinate-ts 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Martin Kosař
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ <img src="./docs/assets/scratching-platypus-coordinate.png" alt="Scratching platypus" width="120" align="right"/>
2
+
3
+ ### @scratching-platypus/coordinate-ts
4
+
5
+ A geographic coordinates (latitude/longitude) type for TypeScript with utilities for strict and tolerant comparison.
6
+
7
+ ### Install
8
+
9
+ ```
10
+ npm install @scratching-platypus/coordinate-ts
11
+ ```
12
+
13
+ ### Import
14
+
15
+ ```TypeScript
16
+ import { Coordinate, equals, approxEquals } from "@scratching-platypus/coordinate-ts";
17
+ ```
18
+
19
+ ### Coordinate Type
20
+
21
+ ```TypeScript
22
+ const a: Coordinate = { latitude: 50.0802767, longitude: 16.2958756 };
23
+ ```
24
+
25
+ ```TypeScript
26
+ const b: Coordinate = { latitude: 50.0797031, longitude: 16.2961389 };
27
+ ```
28
+
29
+ ### Strict Equality
30
+
31
+ ```TypeScript
32
+ equals(a, b); // false
33
+ ```
34
+
35
+ ### Tolerant Equality
36
+
37
+ Compares latitude and longitude independently using absolute difference in degrees.
38
+
39
+ ```TypeScript
40
+ approxEquals(a, b); // false, epsilon = 1e-9
41
+ approxEquals(a, b, 1e-3); // true
42
+ ```
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ // src/coordinate.ts
2
+ function equals(a, b) {
3
+ return a.latitude === b.latitude && a.longitude === b.longitude;
4
+ }
5
+ function approxEquals(a, b, epsilon = 1e-9) {
6
+ return Math.abs(a.latitude - b.latitude) <= epsilon && Math.abs(a.longitude - b.longitude) <= epsilon;
7
+ }
8
+ export {
9
+ approxEquals,
10
+ equals
11
+ };
12
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/coordinate.ts"],
4
+ "sourcesContent": ["export type Coordinate = {\n latitude: number;\n longitude: number;\n};\n\nexport function equals(a: Coordinate, b: Coordinate): boolean {\n return a.latitude === b.latitude && a.longitude === b.longitude;\n}\n\nexport function approxEquals(a: Coordinate, b: Coordinate, epsilon = 1e-9): boolean {\n return Math.abs(a.latitude - b.latitude) <= epsilon && Math.abs(a.longitude - b.longitude) <= epsilon;\n}\n"],
5
+ "mappings": ";AAKO,SAAS,OAAO,GAAe,GAAwB;AAC1D,SAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE;AAC1D;AAEO,SAAS,aAAa,GAAe,GAAe,UAAU,MAAe;AAChF,SAAO,KAAK,IAAI,EAAE,WAAW,EAAE,QAAQ,KAAK,WAAW,KAAK,IAAI,EAAE,YAAY,EAAE,SAAS,KAAK;AAClG;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@scratching-platypus/coordinate-ts",
3
+ "version": "1.0.0",
4
+ "description": "A geographic coordinates (latitude/longitude) type for TypeScript with utilities for strict and tolerant comparison.",
5
+ "type": "module",
6
+ "main": "dist/index.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.mjs"
10
+ }
11
+ },
12
+ "author": {
13
+ "name": "Martin Kosař",
14
+ "email": "koalix@post.cz"
15
+ },
16
+ "license": "MIT",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/scratching-platypus/coordinate-ts.git"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "keywords": [
28
+ "coordinate",
29
+ "coordinates",
30
+ "latitude",
31
+ "longitude",
32
+ "typescript"
33
+ ],
34
+ "scripts": {
35
+ "build": "esbuild src/index.ts --bundle --format=esm --platform=neutral --outfile=dist/index.mjs --target=es2020 --sourcemap",
36
+ "release": "esbuild src/index.ts --bundle --format=esm --platform=neutral --outfile=dist/index.mjs --target=es2020 --sourcemap --minify",
37
+ "dev": "esbuild src/index.ts --bundle --format=esm --platform=neutral --outfile=dist/index.mjs --target=es2020 --sourcemap --watch",
38
+ "test": "vitest",
39
+ "start": "node ./dist/index.mjs"
40
+ },
41
+ "devDependencies": {
42
+ "@eslint/js": "^9.39.2",
43
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
44
+ "@typescript-eslint/parser": "^8.50.1",
45
+ "esbuild": "^0.27.2",
46
+ "eslint": "^9.39.2",
47
+ "prettier": "3.7.4",
48
+ "typescript": "^5.9.3",
49
+ "typescript-eslint": "^8.50.1",
50
+ "vitest": "^4.0.16"
51
+ }
52
+ }