web/res/js/videojs/ie8/videojs-ie8.js
author Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Mon, 12 Dec 2016 01:54:10 +0100
changeset 1368 0ae5202742bd
permissions -rw-r--r--
change flash to dash
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1368
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     1
/**
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     2
 * HTML5 Element Shim for IE8
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     3
 *
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     4
 * **THIS CODE MUST BE LOADED IN THE <HEAD> OF THE DOCUMENT**
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     5
 *
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     6
 * Video.js uses the video tag as an embed code, even in IE8 which
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     7
 * doesn't have support for HTML5 video. The following code is needed
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     8
 * to make it possible to use the video tag. Otherwise IE8 ignores everything
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     9
 * inside the video tag.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    10
 */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    11
if (typeof window.HTMLVideoElement === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    12
  document.createElement('video');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    13
  document.createElement('audio');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    14
  document.createElement('track');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    15
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    16
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    17
/*!
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    18
 * https://github.com/es-shims/es5-shim
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    19
 * @license es5-shim Copyright 2009-2015 by contributors, MIT License
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    20
 * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    21
 */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    22
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    23
// vim: ts=4 sts=4 sw=4 expandtab
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    24
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    25
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    26
;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    27
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    28
// UMD (Universal Module Definition)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    29
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    30
(function (root, factory) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    31
    'use strict';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    32
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    33
    /* global define, exports, module */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    34
    if (typeof define === 'function' && define.amd) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    35
        // AMD. Register as an anonymous module.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    36
        define(factory);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    37
    } else if (typeof exports === 'object') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    38
        // Node. Does not work with strict CommonJS, but
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    39
        // only CommonJS-like enviroments that support module.exports,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    40
        // like Node.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    41
        module.exports = factory();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    42
    } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    43
        // Browser globals (root is window)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    44
        root.returnExports = factory();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    45
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    46
}(this, function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    47
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    48
/**
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    49
 * Brings an environment as close to ECMAScript 5 compliance
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    50
 * as is possible with the facilities of erstwhile engines.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    51
 *
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    52
 * Annotated ES5: http://es5.github.com/ (specific links below)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    53
 * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    54
 * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    55
 */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    56
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    57
// Shortcut to an often accessed properties, in order to avoid multiple
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    58
// dereference that costs universally. This also holds a reference to known-good
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    59
// functions.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    60
var $Array = Array;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    61
var ArrayPrototype = $Array.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    62
var $Object = Object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    63
var ObjectPrototype = $Object.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    64
var FunctionPrototype = Function.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    65
var $String = String;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    66
var StringPrototype = $String.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    67
var $Number = Number;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    68
var NumberPrototype = $Number.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    69
var array_slice = ArrayPrototype.slice;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    70
var array_splice = ArrayPrototype.splice;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    71
var array_push = ArrayPrototype.push;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    72
var array_unshift = ArrayPrototype.unshift;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    73
var array_concat = ArrayPrototype.concat;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    74
var call = FunctionPrototype.call;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    75
var apply = FunctionPrototype.apply;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    76
var max = Math.max;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    77
var min = Math.min;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    78
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    79
// Having a toString local variable name breaks in Opera so use to_string.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    80
var to_string = ObjectPrototype.toString;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    81
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    82
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    83
var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    84
var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    85
var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    86
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    87
/* inlined from http://npmjs.com/define-properties */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    88
var supportsDescriptors = $Object.defineProperty && (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    89
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    90
        var obj = {};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    91
        $Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    92
        for (var _ in obj) { return false; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    93
        return obj.x === obj;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    94
    } catch (e) { /* this is ES3 */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    95
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    96
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    97
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    98
var defineProperties = (function (has) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    99
  // Define configurable, writable, and non-enumerable props
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   100
  // if they don't exist.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   101
  var defineProperty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   102
  if (supportsDescriptors) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   103
      defineProperty = function (object, name, method, forceAssign) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   104
          if (!forceAssign && (name in object)) { return; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   105
          $Object.defineProperty(object, name, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   106
              configurable: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   107
              enumerable: false,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   108
              writable: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   109
              value: method
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   110
          });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   111
      };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   112
  } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   113
      defineProperty = function (object, name, method, forceAssign) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   114
          if (!forceAssign && (name in object)) { return; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   115
          object[name] = method;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   116
      };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   117
  }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   118
  return function defineProperties(object, map, forceAssign) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   119
      for (var name in map) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   120
          if (has.call(map, name)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   121
            defineProperty(object, name, map[name], forceAssign);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   122
          }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   123
      }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   124
  };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   125
}(ObjectPrototype.hasOwnProperty));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   126
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   127
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   128
// Util
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   129
// ======
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   130
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   131
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   132
/* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   133
var isPrimitive = function isPrimitive(input) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   134
    var type = typeof input;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   135
    return input === null || (type !== 'object' && type !== 'function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   136
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   137
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   138
var isActualNaN = $Number.isNaN || function (x) { return x !== x; };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   139
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   140
var ES = {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   141
    // ES5 9.4
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   142
    // http://es5.github.com/#x9.4
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   143
    // http://jsperf.com/to-integer
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   144
    /* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   145
    ToInteger: function ToInteger(num) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   146
        var n = +num;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   147
        if (isActualNaN(n)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   148
            n = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   149
        } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   150
            n = (n > 0 || -1) * Math.floor(Math.abs(n));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   151
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   152
        return n;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   153
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   154
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   155
    /* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   156
    ToPrimitive: function ToPrimitive(input) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   157
        var val, valueOf, toStr;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   158
        if (isPrimitive(input)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   159
            return input;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   160
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   161
        valueOf = input.valueOf;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   162
        if (isCallable(valueOf)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   163
            val = valueOf.call(input);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   164
            if (isPrimitive(val)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   165
                return val;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   166
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   167
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   168
        toStr = input.toString;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   169
        if (isCallable(toStr)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   170
            val = toStr.call(input);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   171
            if (isPrimitive(val)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   172
                return val;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   173
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   174
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   175
        throw new TypeError();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   176
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   177
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   178
    // ES5 9.9
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   179
    // http://es5.github.com/#x9.9
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   180
    /* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   181
    ToObject: function (o) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   182
        if (o == null) { // this matches both null and undefined
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   183
            throw new TypeError("can't convert " + o + ' to object');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   184
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   185
        return $Object(o);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   186
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   187
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   188
    /* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   189
    ToUint32: function ToUint32(x) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   190
        return x >>> 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   191
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   192
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   193
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   194
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   195
// Function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   196
// ========
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   197
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   198
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   199
// ES-5 15.3.4.5
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   200
// http://es5.github.com/#x15.3.4.5
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   201
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   202
var Empty = function Empty() {};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   203
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   204
defineProperties(FunctionPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   205
    bind: function bind(that) { // .length is 1
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   206
        // 1. Let Target be the this value.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   207
        var target = this;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   208
        // 2. If IsCallable(Target) is false, throw a TypeError exception.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   209
        if (!isCallable(target)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   210
            throw new TypeError('Function.prototype.bind called on incompatible ' + target);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   211
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   212
        // 3. Let A be a new (possibly empty) internal list of all of the
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   213
        //   argument values provided after thisArg (arg1, arg2 etc), in order.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   214
        // XXX slicedArgs will stand in for "A" if used
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   215
        var args = array_slice.call(arguments, 1); // for normal call
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   216
        // 4. Let F be a new native ECMAScript object.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   217
        // 11. Set the [[Prototype]] internal property of F to the standard
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   218
        //   built-in Function prototype object as specified in 15.3.3.1.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   219
        // 12. Set the [[Call]] internal property of F as described in
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   220
        //   15.3.4.5.1.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   221
        // 13. Set the [[Construct]] internal property of F as described in
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   222
        //   15.3.4.5.2.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   223
        // 14. Set the [[HasInstance]] internal property of F as described in
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   224
        //   15.3.4.5.3.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   225
        var bound;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   226
        var binder = function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   227
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   228
            if (this instanceof bound) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   229
                // 15.3.4.5.2 [[Construct]]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   230
                // When the [[Construct]] internal method of a function object,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   231
                // F that was created using the bind function is called with a
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   232
                // list of arguments ExtraArgs, the following steps are taken:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   233
                // 1. Let target be the value of F's [[TargetFunction]]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   234
                //   internal property.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   235
                // 2. If target has no [[Construct]] internal method, a
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   236
                //   TypeError exception is thrown.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   237
                // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   238
                //   property.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   239
                // 4. Let args be a new list containing the same values as the
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   240
                //   list boundArgs in the same order followed by the same
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   241
                //   values as the list ExtraArgs in the same order.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   242
                // 5. Return the result of calling the [[Construct]] internal
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   243
                //   method of target providing args as the arguments.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   244
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   245
                var result = target.apply(
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   246
                    this,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   247
                    array_concat.call(args, array_slice.call(arguments))
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   248
                );
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   249
                if ($Object(result) === result) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   250
                    return result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   251
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   252
                return this;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   253
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   254
            } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   255
                // 15.3.4.5.1 [[Call]]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   256
                // When the [[Call]] internal method of a function object, F,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   257
                // which was created using the bind function is called with a
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   258
                // this value and a list of arguments ExtraArgs, the following
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   259
                // steps are taken:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   260
                // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   261
                //   property.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   262
                // 2. Let boundThis be the value of F's [[BoundThis]] internal
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   263
                //   property.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   264
                // 3. Let target be the value of F's [[TargetFunction]] internal
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   265
                //   property.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   266
                // 4. Let args be a new list containing the same values as the
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   267
                //   list boundArgs in the same order followed by the same
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   268
                //   values as the list ExtraArgs in the same order.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   269
                // 5. Return the result of calling the [[Call]] internal method
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   270
                //   of target providing boundThis as the this value and
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   271
                //   providing args as the arguments.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   272
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   273
                // equiv: target.call(this, ...boundArgs, ...args)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   274
                return target.apply(
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   275
                    that,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   276
                    array_concat.call(args, array_slice.call(arguments))
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   277
                );
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   278
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   279
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   280
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   281
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   282
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   283
        // 15. If the [[Class]] internal property of Target is "Function", then
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   284
        //     a. Let L be the length property of Target minus the length of A.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   285
        //     b. Set the length own property of F to either 0 or L, whichever is
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   286
        //       larger.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   287
        // 16. Else set the length own property of F to 0.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   288
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   289
        var boundLength = max(0, target.length - args.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   290
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   291
        // 17. Set the attributes of the length own property of F to the values
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   292
        //   specified in 15.3.5.1.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   293
        var boundArgs = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   294
        for (var i = 0; i < boundLength; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   295
            array_push.call(boundArgs, '$' + i);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   296
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   297
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   298
        // XXX Build a dynamic function with desired amount of arguments is the only
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   299
        // way to set the length property of a function.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   300
        // In environments where Content Security Policies enabled (Chrome extensions,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   301
        // for ex.) all use of eval or Function costructor throws an exception.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   302
        // However in all of these environments Function.prototype.bind exists
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   303
        // and so this code will never be executed.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   304
        bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   305
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   306
        if (target.prototype) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   307
            Empty.prototype = target.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   308
            bound.prototype = new Empty();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   309
            // Clean up dangling references.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   310
            Empty.prototype = null;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   311
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   312
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   313
        // TODO
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   314
        // 18. Set the [[Extensible]] internal property of F to true.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   315
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   316
        // TODO
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   317
        // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   318
        // 20. Call the [[DefineOwnProperty]] internal method of F with
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   319
        //   arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   320
        //   thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   321
        //   false.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   322
        // 21. Call the [[DefineOwnProperty]] internal method of F with
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   323
        //   arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   324
        //   [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   325
        //   and false.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   326
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   327
        // TODO
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   328
        // NOTE Function objects created using Function.prototype.bind do not
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   329
        // have a prototype property or the [[Code]], [[FormalParameters]], and
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   330
        // [[Scope]] internal properties.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   331
        // XXX can't delete prototype in pure-js.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   332
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   333
        // 22. Return F.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   334
        return bound;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   335
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   336
});
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   337
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   338
// _Please note: Shortcuts are defined after `Function.prototype.bind` as we
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   339
// use it in defining shortcuts.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   340
var owns = call.bind(ObjectPrototype.hasOwnProperty);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   341
var toStr = call.bind(ObjectPrototype.toString);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   342
var arraySlice = call.bind(array_slice);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   343
var arraySliceApply = apply.bind(array_slice);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   344
var strSlice = call.bind(StringPrototype.slice);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   345
var strSplit = call.bind(StringPrototype.split);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   346
var strIndexOf = call.bind(StringPrototype.indexOf);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   347
var pushCall = call.bind(array_push);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   348
var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   349
var arraySort = call.bind(ArrayPrototype.sort);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   350
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   351
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   352
// Array
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   353
// =====
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   354
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   355
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   356
var isArray = $Array.isArray || function isArray(obj) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   357
    return toStr(obj) === '[object Array]';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   358
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   359
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   360
// ES5 15.4.4.12
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   361
// http://es5.github.com/#x15.4.4.13
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   362
// Return len+argCount.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   363
// [bugfix, ielt8]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   364
// IE < 8 bug: [].unshift(0) === undefined but should be "1"
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   365
var hasUnshiftReturnValueBug = [].unshift(0) !== 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   366
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   367
    unshift: function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   368
        array_unshift.apply(this, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   369
        return this.length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   370
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   371
}, hasUnshiftReturnValueBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   372
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   373
// ES5 15.4.3.2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   374
// http://es5.github.com/#x15.4.3.2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   375
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   376
defineProperties($Array, { isArray: isArray });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   377
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   378
// The IsCallable() check in the Array functions
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   379
// has been replaced with a strict check on the
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   380
// internal class of the object to trap cases where
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   381
// the provided function was actually a regular
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   382
// expression literal, which in V8 and
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   383
// JavaScriptCore is a typeof "function".  Only in
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   384
// V8 are regular expression literals permitted as
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   385
// reduce parameters, so it is desirable in the
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   386
// general case for the shim to match the more
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   387
// strict and common behavior of rejecting regular
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   388
// expressions.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   389
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   390
// ES5 15.4.4.18
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   391
// http://es5.github.com/#x15.4.4.18
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   392
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   393
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   394
// Check failure of by-index access of string characters (IE < 9)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   395
// and failure of `0 in boxedString` (Rhino)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   396
var boxedString = $Object('a');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   397
var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   398
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   399
var properlyBoxesContext = function properlyBoxed(method) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   400
    // Check node 0.6.21 bug where third parameter is not boxed
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   401
    var properlyBoxesNonStrict = true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   402
    var properlyBoxesStrict = true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   403
    var threwException = false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   404
    if (method) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   405
        try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   406
            method.call('foo', function (_, __, context) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   407
                if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   408
            });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   409
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   410
            method.call([1], function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   411
                'use strict';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   412
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   413
                properlyBoxesStrict = typeof this === 'string';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   414
            }, 'x');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   415
        } catch (e) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   416
            threwException = true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   417
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   418
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   419
    return !!method && !threwException && properlyBoxesNonStrict && properlyBoxesStrict;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   420
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   421
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   422
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   423
    forEach: function forEach(callbackfn/*, thisArg*/) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   424
        var object = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   425
        var self = splitString && isString(this) ? strSplit(this, '') : object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   426
        var i = -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   427
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   428
        var T;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   429
        if (arguments.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   430
          T = arguments[1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   431
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   432
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   433
        // If no callback function or if callback is not a callable function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   434
        if (!isCallable(callbackfn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   435
            throw new TypeError('Array.prototype.forEach callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   436
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   437
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   438
        while (++i < length) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   439
            if (i in self) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   440
                // Invoke the callback function with call, passing arguments:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   441
                // context, property value, property key, thisArg object
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   442
                if (typeof T === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   443
                    callbackfn(self[i], i, object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   444
                } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   445
                    callbackfn.call(T, self[i], i, object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   446
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   447
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   448
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   449
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   450
}, !properlyBoxesContext(ArrayPrototype.forEach));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   451
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   452
// ES5 15.4.4.19
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   453
// http://es5.github.com/#x15.4.4.19
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   454
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   455
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   456
    map: function map(callbackfn/*, thisArg*/) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   457
        var object = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   458
        var self = splitString && isString(this) ? strSplit(this, '') : object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   459
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   460
        var result = $Array(length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   461
        var T;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   462
        if (arguments.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   463
            T = arguments[1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   464
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   465
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   466
        // If no callback function or if callback is not a callable function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   467
        if (!isCallable(callbackfn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   468
            throw new TypeError('Array.prototype.map callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   469
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   470
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   471
        for (var i = 0; i < length; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   472
            if (i in self) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   473
                if (typeof T === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   474
                    result[i] = callbackfn(self[i], i, object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   475
                } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   476
                    result[i] = callbackfn.call(T, self[i], i, object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   477
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   478
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   479
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   480
        return result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   481
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   482
}, !properlyBoxesContext(ArrayPrototype.map));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   483
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   484
// ES5 15.4.4.20
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   485
// http://es5.github.com/#x15.4.4.20
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   486
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   487
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   488
    filter: function filter(callbackfn/*, thisArg*/) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   489
        var object = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   490
        var self = splitString && isString(this) ? strSplit(this, '') : object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   491
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   492
        var result = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   493
        var value;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   494
        var T;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   495
        if (arguments.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   496
            T = arguments[1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   497
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   498
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   499
        // If no callback function or if callback is not a callable function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   500
        if (!isCallable(callbackfn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   501
            throw new TypeError('Array.prototype.filter callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   502
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   503
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   504
        for (var i = 0; i < length; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   505
            if (i in self) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   506
                value = self[i];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   507
                if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   508
                    pushCall(result, value);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   509
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   510
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   511
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   512
        return result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   513
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   514
}, !properlyBoxesContext(ArrayPrototype.filter));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   515
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   516
// ES5 15.4.4.16
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   517
// http://es5.github.com/#x15.4.4.16
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   518
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   519
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   520
    every: function every(callbackfn/*, thisArg*/) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   521
        var object = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   522
        var self = splitString && isString(this) ? strSplit(this, '') : object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   523
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   524
        var T;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   525
        if (arguments.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   526
            T = arguments[1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   527
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   528
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   529
        // If no callback function or if callback is not a callable function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   530
        if (!isCallable(callbackfn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   531
            throw new TypeError('Array.prototype.every callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   532
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   533
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   534
        for (var i = 0; i < length; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   535
            if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   536
                return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   537
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   538
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   539
        return true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   540
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   541
}, !properlyBoxesContext(ArrayPrototype.every));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   542
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   543
// ES5 15.4.4.17
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   544
// http://es5.github.com/#x15.4.4.17
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   545
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   546
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   547
    some: function some(callbackfn/*, thisArg */) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   548
        var object = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   549
        var self = splitString && isString(this) ? strSplit(this, '') : object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   550
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   551
        var T;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   552
        if (arguments.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   553
            T = arguments[1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   554
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   555
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   556
        // If no callback function or if callback is not a callable function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   557
        if (!isCallable(callbackfn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   558
            throw new TypeError('Array.prototype.some callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   559
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   560
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   561
        for (var i = 0; i < length; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   562
            if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   563
                return true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   564
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   565
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   566
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   567
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   568
}, !properlyBoxesContext(ArrayPrototype.some));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   569
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   570
// ES5 15.4.4.21
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   571
// http://es5.github.com/#x15.4.4.21
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   572
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   573
var reduceCoercesToObject = false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   574
if (ArrayPrototype.reduce) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   575
    reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   576
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   577
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   578
    reduce: function reduce(callbackfn/*, initialValue*/) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   579
        var object = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   580
        var self = splitString && isString(this) ? strSplit(this, '') : object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   581
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   582
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   583
        // If no callback function or if callback is not a callable function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   584
        if (!isCallable(callbackfn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   585
            throw new TypeError('Array.prototype.reduce callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   586
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   587
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   588
        // no value to return if no initial value and an empty array
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   589
        if (length === 0 && arguments.length === 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   590
            throw new TypeError('reduce of empty array with no initial value');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   591
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   592
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   593
        var i = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   594
        var result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   595
        if (arguments.length >= 2) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   596
            result = arguments[1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   597
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   598
            do {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   599
                if (i in self) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   600
                    result = self[i++];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   601
                    break;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   602
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   603
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   604
                // if array contains no values, no initial value to return
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   605
                if (++i >= length) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   606
                    throw new TypeError('reduce of empty array with no initial value');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   607
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   608
            } while (true);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   609
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   610
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   611
        for (; i < length; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   612
            if (i in self) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   613
                result = callbackfn(result, self[i], i, object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   614
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   615
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   616
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   617
        return result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   618
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   619
}, !reduceCoercesToObject);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   620
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   621
// ES5 15.4.4.22
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   622
// http://es5.github.com/#x15.4.4.22
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   623
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   624
var reduceRightCoercesToObject = false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   625
if (ArrayPrototype.reduceRight) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   626
    reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   627
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   628
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   629
    reduceRight: function reduceRight(callbackfn/*, initial*/) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   630
        var object = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   631
        var self = splitString && isString(this) ? strSplit(this, '') : object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   632
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   633
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   634
        // If no callback function or if callback is not a callable function
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   635
        if (!isCallable(callbackfn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   636
            throw new TypeError('Array.prototype.reduceRight callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   637
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   638
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   639
        // no value to return if no initial value, empty array
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   640
        if (length === 0 && arguments.length === 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   641
            throw new TypeError('reduceRight of empty array with no initial value');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   642
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   643
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   644
        var result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   645
        var i = length - 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   646
        if (arguments.length >= 2) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   647
            result = arguments[1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   648
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   649
            do {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   650
                if (i in self) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   651
                    result = self[i--];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   652
                    break;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   653
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   654
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   655
                // if array contains no values, no initial value to return
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   656
                if (--i < 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   657
                    throw new TypeError('reduceRight of empty array with no initial value');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   658
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   659
            } while (true);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   660
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   661
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   662
        if (i < 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   663
            return result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   664
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   665
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   666
        do {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   667
            if (i in self) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   668
                result = callbackfn(result, self[i], i, object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   669
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   670
        } while (i--);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   671
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   672
        return result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   673
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   674
}, !reduceRightCoercesToObject);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   675
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   676
// ES5 15.4.4.14
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   677
// http://es5.github.com/#x15.4.4.14
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   678
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   679
var hasFirefox2IndexOfBug = ArrayPrototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   680
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   681
    indexOf: function indexOf(searchElement/*, fromIndex */) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   682
        var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   683
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   684
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   685
        if (length === 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   686
            return -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   687
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   688
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   689
        var i = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   690
        if (arguments.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   691
            i = ES.ToInteger(arguments[1]);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   692
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   693
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   694
        // handle negative indices
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   695
        i = i >= 0 ? i : max(0, length + i);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   696
        for (; i < length; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   697
            if (i in self && self[i] === searchElement) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   698
                return i;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   699
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   700
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   701
        return -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   702
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   703
}, hasFirefox2IndexOfBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   704
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   705
// ES5 15.4.4.15
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   706
// http://es5.github.com/#x15.4.4.15
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   707
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   708
var hasFirefox2LastIndexOfBug = ArrayPrototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   709
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   710
    lastIndexOf: function lastIndexOf(searchElement/*, fromIndex */) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   711
        var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   712
        var length = ES.ToUint32(self.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   713
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   714
        if (length === 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   715
            return -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   716
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   717
        var i = length - 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   718
        if (arguments.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   719
            i = min(i, ES.ToInteger(arguments[1]));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   720
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   721
        // handle negative indices
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   722
        i = i >= 0 ? i : length - Math.abs(i);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   723
        for (; i >= 0; i--) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   724
            if (i in self && searchElement === self[i]) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   725
                return i;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   726
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   727
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   728
        return -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   729
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   730
}, hasFirefox2LastIndexOfBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   731
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   732
// ES5 15.4.4.12
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   733
// http://es5.github.com/#x15.4.4.12
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   734
var spliceNoopReturnsEmptyArray = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   735
    var a = [1, 2];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   736
    var result = a.splice();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   737
    return a.length === 2 && isArray(result) && result.length === 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   738
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   739
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   740
    // Safari 5.0 bug where .splice() returns undefined
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   741
    splice: function splice(start, deleteCount) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   742
        if (arguments.length === 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   743
            return [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   744
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   745
            return array_splice.apply(this, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   746
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   747
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   748
}, !spliceNoopReturnsEmptyArray);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   749
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   750
var spliceWorksWithEmptyObject = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   751
    var obj = {};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   752
    ArrayPrototype.splice.call(obj, 0, 0, 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   753
    return obj.length === 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   754
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   755
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   756
    splice: function splice(start, deleteCount) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   757
        if (arguments.length === 0) { return []; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   758
        var args = arguments;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   759
        this.length = max(ES.ToInteger(this.length), 0);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   760
        if (arguments.length > 0 && typeof deleteCount !== 'number') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   761
            args = arraySlice(arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   762
            if (args.length < 2) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   763
                pushCall(args, this.length - start);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   764
            } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   765
                args[1] = ES.ToInteger(deleteCount);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   766
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   767
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   768
        return array_splice.apply(this, args);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   769
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   770
}, !spliceWorksWithEmptyObject);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   771
var spliceWorksWithLargeSparseArrays = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   772
    // Per https://github.com/es-shims/es5-shim/issues/295
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   773
    // Safari 7/8 breaks with sparse arrays of size 1e5 or greater
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   774
    var arr = new $Array(1e5);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   775
    // note: the index MUST be 8 or larger or the test will false pass
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   776
    arr[8] = 'x';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   777
    arr.splice(1, 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   778
    // note: this test must be defined *after* the indexOf shim
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   779
    // per https://github.com/es-shims/es5-shim/issues/313
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   780
    return arr.indexOf('x') === 7;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   781
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   782
var spliceWorksWithSmallSparseArrays = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   783
    // Per https://github.com/es-shims/es5-shim/issues/295
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   784
    // Opera 12.15 breaks on this, no idea why.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   785
    var n = 256;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   786
    var arr = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   787
    arr[n] = 'a';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   788
    arr.splice(n + 1, 0, 'b');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   789
    return arr[n] === 'a';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   790
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   791
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   792
    splice: function splice(start, deleteCount) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   793
        var O = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   794
        var A = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   795
        var len = ES.ToUint32(O.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   796
        var relativeStart = ES.ToInteger(start);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   797
        var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   798
        var actualDeleteCount = min(max(ES.ToInteger(deleteCount), 0), len - actualStart);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   799
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   800
        var k = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   801
        var from;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   802
        while (k < actualDeleteCount) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   803
            from = $String(actualStart + k);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   804
            if (owns(O, from)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   805
                A[k] = O[from];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   806
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   807
            k += 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   808
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   809
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   810
        var items = arraySlice(arguments, 2);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   811
        var itemCount = items.length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   812
        var to;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   813
        if (itemCount < actualDeleteCount) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   814
            k = actualStart;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   815
            while (k < (len - actualDeleteCount)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   816
                from = $String(k + actualDeleteCount);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   817
                to = $String(k + itemCount);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   818
                if (owns(O, from)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   819
                    O[to] = O[from];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   820
                } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   821
                    delete O[to];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   822
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   823
                k += 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   824
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   825
            k = len;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   826
            while (k > (len - actualDeleteCount + itemCount)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   827
                delete O[k - 1];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   828
                k -= 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   829
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   830
        } else if (itemCount > actualDeleteCount) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   831
            k = len - actualDeleteCount;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   832
            while (k > actualStart) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   833
                from = $String(k + actualDeleteCount - 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   834
                to = $String(k + itemCount - 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   835
                if (owns(O, from)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   836
                    O[to] = O[from];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   837
                } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   838
                    delete O[to];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   839
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   840
                k -= 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   841
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   842
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   843
        k = actualStart;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   844
        for (var i = 0; i < items.length; ++i) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   845
            O[k] = items[i];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   846
            k += 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   847
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   848
        O.length = len - actualDeleteCount + itemCount;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   849
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   850
        return A;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   851
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   852
}, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   853
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   854
var originalJoin = ArrayPrototype.join;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   855
var hasStringJoinBug;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   856
try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   857
    hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   858
} catch (e) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   859
    hasStringJoinBug = true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   860
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   861
if (hasStringJoinBug) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   862
    defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   863
        join: function join(separator) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   864
            var sep = typeof separator === 'undefined' ? ',' : separator;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   865
            return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   866
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   867
    }, hasStringJoinBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   868
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   869
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   870
var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   871
if (hasJoinUndefinedBug) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   872
    defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   873
        join: function join(separator) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   874
            var sep = typeof separator === 'undefined' ? ',' : separator;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   875
            return originalJoin.call(this, sep);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   876
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   877
    }, hasJoinUndefinedBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   878
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   879
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   880
var pushShim = function push(item) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   881
    var O = ES.ToObject(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   882
    var n = ES.ToUint32(O.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   883
    var i = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   884
    while (i < arguments.length) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   885
        O[n + i] = arguments[i];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   886
        i += 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   887
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   888
    O.length = n + i;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   889
    return n + i;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   890
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   891
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   892
var pushIsNotGeneric = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   893
    var obj = {};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   894
    var result = Array.prototype.push.call(obj, undefined);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   895
    return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   896
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   897
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   898
    push: function push(item) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   899
        if (isArray(this)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   900
            return array_push.apply(this, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   901
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   902
        return pushShim.apply(this, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   903
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   904
}, pushIsNotGeneric);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   905
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   906
// This fixes a very weird bug in Opera 10.6 when pushing `undefined
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   907
var pushUndefinedIsWeird = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   908
    var arr = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   909
    var result = arr.push(undefined);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   910
    return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   911
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   912
defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   913
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   914
// ES5 15.2.3.14
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   915
// http://es5.github.io/#x15.4.4.10
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   916
// Fix boxed string bug
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   917
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   918
    slice: function (start, end) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   919
        var arr = isString(this) ? strSplit(this, '') : this;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   920
        return arraySliceApply(arr, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   921
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   922
}, splitString);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   923
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   924
var sortIgnoresNonFunctions = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   925
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   926
        [1, 2].sort(null);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   927
        [1, 2].sort({});
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   928
        return true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   929
    } catch (e) { /**/ }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   930
    return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   931
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   932
var sortThrowsOnRegex = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   933
    // this is a problem in Firefox 4, in which `typeof /a/ === 'function'`
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   934
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   935
        [1, 2].sort(/a/);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   936
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   937
    } catch (e) { /**/ }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   938
    return true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   939
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   940
var sortIgnoresUndefined = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   941
    // applies in IE 8, for one.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   942
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   943
        [1, 2].sort(undefined);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   944
        return true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   945
    } catch (e) { /**/ }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   946
    return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   947
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   948
defineProperties(ArrayPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   949
    sort: function sort(compareFn) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   950
        if (typeof compareFn === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   951
            return arraySort(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   952
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   953
        if (!isCallable(compareFn)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   954
            throw new TypeError('Array.prototype.sort callback must be a function');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   955
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   956
        return arraySort(this, compareFn);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   957
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   958
}, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   959
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   960
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   961
// Object
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   962
// ======
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   963
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   964
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   965
// ES5 15.2.3.14
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   966
// http://es5.github.com/#x15.2.3.14
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   967
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   968
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   969
var hasDontEnumBug = !({ 'toString': null }).propertyIsEnumerable('toString');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   970
var hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   971
var hasStringEnumBug = !owns('x', '0');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   972
var equalsConstructorPrototype = function (o) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   973
    var ctor = o.constructor;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   974
    return ctor && ctor.prototype === o;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   975
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   976
var blacklistedKeys = {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   977
    $window: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   978
    $console: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   979
    $parent: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   980
    $self: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   981
    $frame: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   982
    $frames: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   983
    $frameElement: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   984
    $webkitIndexedDB: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   985
    $webkitStorageInfo: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   986
    $external: true
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   987
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   988
var hasAutomationEqualityBug = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   989
    /* globals window */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   990
    if (typeof window === 'undefined') { return false; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   991
    for (var k in window) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   992
        try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   993
            if (!blacklistedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   994
                equalsConstructorPrototype(window[k]);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   995
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   996
        } catch (e) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   997
            return true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   998
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   999
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1000
    return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1001
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1002
var equalsConstructorPrototypeIfNotBuggy = function (object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1003
    if (typeof window === 'undefined' || !hasAutomationEqualityBug) { return equalsConstructorPrototype(object); }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1004
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1005
        return equalsConstructorPrototype(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1006
    } catch (e) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1007
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1008
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1009
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1010
var dontEnums = [
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1011
    'toString',
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1012
    'toLocaleString',
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1013
    'valueOf',
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1014
    'hasOwnProperty',
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1015
    'isPrototypeOf',
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1016
    'propertyIsEnumerable',
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1017
    'constructor'
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1018
];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1019
var dontEnumsLength = dontEnums.length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1020
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1021
// taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1022
// can be replaced with require('is-arguments') if we ever use a build process instead
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1023
var isStandardArguments = function isArguments(value) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1024
    return toStr(value) === '[object Arguments]';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1025
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1026
var isLegacyArguments = function isArguments(value) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1027
    return value !== null &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1028
        typeof value === 'object' &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1029
        typeof value.length === 'number' &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1030
        value.length >= 0 &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1031
        !isArray(value) &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1032
        isCallable(value.callee);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1033
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1034
var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1035
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1036
defineProperties($Object, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1037
    keys: function keys(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1038
        var isFn = isCallable(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1039
        var isArgs = isArguments(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1040
        var isObject = object !== null && typeof object === 'object';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1041
        var isStr = isObject && isString(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1042
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1043
        if (!isObject && !isFn && !isArgs) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1044
            throw new TypeError('Object.keys called on a non-object');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1045
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1046
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1047
        var theKeys = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1048
        var skipProto = hasProtoEnumBug && isFn;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1049
        if ((isStr && hasStringEnumBug) || isArgs) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1050
            for (var i = 0; i < object.length; ++i) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1051
                pushCall(theKeys, $String(i));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1052
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1053
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1054
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1055
        if (!isArgs) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1056
            for (var name in object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1057
                if (!(skipProto && name === 'prototype') && owns(object, name)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1058
                    pushCall(theKeys, $String(name));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1059
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1060
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1061
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1062
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1063
        if (hasDontEnumBug) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1064
            var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1065
            for (var j = 0; j < dontEnumsLength; j++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1066
                var dontEnum = dontEnums[j];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1067
                if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1068
                    pushCall(theKeys, dontEnum);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1069
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1070
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1071
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1072
        return theKeys;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1073
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1074
});
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1075
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1076
var keysWorksWithArguments = $Object.keys && (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1077
    // Safari 5.0 bug
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1078
    return $Object.keys(arguments).length === 2;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1079
}(1, 2));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1080
var keysHasArgumentsLengthBug = $Object.keys && (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1081
    var argKeys = $Object.keys(arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1082
    return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1083
}(1));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1084
var originalKeys = $Object.keys;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1085
defineProperties($Object, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1086
    keys: function keys(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1087
        if (isArguments(object)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1088
            return originalKeys(arraySlice(object));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1089
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1090
            return originalKeys(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1091
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1092
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1093
}, !keysWorksWithArguments || keysHasArgumentsLengthBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1094
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1095
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1096
// Date
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1097
// ====
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1098
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1099
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1100
var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1101
var aNegativeTestDate = new Date(-1509842289600292);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1102
var aPositiveTestDate = new Date(1449662400000);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1103
var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1104
var hasToDateStringFormatBug;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1105
var hasToStringFormatBug;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1106
var timeZoneOffset = aNegativeTestDate.getTimezoneOffset();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1107
if (timeZoneOffset < -720) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1108
    hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1109
    hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1110
} else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1111
    hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1112
    hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1113
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1114
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1115
var originalGetFullYear = call.bind(Date.prototype.getFullYear);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1116
var originalGetMonth = call.bind(Date.prototype.getMonth);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1117
var originalGetDate = call.bind(Date.prototype.getDate);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1118
var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1119
var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1120
var originalGetUTCDate = call.bind(Date.prototype.getUTCDate);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1121
var originalGetUTCDay = call.bind(Date.prototype.getUTCDay);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1122
var originalGetUTCHours = call.bind(Date.prototype.getUTCHours);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1123
var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1124
var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1125
var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1126
var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1127
var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1128
var daysInMonth = function daysInMonth(month, year) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1129
    return originalGetDate(new Date(year, month, 0));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1130
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1131
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1132
defineProperties(Date.prototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1133
    getFullYear: function getFullYear() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1134
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1135
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1136
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1137
        var year = originalGetFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1138
        if (year < 0 && originalGetMonth(this) > 11) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1139
            return year + 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1140
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1141
        return year;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1142
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1143
    getMonth: function getMonth() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1144
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1145
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1146
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1147
        var year = originalGetFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1148
        var month = originalGetMonth(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1149
        if (year < 0 && month > 11) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1150
            return 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1151
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1152
        return month;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1153
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1154
    getDate: function getDate() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1155
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1156
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1157
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1158
        var year = originalGetFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1159
        var month = originalGetMonth(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1160
        var date = originalGetDate(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1161
        if (year < 0 && month > 11) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1162
            if (month === 12) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1163
                return date;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1164
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1165
            var days = daysInMonth(0, year + 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1166
            return (days - date) + 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1167
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1168
        return date;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1169
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1170
    getUTCFullYear: function getUTCFullYear() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1171
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1172
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1173
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1174
        var year = originalGetUTCFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1175
        if (year < 0 && originalGetUTCMonth(this) > 11) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1176
            return year + 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1177
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1178
        return year;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1179
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1180
    getUTCMonth: function getUTCMonth() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1181
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1182
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1183
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1184
        var year = originalGetUTCFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1185
        var month = originalGetUTCMonth(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1186
        if (year < 0 && month > 11) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1187
            return 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1188
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1189
        return month;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1190
    },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1191
    getUTCDate: function getUTCDate() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1192
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1193
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1194
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1195
        var year = originalGetUTCFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1196
        var month = originalGetUTCMonth(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1197
        var date = originalGetUTCDate(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1198
        if (year < 0 && month > 11) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1199
            if (month === 12) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1200
                return date;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1201
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1202
            var days = daysInMonth(0, year + 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1203
            return (days - date) + 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1204
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1205
        return date;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1206
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1207
}, hasNegativeMonthYearBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1208
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1209
defineProperties(Date.prototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1210
    toUTCString: function toUTCString() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1211
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1212
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1213
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1214
        var day = originalGetUTCDay(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1215
        var date = originalGetUTCDate(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1216
        var month = originalGetUTCMonth(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1217
        var year = originalGetUTCFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1218
        var hour = originalGetUTCHours(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1219
        var minute = originalGetUTCMinutes(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1220
        var second = originalGetUTCSeconds(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1221
        return dayName[day] + ', ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1222
            (date < 10 ? '0' + date : date) + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1223
            monthName[month] + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1224
            year + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1225
            (hour < 10 ? '0' + hour : hour) + ':' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1226
            (minute < 10 ? '0' + minute : minute) + ':' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1227
            (second < 10 ? '0' + second : second) + ' GMT';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1228
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1229
}, hasNegativeMonthYearBug || hasToUTCStringFormatBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1230
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1231
// Opera 12 has `,`
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1232
defineProperties(Date.prototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1233
    toDateString: function toDateString() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1234
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1235
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1236
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1237
        var day = this.getDay();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1238
        var date = this.getDate();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1239
        var month = this.getMonth();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1240
        var year = this.getFullYear();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1241
        return dayName[day] + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1242
            monthName[month] + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1243
            (date < 10 ? '0' + date : date) + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1244
            year;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1245
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1246
}, hasNegativeMonthYearBug || hasToDateStringFormatBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1247
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1248
// can't use defineProperties here because of toString enumeration issue in IE <= 8
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1249
if (hasNegativeMonthYearBug || hasToStringFormatBug) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1250
    Date.prototype.toString = function toString() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1251
        if (!this || !(this instanceof Date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1252
            throw new TypeError('this is not a Date object.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1253
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1254
        var day = this.getDay();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1255
        var date = this.getDate();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1256
        var month = this.getMonth();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1257
        var year = this.getFullYear();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1258
        var hour = this.getHours();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1259
        var minute = this.getMinutes();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1260
        var second = this.getSeconds();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1261
        var timezoneOffset = this.getTimezoneOffset();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1262
        var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1263
        var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1264
        return dayName[day] + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1265
            monthName[month] + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1266
            (date < 10 ? '0' + date : date) + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1267
            year + ' ' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1268
            (hour < 10 ? '0' + hour : hour) + ':' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1269
            (minute < 10 ? '0' + minute : minute) + ':' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1270
            (second < 10 ? '0' + second : second) + ' GMT' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1271
            (timezoneOffset > 0 ? '-' : '+') +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1272
            (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1273
            (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1274
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1275
    if (supportsDescriptors) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1276
        $Object.defineProperty(Date.prototype, 'toString', {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1277
            configurable: true,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1278
            enumerable: false,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1279
            writable: true
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1280
        });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1281
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1282
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1283
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1284
// ES5 15.9.5.43
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1285
// http://es5.github.com/#x15.9.5.43
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1286
// This function returns a String value represent the instance in time
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1287
// represented by this Date object. The format of the String is the Date Time
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1288
// string format defined in 15.9.1.15. All fields are present in the String.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1289
// The time zone is always UTC, denoted by the suffix Z. If the time value of
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1290
// this object is not a finite Number a RangeError exception is thrown.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1291
var negativeDate = -62198755200000;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1292
var negativeYearString = '-000001';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1293
var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1294
var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1295
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1296
defineProperties(Date.prototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1297
    toISOString: function toISOString() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1298
        if (!isFinite(this)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1299
            throw new RangeError('Date.prototype.toISOString called on non-finite value.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1300
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1301
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1302
        var year = originalGetUTCFullYear(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1303
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1304
        var month = originalGetUTCMonth(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1305
        // see https://github.com/es-shims/es5-shim/issues/111
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1306
        year += Math.floor(month / 12);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1307
        month = (month % 12 + 12) % 12;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1308
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1309
        // the date time string format is specified in 15.9.1.15.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1310
        var result = [month + 1, originalGetUTCDate(this), originalGetUTCHours(this), originalGetUTCMinutes(this), originalGetUTCSeconds(this)];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1311
        year = (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1312
            (year < 0 ? '-' : (year > 9999 ? '+' : '')) +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1313
            strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1314
        );
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1315
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1316
        for (var i = 0; i < result.length; ++i) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1317
          // pad months, days, hours, minutes, and seconds to have two digits.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1318
          result[i] = strSlice('00' + result[i], -2);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1319
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1320
        // pad milliseconds to have three digits.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1321
        return (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1322
            year + '-' + arraySlice(result, 0, 2).join('-') +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1323
            'T' + arraySlice(result, 2).join(':') + '.' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1324
            strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z'
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1325
        );
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1326
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1327
}, hasNegativeDateBug || hasSafari51DateBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1328
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1329
// ES5 15.9.5.44
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1330
// http://es5.github.com/#x15.9.5.44
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1331
// This function provides a String representation of a Date object for use by
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1332
// JSON.stringify (15.12.3).
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1333
var dateToJSONIsSupported = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1334
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1335
        return Date.prototype.toJSON &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1336
            new Date(NaN).toJSON() === null &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1337
            new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1338
            Date.prototype.toJSON.call({ // generic
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1339
                toISOString: function () { return true; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1340
            });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1341
    } catch (e) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1342
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1343
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1344
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1345
if (!dateToJSONIsSupported) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1346
    Date.prototype.toJSON = function toJSON(key) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1347
        // When the toJSON method is called with argument key, the following
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1348
        // steps are taken:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1349
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1350
        // 1.  Let O be the result of calling ToObject, giving it the this
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1351
        // value as its argument.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1352
        // 2. Let tv be ES.ToPrimitive(O, hint Number).
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1353
        var O = $Object(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1354
        var tv = ES.ToPrimitive(O);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1355
        // 3. If tv is a Number and is not finite, return null.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1356
        if (typeof tv === 'number' && !isFinite(tv)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1357
            return null;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1358
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1359
        // 4. Let toISO be the result of calling the [[Get]] internal method of
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1360
        // O with argument "toISOString".
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1361
        var toISO = O.toISOString;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1362
        // 5. If IsCallable(toISO) is false, throw a TypeError exception.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1363
        if (!isCallable(toISO)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1364
            throw new TypeError('toISOString property is not callable');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1365
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1366
        // 6. Return the result of calling the [[Call]] internal method of
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1367
        //  toISO with O as the this value and an empty argument list.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1368
        return toISO.call(O);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1369
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1370
        // NOTE 1 The argument is ignored.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1371
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1372
        // NOTE 2 The toJSON function is intentionally generic; it does not
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1373
        // require that its this value be a Date object. Therefore, it can be
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1374
        // transferred to other kinds of objects for use as a method. However,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1375
        // it does require that any such object have a toISOString method. An
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1376
        // object is free to use the argument key to filter its
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1377
        // stringification.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1378
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1379
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1380
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1381
// ES5 15.9.4.2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1382
// http://es5.github.com/#x15.9.4.2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1383
// based on work shared by Daniel Friesen (dantman)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1384
// http://gist.github.com/303249
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1385
var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1386
var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z'));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1387
var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z'));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1388
if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1389
    // XXX global assignment won't work in embeddings that use
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1390
    // an alternate object for the context.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1391
    /* global Date: true */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1392
    /* eslint-disable no-undef */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1393
    var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1394
    var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1395
    Date = (function (NativeDate) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1396
    /* eslint-enable no-undef */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1397
        // Date.length === 7
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1398
        var DateShim = function Date(Y, M, D, h, m, s, ms) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1399
            var length = arguments.length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1400
            var date;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1401
            if (this instanceof NativeDate) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1402
                var seconds = s;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1403
                var millis = ms;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1404
                if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1405
                    // work around a Safari 8/9 bug where it treats the seconds as signed
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1406
                    var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1407
                    var sToShift = Math.floor(msToShift / 1e3);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1408
                    seconds += sToShift;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1409
                    millis -= sToShift * 1e3;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1410
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1411
                date = length === 1 && $String(Y) === Y ? // isString(Y)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1412
                    // We explicitly pass it through parse:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1413
                    new NativeDate(DateShim.parse(Y)) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1414
                    // We have to manually make calls depending on argument
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1415
                    // length here
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1416
                    length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1417
                    length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1418
                    length >= 5 ? new NativeDate(Y, M, D, h, m) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1419
                    length >= 4 ? new NativeDate(Y, M, D, h) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1420
                    length >= 3 ? new NativeDate(Y, M, D) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1421
                    length >= 2 ? new NativeDate(Y, M) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1422
                    length >= 1 ? new NativeDate(Y) :
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1423
                                  new NativeDate();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1424
            } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1425
                date = NativeDate.apply(this, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1426
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1427
            if (!isPrimitive(date)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1428
              // Prevent mixups with unfixed Date object
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1429
              defineProperties(date, { constructor: DateShim }, true);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1430
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1431
            return date;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1432
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1433
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1434
        // 15.9.1.15 Date Time String Format.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1435
        var isoDateExpression = new RegExp('^' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1436
            '(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1437
                                      // 6-digit extended year
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1438
            '(?:-(\\d{2})' + // optional month capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1439
            '(?:-(\\d{2})' + // optional day capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1440
            '(?:' + // capture hours:minutes:seconds.milliseconds
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1441
                'T(\\d{2})' + // hours capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1442
                ':(\\d{2})' + // minutes capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1443
                '(?:' + // optional :seconds.milliseconds
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1444
                    ':(\\d{2})' + // seconds capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1445
                    '(?:(\\.\\d{1,}))?' + // milliseconds capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1446
                ')?' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1447
            '(' + // capture UTC offset component
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1448
                'Z|' + // UTC capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1449
                '(?:' + // offset specifier +/-hours:minutes
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1450
                    '([-+])' + // sign capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1451
                    '(\\d{2})' + // hours offset capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1452
                    ':(\\d{2})' + // minutes offset capture
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1453
                ')' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1454
            ')?)?)?)?' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1455
        '$');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1456
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1457
        var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1458
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1459
        var dayFromMonth = function dayFromMonth(year, month) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1460
            var t = month > 1 ? 1 : 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1461
            return (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1462
                months[month] +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1463
                Math.floor((year - 1969 + t) / 4) -
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1464
                Math.floor((year - 1901 + t) / 100) +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1465
                Math.floor((year - 1601 + t) / 400) +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1466
                365 * (year - 1970)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1467
            );
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1468
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1469
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1470
        var toUTC = function toUTC(t) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1471
            var s = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1472
            var ms = t;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1473
            if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1474
                // work around a Safari 8/9 bug where it treats the seconds as signed
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1475
                var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1476
                var sToShift = Math.floor(msToShift / 1e3);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1477
                s += sToShift;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1478
                ms -= sToShift * 1e3;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1479
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1480
            return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1481
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1482
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1483
        // Copy any custom methods a 3rd party library may have added
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1484
        for (var key in NativeDate) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1485
            if (owns(NativeDate, key)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1486
                DateShim[key] = NativeDate[key];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1487
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1488
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1489
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1490
        // Copy "native" methods explicitly; they may be non-enumerable
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1491
        defineProperties(DateShim, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1492
            now: NativeDate.now,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1493
            UTC: NativeDate.UTC
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1494
        }, true);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1495
        DateShim.prototype = NativeDate.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1496
        defineProperties(DateShim.prototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1497
            constructor: DateShim
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1498
        }, true);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1499
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1500
        // Upgrade Date.parse to handle simplified ISO 8601 strings
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1501
        var parseShim = function parse(string) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1502
            var match = isoDateExpression.exec(string);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1503
            if (match) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1504
                // parse months, days, hours, minutes, seconds, and milliseconds
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1505
                // provide default values if necessary
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1506
                // parse the UTC offset component
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1507
                var year = $Number(match[1]),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1508
                    month = $Number(match[2] || 1) - 1,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1509
                    day = $Number(match[3] || 1) - 1,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1510
                    hour = $Number(match[4] || 0),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1511
                    minute = $Number(match[5] || 0),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1512
                    second = $Number(match[6] || 0),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1513
                    millisecond = Math.floor($Number(match[7] || 0) * 1000),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1514
                    // When time zone is missed, local offset should be used
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1515
                    // (ES 5.1 bug)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1516
                    // see https://bugs.ecmascript.org/show_bug.cgi?id=112
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1517
                    isLocalTime = Boolean(match[4] && !match[8]),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1518
                    signOffset = match[9] === '-' ? 1 : -1,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1519
                    hourOffset = $Number(match[10] || 0),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1520
                    minuteOffset = $Number(match[11] || 0),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1521
                    result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1522
                var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1523
                if (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1524
                    hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1525
                    minute < 60 && second < 60 && millisecond < 1000 &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1526
                    month > -1 && month < 12 && hourOffset < 24 &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1527
                    minuteOffset < 60 && // detect invalid offsets
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1528
                    day > -1 &&
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1529
                    day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month))
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1530
                ) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1531
                    result = (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1532
                        (dayFromMonth(year, month) + day) * 24 +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1533
                        hour +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1534
                        hourOffset * signOffset
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1535
                    ) * 60;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1536
                    result = (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1537
                        (result + minute + minuteOffset * signOffset) * 60 +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1538
                        second
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1539
                    ) * 1000 + millisecond;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1540
                    if (isLocalTime) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1541
                        result = toUTC(result);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1542
                    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1543
                    if (-8.64e15 <= result && result <= 8.64e15) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1544
                        return result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1545
                    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1546
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1547
                return NaN;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1548
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1549
            return NativeDate.parse.apply(this, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1550
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1551
        defineProperties(DateShim, { parse: parseShim });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1552
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1553
        return DateShim;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1554
    }(Date));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1555
    /* global Date: false */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1556
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1557
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1558
// ES5 15.9.4.4
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1559
// http://es5.github.com/#x15.9.4.4
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1560
if (!Date.now) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1561
    Date.now = function now() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1562
        return new Date().getTime();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1563
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1564
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1565
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1566
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1567
// Number
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1568
// ======
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1569
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1570
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1571
// ES5.1 15.7.4.5
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1572
// http://es5.github.com/#x15.7.4.5
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1573
var hasToFixedBugs = NumberPrototype.toFixed && (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1574
  (0.00008).toFixed(3) !== '0.000' ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1575
  (0.9).toFixed(0) !== '1' ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1576
  (1.255).toFixed(2) !== '1.25' ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1577
  (1000000000000000128).toFixed(0) !== '1000000000000000128'
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1578
);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1579
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1580
var toFixedHelpers = {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1581
  base: 1e7,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1582
  size: 6,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1583
  data: [0, 0, 0, 0, 0, 0],
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1584
  multiply: function multiply(n, c) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1585
      var i = -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1586
      var c2 = c;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1587
      while (++i < toFixedHelpers.size) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1588
          c2 += n * toFixedHelpers.data[i];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1589
          toFixedHelpers.data[i] = c2 % toFixedHelpers.base;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1590
          c2 = Math.floor(c2 / toFixedHelpers.base);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1591
      }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1592
  },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1593
  divide: function divide(n) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1594
      var i = toFixedHelpers.size, c = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1595
      while (--i >= 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1596
          c += toFixedHelpers.data[i];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1597
          toFixedHelpers.data[i] = Math.floor(c / n);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1598
          c = (c % n) * toFixedHelpers.base;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1599
      }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1600
  },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1601
  numToString: function numToString() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1602
      var i = toFixedHelpers.size;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1603
      var s = '';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1604
      while (--i >= 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1605
          if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1606
              var t = $String(toFixedHelpers.data[i]);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1607
              if (s === '') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1608
                  s = t;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1609
              } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1610
                  s += strSlice('0000000', 0, 7 - t.length) + t;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1611
              }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1612
          }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1613
      }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1614
      return s;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1615
  },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1616
  pow: function pow(x, n, acc) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1617
      return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1618
  },
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1619
  log: function log(x) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1620
      var n = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1621
      var x2 = x;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1622
      while (x2 >= 4096) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1623
          n += 12;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1624
          x2 /= 4096;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1625
      }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1626
      while (x2 >= 2) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1627
          n += 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1628
          x2 /= 2;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1629
      }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1630
      return n;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1631
  }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1632
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1633
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1634
var toFixedShim = function toFixed(fractionDigits) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1635
    var f, x, s, m, e, z, j, k;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1636
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1637
    // Test for NaN and round fractionDigits down
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1638
    f = $Number(fractionDigits);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1639
    f = isActualNaN(f) ? 0 : Math.floor(f);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1640
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1641
    if (f < 0 || f > 20) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1642
        throw new RangeError('Number.toFixed called with invalid number of decimals');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1643
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1644
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1645
    x = $Number(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1646
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1647
    if (isActualNaN(x)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1648
        return 'NaN';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1649
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1650
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1651
    // If it is too big or small, return the string value of the number
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1652
    if (x <= -1e21 || x >= 1e21) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1653
        return $String(x);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1654
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1655
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1656
    s = '';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1657
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1658
    if (x < 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1659
        s = '-';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1660
        x = -x;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1661
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1662
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1663
    m = '0';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1664
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1665
    if (x > 1e-21) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1666
        // 1e-21 < x < 1e21
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1667
        // -70 < log2(x) < 70
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1668
        e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1669
        z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1670
        z *= 0x10000000000000; // Math.pow(2, 52);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1671
        e = 52 - e;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1672
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1673
        // -18 < e < 122
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1674
        // x = z / 2 ^ e
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1675
        if (e > 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1676
            toFixedHelpers.multiply(0, z);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1677
            j = f;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1678
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1679
            while (j >= 7) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1680
                toFixedHelpers.multiply(1e7, 0);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1681
                j -= 7;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1682
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1683
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1684
            toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1685
            j = e - 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1686
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1687
            while (j >= 23) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1688
                toFixedHelpers.divide(1 << 23);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1689
                j -= 23;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1690
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1691
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1692
            toFixedHelpers.divide(1 << j);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1693
            toFixedHelpers.multiply(1, 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1694
            toFixedHelpers.divide(2);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1695
            m = toFixedHelpers.numToString();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1696
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1697
            toFixedHelpers.multiply(0, z);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1698
            toFixedHelpers.multiply(1 << (-e), 0);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1699
            m = toFixedHelpers.numToString() + strSlice('0.00000000000000000000', 2, 2 + f);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1700
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1701
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1702
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1703
    if (f > 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1704
        k = m.length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1705
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1706
        if (k <= f) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1707
            m = s + strSlice('0.0000000000000000000', 0, f - k + 2) + m;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1708
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1709
            m = s + strSlice(m, 0, k - f) + '.' + strSlice(m, k - f);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1710
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1711
    } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1712
        m = s + m;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1713
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1714
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1715
    return m;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1716
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1717
defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1718
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1719
var hasToPrecisionUndefinedBug = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1720
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1721
        return 1.0.toPrecision(undefined) === '1';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1722
    } catch (e) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1723
        return true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1724
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1725
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1726
var originalToPrecision = NumberPrototype.toPrecision;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1727
defineProperties(NumberPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1728
    toPrecision: function toPrecision(precision) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1729
        return typeof precision === 'undefined' ? originalToPrecision.call(this) : originalToPrecision.call(this, precision);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1730
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1731
}, hasToPrecisionUndefinedBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1732
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1733
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1734
// String
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1735
// ======
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1736
//
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1737
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1738
// ES5 15.5.4.14
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1739
// http://es5.github.com/#x15.5.4.14
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1740
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1741
// [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1742
// Many browsers do not split properly with regular expressions or they
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1743
// do not perform the split correctly under obscure conditions.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1744
// See http://blog.stevenlevithan.com/archives/cross-browser-split
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1745
// I've tested in many browsers and this seems to cover the deviant ones:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1746
//    'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1747
//    '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1748
//    'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1749
//       [undefined, "t", undefined, "e", ...]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1750
//    ''.split(/.?/) should be [], not [""]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1751
//    '.'.split(/()()/) should be ["."], not ["", "", "."]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1752
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1753
if (
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1754
    'ab'.split(/(?:ab)*/).length !== 2 ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1755
    '.'.split(/(.?)(.?)/).length !== 4 ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1756
    'tesst'.split(/(s)*/)[1] === 't' ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1757
    'test'.split(/(?:)/, -1).length !== 4 ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1758
    ''.split(/.?/).length ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1759
    '.'.split(/()()/).length > 1
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1760
) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1761
    (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1762
        var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1763
        var maxSafe32BitInt = Math.pow(2, 32) - 1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1764
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1765
        StringPrototype.split = function (separator, limit) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1766
            var string = String(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1767
            if (typeof separator === 'undefined' && limit === 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1768
                return [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1769
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1770
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1771
            // If `separator` is not a regex, use native split
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1772
            if (!isRegex(separator)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1773
                return strSplit(this, separator, limit);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1774
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1775
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1776
            var output = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1777
            var flags = (separator.ignoreCase ? 'i' : '') +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1778
                        (separator.multiline ? 'm' : '') +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1779
                        (separator.unicode ? 'u' : '') + // in ES6
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1780
                        (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1781
                lastLastIndex = 0,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1782
                // Make `global` and avoid `lastIndex` issues by working with a copy
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1783
                separator2, match, lastIndex, lastLength;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1784
            var separatorCopy = new RegExp(separator.source, flags + 'g');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1785
            if (!compliantExecNpcg) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1786
                // Doesn't need flags gy, but they don't hurt
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1787
                separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1788
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1789
            /* Values for `limit`, per the spec:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1790
             * If undefined: 4294967295 // maxSafe32BitInt
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1791
             * If 0, Infinity, or NaN: 0
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1792
             * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1793
             * If negative number: 4294967296 - Math.floor(Math.abs(limit))
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1794
             * If other: Type-convert, then use the above rules
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1795
             */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1796
            var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1797
            match = separatorCopy.exec(string);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1798
            while (match) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1799
                // `separatorCopy.lastIndex` is not reliable cross-browser
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1800
                lastIndex = match.index + match[0].length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1801
                if (lastIndex > lastLastIndex) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1802
                    pushCall(output, strSlice(string, lastLastIndex, match.index));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1803
                    // Fix browsers whose `exec` methods don't consistently return `undefined` for
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1804
                    // nonparticipating capturing groups
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1805
                    if (!compliantExecNpcg && match.length > 1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1806
                        /* eslint-disable no-loop-func */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1807
                        match[0].replace(separator2, function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1808
                            for (var i = 1; i < arguments.length - 2; i++) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1809
                                if (typeof arguments[i] === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1810
                                    match[i] = void 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1811
                                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1812
                            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1813
                        });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1814
                        /* eslint-enable no-loop-func */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1815
                    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1816
                    if (match.length > 1 && match.index < string.length) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1817
                        array_push.apply(output, arraySlice(match, 1));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1818
                    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1819
                    lastLength = match[0].length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1820
                    lastLastIndex = lastIndex;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1821
                    if (output.length >= splitLimit) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1822
                        break;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1823
                    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1824
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1825
                if (separatorCopy.lastIndex === match.index) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1826
                    separatorCopy.lastIndex++; // Avoid an infinite loop
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1827
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1828
                match = separatorCopy.exec(string);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1829
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1830
            if (lastLastIndex === string.length) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1831
                if (lastLength || !separatorCopy.test('')) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1832
                    pushCall(output, '');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1833
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1834
            } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1835
                pushCall(output, strSlice(string, lastLastIndex));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1836
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1837
            return output.length > splitLimit ? strSlice(output, 0, splitLimit) : output;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1838
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1839
    }());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1840
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1841
// [bugfix, chrome]
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1842
// If separator is undefined, then the result array contains just one String,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1843
// which is the this value (converted to a String). If limit is not undefined,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1844
// then the output array is truncated so that it contains no more than limit
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1845
// elements.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1846
// "0".split(undefined, 0) -> []
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1847
} else if ('0'.split(void 0, 0).length) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1848
    StringPrototype.split = function split(separator, limit) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1849
        if (typeof separator === 'undefined' && limit === 0) { return []; }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1850
        return strSplit(this, separator, limit);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1851
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1852
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1853
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1854
var str_replace = StringPrototype.replace;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1855
var replaceReportsGroupsCorrectly = (function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1856
    var groups = [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1857
    'x'.replace(/x(.)?/g, function (match, group) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1858
        pushCall(groups, group);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1859
    });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1860
    return groups.length === 1 && typeof groups[0] === 'undefined';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1861
}());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1862
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1863
if (!replaceReportsGroupsCorrectly) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1864
    StringPrototype.replace = function replace(searchValue, replaceValue) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1865
        var isFn = isCallable(replaceValue);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1866
        var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1867
        if (!isFn || !hasCapturingGroups) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1868
            return str_replace.call(this, searchValue, replaceValue);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1869
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1870
            var wrappedReplaceValue = function (match) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1871
                var length = arguments.length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1872
                var originalLastIndex = searchValue.lastIndex;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1873
                searchValue.lastIndex = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1874
                var args = searchValue.exec(match) || [];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1875
                searchValue.lastIndex = originalLastIndex;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1876
                pushCall(args, arguments[length - 2], arguments[length - 1]);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1877
                return replaceValue.apply(this, args);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1878
            };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1879
            return str_replace.call(this, searchValue, wrappedReplaceValue);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1880
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1881
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1882
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1883
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1884
// ECMA-262, 3rd B.2.3
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1885
// Not an ECMAScript standard, although ECMAScript 3rd Edition has a
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1886
// non-normative section suggesting uniform semantics and it should be
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1887
// normalized across all browsers
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1888
// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1889
var string_substr = StringPrototype.substr;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1890
var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1891
defineProperties(StringPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1892
    substr: function substr(start, length) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1893
        var normalizedStart = start;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1894
        if (start < 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1895
            normalizedStart = max(this.length + start, 0);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1896
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1897
        return string_substr.call(this, normalizedStart, length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1898
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1899
}, hasNegativeSubstrBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1900
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1901
// ES5 15.5.4.20
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1902
// whitespace from: http://es5.github.io/#x15.5.4.20
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1903
var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1904
    '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1905
    '\u2029\uFEFF';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1906
var zeroWidth = '\u200b';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1907
var wsRegexChars = '[' + ws + ']';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1908
var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1909
var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1910
var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim());
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1911
defineProperties(StringPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1912
    // http://blog.stevenlevithan.com/archives/faster-trim-javascript
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1913
    // http://perfectionkills.com/whitespace-deviations/
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1914
    trim: function trim() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1915
        if (typeof this === 'undefined' || this === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1916
            throw new TypeError("can't convert " + this + ' to object');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1917
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1918
        return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1919
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1920
}, hasTrimWhitespaceBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1921
var trim = call.bind(String.prototype.trim);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1922
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1923
var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1924
defineProperties(StringPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1925
    lastIndexOf: function lastIndexOf(searchString) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1926
        if (typeof this === 'undefined' || this === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1927
            throw new TypeError("can't convert " + this + ' to object');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1928
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1929
        var S = $String(this);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1930
        var searchStr = $String(searchString);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1931
        var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1932
        var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1933
        var start = min(max(pos, 0), S.length);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1934
        var searchLen = searchStr.length;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1935
        var k = start + searchLen;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1936
        while (k > 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1937
            k = max(0, k - searchLen);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1938
            var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1939
            if (index !== -1) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1940
                return k + index;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1941
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1942
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1943
        return -1;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1944
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1945
}, hasLastIndexBug);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1946
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1947
var originalLastIndexOf = StringPrototype.lastIndexOf;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1948
defineProperties(StringPrototype, {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1949
    lastIndexOf: function lastIndexOf(searchString) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1950
        return originalLastIndexOf.apply(this, arguments);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1951
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1952
}, StringPrototype.lastIndexOf.length !== 1);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1953
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1954
// ES-5 15.1.2.2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1955
/* eslint-disable radix */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1956
if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1957
/* eslint-enable radix */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1958
    /* global parseInt: true */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1959
    parseInt = (function (origParseInt) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1960
        var hexRegex = /^[\-+]?0[xX]/;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1961
        return function parseInt(str, radix) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1962
            var string = trim(str);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1963
            var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1964
            return origParseInt(string, defaultedRadix);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1965
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1966
    }(parseInt));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1967
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1968
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1969
// https://es5.github.io/#x15.1.2.3
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1970
if (1 / parseFloat('-0') !== -Infinity) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1971
    /* global parseFloat: true */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1972
    parseFloat = (function (origParseFloat) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1973
        return function parseFloat(string) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1974
            var inputString = trim(string);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1975
            var result = origParseFloat(inputString);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1976
            return result === 0 && strSlice(inputString, 0, 1) === '-' ? -0 : result;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1977
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1978
    }(parseFloat));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1979
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1980
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1981
if (String(new RangeError('test')) !== 'RangeError: test') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1982
    var errorToStringShim = function toString() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1983
        if (typeof this === 'undefined' || this === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1984
            throw new TypeError("can't convert " + this + ' to object');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1985
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1986
        var name = this.name;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1987
        if (typeof name === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1988
            name = 'Error';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1989
        } else if (typeof name !== 'string') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1990
            name = $String(name);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1991
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1992
        var msg = this.message;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1993
        if (typeof msg === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1994
            msg = '';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1995
        } else if (typeof msg !== 'string') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1996
            msg = $String(msg);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1997
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1998
        if (!name) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  1999
            return msg;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2000
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2001
        if (!msg) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2002
            return name;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2003
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2004
        return name + ': ' + msg;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2005
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2006
    // can't use defineProperties here because of toString enumeration issue in IE <= 8
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2007
    Error.prototype.toString = errorToStringShim;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2008
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2009
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2010
if (supportsDescriptors) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2011
    var ensureNonEnumerable = function (obj, prop) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2012
        if (isEnum(obj, prop)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2013
            var desc = Object.getOwnPropertyDescriptor(obj, prop);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2014
            desc.enumerable = false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2015
            Object.defineProperty(obj, prop, desc);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2016
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2017
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2018
    ensureNonEnumerable(Error.prototype, 'message');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2019
    if (Error.prototype.message !== '') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2020
      Error.prototype.message = '';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2021
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2022
    ensureNonEnumerable(Error.prototype, 'name');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2023
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2024
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2025
if (String(/a/mig) !== '/a/gim') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2026
    var regexToString = function toString() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2027
        var str = '/' + this.source + '/';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2028
        if (this.global) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2029
            str += 'g';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2030
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2031
        if (this.ignoreCase) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2032
            str += 'i';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2033
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2034
        if (this.multiline) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2035
            str += 'm';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2036
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2037
        return str;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2038
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2039
    // can't use defineProperties here because of toString enumeration issue in IE <= 8
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2040
    RegExp.prototype.toString = regexToString;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2041
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2042
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2043
}));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2044
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2045
/*!
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2046
 * https://github.com/es-shims/es5-shim
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2047
 * @license es5-shim Copyright 2009-2015 by contributors, MIT License
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2048
 * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2049
 */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2050
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2051
// vim: ts=4 sts=4 sw=4 expandtab
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2052
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2053
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2054
;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2055
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2056
// UMD (Universal Module Definition)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2057
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2058
(function (root, factory) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2059
    'use strict';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2060
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2061
    /* global define, exports, module */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2062
    if (typeof define === 'function' && define.amd) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2063
        // AMD. Register as an anonymous module.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2064
        define(factory);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2065
    } else if (typeof exports === 'object') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2066
        // Node. Does not work with strict CommonJS, but
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2067
        // only CommonJS-like enviroments that support module.exports,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2068
        // like Node.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2069
        module.exports = factory();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2070
    } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2071
        // Browser globals (root is window)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2072
        root.returnExports = factory();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2073
  }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2074
}(this, function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2075
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2076
var call = Function.call;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2077
var prototypeOfObject = Object.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2078
var owns = call.bind(prototypeOfObject.hasOwnProperty);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2079
var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2080
var toStr = call.bind(prototypeOfObject.toString);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2081
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2082
// If JS engine supports accessors creating shortcuts.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2083
var defineGetter;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2084
var defineSetter;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2085
var lookupGetter;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2086
var lookupSetter;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2087
var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2088
if (supportsAccessors) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2089
    /* eslint-disable no-underscore-dangle */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2090
    defineGetter = call.bind(prototypeOfObject.__defineGetter__);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2091
    defineSetter = call.bind(prototypeOfObject.__defineSetter__);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2092
    lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2093
    lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2094
    /* eslint-enable no-underscore-dangle */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2095
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2096
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2097
// ES5 15.2.3.2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2098
// http://es5.github.com/#x15.2.3.2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2099
if (!Object.getPrototypeOf) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2100
    // https://github.com/es-shims/es5-shim/issues#issue/2
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2101
    // http://ejohn.org/blog/objectgetprototypeof/
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2102
    // recommended by fschaefer on github
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2103
    //
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2104
    // sure, and webreflection says ^_^
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2105
    // ... this will nerever possibly return null
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2106
    // ... Opera Mini breaks here with infinite loops
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2107
    Object.getPrototypeOf = function getPrototypeOf(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2108
        /* eslint-disable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2109
        var proto = object.__proto__;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2110
        /* eslint-enable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2111
        if (proto || proto === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2112
            return proto;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2113
        } else if (toStr(object.constructor) === '[object Function]') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2114
            return object.constructor.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2115
        } else if (object instanceof Object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2116
          return prototypeOfObject;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2117
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2118
          // Correctly return null for Objects created with `Object.create(null)`
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2119
          // (shammed or native) or `{ __proto__: null}`.  Also returns null for
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2120
          // cross-realm objects on browsers that lack `__proto__` support (like
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2121
          // IE <11), but that's the best we can do.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2122
          return null;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2123
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2124
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2125
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2126
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2127
// ES5 15.2.3.3
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2128
// http://es5.github.com/#x15.2.3.3
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2129
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2130
var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2131
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2132
        object.sentinel = 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2133
        return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2134
    } catch (exception) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2135
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2136
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2137
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2138
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2139
// check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2140
if (Object.defineProperty) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2141
    var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2142
    var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2143
    doesGetOwnPropertyDescriptorWork(document.createElement('div'));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2144
    if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2145
        var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2146
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2147
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2148
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2149
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2150
    var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2151
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2152
    /* eslint-disable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2153
    Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2154
        if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2155
            throw new TypeError(ERR_NON_OBJECT + object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2156
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2157
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2158
        // make a valiant attempt to use the real getOwnPropertyDescriptor
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2159
        // for I8's DOM elements.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2160
        if (getOwnPropertyDescriptorFallback) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2161
            try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2162
                return getOwnPropertyDescriptorFallback.call(Object, object, property);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2163
            } catch (exception) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2164
                // try the shim if the real one doesn't work
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2165
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2166
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2167
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2168
        var descriptor;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2169
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2170
        // If object does not owns property return undefined immediately.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2171
        if (!owns(object, property)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2172
            return descriptor;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2173
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2174
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2175
        // If object has a property then it's for sure `configurable`, and
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2176
        // probably `enumerable`. Detect enumerability though.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2177
        descriptor = {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2178
            enumerable: isEnumerable(object, property),
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2179
            configurable: true
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2180
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2181
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2182
        // If JS engine supports accessor properties then property may be a
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2183
        // getter or setter.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2184
        if (supportsAccessors) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2185
            // Unfortunately `__lookupGetter__` will return a getter even
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2186
            // if object has own non getter property along with a same named
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2187
            // inherited getter. To avoid misbehavior we temporary remove
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2188
            // `__proto__` so that `__lookupGetter__` will return getter only
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2189
            // if it's owned by an object.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2190
            var prototype = object.__proto__;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2191
            var notPrototypeOfObject = object !== prototypeOfObject;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2192
            // avoid recursion problem, breaking in Opera Mini when
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2193
            // Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2194
            // or any other Object.prototype accessor
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2195
            if (notPrototypeOfObject) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2196
                object.__proto__ = prototypeOfObject;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2197
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2198
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2199
            var getter = lookupGetter(object, property);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2200
            var setter = lookupSetter(object, property);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2201
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2202
            if (notPrototypeOfObject) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2203
                // Once we have getter and setter we can put values back.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2204
                object.__proto__ = prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2205
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2206
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2207
            if (getter || setter) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2208
                if (getter) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2209
                    descriptor.get = getter;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2210
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2211
                if (setter) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2212
                    descriptor.set = setter;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2213
                }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2214
                // If it was accessor property we're done and return here
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2215
                // in order to avoid adding `value` to the descriptor.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2216
                return descriptor;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2217
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2218
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2219
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2220
        // If we got this far we know that object has an own property that is
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2221
        // not an accessor so we set it as a value and return descriptor.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2222
        descriptor.value = object[property];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2223
        descriptor.writable = true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2224
        return descriptor;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2225
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2226
    /* eslint-enable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2227
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2228
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2229
// ES5 15.2.3.4
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2230
// http://es5.github.com/#x15.2.3.4
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2231
if (!Object.getOwnPropertyNames) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2232
    Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2233
        return Object.keys(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2234
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2235
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2236
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2237
// ES5 15.2.3.5
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2238
// http://es5.github.com/#x15.2.3.5
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2239
if (!Object.create) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2240
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2241
    // Contributed by Brandon Benvie, October, 2012
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2242
    var createEmpty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2243
    var supportsProto = !({ __proto__: null } instanceof Object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2244
                        // the following produces false positives
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2245
                        // in Opera Mini => not a reliable check
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2246
                        // Object.prototype.__proto__ === null
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2247
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2248
    // Check for document.domain and active x support
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2249
    // No need to use active x approach when document.domain is not set
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2250
    // see https://github.com/es-shims/es5-shim/issues/150
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2251
    // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2252
    /* global ActiveXObject */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2253
    var shouldUseActiveX = function shouldUseActiveX() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2254
        // return early if document.domain not set
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2255
        if (!document.domain) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2256
            return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2257
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2258
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2259
        try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2260
            return !!new ActiveXObject('htmlfile');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2261
        } catch (exception) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2262
            return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2263
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2264
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2265
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2266
    // This supports IE8 when document.domain is used
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2267
    // see https://github.com/es-shims/es5-shim/issues/150
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2268
    // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2269
    var getEmptyViaActiveX = function getEmptyViaActiveX() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2270
        var empty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2271
        var xDoc;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2272
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2273
        xDoc = new ActiveXObject('htmlfile');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2274
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2275
        xDoc.write('<script><\/script>');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2276
        xDoc.close();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2277
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2278
        empty = xDoc.parentWindow.Object.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2279
        xDoc = null;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2280
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2281
        return empty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2282
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2283
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2284
    // The original implementation using an iframe
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2285
    // before the activex approach was added
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2286
    // see https://github.com/es-shims/es5-shim/issues/150
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2287
    var getEmptyViaIFrame = function getEmptyViaIFrame() {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2288
        var iframe = document.createElement('iframe');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2289
        var parent = document.body || document.documentElement;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2290
        var empty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2291
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2292
        iframe.style.display = 'none';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2293
        parent.appendChild(iframe);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2294
        /* eslint-disable no-script-url */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2295
        iframe.src = 'javascript:';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2296
        /* eslint-enable no-script-url */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2297
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2298
        empty = iframe.contentWindow.Object.prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2299
        parent.removeChild(iframe);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2300
        iframe = null;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2301
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2302
        return empty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2303
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2304
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2305
    /* global document */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2306
    if (supportsProto || typeof document === 'undefined') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2307
        createEmpty = function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2308
            return { __proto__: null };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2309
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2310
    } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2311
        // In old IE __proto__ can't be used to manually set `null`, nor does
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2312
        // any other method exist to make an object that inherits from nothing,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2313
        // aside from Object.prototype itself. Instead, create a new global
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2314
        // object and *steal* its Object.prototype and strip it bare. This is
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2315
        // used as the prototype to create nullary objects.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2316
        createEmpty = function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2317
            // Determine which approach to use
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2318
            // see https://github.com/es-shims/es5-shim/issues/150
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2319
            var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2320
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2321
            delete empty.constructor;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2322
            delete empty.hasOwnProperty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2323
            delete empty.propertyIsEnumerable;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2324
            delete empty.isPrototypeOf;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2325
            delete empty.toLocaleString;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2326
            delete empty.toString;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2327
            delete empty.valueOf;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2328
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2329
            var Empty = function Empty() {};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2330
            Empty.prototype = empty;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2331
            // short-circuit future calls
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2332
            createEmpty = function () {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2333
                return new Empty();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2334
            };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2335
            return new Empty();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2336
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2337
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2338
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2339
    Object.create = function create(prototype, properties) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2340
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2341
        var object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2342
        var Type = function Type() {}; // An empty constructor.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2343
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2344
        if (prototype === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2345
            object = createEmpty();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2346
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2347
            if (typeof prototype !== 'object' && typeof prototype !== 'function') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2348
                // In the native implementation `parent` can be `null`
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2349
                // OR *any* `instanceof Object`  (Object|Function|Array|RegExp|etc)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2350
                // Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2351
                // like they are in modern browsers. Using `Object.create` on DOM elements
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2352
                // is...err...probably inappropriate, but the native version allows for it.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2353
                throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2354
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2355
            Type.prototype = prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2356
            object = new Type();
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2357
            // IE has no built-in implementation of `Object.getPrototypeOf`
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2358
            // neither `__proto__`, but this manually setting `__proto__` will
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2359
            // guarantee that `Object.getPrototypeOf` will work as expected with
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2360
            // objects created using `Object.create`
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2361
            /* eslint-disable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2362
            object.__proto__ = prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2363
            /* eslint-enable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2364
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2365
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2366
        if (properties !== void 0) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2367
            Object.defineProperties(object, properties);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2368
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2369
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2370
        return object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2371
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2372
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2373
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2374
// ES5 15.2.3.6
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2375
// http://es5.github.com/#x15.2.3.6
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2376
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2377
// Patch for WebKit and IE8 standard mode
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2378
// Designed by hax <hax.github.com>
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2379
// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2380
// IE8 Reference:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2381
//     http://msdn.microsoft.com/en-us/library/dd282900.aspx
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2382
//     http://msdn.microsoft.com/en-us/library/dd229916.aspx
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2383
// WebKit Bugs:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2384
//     https://bugs.webkit.org/show_bug.cgi?id=36423
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2385
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2386
var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2387
    try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2388
        Object.defineProperty(object, 'sentinel', {});
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2389
        return 'sentinel' in object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2390
    } catch (exception) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2391
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2392
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2393
};
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2394
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2395
// check whether defineProperty works if it's given. Otherwise,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2396
// shim partially.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2397
if (Object.defineProperty) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2398
    var definePropertyWorksOnObject = doesDefinePropertyWork({});
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2399
    var definePropertyWorksOnDom = typeof document === 'undefined' ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2400
        doesDefinePropertyWork(document.createElement('div'));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2401
    if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2402
        var definePropertyFallback = Object.defineProperty,
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2403
            definePropertiesFallback = Object.defineProperties;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2404
    }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2405
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2406
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2407
if (!Object.defineProperty || definePropertyFallback) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2408
    var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2409
    var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2410
    var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2411
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2412
    Object.defineProperty = function defineProperty(object, property, descriptor) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2413
        if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2414
            throw new TypeError(ERR_NON_OBJECT_TARGET + object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2415
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2416
        if ((typeof descriptor !== 'object' && typeof descriptor !== 'function') || descriptor === null) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2417
            throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2418
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2419
        // make a valiant attempt to use the real defineProperty
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2420
        // for I8's DOM elements.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2421
        if (definePropertyFallback) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2422
            try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2423
                return definePropertyFallback.call(Object, object, property, descriptor);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2424
            } catch (exception) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2425
                // try the shim if the real one doesn't work
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2426
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2427
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2428
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2429
        // If it's a data property.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2430
        if ('value' in descriptor) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2431
            // fail silently if 'writable', 'enumerable', or 'configurable'
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2432
            // are requested but not supported
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2433
            /*
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2434
            // alternate approach:
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2435
            if ( // can't implement these features; allow false but not true
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2436
                ('writable' in descriptor && !descriptor.writable) ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2437
                ('enumerable' in descriptor && !descriptor.enumerable) ||
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2438
                ('configurable' in descriptor && !descriptor.configurable)
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2439
            ))
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2440
                throw new RangeError(
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2441
                    'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2442
                );
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2443
            */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2444
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2445
            if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2446
                // As accessors are supported only on engines implementing
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2447
                // `__proto__` we can safely override `__proto__` while defining
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2448
                // a property to make sure that we don't hit an inherited
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2449
                // accessor.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2450
                /* eslint-disable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2451
                var prototype = object.__proto__;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2452
                object.__proto__ = prototypeOfObject;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2453
                // Deleting a property anyway since getter / setter may be
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2454
                // defined on object itself.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2455
                delete object[property];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2456
                object[property] = descriptor.value;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2457
                // Setting original `__proto__` back now.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2458
                object.__proto__ = prototype;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2459
                /* eslint-enable no-proto */
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2460
            } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2461
                object[property] = descriptor.value;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2462
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2463
        } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2464
            if (!supportsAccessors && (('get' in descriptor) || ('set' in descriptor))) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2465
                throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2466
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2467
            // If we got that far then getters and setters can be defined !!
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2468
            if ('get' in descriptor) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2469
                defineGetter(object, property, descriptor.get);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2470
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2471
            if ('set' in descriptor) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2472
                defineSetter(object, property, descriptor.set);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2473
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2474
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2475
        return object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2476
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2477
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2478
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2479
// ES5 15.2.3.7
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2480
// http://es5.github.com/#x15.2.3.7
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2481
if (!Object.defineProperties || definePropertiesFallback) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2482
    Object.defineProperties = function defineProperties(object, properties) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2483
        // make a valiant attempt to use the real defineProperties
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2484
        if (definePropertiesFallback) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2485
            try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2486
                return definePropertiesFallback.call(Object, object, properties);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2487
            } catch (exception) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2488
                // try the shim if the real one doesn't work
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2489
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2490
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2491
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2492
        Object.keys(properties).forEach(function (property) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2493
            if (property !== '__proto__') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2494
                Object.defineProperty(object, property, properties[property]);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2495
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2496
        });
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2497
        return object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2498
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2499
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2500
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2501
// ES5 15.2.3.8
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2502
// http://es5.github.com/#x15.2.3.8
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2503
if (!Object.seal) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2504
    Object.seal = function seal(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2505
        if (Object(object) !== object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2506
            throw new TypeError('Object.seal can only be called on Objects.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2507
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2508
        // this is misleading and breaks feature-detection, but
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2509
        // allows "securable" code to "gracefully" degrade to working
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2510
        // but insecure code.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2511
        return object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2512
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2513
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2514
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2515
// ES5 15.2.3.9
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2516
// http://es5.github.com/#x15.2.3.9
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2517
if (!Object.freeze) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2518
    Object.freeze = function freeze(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2519
        if (Object(object) !== object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2520
            throw new TypeError('Object.freeze can only be called on Objects.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2521
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2522
        // this is misleading and breaks feature-detection, but
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2523
        // allows "securable" code to "gracefully" degrade to working
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2524
        // but insecure code.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2525
        return object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2526
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2527
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2528
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2529
// detect a Rhino bug and patch it
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2530
try {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2531
    Object.freeze(function () {});
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2532
} catch (exception) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2533
    Object.freeze = (function (freezeObject) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2534
        return function freeze(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2535
            if (typeof object === 'function') {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2536
                return object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2537
            } else {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2538
                return freezeObject(object);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2539
            }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2540
        };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2541
    }(Object.freeze));
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2542
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2543
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2544
// ES5 15.2.3.10
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2545
// http://es5.github.com/#x15.2.3.10
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2546
if (!Object.preventExtensions) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2547
    Object.preventExtensions = function preventExtensions(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2548
        if (Object(object) !== object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2549
            throw new TypeError('Object.preventExtensions can only be called on Objects.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2550
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2551
        // this is misleading and breaks feature-detection, but
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2552
        // allows "securable" code to "gracefully" degrade to working
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2553
        // but insecure code.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2554
        return object;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2555
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2556
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2557
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2558
// ES5 15.2.3.11
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2559
// http://es5.github.com/#x15.2.3.11
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2560
if (!Object.isSealed) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2561
    Object.isSealed = function isSealed(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2562
        if (Object(object) !== object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2563
            throw new TypeError('Object.isSealed can only be called on Objects.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2564
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2565
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2566
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2567
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2568
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2569
// ES5 15.2.3.12
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2570
// http://es5.github.com/#x15.2.3.12
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2571
if (!Object.isFrozen) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2572
    Object.isFrozen = function isFrozen(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2573
        if (Object(object) !== object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2574
            throw new TypeError('Object.isFrozen can only be called on Objects.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2575
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2576
        return false;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2577
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2578
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2579
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2580
// ES5 15.2.3.13
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2581
// http://es5.github.com/#x15.2.3.13
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2582
if (!Object.isExtensible) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2583
    Object.isExtensible = function isExtensible(object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2584
        // 1. If Type(O) is not Object throw a TypeError exception.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2585
        if (Object(object) !== object) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2586
            throw new TypeError('Object.isExtensible can only be called on Objects.');
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2587
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2588
        // 2. Return the Boolean value of the [[Extensible]] internal property of O.
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2589
        var name = '';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2590
        while (owns(object, name)) {
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2591
            name += '?';
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2592
        }
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2593
        object[name] = true;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2594
        var returnValue = owns(object, name);
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2595
        delete object[name];
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2596
        return returnValue;
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2597
    };
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2598
}
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2599
0ae5202742bd change flash to dash
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
  2600
}));