aviation-names 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/DATA_SOURCES.md +354 -0
- package/LICENSE +39 -0
- package/README.md +153 -0
- package/dist/airline-IWluLwUC.cjs +23 -0
- package/dist/airline-br_1PcDp.js +19 -0
- package/dist/airline.cjs +3 -0
- package/dist/airline.d.cts +17 -0
- package/dist/airline.d.ts +17 -0
- package/dist/airline.js +2 -0
- package/dist/airport-DsCO0sQC.js +16 -0
- package/dist/airport-DxZ75Ncw.cjs +20 -0
- package/dist/airport.cjs +3 -0
- package/dist/airport.d.cts +14 -0
- package/dist/airport.d.ts +14 -0
- package/dist/airport.js +2 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lookup-CLa4T8Yj.js +28 -0
- package/dist/lookup-DZ-BzxSo.cjs +33 -0
- package/package.json +79 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/airport.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Looks up an airport display name by its 3-letter IATA code.
|
|
4
|
+
*
|
|
5
|
+
* Input is trimmed and upper-cased, so `"cgk"` and `" CGK "` both resolve.
|
|
6
|
+
* Unknown or malformed codes return `null` rather than throwing.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* airport("CGK"); // "Soekarno-Hatta International Airport"
|
|
10
|
+
* airport("ZZZ"); // null
|
|
11
|
+
*/
|
|
12
|
+
declare const airport: (code: string) => string | null;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { airport };
|
package/dist/airport.js
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_airport = require("./airport-DxZ75Ncw.cjs");
|
|
3
|
+
const require_airline = require("./airline-IWluLwUC.cjs");
|
|
4
|
+
exports.airline = require_airline.airline;
|
|
5
|
+
exports.airport = require_airport.airport;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an O(1) lookup over a packed `<code><name>` record string.
|
|
3
|
+
*
|
|
4
|
+
* The dataset ships as a single string literal rather than an object literal:
|
|
5
|
+
* it is the smallest gzip payload of the representations benchmarked, and the
|
|
6
|
+
* engine only pays to parse one string at import time. The index is built on
|
|
7
|
+
* the first well-formed lookup, so importing without calling costs nothing
|
|
8
|
+
* beyond the string itself.
|
|
9
|
+
*
|
|
10
|
+
* A Map is used rather than a plain object because `obj["constructor"]` and
|
|
11
|
+
* `obj["toString"]` return inherited functions instead of `undefined`, which
|
|
12
|
+
* would leak a non-name value out of a lookup.
|
|
13
|
+
*/
|
|
14
|
+
function createLookup(packed, codeLength) {
|
|
15
|
+
let index = null;
|
|
16
|
+
return function lookup(code) {
|
|
17
|
+
if (typeof code !== "string") return null;
|
|
18
|
+
const key = code.trim().toUpperCase();
|
|
19
|
+
if (key.length !== codeLength) return null;
|
|
20
|
+
if (index === null) {
|
|
21
|
+
index = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const record of packed.split("")) index.set(record.slice(0, codeLength), record.slice(codeLength));
|
|
23
|
+
}
|
|
24
|
+
return index.get(key) ?? null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createLookup as t };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an O(1) lookup over a packed `<code><name>` record string.
|
|
3
|
+
*
|
|
4
|
+
* The dataset ships as a single string literal rather than an object literal:
|
|
5
|
+
* it is the smallest gzip payload of the representations benchmarked, and the
|
|
6
|
+
* engine only pays to parse one string at import time. The index is built on
|
|
7
|
+
* the first well-formed lookup, so importing without calling costs nothing
|
|
8
|
+
* beyond the string itself.
|
|
9
|
+
*
|
|
10
|
+
* A Map is used rather than a plain object because `obj["constructor"]` and
|
|
11
|
+
* `obj["toString"]` return inherited functions instead of `undefined`, which
|
|
12
|
+
* would leak a non-name value out of a lookup.
|
|
13
|
+
*/
|
|
14
|
+
function createLookup(packed, codeLength) {
|
|
15
|
+
let index = null;
|
|
16
|
+
return function lookup(code) {
|
|
17
|
+
if (typeof code !== "string") return null;
|
|
18
|
+
const key = code.trim().toUpperCase();
|
|
19
|
+
if (key.length !== codeLength) return null;
|
|
20
|
+
if (index === null) {
|
|
21
|
+
index = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const record of packed.split("")) index.set(record.slice(0, codeLength), record.slice(codeLength));
|
|
23
|
+
}
|
|
24
|
+
return index.get(key) ?? null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
Object.defineProperty(exports, "createLookup", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function() {
|
|
31
|
+
return createLookup;
|
|
32
|
+
}
|
|
33
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aviation-names",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Fast, offline airport and airline name lookup by IATA code. No API, no database, no network requests.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"aviation",
|
|
7
|
+
"airport",
|
|
8
|
+
"airline",
|
|
9
|
+
"iata",
|
|
10
|
+
"iata-code",
|
|
11
|
+
"airport-code",
|
|
12
|
+
"airline-code",
|
|
13
|
+
"airport-names",
|
|
14
|
+
"airline-names",
|
|
15
|
+
"flight",
|
|
16
|
+
"travel",
|
|
17
|
+
"offline",
|
|
18
|
+
"lookup",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "nixentric",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/nixentric/aviation-names.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/nixentric/aviation-names/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/nixentric/aviation-names#readme",
|
|
31
|
+
"type": "module",
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md",
|
|
39
|
+
"DATA_SOURCES.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"main": "./dist/index.cjs",
|
|
43
|
+
"module": "./dist/index.js",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
48
|
+
"import": "./dist/index.js",
|
|
49
|
+
"require": "./dist/index.cjs"
|
|
50
|
+
},
|
|
51
|
+
"./airport": {
|
|
52
|
+
"types": "./dist/airport.d.ts",
|
|
53
|
+
"import": "./dist/airport.js",
|
|
54
|
+
"require": "./dist/airport.cjs"
|
|
55
|
+
},
|
|
56
|
+
"./airline": {
|
|
57
|
+
"types": "./dist/airline.d.ts",
|
|
58
|
+
"import": "./dist/airline.js",
|
|
59
|
+
"require": "./dist/airline.cjs"
|
|
60
|
+
},
|
|
61
|
+
"./package.json": "./package.json"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsdown",
|
|
65
|
+
"typecheck": "tsc --noEmit",
|
|
66
|
+
"test": "npm run build && node --test tests/*.test.ts tests/*.test.mjs",
|
|
67
|
+
"benchmark": "node scripts/benchmark.ts",
|
|
68
|
+
"update-data": "node scripts/update-data.ts",
|
|
69
|
+
"size": "node scripts/size.ts",
|
|
70
|
+
"prepack": "npm run build",
|
|
71
|
+
"verify-pack": "npm run build && node scripts/verify-pack.ts",
|
|
72
|
+
"test:compat": "node --test tests/*.test.mjs"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@types/node": "^26.3.0",
|
|
76
|
+
"tsdown": "^0.22.14",
|
|
77
|
+
"typescript": "^5.9.0"
|
|
78
|
+
}
|
|
79
|
+
}
|