polyfills.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. /**
  8. * An AMD wrapper around generic polyfills
  9. */
  10. define([], function () {
  11. //bind polyfill from public domain
  12. //
  13. // "Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/".
  14. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FFunction%2Fbind#Compatibility
  15. //
  16. if (!Function.prototype.bind) {
  17. Function.prototype.bind = function (oThis) {
  18. if (typeof this !== 'function') {
  19. // closest thing possible to the ECMAScript 5 internal IsCallable function
  20. throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
  21. }
  22. var aArgs = Array.prototype.slice.call(arguments, 1),
  23. fToBind = this,
  24. fNOP = function fNOP() {},
  25. fBound = function fBound() {
  26. return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
  27. };
  28. fNOP.prototype = this.prototype;
  29. fBound.prototype = new fNOP();
  30. return fBound;
  31. };
  32. }
  33. return true;
  34. });
  35. //# sourceMappingURL=polyfills.js.map