UNPKG

t0n

Version:

Collection of elegant typescript resources for web artisans

11 lines (9 loc) 420 B
export function toInt(data: any[] | string | number): number { if (typeof data === 'number' && Number.isInteger(data)) return data const jsonString = JSON.stringify(data) // Simplified implementation without MD5 (less accurate than the original) // TODO: add o md5 and stable-hash const numericString = jsonString.replace(/\D/g, '') return numericString ? parseInt(numericString.slice(0, 16), 10) : 0 }