When an algorithm derives a decision key (dedupe) or signal (parsed config) that can suppress/merge data, make that derivation collision- and normalization-safe, and define precedence explicitly.
Dedupe keys (avoid collision-based suppression):
import { createHash } from 'node:crypto'
export function imageDedupeKey(blob: Blob, data: Uint8Array): string {
// Collision-resistant key: hash actual bytes (optionally include size)
const digest = createHash('sha256').update(data).digest('hex')
return `${blob.size}|${digest}`
}
Parsed/merged config (normalize + deterministic precedence):
function hasAnyInheritedProxy(env: Record<string, string>, family: 'http'|'https') {
const keys = [
`${family}_proxy`,
`${family.toUpperCase()}_PROXY`
]
return keys.some(k => (env[k] ?? '').length > 0)
}
Why: these patterns prevent subtle, hard-to-debug behavior like “silent suppression” from hash collisions and inconsistent merging from incomplete normalization/precedence handling.