Registry / database / thai-address-custom-database

thai-address-custom-database

JSON →
library1.0.2jsnpmunverified

The `thai-address-custom-database` package offers a client-side database for Thai addresses, removing the need for server-side lookups. It builds upon the `Sellsuki/thai-address-database` project and specifically incorporates the database and `preprocess()` function from `jquery.Thailand.js` version 1.5.1 (commit 4e5f496). The current stable version is 1.0.2. This library is updated infrequently, primarily providing database maintenance and minor library updates. A key differentiator is its ability to generate the client-side `db.json` from an `xlsx` spreadsheet via a migration script. However, it currently only supports the `db.json` format and does not include support for `db.zip` or `geodb` variants found in some related projects. It requires Node.js version 12 or higher.

npm install thai-address-custom-database
INSTALL
IMPORT
SIG · THAI-ADDRESS-CUSTO
T
thai-address-custom-database
databasejavascriptv1.0.2
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-custom-database';
const { searchAddressByDistrict } = require('thai-address-custom-database');
This is the primary function for searching addresses. The package is primarily designed for ES Modules, though CJS `require` might work via transpilation/bundling environments.
preprocess
import { preprocess } from 'thai-address-custom-database';
import preprocess from 'thai-address-custom-database';
The `preprocess` function is part of the integrated `jquery.Thailand.js` 1.5.1 logic, often used for initial data preparation or normalization.
* as ThaiAddress
import * as ThaiAddress from 'thai-address-custom-database';
import ThaiAddress from 'thai-address-custom-database';
Use this pattern to import all named exports into a single namespace object (e.g., `ThaiAddress.searchAddressByDistrict`). There is no default export.

Demonstrates how to import and use the `searchAddressByDistrict` function to query Thai address data.

import { searchAddressByDistrict } from 'thai-address-custom-database'; interface AddressResult { district: string; amphoe: string; province: string; zipcode: string; } function simulateAddressSearch(query: string): void { console.log(`\n--- Searching for "${query}" ---`); const results: AddressResult[] = searchAddressByDistrict(query); if (results && results.length > 0) { results.forEach(item => { console.log(`${item.district} » ${item.amphoe} » ${item.province} » ${item.zipcode}`); }); } else { console.log(`No results found for "${query}".`); } } // Example searches simulateAddressSearch('บางกะปิ'); simulateAddressSearch('จตุจักร'); simulateAddressSearch('บางพลี'); simulateAddressSearch('สุขุมวิท 21'); // Should return some results if found simulateAddressSearch('กรุงเทพ'); // Might return many results or none depending on specific search logic simulateAddressSearch('xyz-nonexistent'); // Expected no results
Debug
Known issues
gotchaThe README examples incorrectly show `import ... from 'thai-address-database'` instead of the actual package name `thai-address-custom-database`. Copying the README's import path will result in a 'module not found' error.
fix
Always use `import ... from 'thai-address-custom-database'` when importing this package.
affects: >=1.0.0
gotchaThis package is explicitly limited to `db.json` database files. It does not support `db.zip` or `geodb` formats that might be available in other related Thai address database projects.
fix
Ensure your database operations and expectations align with the `db.json` format. If other formats are required, consider alternative libraries.
affects: >=1.0.0
gotchaThe database migration script (`npm run migrate`) strictly requires the input file to be named `database.xlsx` and saved in the Excel Workbook (.xlsx) format. Using an older `.xls` format or an incorrect filename will cause the migration to fail.
fix
Verify that your updated address data is saved as `database.xlsx` (specifically the Excel Workbook format) before running `npm run migrate`.
affects: >=1.0.0
gotchaThe package's database and `preprocess()` function are based on `jquery.Thailand.js` version 1.5.1. Future updates or breaking changes in the original `jquery.Thailand.js` project's database schema or logic may not be automatically reflected or compatible, potentially requiring manual updates to this custom database package.
fix
Be aware of potential data freshness or compatibility issues with newer versions of upstream data sources. Monitor the `thai-address-custom-database` repository for updates if upstream changes occur.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'thai-address-database'
The module was imported using the name 'thai-address-database' as seen in some documentation examples, but the actual package name is 'thai-address-custom-database'.
fix
Change your import statement from `import { ... } from 'thai-address-database'` to `import { ... } from 'thai-address-custom-database'`.
TypeError: searchAddressByDistrict is not a function
This error typically occurs when attempting to use CommonJS `require()` syntax with an ES Module, or if the named export is incorrect or not found.
fix
Ensure you are using ES Module `import { searchAddressByDistrict } from 'thai-address-custom-database';` in an environment configured for ESM. Verify the export name is correct.
Error: Input file must be 'database.xlsx' in .xlsx format.
When running `npm run migrate`, the script expects a specific Excel file named `database.xlsx` saved in the modern Excel Workbook format.
fix
Confirm that the address data spreadsheet is correctly named `database.xlsx` and saved with the .xlsx extension (not .xls) before executing `npm run migrate`.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
3
Resources