Ultra-fast Dutch postcode lookup with embedded data. This package provides lightning-fast postcode and address lookups for the Netherlands, with all data embedded directly in the native binary.
- Blazing Fast: Sub-millisecond lookup times using Finite State Transducers (FST)
- Self-Contained: All data embedded in the binary - no external files needed
- Tiny Footprint: Only ~4MB compressed data using brotli compression
- Memory Efficient: ~15MB RAM usage with intelligent data structures
- TypeScript Support: Full TypeScript definitions included
- Cross-Platform: Pre-built binaries for Windows, macOS, and Linux
npm install postrustconst { lookup } = require('postrust');
const result = lookup('1012AB', 1);
if (result) {
console.log(`${result.straat} ${result.huisnummer}, ${result.woonplaats}`);
// Output: Nieuwezijds Voorburgwal 1, Amsterdam
}import { lookup, LookupResult } from 'postrust';
const result: LookupResult | null = lookup('1012AB', 1);
if (result) {
console.log(`Found: ${result.postcode} - ${result.straat} ${result.huisnummer}, ${result.woonplaats}`);
}const { lookupBatch } = require('postrust');
const queries = [
['1012AB', 1],
['2000AA', 10],
['3000BB', 5]
];
const results = lookupBatch(queries);
results.forEach((result, i) => {
if (result) {
console.log(`${queries[i][0]} → ${result.straat} ${result.huisnummer}, ${result.woonplaats}`);
} else {
console.log(`${queries[i][0]} → Not found`);
}
});const { getInfo } = require('postrust');
console.log(getInfo());
// Output:
// postRUST NPM Package
// Memory usage: 14.75 MB
// Compressed data size: 3.94 MBLookup a single postcode and house number combination.
Parameters:
postcode- Dutch postcode (e.g., "1012AB")huisnummer- House number (e.g., 1)
Returns: LookupResult object or null if not found
Lookup multiple postcode/house number combinations in a single call.
Parameters:
queries- Array of[postcode, huisnummer]tuples
Returns: Array of LookupResult objects or null for each query
interface LookupResult {
postcode: string; // "1012AB"
straat: string; // "Nieuwezijds Voorburgwal"
huisnummer: number; // 1
woonplaats: string; // "Amsterdam"
}Get information about the loaded dataset and memory usage.
Initialize the package (called automatically when the module is loaded).
- Lookup Speed: Sub-millisecond response times
- Memory Usage: ~15MB RAM (data decompressed in memory)
- Binary Size: ~5MB (includes all data and dependencies)
- Data Compression: 73% reduction using brotli compression
- Cold Start: Near-instant (data already embedded)
This package uses several advanced techniques for optimal performance:
- Finite State Transducers (FST): Extremely efficient data structure for string lookups
- Delta Compression: House numbers are delta-compressed to save space
- Brotli Compression: All data is compressed with maximum brotli settings
- Native Code: Core logic implemented in Rust for maximum speed
- Embedded Data: No file I/O during runtime - everything is in memory
# Clone the repository
git clone https://github.com/your-username/postrust.git
cd postrust/postrust-npm
# Install dependencies
npm install
# Build the native module
npm run build
# Test
node test.jsThe postcode data is sourced from official Dutch postal databases and includes:
- All valid Dutch postcodes
- Street names and house numbers
- Municipality information
- Regular updates to ensure data accuracy
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Note: This package is optimized for server-side Node.js applications. For browser usage, consider using the REST API version instead due to the large data size.