Discard.js patch from msimerson