nehoid
Version:
Advanced unique ID generation utility with multi-layer encoding, collision detection, and context-aware features
48 lines • 1.73 kB
TypeScript
/**
* Utility methods for NehoID operations.
*
* This module provides helper functions for common ID-related tasks,
* including coordinate hashing for location-based privacy and other
* utility operations that support the core NehoID functionality.
*/
export declare class Utils {
/**
* Hashes geographic coordinates for privacy preservation.
*
* This method reduces the precision of latitude and longitude coordinates
* to protect user privacy while maintaining useful location-based grouping.
* The coordinates are rounded to one decimal place before hashing.
*
* @param latitude - The latitude coordinate (-90 to 90)
* @param longitude - The longitude coordinate (-180 to 180)
* @returns A compact base36 hash string representing the rounded coordinates
*
* @example
* ```typescript
* // Hash coordinates for location-based grouping
* const locationHash = Utils.hashCoordinates(37.7749, -122.4194);
* // Output: '2a3b1c' (example hash)
*
* // Use in ID generation for location-aware IDs
* const id = NehoID.generate({
* prefix: `loc-${locationHash}-`
* });
* ```
*
* @example
* ```typescript
* // Privacy-preserving location clustering
* const users = [
* { id: 1, lat: 37.7749, lng: -122.4194 },
* { id: 2, lat: 37.7750, lng: -122.4195 } // Very close location
* ];
*
* const clusters = users.map(user =>
* Utils.hashCoordinates(user.lat, user.lng)
* );
* // Both users will have the same hash due to rounding
* ```
*/
static hashCoordinates(latitude: number, longitude: number): string;
}
//# sourceMappingURL=utils.d.ts.map