As discussed with Steven W. just now, we should move this into MW core (so, amongst other things, VisualEditor can depend on it and not have to re-invent the wheel).
Version: master
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=16066