Registry / data / thai-address-database

thai-address-database

JSON →
library0.0.30jsnpmunverified

The `thai-address-database` package offers a client-side solution for managing and searching Thai address data within JavaScript applications. Currently at version 0.0.30, it provides functions like `searchAddressByDistrict` to query a local `db.json` file, eliminating the need for a server-side component for address lookups. The library is based on the database and `preprocess()` function from `jquery.Thailand.js` version 1.5.1. While it allows for database updates via an `npm run migrate` script, which converts a `database.xlsx` file into `db.json`, it is still in early development, with noted limitations such as exclusive support for `db.json` and no current support for `db.zip` or geodatabases. Its primary differentiator is enabling offline or client-only address search capabilities for Thai addresses.

npm install thai-address-database
INSTALL
IMPORT
SIG · THAI-ADDRESS-DATAB
T
thai-address-database
datajavascriptv0.0.30
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

searchAddressByDistrict
import { searchAddressByDistrict } from 'thai-address-database';
const searchAddressByDistrict = require('thai-address-database'); import searchAddressByDistrict from 'thai-address-database';
This package primarily uses named exports. Direct CommonJS `require` might not correctly expose the named functions, and it is not a default export.

Demonstrates how to import and use the `searchAddressByDistrict` function to query Thai address data, logging results to the console.

import { searchAddressByDistrict } from 'thai-address-database'; // In a browser environment, ensure db.json is accessible or bundled. // For Node.js, the package typically handles database resolution. // Simulate an input change or a search query function performAddressSearch(query) { const results = searchAddressByDistrict(query); console.log(`\n--- Search results for "${query}" ---`); if (results && results.length > 0) { results.forEach(item => { console.log(`${item.district} » ${item.amphoe} » ${item.province} » ${item.zipcode}`); }); } else { console.log("No matching addresses found."); } } // Example usage: performAddressSearch('สีลม'); performAddressSearch('ดินแดง'); performAddressSearch('ปทุมวัน'); performAddressSearch('ถนนเพชรบุรีตัดใหม่'); // A query that might not yield direct district results performAddressSearch('NonExistentPlace');
Debug
Known issues
gotchaThe library currently only supports `db.json` for its address data. It does not support `db.zip` or `geodb` formats that might be present in related or original projects.
fix
Ensure your database is in `db.json` format. The package includes an `npm run migrate` script to convert `database.xlsx` to `db.json`.
affects: >=0.0.1
gotchaTo update the local address database, you must use the provided `npm run migrate` command after modifying the `database.xlsx` file. Manual manipulation of `db.json` is not recommended as it can be overwritten.
fix
Run `npm run migrate` in your project's root directory after updating `database.xlsx`. Ensure the Excel file is always `.xlsx` format.
affects: >=0.0.1
gotchaThis package is based on an older version (1.5.1) of the database and `preprocess()` function from `jquery.Thailand.js`. Be aware of potential differences in data structure or available functionality compared to newer versions of the original project.
fix
Refer to the `thai-address-database` documentation for specific functionality. If you require features or data from newer `jquery.Thailand.js` versions, you may need to contribute or seek alternatives.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'thai-address-database'
The package has not been installed or is not correctly resolved by your module bundler/Node.js environment.
fix
Run `npm install thai-address-database` or `yarn add thai-address-database` in your project directory.
searchAddressByDistrict is not a function
The `searchAddressByDistrict` function was imported incorrectly, often due to attempting a default import or incorrect CommonJS `require`.
fix
Use a named import: `import { searchAddressByDistrict } from 'thai-address-database';`
Error: ENOENT: no such file or directory, open '.../node_modules/thai-address-database/database/db.json'
The `db.json` file, which contains the address data, is missing or inaccessible in the expected location.
fix
Ensure the package is fully installed and the database file is present. If you are developing or have manually altered the database, run `npm run migrate` to generate/restore `db.json` from `database.xlsx`.
Upgrade
Version history
0.0.30latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
thai-address-database — npm install thai-address-database · libregistry