lltz 0.0.1 → 1.1.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/README.md CHANGED
@@ -28,6 +28,21 @@ The other variants, `timezones-1970.lltz` and `timezones-now.lltz`, can be downl
28
28
 
29
29
  ### Node.js / Bun
30
30
 
31
+ #### Simple Usage
32
+
33
+ ```typescript
34
+ import * as Lltz from 'lltz/server'
35
+
36
+ const lookup = Lltz.make() // Automatically loads the built-in timezones.lltz file
37
+
38
+ const timezones = lookup(40.7128, -74.006) // New York
39
+ console.log(timezones) // ['America/New_York']
40
+ ```
41
+
42
+ #### Manual Data Loading
43
+
44
+ If you need to use a different data file or have custom requirements:
45
+
31
46
  ```typescript
32
47
  import fs from 'node:fs'
33
48
 
Binary file
@@ -0,0 +1,15 @@
1
+ import { Lookup } from "./index.js";
2
+
3
+ //#region src/server.d.ts
4
+
5
+ /**
6
+ * Creates a timezone lookup function from the provided binary data.
7
+ *
8
+ * @param arrayBufferOrUint8Array - Optional binary data containing the timezone database (LLTZ
9
+ * format). If not provided, the built-in `timezones.lltz` file will be automatically loaded.
10
+ * @returns {Lookup} A timezone lookup function.
11
+ * @throws An error if the binary data is invalid or if the built-in data file cannot be loaded.
12
+ */
13
+ declare const make: (arrayBufferOrUint8Array?: ArrayBuffer | Uint8Array) => Lookup;
14
+ //#endregion
15
+ export { type Lookup, make };
package/dist/server.js ADDED
@@ -0,0 +1,28 @@
1
+ import { make as make$1 } from "./index.js";
2
+ import fs from "node:fs";
3
+
4
+ //#region src/server.ts
5
+ const load = () => {
6
+ try {
7
+ return fs.readFileSync(new URL(import.meta.resolve("lltz/data/timezones.lltz")));
8
+ } catch {}
9
+ try {
10
+ return fs.readFileSync(new URL("../data/timezones.lltz", import.meta.url));
11
+ } catch {}
12
+ try {
13
+ return fs.readFileSync("node_modules/lltz/data/timezones.lltz");
14
+ } catch {}
15
+ throw new Error("failed to load built-in timezones.lltz file");
16
+ };
17
+ /**
18
+ * Creates a timezone lookup function from the provided binary data.
19
+ *
20
+ * @param arrayBufferOrUint8Array - Optional binary data containing the timezone database (LLTZ
21
+ * format). If not provided, the built-in `timezones.lltz` file will be automatically loaded.
22
+ * @returns {Lookup} A timezone lookup function.
23
+ * @throws An error if the binary data is invalid or if the built-in data file cannot be loaded.
24
+ */
25
+ const make = (arrayBufferOrUint8Array) => make$1(arrayBufferOrUint8Array ?? load());
26
+
27
+ //#endregion
28
+ export { make };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lltz",
3
- "version": "0.0.1",
3
+ "version": "1.1.0",
4
4
  "author": "Utkarsh Kukreti <utkarshkukreti@gmail.com>",
5
5
  "description": "A high-performance, memory-efficient offline timezone lookup library for TypeScript using a custom binary format and quadtree spatial indexing.",
6
6
  "keywords": [
@@ -20,17 +20,28 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "type": "module",
23
+ "packageManager": "pnpm@10.28.0",
23
24
  "main": "./dist/index.js",
24
25
  "module": "./dist/index.js",
25
26
  "types": "./dist/index.d.ts",
26
27
  "exports": {
27
28
  ".": "./dist/index.js",
29
+ "./server": "./dist/server.js",
28
30
  "./data/*": "./data/*"
29
31
  },
30
32
  "files": [
31
33
  "data/timezones.lltz",
32
34
  "dist"
33
35
  ],
36
+ "scripts": {
37
+ "build": "tsc && tsdown",
38
+ "prepublishOnly": "make && pnpm build",
39
+ "lint": "prettier --check .",
40
+ "format": "prettier --write .",
41
+ "test": "node --max-old-space-size=8192 tests/index.ts",
42
+ "bench": "node benches/index.ts",
43
+ "bench:memory": "node benches/memory.ts lltz:timezones && node benches/memory.ts geo-tz:timezones"
44
+ },
34
45
  "devDependencies": {
35
46
  "@ianvs/prettier-plugin-sort-imports": "4.7.0",
36
47
  "@types/node": "24.10.8",
@@ -39,13 +50,5 @@
39
50
  "tinybench": "6.0.0",
40
51
  "tsdown": "0.19.0",
41
52
  "typescript": "5.9.3"
42
- },
43
- "scripts": {
44
- "build": "tsc && tsdown",
45
- "lint": "prettier --check .",
46
- "format": "prettier --write .",
47
- "test": "node --max-old-space-size=8192 tests/index.ts",
48
- "bench": "node benches/index.ts",
49
- "bench:memory": "node benches/memory.ts lltz:timezones && node benches/memory.ts geo-tz:timezones"
50
53
  }
51
- }
54
+ }