test color selection for debug

node v8.17.0
version: 1.0.0
endpointsharetweet
function selectColor(namespace, numColors) { var hash = 0, i; for (i in namespace) { hash = ((hash << 5) - hash) + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } return Math.abs(hash) % numColors; } var namespaceA = 'server:webpack:hot'; var namespaceB = 'server:webpack:dev'; for(var i = 256; i > 0; i--) { var a = selectColor(namespaceA, i); var b = selectColor(namespaceB, i); if (a === b) console.log(`found collision for ${i}`); }
Loading…

no comments

    sign in to comment