thaizip 0.7.3 → 0.7.5

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
@@ -1,9 +1,17 @@
1
1
  # thaizip
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/thaizip.svg)](https://www.npmjs.com/package/thaizip)
4
+ [![npm downloads](https://img.shields.io/npm/dm/thaizip.svg)](https://www.npmjs.com/package/thaizip)
5
+ [![license](https://img.shields.io/npm/l/thaizip.svg)](https://github.com/naay99999/thai-zip/blob/main/LICENSE)
6
+
3
7
  Fast fuzzy autocomplete for Thai addresses — subdistrict, district, province, postal code. Thai and English input, zero runtime dependencies, React optional.
4
8
 
5
9
  **Docs:** https://naay99999.github.io/thai-zip/ (ไทย / [English](https://naay99999.github.io/thai-zip/en/))
6
10
 
11
+ | Thai input | English input (romanization alias) |
12
+ |---|---|
13
+ | ![thaizip demo — typing "ลาดพร้าว" and getting fuzzy Thai suggestions](.github/assets/demo.png) | ![thaizip demo — typing "ladprao" and matching the same Thai suggestions](.github/assets/demo-en.png) |
14
+
7
15
  ```bash
8
16
  npm install thaizip
9
17
  ```
@@ -12,7 +20,7 @@ npm install thaizip
12
20
  |---|---|
13
21
  | `thaizip` | core functions + types (no React code, 4.4 KB gzip) |
14
22
  | `thaizip/react` | `useThaiAddressAutocomplete` (ships `"use client"`) |
15
- | `thaizip/data` | `loadDefaultIndex`, `clearDefaultIndex` (132 KB gzip) |
23
+ | `thaizip/data` | `loadDefaultIndex`, `clearDefaultIndex`, `getDefaultIndexIfLoaded` (2.3 KB gzip, plus a 114 KB gzip data chunk fetched lazily on the first `loadDefaultIndex()` call) |
16
24
 
17
25
  ## Quick start
18
26
 
@@ -59,6 +67,8 @@ lookupByZipCode(index, '45000') // exact
59
67
  lookupByZipCode(index, '450') // prefix
60
68
  ```
61
69
 
70
+ Direct ZIP lookup rejects raw inputs longer than 1000 characters before scanning them. A finite `zipLimit` also bounds how many matching records are collected.
71
+
62
72
  ### English input
63
73
 
64
74
  The dataset indexes official RTGS spellings, so `bang rak` and `chatuchak` work directly. 87 common non-RTGS spellings are mapped on first: `lardprao` → `lat phrao`, `ladkrabang` → `lat krabang`, `krungthep` → `bangkok`. It is a curated dictionary, not a transliterator — unlisted spellings still miss. Opt out with `romanizationAliases: false`.