experiments: Extract mediawiki.hash class

Authored by phuedx on Jun 19 2017, 8:57 AM.


experiments: Extract mediawiki.hash class

mw.experiments uses a private implementation of the Jenkins
one-at-a-time hash function, whereas, say, the Resource Loader uses a
private implementation of the FNV-1 (32-bit) hash function [0]. The
FNV-1a hash function is also implemented separately in the Popups
extension [1].

Ideally, all three should use the same hash function and it should be
publicly available. To achieve these ends we'll:

  1. Extract the private implementations of both hash functions;
  2. Clarify the API, if necessary;
  3. Update mw.experiments and Popups to use a hash function provided by


This change is part of #1.

[0] https://github.com/wikimedia/mediawiki/blob/5604684b/resources/src/mediawiki/mediawiki.js#L24-L53
[1] https://github.com/wikimedia/mediawiki-extensions-Popups/blob/9ed1703c/src/changeListeners/eventLogging.js#L7-L29

Change-Id: Id2d5c4ac945a467d2beefbac9627ec99d35f7502