lltz 1.0.0 → 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 +15 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +28 -0
- package/package.json +2 -1
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
|
|
package/dist/server.d.ts
ADDED
|
@@ -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": "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": [
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": "./dist/index.js",
|
|
29
|
+
"./server": "./dist/server.js",
|
|
29
30
|
"./data/*": "./data/*"
|
|
30
31
|
},
|
|
31
32
|
"files": [
|