master
Raw Download raw file
 1/*
 2 *  Sugar ES6 Patch
 3 *
 4 *  This patch will restore Sugar methods that have been "underwritten"
 5 *  by new ES6 method implementations. This patch is only for versions
 6 *  below 1.4.0! If you are not sure if you need this, then it's likely
 7 *  you don't. Consider upgrading to 1.4.0 instead.
 8 *
 9 */
10(function() {
11
12  var SugarMethods = 'SugarMethods';
13
14  function restoreMethods(klass, method) {
15    var sugar   = klass[SugarMethods] && klass[SugarMethods][method];
16    var current = klass.prototype[method];
17    if(sugar && sugar !== current) {
18      klass.prototype[method] = sugar['method'];
19    }
20  }
21
22  restoreMethods(Array, 'find');
23  restoreMethods(Array, 'findIndex');
24  restoreMethods(String, 'repeat');
25  restoreMethods(String, 'normalize');
26
27})();