videojs-ng 6.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/LICENSE +13 -0
- data/README.md +98 -0
- data/Rakefile +2 -0
- data/lib/videojs/ng.rb +8 -0
- data/lib/videojs/ng/version.rb +5 -0
- data/vendor/LICENSE +13 -0
- data/vendor/assets/fonts/VideoJS.eot +0 -0
- data/vendor/assets/fonts/VideoJS.svg +102 -0
- data/vendor/assets/fonts/VideoJS.ttf +0 -0
- data/vendor/assets/fonts/VideoJS.woff +0 -0
- data/vendor/assets/javascripts/video-ie8.js +2600 -0
- data/vendor/assets/javascripts/video-lang.js +1 -0
- data/vendor/assets/javascripts/video-lang/ar.js +34 -0
- data/vendor/assets/javascripts/video-lang/ba.js +26 -0
- data/vendor/assets/javascripts/video-lang/bg.js +26 -0
- data/vendor/assets/javascripts/video-lang/ca.js +26 -0
- data/vendor/assets/javascripts/video-lang/cs.js +26 -0
- data/vendor/assets/javascripts/video-lang/da.js +26 -0
- data/vendor/assets/javascripts/video-lang/de.js +84 -0
- data/vendor/assets/javascripts/video-lang/el.js +40 -0
- data/vendor/assets/javascripts/video-lang/en.js +84 -0
- data/vendor/assets/javascripts/video-lang/es.js +27 -0
- data/vendor/assets/javascripts/video-lang/fa.js +26 -0
- data/vendor/assets/javascripts/video-lang/fi.js +26 -0
- data/vendor/assets/javascripts/video-lang/fr.js +84 -0
- data/vendor/assets/javascripts/video-lang/gl.js +27 -0
- data/vendor/assets/javascripts/video-lang/hr.js +26 -0
- data/vendor/assets/javascripts/video-lang/hu.js +26 -0
- data/vendor/assets/javascripts/video-lang/it.js +26 -0
- data/vendor/assets/javascripts/video-lang/ja.js +26 -0
- data/vendor/assets/javascripts/video-lang/ko.js +26 -0
- data/vendor/assets/javascripts/video-lang/nb.js +26 -0
- data/vendor/assets/javascripts/video-lang/nl.js +37 -0
- data/vendor/assets/javascripts/video-lang/nn.js +26 -0
- data/vendor/assets/javascripts/video-lang/pl.js +34 -0
- data/vendor/assets/javascripts/video-lang/pt-BR.js +26 -0
- data/vendor/assets/javascripts/video-lang/pt-PT.js +41 -0
- data/vendor/assets/javascripts/video-lang/ru.js +40 -0
- data/vendor/assets/javascripts/video-lang/sk.js +84 -0
- data/vendor/assets/javascripts/video-lang/sr.js +26 -0
- data/vendor/assets/javascripts/video-lang/sv.js +26 -0
- data/vendor/assets/javascripts/video-lang/tr.js +76 -0
- data/vendor/assets/javascripts/video-lang/uk.js +40 -0
- data/vendor/assets/javascripts/video-lang/vi.js +41 -0
- data/vendor/assets/javascripts/video-lang/zh-CN.js +40 -0
- data/vendor/assets/javascripts/video-lang/zh-TW.js +40 -0
- data/vendor/assets/javascripts/video-novtt.js +23012 -0
- data/vendor/assets/javascripts/video.js +24838 -0
- data/vendor/assets/stylesheets/video-cdn.css +1389 -0
- data/vendor/assets/stylesheets/video.css.erb +1401 -0
- data/videojs-ng.gemspec +26 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 24d8de9c6b3db3f90ec845a774cc3144570d96ac
|
4
|
+
data.tar.gz: 68e2a2335b86a0a8283eab16d0e69380130cd84e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b5ab7444b71ae2b3f7906c08e4aa33c337ce121f10683268211ccf8d7933f2d5005f4fe0e4b0069ecdf585919b201bcd90ddb93260b6869de391684c62b58a4
|
7
|
+
data.tar.gz: 3d92a46bed57f03617c5c46e57ccf59441a5023cbee8715746d0a4472a40c8267aec86652c5a88a3822769c11246a0fb829e1c6a0409db893afe2fcf9192e74d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2015, koparo.com <info@koparo.com>
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Videojs::Ng
|
2
|
+
|
3
|
+
Video.js is an open source library for working with video on the web, also known as an HTML video player.
|
4
|
+
|
5
|
+
This gem bundles the upstream distribution for use with the Ruby on Rails framework. The version number of
|
6
|
+
the gem always tracks the upstream javascript release and the gem itself doesn't provide any additional
|
7
|
+
methods or helpers. If a need for helpers arises in the future they will be developed as a separate gem
|
8
|
+
with this one as its dependency. Should a gem bug be discovered an additional version identifier will be
|
9
|
+
appended and incremented after the upstream version number.
|
10
|
+
|
11
|
+
The gem is developed and tested against Rails 5
|
12
|
+
|
13
|
+
## License
|
14
|
+
videojs-ng and changes made to videojs required for rails are licensed under ISC.
|
15
|
+
|
16
|
+
The original videojs code distributed with this gem is licensed under [Apache 2](https://tldrlegal.com/license/apache-license-2.0-%28apache-2.0%29)
|
17
|
+
You can find the videojs license file in the vendor directory, changes made to the original code base are as follows:
|
18
|
+
|
19
|
+
- added `video-lang.js` to optionally load all existing language files
|
20
|
+
- for consistency with other includes the following renames have been done
|
21
|
+
- `videojs-ie8.js` to `video-ie8.js`
|
22
|
+
- `video.novtt.js` to `video-novtt.js`
|
23
|
+
- `video-js.css` to `video.css.erb`
|
24
|
+
- `video-js-cdn.css` to `video-cdn.css`
|
25
|
+
- `video-js.css` was changed to load assets via rails `asset_path`
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
Add this line to your application's Gemfile:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
gem 'videojs-ng'
|
33
|
+
```
|
34
|
+
|
35
|
+
And then execute:
|
36
|
+
|
37
|
+
$ bundle
|
38
|
+
|
39
|
+
Or install it yourself as:
|
40
|
+
|
41
|
+
$ gem install videojs-ng
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
### CSS
|
46
|
+
|
47
|
+
#### self serving assets (recommended)
|
48
|
+
|
49
|
+
include the stylesheet in application.css file:
|
50
|
+
|
51
|
+
*= require video
|
52
|
+
|
53
|
+
and be sure to include the static assets in `config/initializers/assets.rb`
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
Rails.application.config.assets.precompile += %w( VideoJS.eot VideoJS.svg VideoJS.ttf VideoJS.woff )
|
57
|
+
```
|
58
|
+
|
59
|
+
#### using CDN for fonts
|
60
|
+
|
61
|
+
*= require video-cdn
|
62
|
+
|
63
|
+
### Player variants
|
64
|
+
|
65
|
+
#### default player (recommended)
|
66
|
+
|
67
|
+
Add the following directive to your JavaScript manifest file (application.js):
|
68
|
+
|
69
|
+
//= require video
|
70
|
+
|
71
|
+
#### without Mozilla vtt.js
|
72
|
+
|
73
|
+
By default videojs ships with Apache 2 licensed vtt.js use the novtt include
|
74
|
+
in application.js if you want to avoid it:
|
75
|
+
|
76
|
+
//= require video-novtt
|
77
|
+
|
78
|
+
#### IE8 support
|
79
|
+
|
80
|
+
If you happen to need ie8 support include (application.js):
|
81
|
+
|
82
|
+
//= require video-ie8
|
83
|
+
|
84
|
+
### Languages
|
85
|
+
|
86
|
+
Video.js includes localization support to present text in a language other than the default English where appropriate.
|
87
|
+
|
88
|
+
You can add the language you need to support by requiring it in your application.js:
|
89
|
+
|
90
|
+
//= require video-lang/es
|
91
|
+
|
92
|
+
If you want to load all existing supported languages require just video-lang in application.js:
|
93
|
+
|
94
|
+
//= require video-lang
|
95
|
+
|
96
|
+
## Contributing
|
97
|
+
|
98
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/koparo/videojs-ng.
|
data/Rakefile
ADDED
data/lib/videojs/ng.rb
ADDED
data/vendor/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright Brightcove, Inc.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
Binary file
|
@@ -0,0 +1,102 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4
|
+
<defs>
|
5
|
+
<font id="VideoJS" horiz-adv-x="1792">
|
6
|
+
<font-face font-family="VideoJS"
|
7
|
+
units-per-em="1792" ascent="1792"
|
8
|
+
descent="0" />
|
9
|
+
<missing-glyph horiz-adv-x="0" />
|
10
|
+
<glyph glyph-name="play"
|
11
|
+
unicode=""
|
12
|
+
horiz-adv-x="1792" d=" M597.3333333333334 1418.6666666666665V373.3333333333333L1418.6666666666667 896z" />
|
13
|
+
<glyph glyph-name="play-circle"
|
14
|
+
unicode=""
|
15
|
+
horiz-adv-x="1792" d=" M746.6666666666667 560L1194.6666666666667 896L746.6666666666667 1232V560zM896 1642.6666666666667C483.4666666666667 1642.6666666666667 149.3333333333334 1308.5333333333333 149.3333333333334 896S483.4666666666667 149.3333333333333 896 149.3333333333333S1642.6666666666667 483.4666666666667 1642.6666666666667 896S1308.5333333333333 1642.6666666666667 896 1642.6666666666667zM896 298.6666666666665C566.72 298.6666666666665 298.6666666666667 566.7199999999998 298.6666666666667 896S566.72 1493.3333333333333 896 1493.3333333333333S1493.3333333333335 1225.28 1493.3333333333335 896S1225.2800000000002 298.6666666666665 896 298.6666666666665z" />
|
16
|
+
<glyph glyph-name="pause"
|
17
|
+
unicode=""
|
18
|
+
horiz-adv-x="1792" d=" M448 373.3333333333333H746.6666666666667V1418.6666666666665H448V373.3333333333333zM1045.3333333333335 1418.6666666666665V373.3333333333333H1344V1418.6666666666665H1045.3333333333335z" />
|
19
|
+
<glyph glyph-name="volume-mute"
|
20
|
+
unicode=""
|
21
|
+
horiz-adv-x="1792" d=" M1232 896C1232 1027.7866666666666 1155.8400000000001 1141.6533333333332 1045.3333333333335 1196.5333333333333V1031.52L1228.6399999999999 848.2133333333334C1230.88 863.8933333333334 1232 879.9466666666667 1232 896.0000000000001zM1418.6666666666667 896C1418.6666666666667 825.8133333333333 1403.3600000000001 759.7333333333333 1378.3466666666668 698.8799999999999L1491.466666666667 585.7599999999998C1540 678.72 1568 783.9999999999999 1568 896C1568 1215.5733333333333 1344.3733333333334 1482.88 1045.3333333333335 1550.8266666666666V1396.6399999999999C1261.1200000000001 1332.4266666666667 1418.6666666666667 1132.6933333333332 1418.6666666666667 896zM319.2000000000001 1568L224 1472.8L576.8 1120H224V672H522.6666666666667L896 298.6666666666665V800.8L1213.7066666666667 483.0933333333332C1163.68 444.6399999999999 1107.3066666666666 413.6533333333332 1045.3333333333335 394.9866666666665V240.7999999999998C1148 264.32 1241.7066666666667 311.3599999999997 1320.48 375.9466666666663L1472.8000000000002 224L1568 319.1999999999998L896 991.1999999999998L319.2000000000001 1568zM896 1493.3333333333333L739.9466666666667 1337.28L896 1181.2266666666667V1493.3333333333333z" />
|
22
|
+
<glyph glyph-name="volume-low"
|
23
|
+
unicode=""
|
24
|
+
horiz-adv-x="1792" d=" M522.6666666666667 1120V672H821.3333333333334L1194.6666666666667 298.6666666666665V1493.3333333333333L821.3333333333334 1120H522.6666666666667z" />
|
25
|
+
<glyph glyph-name="volume-mid"
|
26
|
+
unicode=""
|
27
|
+
horiz-adv-x="1792" d=" M1381.3333333333335 896C1381.3333333333335 1027.7866666666666 1305.1733333333334 1141.6533333333332 1194.6666666666667 1196.5333333333333V595.0933333333332C1305.1733333333334 650.3466666666666 1381.3333333333335 764.2133333333331 1381.3333333333335 896zM373.3333333333334 1120V672H672L1045.3333333333335 298.6666666666665V1493.3333333333333L672 1120H373.3333333333334z" />
|
28
|
+
<glyph glyph-name="volume-high"
|
29
|
+
unicode=""
|
30
|
+
horiz-adv-x="1792" d=" M224 1120V672H522.6666666666667L896 298.6666666666665V1493.3333333333333L522.6666666666667 1120H224zM1232 896C1232 1027.7866666666666 1155.8400000000001 1141.6533333333332 1045.3333333333335 1196.5333333333333V595.0933333333332C1155.8400000000001 650.3466666666666 1232 764.2133333333331 1232 896zM1045.3333333333335 1550.8266666666666V1396.6399999999999C1261.1200000000001 1332.4266666666667 1418.6666666666667 1132.6933333333332 1418.6666666666667 896S1261.1200000000001 459.5733333333333 1045.3333333333335 395.3600000000002V241.1733333333332C1344.3733333333334 309.1199999999999 1568 576.0533333333333 1568 896S1344.3733333333334 1482.88 1045.3333333333335 1550.8266666666666z" />
|
31
|
+
<glyph glyph-name="fullscreen-enter"
|
32
|
+
unicode=""
|
33
|
+
horiz-adv-x="1792" d=" M522.6666666666667 746.6666666666665H373.3333333333334V373.3333333333333H746.6666666666667V522.6666666666665H522.6666666666667V746.6666666666665zM373.3333333333334 1045.3333333333333H522.6666666666667V1269.3333333333333H746.6666666666667V1418.6666666666665H373.3333333333334V1045.3333333333333zM1269.3333333333335 522.6666666666665H1045.3333333333335V373.3333333333333H1418.6666666666667V746.6666666666665H1269.3333333333335V522.6666666666665zM1045.3333333333335 1418.6666666666665V1269.3333333333333H1269.3333333333335V1045.3333333333333H1418.6666666666667V1418.6666666666665H1045.3333333333335z" />
|
34
|
+
<glyph glyph-name="fullscreen-exit"
|
35
|
+
unicode=""
|
36
|
+
horiz-adv-x="1792" d=" M373.3333333333334 597.3333333333333H597.3333333333334V373.3333333333333H746.6666666666667V746.6666666666665H373.3333333333334V597.3333333333333zM597.3333333333334 1194.6666666666665H373.3333333333334V1045.3333333333333H746.6666666666667V1418.6666666666665H597.3333333333334V1194.6666666666665zM1045.3333333333335 373.3333333333333H1194.6666666666667V597.3333333333333H1418.6666666666667V746.6666666666665H1045.3333333333335V373.3333333333333zM1194.6666666666667 1194.6666666666665V1418.6666666666665H1045.3333333333335V1045.3333333333333H1418.6666666666667V1194.6666666666665H1194.6666666666667z" />
|
37
|
+
<glyph glyph-name="square"
|
38
|
+
unicode=""
|
39
|
+
horiz-adv-x="1792" d=" M1344 1493.3333333333333H448C365.4933333333334 1493.3333333333333 298.6666666666667 1426.5066666666667 298.6666666666667 1344V448C298.6666666666667 365.4933333333331 365.4933333333334 298.6666666666665 448 298.6666666666665H1344C1426.506666666667 298.6666666666665 1493.3333333333335 365.4933333333331 1493.3333333333335 448V1344C1493.3333333333335 1426.5066666666667 1426.506666666667 1493.3333333333333 1344 1493.3333333333333zM1344 448H448V1344H1344V448z" />
|
40
|
+
<glyph glyph-name="spinner"
|
41
|
+
unicode=""
|
42
|
+
horiz-adv-x="1792" d=" M701.8666666666668 1008L1057.6533333333334 1624.3733333333334C1005.7600000000002 1635.9466666666667 951.6266666666666 1642.6666666666667 896 1642.6666666666667C716.8000000000001 1642.6666666666667 552.9066666666668 1579.5733333333333 424.1066666666667 1474.2933333333333L697.76 1000.5333333333334L701.8666666666666 1008zM1608.32 1120C1539.6266666666666 1338.4 1373.1200000000001 1512.7466666666667 1160.6933333333332 1593.3866666666668L887.4133333333334 1120H1608.32zM1627.7333333333336 1045.3333333333333H1068.48L1090.1333333333334 1008L1445.92 392C1567.6266666666668 524.9066666666668 1642.6666666666667 701.4933333333333 1642.6666666666667 896C1642.6666666666667 947.1466666666666 1637.44 997.1733333333332 1627.7333333333336 1045.3333333333333zM637.2800000000001 896L346.08 1400C224.3733333333333 1267.0933333333332 149.3333333333334 1090.5066666666667 149.3333333333334 896C149.3333333333334 844.8533333333332 154.56 794.8266666666666 164.2666666666667 746.6666666666665H723.5200000000001L637.2800000000002 896zM183.68 672C252.3733333333334 453.5999999999999 418.88 279.2533333333334 631.3066666666667 198.6133333333332L904.5866666666668 672H183.68zM1025.1733333333334 672L733.9733333333334 167.6266666666666C786.24 156.0533333333333 840.3733333333334 149.3333333333333 896 149.3333333333333C1075.2 149.3333333333333 1239.0933333333332 212.4266666666665 1367.8933333333334 317.7066666666665L1094.24 791.4666666666666L1025.1733333333334 672z" />
|
43
|
+
<glyph glyph-name="subtitles"
|
44
|
+
unicode=""
|
45
|
+
horiz-adv-x="1792" d=" M1493.3333333333335 1493.3333333333333H298.6666666666667C216.16 1493.3333333333333 149.3333333333334 1426.5066666666667 149.3333333333334 1344V448C149.3333333333334 365.4933333333331 216.16 298.6666666666665 298.6666666666667 298.6666666666665H1493.3333333333335C1575.8400000000001 298.6666666666665 1642.6666666666667 365.4933333333331 1642.6666666666667 448V1344C1642.6666666666667 1426.5066666666667 1575.8400000000001 1493.3333333333333 1493.3333333333335 1493.3333333333333zM298.6666666666667 896H597.3333333333334V746.6666666666665H298.6666666666667V896zM1045.3333333333335 448H298.6666666666667V597.3333333333333H1045.3333333333335V448zM1493.3333333333335 448H1194.6666666666667V597.3333333333333H1493.3333333333335V448zM1493.3333333333335 746.6666666666665H746.6666666666667V896H1493.3333333333335V746.6666666666665z" />
|
46
|
+
<glyph glyph-name="captions"
|
47
|
+
unicode=""
|
48
|
+
horiz-adv-x="1792" d=" M1418.6666666666667 1493.3333333333333H373.3333333333334C290.8266666666667 1493.3333333333333 224 1426.5066666666667 224 1344V448C224 365.4933333333331 290.8266666666667 298.6666666666665 373.3333333333334 298.6666666666665H1418.6666666666667C1501.1733333333334 298.6666666666665 1568 365.4933333333331 1568 448V1344C1568 1426.5066666666667 1501.1733333333334 1493.3333333333333 1418.6666666666667 1493.3333333333333zM821.3333333333334 970.6666666666666H709.3333333333334V1008H560V783.9999999999999H709.3333333333334V821.3333333333333H821.3333333333334V746.6666666666665C821.3333333333334 705.5999999999999 788.1066666666667 672 746.6666666666667 672H522.6666666666667C481.2266666666667 672 448 705.5999999999999 448 746.6666666666665V1045.3333333333333C448 1086.4 481.2266666666667 1120 522.6666666666667 1120H746.6666666666667C788.1066666666667 1120 821.3333333333334 1086.4 821.3333333333334 1045.3333333333333V970.6666666666666zM1344 970.6666666666666H1232V1008H1082.6666666666667V783.9999999999999H1232V821.3333333333333H1344V746.6666666666665C1344 705.5999999999999 1310.7733333333333 672 1269.3333333333335 672H1045.3333333333335C1003.8933333333334 672 970.6666666666669 705.5999999999999 970.6666666666669 746.6666666666665V1045.3333333333333C970.6666666666669 1086.4 1003.8933333333334 1120 1045.3333333333335 1120H1269.3333333333335C1310.7733333333333 1120 1344 1086.4 1344 1045.3333333333333V970.6666666666666z" />
|
49
|
+
<glyph glyph-name="chapters"
|
50
|
+
unicode=""
|
51
|
+
horiz-adv-x="1792" d=" M224 821.3333333333333H373.3333333333334V970.6666666666666H224V821.3333333333333zM224 522.6666666666665H373.3333333333334V672H224V522.6666666666665zM224 1120H373.3333333333334V1269.3333333333333H224V1120zM522.6666666666667 821.3333333333333H1568V970.6666666666666H522.6666666666667V821.3333333333333zM522.6666666666667 522.6666666666665H1568V672H522.6666666666667V522.6666666666665zM522.6666666666667 1269.3333333333333V1120H1568V1269.3333333333333H522.6666666666667z" />
|
52
|
+
<glyph glyph-name="share"
|
53
|
+
unicode=""
|
54
|
+
horiz-adv-x="1792" d=" M1344 590.9866666666665C1287.2533333333333 590.9866666666665 1236.1066666666668 568.9599999999998 1197.2800000000002 533.4933333333331L665.2800000000001 843.7333333333333C669.3866666666667 860.5333333333333 672 878.08 672 896S669.3866666666667 931.4666666666666 665.2800000000001 948.2666666666667L1191.68 1255.52C1231.6266666666668 1218.1866666666665 1285.0133333333335 1195.04 1344 1195.04C1467.5733333333335 1195.04 1568 1295.4666666666665 1568 1419.04S1467.5733333333335 1643.04 1344 1643.04S1120 1542.6133333333332 1120 1419.04C1120 1401.12 1122.6133333333335 1383.5733333333333 1126.72 1366.773333333333L600.3199999999999 1059.5199999999998C560.3733333333333 1096.853333333333 506.9866666666666 1119.9999999999998 448 1119.9999999999998C324.4266666666666 1119.9999999999998 224 1019.5733333333332 224 895.9999999999998S324.4266666666666 671.9999999999998 448 671.9999999999998C506.9866666666666 671.9999999999998 560.3733333333333 695.1466666666665 600.3199999999999 732.4799999999998L1132.32 422.2399999999998C1128.5866666666666 406.5599999999997 1126.3466666666666 390.133333333333 1126.3466666666666 373.3333333333331C1126.3466666666666 253.1199999999997 1223.7866666666669 155.6799999999996 1344 155.6799999999996S1561.6533333333334 253.1199999999997 1561.6533333333334 373.3333333333331S1464.2133333333334 590.9866666666662 1344 590.9866666666662z" />
|
55
|
+
<glyph glyph-name="cog"
|
56
|
+
unicode=""
|
57
|
+
horiz-adv-x="1792" d=" M1450.7733333333333 823.1999999999999C1453.76 847.0933333333334 1456 871.3599999999999 1456 896S1453.76 944.9066666666666 1450.7733333333333 968.8L1608.6933333333336 1092.3733333333332C1622.8800000000003 1103.5733333333333 1626.986666666667 1123.7333333333331 1617.6533333333336 1140.1599999999999L1468.3200000000004 1398.8799999999999C1458.986666666667 1414.9333333333334 1439.5733333333335 1421.6533333333332 1422.7733333333338 1414.9333333333334L1236.8533333333337 1339.8933333333332C1198.4000000000003 1369.3866666666668 1156.2133333333338 1394.3999999999999 1110.6666666666672 1413.44L1082.6666666666667 1611.3066666666666C1079.3066666666668 1628.8533333333332 1064 1642.6666666666667 1045.3333333333335 1642.6666666666667H746.6666666666667C728 1642.6666666666667 712.6933333333334 1628.8533333333332 709.7066666666668 1611.3066666666666L681.7066666666668 1413.44C636.1600000000002 1394.4 593.9733333333335 1369.76 555.5200000000001 1339.8933333333332L369.6 1414.9333333333334C352.8000000000001 1421.28 333.3866666666667 1414.9333333333334 324.0533333333334 1398.88L174.72 1140.1599999999999C165.3866666666667 1124.1066666666666 169.4933333333334 1103.9466666666667 183.68 1092.3733333333332L341.2266666666667 968.8C338.2400000000001 944.9066666666666 336 920.64 336 896S338.2400000000001 847.0933333333334 341.2266666666667 823.1999999999999L183.68 699.6266666666668C169.4933333333334 688.4266666666667 165.3866666666667 668.2666666666667 174.72 651.8399999999999L324.0533333333334 393.1199999999999C333.3866666666667 377.0666666666666 352.8 370.3466666666666 369.6 377.0666666666666L555.5200000000001 452.1066666666666C593.9733333333334 422.6133333333333 636.16 397.5999999999999 681.7066666666668 378.56L709.7066666666668 180.6933333333334C712.6933333333334 163.1466666666668 728 149.3333333333333 746.6666666666667 149.3333333333333H1045.3333333333335C1064 149.3333333333333 1079.3066666666668 163.1466666666665 1082.2933333333333 180.6933333333334L1110.2933333333333 378.56C1155.84 397.5999999999999 1198.0266666666666 422.24 1236.48 452.1066666666666L1422.3999999999999 377.0666666666666C1439.2 370.7199999999998 1458.6133333333332 377.0666666666666 1467.9466666666665 393.1199999999999L1617.2799999999997 651.8399999999999C1626.6133333333332 667.8933333333332 1622.5066666666664 688.0533333333333 1608.3199999999997 699.6266666666668L1450.773333333333 823.1999999999999zM896 634.6666666666665C751.52 634.6666666666665 634.6666666666667 751.52 634.6666666666667 896S751.52 1157.3333333333333 896 1157.3333333333333S1157.3333333333335 1040.48 1157.3333333333335 896S1040.48 634.6666666666665 896 634.6666666666665z" />
|
58
|
+
<glyph glyph-name="circle"
|
59
|
+
unicode=""
|
60
|
+
horiz-adv-x="1792" d=" M149.3333333333334 896C149.3333333333334 483.6273867930074 483.6273867930075 149.3333333333333 896 149.3333333333333C1308.3726132069926 149.3333333333333 1642.6666666666667 483.6273867930074 1642.6666666666667 896C1642.6666666666667 1308.3726132069926 1308.3726132069926 1642.6666666666667 896 1642.6666666666667C483.6273867930075 1642.6666666666667 149.3333333333334 1308.3726132069926 149.3333333333334 896z" />
|
61
|
+
<glyph glyph-name="circle-outline"
|
62
|
+
unicode=""
|
63
|
+
horiz-adv-x="1792" d=" M896 1642.6666666666667C483.4666666666667 1642.6666666666667 149.3333333333334 1308.5333333333333 149.3333333333334 896S483.4666666666667 149.3333333333333 896 149.3333333333333S1642.6666666666667 483.4666666666667 1642.6666666666667 896S1308.5333333333333 1642.6666666666667 896 1642.6666666666667zM896 298.6666666666665C566.72 298.6666666666665 298.6666666666667 566.7199999999998 298.6666666666667 896S566.72 1493.3333333333333 896 1493.3333333333333S1493.3333333333335 1225.28 1493.3333333333335 896S1225.2800000000002 298.6666666666665 896 298.6666666666665z" />
|
64
|
+
<glyph glyph-name="circle-inner-circle"
|
65
|
+
unicode=""
|
66
|
+
horiz-adv-x="1792" d=" M896 1642.6666666666667C484.2133333333334 1642.6666666666667 149.3333333333334 1307.7866666666666 149.3333333333334 896S484.2133333333334 149.3333333333333 896 149.3333333333333S1642.6666666666667 484.2133333333331 1642.6666666666667 896S1307.7866666666669 1642.6666666666667 896 1642.6666666666667zM896 298.6666666666665C566.72 298.6666666666665 298.6666666666667 566.7199999999998 298.6666666666667 896S566.72 1493.3333333333333 896 1493.3333333333333S1493.3333333333335 1225.28 1493.3333333333335 896S1225.2800000000002 298.6666666666665 896 298.6666666666665zM1120 896C1120 772.4266666666666 1019.5733333333334 672 896 672S672 772.4266666666666 672 896S772.4266666666667 1120 896 1120S1120 1019.5733333333332 1120 896z" />
|
67
|
+
<glyph glyph-name="hd"
|
68
|
+
unicode=""
|
69
|
+
horiz-adv-x="1792" d=" M1418.6666666666667 1568H373.3333333333334C290.4533333333333 1568 224 1500.8 224 1418.6666666666665V373.3333333333333C224 291.1999999999998 290.4533333333334 224 373.3333333333334 224H1418.6666666666667C1500.8000000000002 224 1568 291.1999999999998 1568 373.3333333333333V1418.6666666666665C1568 1500.8 1500.8000000000002 1568 1418.6666666666667 1568zM821.3333333333334 672H709.3333333333334V821.3333333333333H560V672H448V1120H560V933.3333333333331H709.3333333333334V1120H821.3333333333334V672zM970.6666666666669 1120H1269.3333333333335C1310.4 1120 1344 1086.4 1344 1045.3333333333333V746.6666666666665C1344 705.5999999999999 1310.4 672 1269.3333333333335 672H970.6666666666669V1120zM1082.6666666666667 783.9999999999999H1232V1008H1082.6666666666667V783.9999999999999z" />
|
70
|
+
<glyph glyph-name="cancel"
|
71
|
+
unicode=""
|
72
|
+
horiz-adv-x="1792" d=" M896 1642.6666666666667C483.4666666666667 1642.6666666666667 149.3333333333334 1308.5333333333333 149.3333333333334 896S483.4666666666667 149.3333333333333 896 149.3333333333333S1642.6666666666667 483.4666666666667 1642.6666666666667 896S1308.5333333333333 1642.6666666666667 896 1642.6666666666667zM1269.3333333333335 628.3199999999999L1163.68 522.6666666666665L896 790.3466666666667L628.3199999999999 522.6666666666665L522.6666666666667 628.3199999999999L790.3466666666668 896L522.6666666666667 1163.68L628.3199999999999 1269.3333333333333L896 1001.6533333333332L1163.68 1269.3333333333333L1269.3333333333335 1163.68L1001.6533333333334 896L1269.3333333333335 628.3199999999999z" />
|
73
|
+
<glyph glyph-name="replay"
|
74
|
+
unicode=""
|
75
|
+
horiz-adv-x="1792" d=" M896 1418.6666666666665V1717.3333333333333L522.6666666666667 1344L896 970.6666666666666V1269.3333333333333C1143.52 1269.3333333333333 1344 1068.8533333333332 1344 821.3333333333333S1143.52 373.3333333333333 896 373.3333333333333S448 573.813333333333 448 821.3333333333333H298.6666666666667C298.6666666666667 491.3066666666664 565.9733333333334 224 896 224S1493.3333333333335 491.3066666666664 1493.3333333333335 821.3333333333333S1226.0266666666669 1418.6666666666665 896 1418.6666666666665z" />
|
76
|
+
<glyph glyph-name="facebook"
|
77
|
+
unicode=""
|
78
|
+
horiz-adv-x="1792" d=" M1343 1780V1516H1186Q1100 1516 1070 1480T1040 1372V1183H1333L1294 887H1040V128H734V887H479V1183H734V1401Q734 1587 838 1689.5T1115 1792Q1262 1792 1343 1780z" />
|
79
|
+
<glyph glyph-name="gplus"
|
80
|
+
unicode=""
|
81
|
+
horiz-adv-x="1792" d=" M799 996Q799 960 831 925.5T908.5 857.5T999 784T1076 680T1108 538Q1108 448 1060 365Q988 243 849 185.5T551 128Q419 128 304.5 169.5T133 307Q96 367 96 438Q96 519 140.5 588T259 703Q390 785 663 803Q631 845 615.5 877T600 950Q600 986 621 1035Q575 1031 553 1031Q405 1031 303.5 1127.5T202 1372Q202 1454 238 1531T337 1662Q414 1728 519.5 1760T737 1792H1155L1017 1704H886Q960 1641 998 1571T1036 1411Q1036 1339 1011.5 1281.5T952.5 1188.5T883 1123.5T823.5 1062T799 996zM653 1092Q691 1092 731 1108.5T797 1152Q850 1209 850 1311Q850 1369 833 1436T784.5 1565.5T700 1669T583 1710Q541 1710 500.5 1690.5T435 1638Q388 1579 388 1478Q388 1432 398 1380.5T429.5 1277.5T481.5 1185T556.5 1118T653 1092zM655 219Q713 219 766.5 232T865.5 271T938.5 344T966 453Q966 478 959 502T944.5 544T917.5 585.5T888 620.5T849.5 655T813 684T771.5 714T735 740Q719 742 687 742Q634 742 582 735T474.5 710T377.5 664T309 589.5T282 484Q282 414 317 360.5T408.5 277.5T527.5 233.5T655 219zM1465 1095H1678V987H1465V768H1360V987H1148V1095H1360V1312H1465V1095z" />
|
82
|
+
<glyph glyph-name="linkedin"
|
83
|
+
unicode=""
|
84
|
+
horiz-adv-x="1792" d=" M477 1167V176H147V1167H477zM498 1473Q499 1400 447.5 1351T312 1302H310Q228 1302 178 1351T128 1473Q128 1547 179.5 1595.5T314 1644T447 1595.5T498 1473zM1664 744V176H1335V706Q1335 811 1294.5 870.5T1168 930Q1105 930 1062.5 895.5T999 810Q988 780 988 729V176H659Q661 575 661 823T660 1119L659 1167H988V1023H986Q1006 1055 1027 1079T1083.5 1131T1170.5 1174.5T1285 1190Q1456 1190 1560 1076.5T1664 744z" />
|
85
|
+
<glyph glyph-name="twitter"
|
86
|
+
unicode=""
|
87
|
+
horiz-adv-x="1792" d=" M1684 1384Q1617 1286 1522 1217Q1523 1203 1523 1175Q1523 1045 1485 915.5T1369.5 667T1185 456.5T927 310.5T604 256Q333 256 108 401Q143 397 186 397Q411 397 587 535Q482 537 399 599.5T285 759Q318 754 346 754Q389 754 431 765Q319 788 245.5 876.5T172 1082V1086Q240 1048 318 1045Q252 1089 213 1160T174 1314Q174 1402 218 1477Q339 1328 512.5 1238.5T884 1139Q876 1177 876 1213Q876 1347 970.5 1441.5T1199 1536Q1339 1536 1435 1434Q1544 1455 1640 1512Q1603 1397 1498 1334Q1591 1344 1684 1384z" />
|
88
|
+
<glyph glyph-name="tumblr"
|
89
|
+
unicode=""
|
90
|
+
horiz-adv-x="1792" d=" M1328 463L1408 226Q1385 191 1297 160T1120 128Q1016 126 929.5 154T787 228T692 334T636.5 454T620 572V1116H452V1331Q524 1357 581 1400.5T672 1490.5T730 1592.5T764 1691.5T779 1780Q780 1785 783.5 1788.5T791 1792H1035V1368H1368V1116H1034V598Q1034 568 1040.5 542T1063 489.5T1112.5 448T1194 434Q1272 436 1328 463z" />
|
91
|
+
<glyph glyph-name="pinterest"
|
92
|
+
unicode=""
|
93
|
+
horiz-adv-x="1792" d=" M1664 896Q1664 687 1561 510.5T1281.5 231T896 128Q785 128 678 160Q737 253 756 324Q765 358 810 535Q830 496 883 467.5T997 439Q1118 439 1213 507.5T1360 696T1412 966Q1412 1080 1352.5 1180T1180 1343T925 1406Q820 1406 729 1377T574.5 1300T465.5 1189.5T398.5 1060T377 926Q377 822 417 743T534 632Q564 620 572 652Q574 659 580 683T588 713Q594 736 577 756Q526 817 526 907Q526 1058 630.5 1166.5T904 1275Q1055 1275 1139.5 1193T1224 980Q1224 810 1155.5 691T980 572Q919 572 882 615.5T859 720Q867 755 885.5 813.5T915.5 916.5T927 992Q927 1042 900 1075T823 1108Q761 1108 718 1051T675 909Q675 836 700 787L601 369Q584 299 588 192Q382 283 255 473T128 896Q128 1105 231 1281.5T510.5 1561T896 1664T1281.5 1561T1561 1281.5T1664 896z" />
|
94
|
+
<glyph glyph-name="audio-description"
|
95
|
+
unicode=""
|
96
|
+
horiz-adv-x="1792" d=" M795.5138904615 457.270933L795.5138904615 1221.5248286325C971.84576475 1225.085121904 1107.39330415 1232.12360523 1207.223857 1161.5835220499998C1303.033991 1093.8857027 1377.7922305 962.20560625 1364.3373135 792.9476205000001C1350.102593 613.9029365000001 1219.6655764999998 463.4600215 1050.12389545 448.2843645000001C965.8259268 440.7398275000001 798.21890505 448.2843645000001 798.21890505 448.2843645000001C798.21890505 448.2843645000001 795.2791410655 453.016494 795.5138904615 457.270933M966.1564647 649.0863960000001C1076.16084135 644.6767075 1152.385591 707.3020429999999 1163.8910079999998 807.9351875C1179.2994744999999 942.71878505 1089.73043585 1030.3691748 960.74508635 1020.7227954L960.74508635 658.08043C960.6196169500002 652.9482330000001 962.7606933 650.3134680000001 966.1564647 649.0863960000001 M1343.2299685 457.3517725000002C1389.9059734 444.3690160000001 1404.0840274999998 496.0596970000001 1424.48294065 532.2791494999999C1469.0084255 611.2788500000001 1502.5101322 712.8584189999999 1503.0416912 828.9881705C1503.8147453000001 995.5680973 1438.8404296 1117.7973688000002 1378.4383305 1200.62456881045L1348.652139905 1200.62456881045C1346.6001063899998 1187.06858424 1356.44474056 1175.024791325 1362.18395859 1164.6588891000001C1408.2649952 1081.49431985 1450.96645015 966.7230041 1451.57490975 834.9817034999999C1452.27106325 683.8655425000002 1402.00636065 557.5072264999999 1343.2299685 457.3517725000002 M1488.0379675 457.3517725000002C1534.7139723999999 444.3690160000001 1548.8825828 496.0671625 1569.29093965 532.2791494999999C1613.8164245 611.2788500000001 1647.3113856500001 712.8584189999999 1647.8496902000002 828.9881705C1648.6227442999998 995.5680973 1583.6484286 1117.7973688000002 1523.2463295 1200.62456881045L1493.460138905 1200.62456881045C1491.40810539 1187.06858424 1501.250041305 1175.021805755 1506.9919575899999 1164.6588891000001C1553.0729942 1081.49431985 1595.7757984 966.7230041 1596.3829087499998 834.9817034999999C1597.07906225 683.8655425000002 1546.8143596500001 557.5072264999999 1488.0379675 457.3517725000002 M1631.9130380000001 457.3517725000002C1678.5890429 444.3690160000001 1692.7576533 496.0671625 1713.1660101500001 532.2791494999999C1757.691495 611.2788500000001 1791.1864561500001 712.8584189999999 1791.7247607000002 828.9881705C1792.4978148 995.5680973 1727.5234991000002 1117.7973688000002 1667.1214 1200.62456881045L1637.3352094050001 1200.62456881045C1635.28317589 1187.06858424 1645.1251118050002 1175.02329854 1650.86702809 1164.6588891000001C1696.9480647 1081.49431985 1739.64951965 966.7230041 1740.25797925 834.9817034999999C1740.95413275 683.8655425000002 1690.6894301500001 557.5072264999999 1631.9130380000001 457.3517725000002 M15.66796875 451.481947L254.03034755 451.481947L319.0356932 551.1747990000001L543.6261075 551.6487970000001C543.6261075 551.6487970000001 543.8541115 483.7032095 543.8541115 451.481947L714.4993835 451.481947L714.4993835 1230.9210795L508.643051 1230.9210795C488.8579955 1197.5411595 15.66796875 451.481947 15.66796875 451.481947L15.66796875 451.481947zM550.0048155000001 959.9708615L550.0048155000001 710.916297L408.4199 711.8642895L550.0048155000001 959.9708615L550.0048155000001 959.9708615z" />
|
97
|
+
<glyph glyph-name="audio"
|
98
|
+
unicode=""
|
99
|
+
horiz-adv-x="1792" d=" M896 1717.3333333333333C524.9066666666668 1717.3333333333333 224 1416.4266666666667 224 1045.3333333333333V522.6666666666665C224 399.0933333333333 324.4266666666667 298.6666666666665 448 298.6666666666665H672V896H373.3333333333334V1045.3333333333333C373.3333333333334 1333.92 607.4133333333334 1568 896 1568S1418.6666666666667 1333.92 1418.6666666666667 1045.3333333333333V896H1120V298.6666666666665H1344C1467.5733333333335 298.6666666666665 1568 399.0933333333333 1568 522.6666666666665V1045.3333333333333C1568 1416.4266666666667 1267.0933333333332 1717.3333333333333 896 1717.3333333333333z" />
|
100
|
+
</font>
|
101
|
+
</defs>
|
102
|
+
</svg>
|
Binary file
|
Binary file
|
@@ -0,0 +1,2600 @@
|
|
1
|
+
/**
|
2
|
+
* HTML5 Element Shim for IE8
|
3
|
+
*
|
4
|
+
* **THIS CODE MUST BE LOADED IN THE <HEAD> OF THE DOCUMENT**
|
5
|
+
*
|
6
|
+
* Video.js uses the video tag as an embed code, even in IE8 which
|
7
|
+
* doesn't have support for HTML5 video. The following code is needed
|
8
|
+
* to make it possible to use the video tag. Otherwise IE8 ignores everything
|
9
|
+
* inside the video tag.
|
10
|
+
*/
|
11
|
+
if (typeof window.HTMLVideoElement === 'undefined') {
|
12
|
+
document.createElement('video');
|
13
|
+
document.createElement('audio');
|
14
|
+
document.createElement('track');
|
15
|
+
}
|
16
|
+
|
17
|
+
/*!
|
18
|
+
* https://github.com/es-shims/es5-shim
|
19
|
+
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
|
20
|
+
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
|
21
|
+
*/
|
22
|
+
|
23
|
+
// vim: ts=4 sts=4 sw=4 expandtab
|
24
|
+
|
25
|
+
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
|
26
|
+
;
|
27
|
+
|
28
|
+
// UMD (Universal Module Definition)
|
29
|
+
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
|
30
|
+
(function (root, factory) {
|
31
|
+
'use strict';
|
32
|
+
|
33
|
+
/* global define, exports, module */
|
34
|
+
if (typeof define === 'function' && define.amd) {
|
35
|
+
// AMD. Register as an anonymous module.
|
36
|
+
define(factory);
|
37
|
+
} else if (typeof exports === 'object') {
|
38
|
+
// Node. Does not work with strict CommonJS, but
|
39
|
+
// only CommonJS-like enviroments that support module.exports,
|
40
|
+
// like Node.
|
41
|
+
module.exports = factory();
|
42
|
+
} else {
|
43
|
+
// Browser globals (root is window)
|
44
|
+
root.returnExports = factory();
|
45
|
+
}
|
46
|
+
}(this, function () {
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Brings an environment as close to ECMAScript 5 compliance
|
50
|
+
* as is possible with the facilities of erstwhile engines.
|
51
|
+
*
|
52
|
+
* Annotated ES5: http://es5.github.com/ (specific links below)
|
53
|
+
* ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
|
54
|
+
* Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
|
55
|
+
*/
|
56
|
+
|
57
|
+
// Shortcut to an often accessed properties, in order to avoid multiple
|
58
|
+
// dereference that costs universally. This also holds a reference to known-good
|
59
|
+
// functions.
|
60
|
+
var $Array = Array;
|
61
|
+
var ArrayPrototype = $Array.prototype;
|
62
|
+
var $Object = Object;
|
63
|
+
var ObjectPrototype = $Object.prototype;
|
64
|
+
var FunctionPrototype = Function.prototype;
|
65
|
+
var $String = String;
|
66
|
+
var StringPrototype = $String.prototype;
|
67
|
+
var $Number = Number;
|
68
|
+
var NumberPrototype = $Number.prototype;
|
69
|
+
var array_slice = ArrayPrototype.slice;
|
70
|
+
var array_splice = ArrayPrototype.splice;
|
71
|
+
var array_push = ArrayPrototype.push;
|
72
|
+
var array_unshift = ArrayPrototype.unshift;
|
73
|
+
var array_concat = ArrayPrototype.concat;
|
74
|
+
var call = FunctionPrototype.call;
|
75
|
+
var apply = FunctionPrototype.apply;
|
76
|
+
var max = Math.max;
|
77
|
+
var min = Math.min;
|
78
|
+
|
79
|
+
// Having a toString local variable name breaks in Opera so use to_string.
|
80
|
+
var to_string = ObjectPrototype.toString;
|
81
|
+
|
82
|
+
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
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; };
|
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; };
|
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; };
|
86
|
+
|
87
|
+
/* inlined from http://npmjs.com/define-properties */
|
88
|
+
var supportsDescriptors = $Object.defineProperty && (function () {
|
89
|
+
try {
|
90
|
+
var obj = {};
|
91
|
+
$Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
|
92
|
+
for (var _ in obj) { return false; }
|
93
|
+
return obj.x === obj;
|
94
|
+
} catch (e) { /* this is ES3 */
|
95
|
+
return false;
|
96
|
+
}
|
97
|
+
}());
|
98
|
+
var defineProperties = (function (has) {
|
99
|
+
// Define configurable, writable, and non-enumerable props
|
100
|
+
// if they don't exist.
|
101
|
+
var defineProperty;
|
102
|
+
if (supportsDescriptors) {
|
103
|
+
defineProperty = function (object, name, method, forceAssign) {
|
104
|
+
if (!forceAssign && (name in object)) { return; }
|
105
|
+
$Object.defineProperty(object, name, {
|
106
|
+
configurable: true,
|
107
|
+
enumerable: false,
|
108
|
+
writable: true,
|
109
|
+
value: method
|
110
|
+
});
|
111
|
+
};
|
112
|
+
} else {
|
113
|
+
defineProperty = function (object, name, method, forceAssign) {
|
114
|
+
if (!forceAssign && (name in object)) { return; }
|
115
|
+
object[name] = method;
|
116
|
+
};
|
117
|
+
}
|
118
|
+
return function defineProperties(object, map, forceAssign) {
|
119
|
+
for (var name in map) {
|
120
|
+
if (has.call(map, name)) {
|
121
|
+
defineProperty(object, name, map[name], forceAssign);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
};
|
125
|
+
}(ObjectPrototype.hasOwnProperty));
|
126
|
+
|
127
|
+
//
|
128
|
+
// Util
|
129
|
+
// ======
|
130
|
+
//
|
131
|
+
|
132
|
+
/* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */
|
133
|
+
var isPrimitive = function isPrimitive(input) {
|
134
|
+
var type = typeof input;
|
135
|
+
return input === null || (type !== 'object' && type !== 'function');
|
136
|
+
};
|
137
|
+
|
138
|
+
var isActualNaN = $Number.isNaN || function (x) { return x !== x; };
|
139
|
+
|
140
|
+
var ES = {
|
141
|
+
// ES5 9.4
|
142
|
+
// http://es5.github.com/#x9.4
|
143
|
+
// http://jsperf.com/to-integer
|
144
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */
|
145
|
+
ToInteger: function ToInteger(num) {
|
146
|
+
var n = +num;
|
147
|
+
if (isActualNaN(n)) {
|
148
|
+
n = 0;
|
149
|
+
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
|
150
|
+
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
151
|
+
}
|
152
|
+
return n;
|
153
|
+
},
|
154
|
+
|
155
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */
|
156
|
+
ToPrimitive: function ToPrimitive(input) {
|
157
|
+
var val, valueOf, toStr;
|
158
|
+
if (isPrimitive(input)) {
|
159
|
+
return input;
|
160
|
+
}
|
161
|
+
valueOf = input.valueOf;
|
162
|
+
if (isCallable(valueOf)) {
|
163
|
+
val = valueOf.call(input);
|
164
|
+
if (isPrimitive(val)) {
|
165
|
+
return val;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
toStr = input.toString;
|
169
|
+
if (isCallable(toStr)) {
|
170
|
+
val = toStr.call(input);
|
171
|
+
if (isPrimitive(val)) {
|
172
|
+
return val;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
throw new TypeError();
|
176
|
+
},
|
177
|
+
|
178
|
+
// ES5 9.9
|
179
|
+
// http://es5.github.com/#x9.9
|
180
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */
|
181
|
+
ToObject: function (o) {
|
182
|
+
if (o == null) { // this matches both null and undefined
|
183
|
+
throw new TypeError("can't convert " + o + ' to object');
|
184
|
+
}
|
185
|
+
return $Object(o);
|
186
|
+
},
|
187
|
+
|
188
|
+
/* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */
|
189
|
+
ToUint32: function ToUint32(x) {
|
190
|
+
return x >>> 0;
|
191
|
+
}
|
192
|
+
};
|
193
|
+
|
194
|
+
//
|
195
|
+
// Function
|
196
|
+
// ========
|
197
|
+
//
|
198
|
+
|
199
|
+
// ES-5 15.3.4.5
|
200
|
+
// http://es5.github.com/#x15.3.4.5
|
201
|
+
|
202
|
+
var Empty = function Empty() {};
|
203
|
+
|
204
|
+
defineProperties(FunctionPrototype, {
|
205
|
+
bind: function bind(that) { // .length is 1
|
206
|
+
// 1. Let Target be the this value.
|
207
|
+
var target = this;
|
208
|
+
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
209
|
+
if (!isCallable(target)) {
|
210
|
+
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
|
211
|
+
}
|
212
|
+
// 3. Let A be a new (possibly empty) internal list of all of the
|
213
|
+
// argument values provided after thisArg (arg1, arg2 etc), in order.
|
214
|
+
// XXX slicedArgs will stand in for "A" if used
|
215
|
+
var args = array_slice.call(arguments, 1); // for normal call
|
216
|
+
// 4. Let F be a new native ECMAScript object.
|
217
|
+
// 11. Set the [[Prototype]] internal property of F to the standard
|
218
|
+
// built-in Function prototype object as specified in 15.3.3.1.
|
219
|
+
// 12. Set the [[Call]] internal property of F as described in
|
220
|
+
// 15.3.4.5.1.
|
221
|
+
// 13. Set the [[Construct]] internal property of F as described in
|
222
|
+
// 15.3.4.5.2.
|
223
|
+
// 14. Set the [[HasInstance]] internal property of F as described in
|
224
|
+
// 15.3.4.5.3.
|
225
|
+
var bound;
|
226
|
+
var binder = function () {
|
227
|
+
|
228
|
+
if (this instanceof bound) {
|
229
|
+
// 15.3.4.5.2 [[Construct]]
|
230
|
+
// When the [[Construct]] internal method of a function object,
|
231
|
+
// F that was created using the bind function is called with a
|
232
|
+
// list of arguments ExtraArgs, the following steps are taken:
|
233
|
+
// 1. Let target be the value of F's [[TargetFunction]]
|
234
|
+
// internal property.
|
235
|
+
// 2. If target has no [[Construct]] internal method, a
|
236
|
+
// TypeError exception is thrown.
|
237
|
+
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
|
238
|
+
// property.
|
239
|
+
// 4. Let args be a new list containing the same values as the
|
240
|
+
// list boundArgs in the same order followed by the same
|
241
|
+
// values as the list ExtraArgs in the same order.
|
242
|
+
// 5. Return the result of calling the [[Construct]] internal
|
243
|
+
// method of target providing args as the arguments.
|
244
|
+
|
245
|
+
var result = target.apply(
|
246
|
+
this,
|
247
|
+
array_concat.call(args, array_slice.call(arguments))
|
248
|
+
);
|
249
|
+
if ($Object(result) === result) {
|
250
|
+
return result;
|
251
|
+
}
|
252
|
+
return this;
|
253
|
+
|
254
|
+
} else {
|
255
|
+
// 15.3.4.5.1 [[Call]]
|
256
|
+
// When the [[Call]] internal method of a function object, F,
|
257
|
+
// which was created using the bind function is called with a
|
258
|
+
// this value and a list of arguments ExtraArgs, the following
|
259
|
+
// steps are taken:
|
260
|
+
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
|
261
|
+
// property.
|
262
|
+
// 2. Let boundThis be the value of F's [[BoundThis]] internal
|
263
|
+
// property.
|
264
|
+
// 3. Let target be the value of F's [[TargetFunction]] internal
|
265
|
+
// property.
|
266
|
+
// 4. Let args be a new list containing the same values as the
|
267
|
+
// list boundArgs in the same order followed by the same
|
268
|
+
// values as the list ExtraArgs in the same order.
|
269
|
+
// 5. Return the result of calling the [[Call]] internal method
|
270
|
+
// of target providing boundThis as the this value and
|
271
|
+
// providing args as the arguments.
|
272
|
+
|
273
|
+
// equiv: target.call(this, ...boundArgs, ...args)
|
274
|
+
return target.apply(
|
275
|
+
that,
|
276
|
+
array_concat.call(args, array_slice.call(arguments))
|
277
|
+
);
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
};
|
282
|
+
|
283
|
+
// 15. If the [[Class]] internal property of Target is "Function", then
|
284
|
+
// a. Let L be the length property of Target minus the length of A.
|
285
|
+
// b. Set the length own property of F to either 0 or L, whichever is
|
286
|
+
// larger.
|
287
|
+
// 16. Else set the length own property of F to 0.
|
288
|
+
|
289
|
+
var boundLength = max(0, target.length - args.length);
|
290
|
+
|
291
|
+
// 17. Set the attributes of the length own property of F to the values
|
292
|
+
// specified in 15.3.5.1.
|
293
|
+
var boundArgs = [];
|
294
|
+
for (var i = 0; i < boundLength; i++) {
|
295
|
+
array_push.call(boundArgs, '$' + i);
|
296
|
+
}
|
297
|
+
|
298
|
+
// XXX Build a dynamic function with desired amount of arguments is the only
|
299
|
+
// way to set the length property of a function.
|
300
|
+
// In environments where Content Security Policies enabled (Chrome extensions,
|
301
|
+
// for ex.) all use of eval or Function costructor throws an exception.
|
302
|
+
// However in all of these environments Function.prototype.bind exists
|
303
|
+
// and so this code will never be executed.
|
304
|
+
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
|
305
|
+
|
306
|
+
if (target.prototype) {
|
307
|
+
Empty.prototype = target.prototype;
|
308
|
+
bound.prototype = new Empty();
|
309
|
+
// Clean up dangling references.
|
310
|
+
Empty.prototype = null;
|
311
|
+
}
|
312
|
+
|
313
|
+
// TODO
|
314
|
+
// 18. Set the [[Extensible]] internal property of F to true.
|
315
|
+
|
316
|
+
// TODO
|
317
|
+
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
|
318
|
+
// 20. Call the [[DefineOwnProperty]] internal method of F with
|
319
|
+
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
|
320
|
+
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
|
321
|
+
// false.
|
322
|
+
// 21. Call the [[DefineOwnProperty]] internal method of F with
|
323
|
+
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
|
324
|
+
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
|
325
|
+
// and false.
|
326
|
+
|
327
|
+
// TODO
|
328
|
+
// NOTE Function objects created using Function.prototype.bind do not
|
329
|
+
// have a prototype property or the [[Code]], [[FormalParameters]], and
|
330
|
+
// [[Scope]] internal properties.
|
331
|
+
// XXX can't delete prototype in pure-js.
|
332
|
+
|
333
|
+
// 22. Return F.
|
334
|
+
return bound;
|
335
|
+
}
|
336
|
+
});
|
337
|
+
|
338
|
+
// _Please note: Shortcuts are defined after `Function.prototype.bind` as we
|
339
|
+
// use it in defining shortcuts.
|
340
|
+
var owns = call.bind(ObjectPrototype.hasOwnProperty);
|
341
|
+
var toStr = call.bind(ObjectPrototype.toString);
|
342
|
+
var arraySlice = call.bind(array_slice);
|
343
|
+
var arraySliceApply = apply.bind(array_slice);
|
344
|
+
var strSlice = call.bind(StringPrototype.slice);
|
345
|
+
var strSplit = call.bind(StringPrototype.split);
|
346
|
+
var strIndexOf = call.bind(StringPrototype.indexOf);
|
347
|
+
var pushCall = call.bind(array_push);
|
348
|
+
var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable);
|
349
|
+
var arraySort = call.bind(ArrayPrototype.sort);
|
350
|
+
|
351
|
+
//
|
352
|
+
// Array
|
353
|
+
// =====
|
354
|
+
//
|
355
|
+
|
356
|
+
var isArray = $Array.isArray || function isArray(obj) {
|
357
|
+
return toStr(obj) === '[object Array]';
|
358
|
+
};
|
359
|
+
|
360
|
+
// ES5 15.4.4.12
|
361
|
+
// http://es5.github.com/#x15.4.4.13
|
362
|
+
// Return len+argCount.
|
363
|
+
// [bugfix, ielt8]
|
364
|
+
// IE < 8 bug: [].unshift(0) === undefined but should be "1"
|
365
|
+
var hasUnshiftReturnValueBug = [].unshift(0) !== 1;
|
366
|
+
defineProperties(ArrayPrototype, {
|
367
|
+
unshift: function () {
|
368
|
+
array_unshift.apply(this, arguments);
|
369
|
+
return this.length;
|
370
|
+
}
|
371
|
+
}, hasUnshiftReturnValueBug);
|
372
|
+
|
373
|
+
// ES5 15.4.3.2
|
374
|
+
// http://es5.github.com/#x15.4.3.2
|
375
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
|
376
|
+
defineProperties($Array, { isArray: isArray });
|
377
|
+
|
378
|
+
// The IsCallable() check in the Array functions
|
379
|
+
// has been replaced with a strict check on the
|
380
|
+
// internal class of the object to trap cases where
|
381
|
+
// the provided function was actually a regular
|
382
|
+
// expression literal, which in V8 and
|
383
|
+
// JavaScriptCore is a typeof "function". Only in
|
384
|
+
// V8 are regular expression literals permitted as
|
385
|
+
// reduce parameters, so it is desirable in the
|
386
|
+
// general case for the shim to match the more
|
387
|
+
// strict and common behavior of rejecting regular
|
388
|
+
// expressions.
|
389
|
+
|
390
|
+
// ES5 15.4.4.18
|
391
|
+
// http://es5.github.com/#x15.4.4.18
|
392
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
|
393
|
+
|
394
|
+
// Check failure of by-index access of string characters (IE < 9)
|
395
|
+
// and failure of `0 in boxedString` (Rhino)
|
396
|
+
var boxedString = $Object('a');
|
397
|
+
var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
|
398
|
+
|
399
|
+
var properlyBoxesContext = function properlyBoxed(method) {
|
400
|
+
// Check node 0.6.21 bug where third parameter is not boxed
|
401
|
+
var properlyBoxesNonStrict = true;
|
402
|
+
var properlyBoxesStrict = true;
|
403
|
+
var threwException = false;
|
404
|
+
if (method) {
|
405
|
+
try {
|
406
|
+
method.call('foo', function (_, __, context) {
|
407
|
+
if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
|
408
|
+
});
|
409
|
+
|
410
|
+
method.call([1], function () {
|
411
|
+
'use strict';
|
412
|
+
|
413
|
+
properlyBoxesStrict = typeof this === 'string';
|
414
|
+
}, 'x');
|
415
|
+
} catch (e) {
|
416
|
+
threwException = true;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
return !!method && !threwException && properlyBoxesNonStrict && properlyBoxesStrict;
|
420
|
+
};
|
421
|
+
|
422
|
+
defineProperties(ArrayPrototype, {
|
423
|
+
forEach: function forEach(callbackfn/*, thisArg*/) {
|
424
|
+
var object = ES.ToObject(this);
|
425
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
426
|
+
var i = -1;
|
427
|
+
var length = ES.ToUint32(self.length);
|
428
|
+
var T;
|
429
|
+
if (arguments.length > 1) {
|
430
|
+
T = arguments[1];
|
431
|
+
}
|
432
|
+
|
433
|
+
// If no callback function or if callback is not a callable function
|
434
|
+
if (!isCallable(callbackfn)) {
|
435
|
+
throw new TypeError('Array.prototype.forEach callback must be a function');
|
436
|
+
}
|
437
|
+
|
438
|
+
while (++i < length) {
|
439
|
+
if (i in self) {
|
440
|
+
// Invoke the callback function with call, passing arguments:
|
441
|
+
// context, property value, property key, thisArg object
|
442
|
+
if (typeof T === 'undefined') {
|
443
|
+
callbackfn(self[i], i, object);
|
444
|
+
} else {
|
445
|
+
callbackfn.call(T, self[i], i, object);
|
446
|
+
}
|
447
|
+
}
|
448
|
+
}
|
449
|
+
}
|
450
|
+
}, !properlyBoxesContext(ArrayPrototype.forEach));
|
451
|
+
|
452
|
+
// ES5 15.4.4.19
|
453
|
+
// http://es5.github.com/#x15.4.4.19
|
454
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
|
455
|
+
defineProperties(ArrayPrototype, {
|
456
|
+
map: function map(callbackfn/*, thisArg*/) {
|
457
|
+
var object = ES.ToObject(this);
|
458
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
459
|
+
var length = ES.ToUint32(self.length);
|
460
|
+
var result = $Array(length);
|
461
|
+
var T;
|
462
|
+
if (arguments.length > 1) {
|
463
|
+
T = arguments[1];
|
464
|
+
}
|
465
|
+
|
466
|
+
// If no callback function or if callback is not a callable function
|
467
|
+
if (!isCallable(callbackfn)) {
|
468
|
+
throw new TypeError('Array.prototype.map callback must be a function');
|
469
|
+
}
|
470
|
+
|
471
|
+
for (var i = 0; i < length; i++) {
|
472
|
+
if (i in self) {
|
473
|
+
if (typeof T === 'undefined') {
|
474
|
+
result[i] = callbackfn(self[i], i, object);
|
475
|
+
} else {
|
476
|
+
result[i] = callbackfn.call(T, self[i], i, object);
|
477
|
+
}
|
478
|
+
}
|
479
|
+
}
|
480
|
+
return result;
|
481
|
+
}
|
482
|
+
}, !properlyBoxesContext(ArrayPrototype.map));
|
483
|
+
|
484
|
+
// ES5 15.4.4.20
|
485
|
+
// http://es5.github.com/#x15.4.4.20
|
486
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
|
487
|
+
defineProperties(ArrayPrototype, {
|
488
|
+
filter: function filter(callbackfn/*, thisArg*/) {
|
489
|
+
var object = ES.ToObject(this);
|
490
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
491
|
+
var length = ES.ToUint32(self.length);
|
492
|
+
var result = [];
|
493
|
+
var value;
|
494
|
+
var T;
|
495
|
+
if (arguments.length > 1) {
|
496
|
+
T = arguments[1];
|
497
|
+
}
|
498
|
+
|
499
|
+
// If no callback function or if callback is not a callable function
|
500
|
+
if (!isCallable(callbackfn)) {
|
501
|
+
throw new TypeError('Array.prototype.filter callback must be a function');
|
502
|
+
}
|
503
|
+
|
504
|
+
for (var i = 0; i < length; i++) {
|
505
|
+
if (i in self) {
|
506
|
+
value = self[i];
|
507
|
+
if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) {
|
508
|
+
pushCall(result, value);
|
509
|
+
}
|
510
|
+
}
|
511
|
+
}
|
512
|
+
return result;
|
513
|
+
}
|
514
|
+
}, !properlyBoxesContext(ArrayPrototype.filter));
|
515
|
+
|
516
|
+
// ES5 15.4.4.16
|
517
|
+
// http://es5.github.com/#x15.4.4.16
|
518
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
|
519
|
+
defineProperties(ArrayPrototype, {
|
520
|
+
every: function every(callbackfn/*, thisArg*/) {
|
521
|
+
var object = ES.ToObject(this);
|
522
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
523
|
+
var length = ES.ToUint32(self.length);
|
524
|
+
var T;
|
525
|
+
if (arguments.length > 1) {
|
526
|
+
T = arguments[1];
|
527
|
+
}
|
528
|
+
|
529
|
+
// If no callback function or if callback is not a callable function
|
530
|
+
if (!isCallable(callbackfn)) {
|
531
|
+
throw new TypeError('Array.prototype.every callback must be a function');
|
532
|
+
}
|
533
|
+
|
534
|
+
for (var i = 0; i < length; i++) {
|
535
|
+
if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
|
536
|
+
return false;
|
537
|
+
}
|
538
|
+
}
|
539
|
+
return true;
|
540
|
+
}
|
541
|
+
}, !properlyBoxesContext(ArrayPrototype.every));
|
542
|
+
|
543
|
+
// ES5 15.4.4.17
|
544
|
+
// http://es5.github.com/#x15.4.4.17
|
545
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
|
546
|
+
defineProperties(ArrayPrototype, {
|
547
|
+
some: function some(callbackfn/*, thisArg */) {
|
548
|
+
var object = ES.ToObject(this);
|
549
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
550
|
+
var length = ES.ToUint32(self.length);
|
551
|
+
var T;
|
552
|
+
if (arguments.length > 1) {
|
553
|
+
T = arguments[1];
|
554
|
+
}
|
555
|
+
|
556
|
+
// If no callback function or if callback is not a callable function
|
557
|
+
if (!isCallable(callbackfn)) {
|
558
|
+
throw new TypeError('Array.prototype.some callback must be a function');
|
559
|
+
}
|
560
|
+
|
561
|
+
for (var i = 0; i < length; i++) {
|
562
|
+
if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
|
563
|
+
return true;
|
564
|
+
}
|
565
|
+
}
|
566
|
+
return false;
|
567
|
+
}
|
568
|
+
}, !properlyBoxesContext(ArrayPrototype.some));
|
569
|
+
|
570
|
+
// ES5 15.4.4.21
|
571
|
+
// http://es5.github.com/#x15.4.4.21
|
572
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
|
573
|
+
var reduceCoercesToObject = false;
|
574
|
+
if (ArrayPrototype.reduce) {
|
575
|
+
reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
|
576
|
+
}
|
577
|
+
defineProperties(ArrayPrototype, {
|
578
|
+
reduce: function reduce(callbackfn/*, initialValue*/) {
|
579
|
+
var object = ES.ToObject(this);
|
580
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
581
|
+
var length = ES.ToUint32(self.length);
|
582
|
+
|
583
|
+
// If no callback function or if callback is not a callable function
|
584
|
+
if (!isCallable(callbackfn)) {
|
585
|
+
throw new TypeError('Array.prototype.reduce callback must be a function');
|
586
|
+
}
|
587
|
+
|
588
|
+
// no value to return if no initial value and an empty array
|
589
|
+
if (length === 0 && arguments.length === 1) {
|
590
|
+
throw new TypeError('reduce of empty array with no initial value');
|
591
|
+
}
|
592
|
+
|
593
|
+
var i = 0;
|
594
|
+
var result;
|
595
|
+
if (arguments.length >= 2) {
|
596
|
+
result = arguments[1];
|
597
|
+
} else {
|
598
|
+
do {
|
599
|
+
if (i in self) {
|
600
|
+
result = self[i++];
|
601
|
+
break;
|
602
|
+
}
|
603
|
+
|
604
|
+
// if array contains no values, no initial value to return
|
605
|
+
if (++i >= length) {
|
606
|
+
throw new TypeError('reduce of empty array with no initial value');
|
607
|
+
}
|
608
|
+
} while (true);
|
609
|
+
}
|
610
|
+
|
611
|
+
for (; i < length; i++) {
|
612
|
+
if (i in self) {
|
613
|
+
result = callbackfn(result, self[i], i, object);
|
614
|
+
}
|
615
|
+
}
|
616
|
+
|
617
|
+
return result;
|
618
|
+
}
|
619
|
+
}, !reduceCoercesToObject);
|
620
|
+
|
621
|
+
// ES5 15.4.4.22
|
622
|
+
// http://es5.github.com/#x15.4.4.22
|
623
|
+
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
|
624
|
+
var reduceRightCoercesToObject = false;
|
625
|
+
if (ArrayPrototype.reduceRight) {
|
626
|
+
reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
|
627
|
+
}
|
628
|
+
defineProperties(ArrayPrototype, {
|
629
|
+
reduceRight: function reduceRight(callbackfn/*, initial*/) {
|
630
|
+
var object = ES.ToObject(this);
|
631
|
+
var self = splitString && isString(this) ? strSplit(this, '') : object;
|
632
|
+
var length = ES.ToUint32(self.length);
|
633
|
+
|
634
|
+
// If no callback function or if callback is not a callable function
|
635
|
+
if (!isCallable(callbackfn)) {
|
636
|
+
throw new TypeError('Array.prototype.reduceRight callback must be a function');
|
637
|
+
}
|
638
|
+
|
639
|
+
// no value to return if no initial value, empty array
|
640
|
+
if (length === 0 && arguments.length === 1) {
|
641
|
+
throw new TypeError('reduceRight of empty array with no initial value');
|
642
|
+
}
|
643
|
+
|
644
|
+
var result;
|
645
|
+
var i = length - 1;
|
646
|
+
if (arguments.length >= 2) {
|
647
|
+
result = arguments[1];
|
648
|
+
} else {
|
649
|
+
do {
|
650
|
+
if (i in self) {
|
651
|
+
result = self[i--];
|
652
|
+
break;
|
653
|
+
}
|
654
|
+
|
655
|
+
// if array contains no values, no initial value to return
|
656
|
+
if (--i < 0) {
|
657
|
+
throw new TypeError('reduceRight of empty array with no initial value');
|
658
|
+
}
|
659
|
+
} while (true);
|
660
|
+
}
|
661
|
+
|
662
|
+
if (i < 0) {
|
663
|
+
return result;
|
664
|
+
}
|
665
|
+
|
666
|
+
do {
|
667
|
+
if (i in self) {
|
668
|
+
result = callbackfn(result, self[i], i, object);
|
669
|
+
}
|
670
|
+
} while (i--);
|
671
|
+
|
672
|
+
return result;
|
673
|
+
}
|
674
|
+
}, !reduceRightCoercesToObject);
|
675
|
+
|
676
|
+
// ES5 15.4.4.14
|
677
|
+
// http://es5.github.com/#x15.4.4.14
|
678
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
|
679
|
+
var hasFirefox2IndexOfBug = ArrayPrototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
|
680
|
+
defineProperties(ArrayPrototype, {
|
681
|
+
indexOf: function indexOf(searchElement/*, fromIndex */) {
|
682
|
+
var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
|
683
|
+
var length = ES.ToUint32(self.length);
|
684
|
+
|
685
|
+
if (length === 0) {
|
686
|
+
return -1;
|
687
|
+
}
|
688
|
+
|
689
|
+
var i = 0;
|
690
|
+
if (arguments.length > 1) {
|
691
|
+
i = ES.ToInteger(arguments[1]);
|
692
|
+
}
|
693
|
+
|
694
|
+
// handle negative indices
|
695
|
+
i = i >= 0 ? i : max(0, length + i);
|
696
|
+
for (; i < length; i++) {
|
697
|
+
if (i in self && self[i] === searchElement) {
|
698
|
+
return i;
|
699
|
+
}
|
700
|
+
}
|
701
|
+
return -1;
|
702
|
+
}
|
703
|
+
}, hasFirefox2IndexOfBug);
|
704
|
+
|
705
|
+
// ES5 15.4.4.15
|
706
|
+
// http://es5.github.com/#x15.4.4.15
|
707
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
|
708
|
+
var hasFirefox2LastIndexOfBug = ArrayPrototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
|
709
|
+
defineProperties(ArrayPrototype, {
|
710
|
+
lastIndexOf: function lastIndexOf(searchElement/*, fromIndex */) {
|
711
|
+
var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this);
|
712
|
+
var length = ES.ToUint32(self.length);
|
713
|
+
|
714
|
+
if (length === 0) {
|
715
|
+
return -1;
|
716
|
+
}
|
717
|
+
var i = length - 1;
|
718
|
+
if (arguments.length > 1) {
|
719
|
+
i = min(i, ES.ToInteger(arguments[1]));
|
720
|
+
}
|
721
|
+
// handle negative indices
|
722
|
+
i = i >= 0 ? i : length - Math.abs(i);
|
723
|
+
for (; i >= 0; i--) {
|
724
|
+
if (i in self && searchElement === self[i]) {
|
725
|
+
return i;
|
726
|
+
}
|
727
|
+
}
|
728
|
+
return -1;
|
729
|
+
}
|
730
|
+
}, hasFirefox2LastIndexOfBug);
|
731
|
+
|
732
|
+
// ES5 15.4.4.12
|
733
|
+
// http://es5.github.com/#x15.4.4.12
|
734
|
+
var spliceNoopReturnsEmptyArray = (function () {
|
735
|
+
var a = [1, 2];
|
736
|
+
var result = a.splice();
|
737
|
+
return a.length === 2 && isArray(result) && result.length === 0;
|
738
|
+
}());
|
739
|
+
defineProperties(ArrayPrototype, {
|
740
|
+
// Safari 5.0 bug where .splice() returns undefined
|
741
|
+
splice: function splice(start, deleteCount) {
|
742
|
+
if (arguments.length === 0) {
|
743
|
+
return [];
|
744
|
+
} else {
|
745
|
+
return array_splice.apply(this, arguments);
|
746
|
+
}
|
747
|
+
}
|
748
|
+
}, !spliceNoopReturnsEmptyArray);
|
749
|
+
|
750
|
+
var spliceWorksWithEmptyObject = (function () {
|
751
|
+
var obj = {};
|
752
|
+
ArrayPrototype.splice.call(obj, 0, 0, 1);
|
753
|
+
return obj.length === 1;
|
754
|
+
}());
|
755
|
+
defineProperties(ArrayPrototype, {
|
756
|
+
splice: function splice(start, deleteCount) {
|
757
|
+
if (arguments.length === 0) { return []; }
|
758
|
+
var args = arguments;
|
759
|
+
this.length = max(ES.ToInteger(this.length), 0);
|
760
|
+
if (arguments.length > 0 && typeof deleteCount !== 'number') {
|
761
|
+
args = arraySlice(arguments);
|
762
|
+
if (args.length < 2) {
|
763
|
+
pushCall(args, this.length - start);
|
764
|
+
} else {
|
765
|
+
args[1] = ES.ToInteger(deleteCount);
|
766
|
+
}
|
767
|
+
}
|
768
|
+
return array_splice.apply(this, args);
|
769
|
+
}
|
770
|
+
}, !spliceWorksWithEmptyObject);
|
771
|
+
var spliceWorksWithLargeSparseArrays = (function () {
|
772
|
+
// Per https://github.com/es-shims/es5-shim/issues/295
|
773
|
+
// Safari 7/8 breaks with sparse arrays of size 1e5 or greater
|
774
|
+
var arr = new $Array(1e5);
|
775
|
+
// note: the index MUST be 8 or larger or the test will false pass
|
776
|
+
arr[8] = 'x';
|
777
|
+
arr.splice(1, 1);
|
778
|
+
// note: this test must be defined *after* the indexOf shim
|
779
|
+
// per https://github.com/es-shims/es5-shim/issues/313
|
780
|
+
return arr.indexOf('x') === 7;
|
781
|
+
}());
|
782
|
+
var spliceWorksWithSmallSparseArrays = (function () {
|
783
|
+
// Per https://github.com/es-shims/es5-shim/issues/295
|
784
|
+
// Opera 12.15 breaks on this, no idea why.
|
785
|
+
var n = 256;
|
786
|
+
var arr = [];
|
787
|
+
arr[n] = 'a';
|
788
|
+
arr.splice(n + 1, 0, 'b');
|
789
|
+
return arr[n] === 'a';
|
790
|
+
}());
|
791
|
+
defineProperties(ArrayPrototype, {
|
792
|
+
splice: function splice(start, deleteCount) {
|
793
|
+
var O = ES.ToObject(this);
|
794
|
+
var A = [];
|
795
|
+
var len = ES.ToUint32(O.length);
|
796
|
+
var relativeStart = ES.ToInteger(start);
|
797
|
+
var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len);
|
798
|
+
var actualDeleteCount = min(max(ES.ToInteger(deleteCount), 0), len - actualStart);
|
799
|
+
|
800
|
+
var k = 0;
|
801
|
+
var from;
|
802
|
+
while (k < actualDeleteCount) {
|
803
|
+
from = $String(actualStart + k);
|
804
|
+
if (owns(O, from)) {
|
805
|
+
A[k] = O[from];
|
806
|
+
}
|
807
|
+
k += 1;
|
808
|
+
}
|
809
|
+
|
810
|
+
var items = arraySlice(arguments, 2);
|
811
|
+
var itemCount = items.length;
|
812
|
+
var to;
|
813
|
+
if (itemCount < actualDeleteCount) {
|
814
|
+
k = actualStart;
|
815
|
+
while (k < (len - actualDeleteCount)) {
|
816
|
+
from = $String(k + actualDeleteCount);
|
817
|
+
to = $String(k + itemCount);
|
818
|
+
if (owns(O, from)) {
|
819
|
+
O[to] = O[from];
|
820
|
+
} else {
|
821
|
+
delete O[to];
|
822
|
+
}
|
823
|
+
k += 1;
|
824
|
+
}
|
825
|
+
k = len;
|
826
|
+
while (k > (len - actualDeleteCount + itemCount)) {
|
827
|
+
delete O[k - 1];
|
828
|
+
k -= 1;
|
829
|
+
}
|
830
|
+
} else if (itemCount > actualDeleteCount) {
|
831
|
+
k = len - actualDeleteCount;
|
832
|
+
while (k > actualStart) {
|
833
|
+
from = $String(k + actualDeleteCount - 1);
|
834
|
+
to = $String(k + itemCount - 1);
|
835
|
+
if (owns(O, from)) {
|
836
|
+
O[to] = O[from];
|
837
|
+
} else {
|
838
|
+
delete O[to];
|
839
|
+
}
|
840
|
+
k -= 1;
|
841
|
+
}
|
842
|
+
}
|
843
|
+
k = actualStart;
|
844
|
+
for (var i = 0; i < items.length; ++i) {
|
845
|
+
O[k] = items[i];
|
846
|
+
k += 1;
|
847
|
+
}
|
848
|
+
O.length = len - actualDeleteCount + itemCount;
|
849
|
+
|
850
|
+
return A;
|
851
|
+
}
|
852
|
+
}, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays);
|
853
|
+
|
854
|
+
var originalJoin = ArrayPrototype.join;
|
855
|
+
var hasStringJoinBug;
|
856
|
+
try {
|
857
|
+
hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3';
|
858
|
+
} catch (e) {
|
859
|
+
hasStringJoinBug = true;
|
860
|
+
}
|
861
|
+
if (hasStringJoinBug) {
|
862
|
+
defineProperties(ArrayPrototype, {
|
863
|
+
join: function join(separator) {
|
864
|
+
var sep = typeof separator === 'undefined' ? ',' : separator;
|
865
|
+
return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep);
|
866
|
+
}
|
867
|
+
}, hasStringJoinBug);
|
868
|
+
}
|
869
|
+
|
870
|
+
var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2';
|
871
|
+
if (hasJoinUndefinedBug) {
|
872
|
+
defineProperties(ArrayPrototype, {
|
873
|
+
join: function join(separator) {
|
874
|
+
var sep = typeof separator === 'undefined' ? ',' : separator;
|
875
|
+
return originalJoin.call(this, sep);
|
876
|
+
}
|
877
|
+
}, hasJoinUndefinedBug);
|
878
|
+
}
|
879
|
+
|
880
|
+
var pushShim = function push(item) {
|
881
|
+
var O = ES.ToObject(this);
|
882
|
+
var n = ES.ToUint32(O.length);
|
883
|
+
var i = 0;
|
884
|
+
while (i < arguments.length) {
|
885
|
+
O[n + i] = arguments[i];
|
886
|
+
i += 1;
|
887
|
+
}
|
888
|
+
O.length = n + i;
|
889
|
+
return n + i;
|
890
|
+
};
|
891
|
+
|
892
|
+
var pushIsNotGeneric = (function () {
|
893
|
+
var obj = {};
|
894
|
+
var result = Array.prototype.push.call(obj, undefined);
|
895
|
+
return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0);
|
896
|
+
}());
|
897
|
+
defineProperties(ArrayPrototype, {
|
898
|
+
push: function push(item) {
|
899
|
+
if (isArray(this)) {
|
900
|
+
return array_push.apply(this, arguments);
|
901
|
+
}
|
902
|
+
return pushShim.apply(this, arguments);
|
903
|
+
}
|
904
|
+
}, pushIsNotGeneric);
|
905
|
+
|
906
|
+
// This fixes a very weird bug in Opera 10.6 when pushing `undefined
|
907
|
+
var pushUndefinedIsWeird = (function () {
|
908
|
+
var arr = [];
|
909
|
+
var result = arr.push(undefined);
|
910
|
+
return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0);
|
911
|
+
}());
|
912
|
+
defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird);
|
913
|
+
|
914
|
+
// ES5 15.2.3.14
|
915
|
+
// http://es5.github.io/#x15.4.4.10
|
916
|
+
// Fix boxed string bug
|
917
|
+
defineProperties(ArrayPrototype, {
|
918
|
+
slice: function (start, end) {
|
919
|
+
var arr = isString(this) ? strSplit(this, '') : this;
|
920
|
+
return arraySliceApply(arr, arguments);
|
921
|
+
}
|
922
|
+
}, splitString);
|
923
|
+
|
924
|
+
var sortIgnoresNonFunctions = (function () {
|
925
|
+
try {
|
926
|
+
[1, 2].sort(null);
|
927
|
+
[1, 2].sort({});
|
928
|
+
return true;
|
929
|
+
} catch (e) { /**/ }
|
930
|
+
return false;
|
931
|
+
}());
|
932
|
+
var sortThrowsOnRegex = (function () {
|
933
|
+
// this is a problem in Firefox 4, in which `typeof /a/ === 'function'`
|
934
|
+
try {
|
935
|
+
[1, 2].sort(/a/);
|
936
|
+
return false;
|
937
|
+
} catch (e) { /**/ }
|
938
|
+
return true;
|
939
|
+
}());
|
940
|
+
var sortIgnoresUndefined = (function () {
|
941
|
+
// applies in IE 8, for one.
|
942
|
+
try {
|
943
|
+
[1, 2].sort(undefined);
|
944
|
+
return true;
|
945
|
+
} catch (e) { /**/ }
|
946
|
+
return false;
|
947
|
+
}());
|
948
|
+
defineProperties(ArrayPrototype, {
|
949
|
+
sort: function sort(compareFn) {
|
950
|
+
if (typeof compareFn === 'undefined') {
|
951
|
+
return arraySort(this);
|
952
|
+
}
|
953
|
+
if (!isCallable(compareFn)) {
|
954
|
+
throw new TypeError('Array.prototype.sort callback must be a function');
|
955
|
+
}
|
956
|
+
return arraySort(this, compareFn);
|
957
|
+
}
|
958
|
+
}, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex);
|
959
|
+
|
960
|
+
//
|
961
|
+
// Object
|
962
|
+
// ======
|
963
|
+
//
|
964
|
+
|
965
|
+
// ES5 15.2.3.14
|
966
|
+
// http://es5.github.com/#x15.2.3.14
|
967
|
+
|
968
|
+
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
|
969
|
+
var hasDontEnumBug = !({ 'toString': null }).propertyIsEnumerable('toString');
|
970
|
+
var hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype');
|
971
|
+
var hasStringEnumBug = !owns('x', '0');
|
972
|
+
var equalsConstructorPrototype = function (o) {
|
973
|
+
var ctor = o.constructor;
|
974
|
+
return ctor && ctor.prototype === o;
|
975
|
+
};
|
976
|
+
var blacklistedKeys = {
|
977
|
+
$window: true,
|
978
|
+
$console: true,
|
979
|
+
$parent: true,
|
980
|
+
$self: true,
|
981
|
+
$frame: true,
|
982
|
+
$frames: true,
|
983
|
+
$frameElement: true,
|
984
|
+
$webkitIndexedDB: true,
|
985
|
+
$webkitStorageInfo: true,
|
986
|
+
$external: true
|
987
|
+
};
|
988
|
+
var hasAutomationEqualityBug = (function () {
|
989
|
+
/* globals window */
|
990
|
+
if (typeof window === 'undefined') { return false; }
|
991
|
+
for (var k in window) {
|
992
|
+
try {
|
993
|
+
if (!blacklistedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
994
|
+
equalsConstructorPrototype(window[k]);
|
995
|
+
}
|
996
|
+
} catch (e) {
|
997
|
+
return true;
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
return false;
|
1001
|
+
}());
|
1002
|
+
var equalsConstructorPrototypeIfNotBuggy = function (object) {
|
1003
|
+
if (typeof window === 'undefined' || !hasAutomationEqualityBug) { return equalsConstructorPrototype(object); }
|
1004
|
+
try {
|
1005
|
+
return equalsConstructorPrototype(object);
|
1006
|
+
} catch (e) {
|
1007
|
+
return false;
|
1008
|
+
}
|
1009
|
+
};
|
1010
|
+
var dontEnums = [
|
1011
|
+
'toString',
|
1012
|
+
'toLocaleString',
|
1013
|
+
'valueOf',
|
1014
|
+
'hasOwnProperty',
|
1015
|
+
'isPrototypeOf',
|
1016
|
+
'propertyIsEnumerable',
|
1017
|
+
'constructor'
|
1018
|
+
];
|
1019
|
+
var dontEnumsLength = dontEnums.length;
|
1020
|
+
|
1021
|
+
// taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js
|
1022
|
+
// can be replaced with require('is-arguments') if we ever use a build process instead
|
1023
|
+
var isStandardArguments = function isArguments(value) {
|
1024
|
+
return toStr(value) === '[object Arguments]';
|
1025
|
+
};
|
1026
|
+
var isLegacyArguments = function isArguments(value) {
|
1027
|
+
return value !== null &&
|
1028
|
+
typeof value === 'object' &&
|
1029
|
+
typeof value.length === 'number' &&
|
1030
|
+
value.length >= 0 &&
|
1031
|
+
!isArray(value) &&
|
1032
|
+
isCallable(value.callee);
|
1033
|
+
};
|
1034
|
+
var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
|
1035
|
+
|
1036
|
+
defineProperties($Object, {
|
1037
|
+
keys: function keys(object) {
|
1038
|
+
var isFn = isCallable(object);
|
1039
|
+
var isArgs = isArguments(object);
|
1040
|
+
var isObject = object !== null && typeof object === 'object';
|
1041
|
+
var isStr = isObject && isString(object);
|
1042
|
+
|
1043
|
+
if (!isObject && !isFn && !isArgs) {
|
1044
|
+
throw new TypeError('Object.keys called on a non-object');
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
var theKeys = [];
|
1048
|
+
var skipProto = hasProtoEnumBug && isFn;
|
1049
|
+
if ((isStr && hasStringEnumBug) || isArgs) {
|
1050
|
+
for (var i = 0; i < object.length; ++i) {
|
1051
|
+
pushCall(theKeys, $String(i));
|
1052
|
+
}
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
if (!isArgs) {
|
1056
|
+
for (var name in object) {
|
1057
|
+
if (!(skipProto && name === 'prototype') && owns(object, name)) {
|
1058
|
+
pushCall(theKeys, $String(name));
|
1059
|
+
}
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
|
1063
|
+
if (hasDontEnumBug) {
|
1064
|
+
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
|
1065
|
+
for (var j = 0; j < dontEnumsLength; j++) {
|
1066
|
+
var dontEnum = dontEnums[j];
|
1067
|
+
if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
|
1068
|
+
pushCall(theKeys, dontEnum);
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
return theKeys;
|
1073
|
+
}
|
1074
|
+
});
|
1075
|
+
|
1076
|
+
var keysWorksWithArguments = $Object.keys && (function () {
|
1077
|
+
// Safari 5.0 bug
|
1078
|
+
return $Object.keys(arguments).length === 2;
|
1079
|
+
}(1, 2));
|
1080
|
+
var keysHasArgumentsLengthBug = $Object.keys && (function () {
|
1081
|
+
var argKeys = $Object.keys(arguments);
|
1082
|
+
return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1;
|
1083
|
+
}(1));
|
1084
|
+
var originalKeys = $Object.keys;
|
1085
|
+
defineProperties($Object, {
|
1086
|
+
keys: function keys(object) {
|
1087
|
+
if (isArguments(object)) {
|
1088
|
+
return originalKeys(arraySlice(object));
|
1089
|
+
} else {
|
1090
|
+
return originalKeys(object);
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
}, !keysWorksWithArguments || keysHasArgumentsLengthBug);
|
1094
|
+
|
1095
|
+
//
|
1096
|
+
// Date
|
1097
|
+
// ====
|
1098
|
+
//
|
1099
|
+
|
1100
|
+
var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0;
|
1101
|
+
var aNegativeTestDate = new Date(-1509842289600292);
|
1102
|
+
var aPositiveTestDate = new Date(1449662400000);
|
1103
|
+
var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT';
|
1104
|
+
var hasToDateStringFormatBug;
|
1105
|
+
var hasToStringFormatBug;
|
1106
|
+
var timeZoneOffset = aNegativeTestDate.getTimezoneOffset();
|
1107
|
+
if (timeZoneOffset < -720) {
|
1108
|
+
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875';
|
1109
|
+
hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
|
1110
|
+
} else {
|
1111
|
+
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875';
|
1112
|
+
hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
var originalGetFullYear = call.bind(Date.prototype.getFullYear);
|
1116
|
+
var originalGetMonth = call.bind(Date.prototype.getMonth);
|
1117
|
+
var originalGetDate = call.bind(Date.prototype.getDate);
|
1118
|
+
var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear);
|
1119
|
+
var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth);
|
1120
|
+
var originalGetUTCDate = call.bind(Date.prototype.getUTCDate);
|
1121
|
+
var originalGetUTCDay = call.bind(Date.prototype.getUTCDay);
|
1122
|
+
var originalGetUTCHours = call.bind(Date.prototype.getUTCHours);
|
1123
|
+
var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes);
|
1124
|
+
var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds);
|
1125
|
+
var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds);
|
1126
|
+
var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
|
1127
|
+
var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
1128
|
+
var daysInMonth = function daysInMonth(month, year) {
|
1129
|
+
return originalGetDate(new Date(year, month, 0));
|
1130
|
+
};
|
1131
|
+
|
1132
|
+
defineProperties(Date.prototype, {
|
1133
|
+
getFullYear: function getFullYear() {
|
1134
|
+
if (!this || !(this instanceof Date)) {
|
1135
|
+
throw new TypeError('this is not a Date object.');
|
1136
|
+
}
|
1137
|
+
var year = originalGetFullYear(this);
|
1138
|
+
if (year < 0 && originalGetMonth(this) > 11) {
|
1139
|
+
return year + 1;
|
1140
|
+
}
|
1141
|
+
return year;
|
1142
|
+
},
|
1143
|
+
getMonth: function getMonth() {
|
1144
|
+
if (!this || !(this instanceof Date)) {
|
1145
|
+
throw new TypeError('this is not a Date object.');
|
1146
|
+
}
|
1147
|
+
var year = originalGetFullYear(this);
|
1148
|
+
var month = originalGetMonth(this);
|
1149
|
+
if (year < 0 && month > 11) {
|
1150
|
+
return 0;
|
1151
|
+
}
|
1152
|
+
return month;
|
1153
|
+
},
|
1154
|
+
getDate: function getDate() {
|
1155
|
+
if (!this || !(this instanceof Date)) {
|
1156
|
+
throw new TypeError('this is not a Date object.');
|
1157
|
+
}
|
1158
|
+
var year = originalGetFullYear(this);
|
1159
|
+
var month = originalGetMonth(this);
|
1160
|
+
var date = originalGetDate(this);
|
1161
|
+
if (year < 0 && month > 11) {
|
1162
|
+
if (month === 12) {
|
1163
|
+
return date;
|
1164
|
+
}
|
1165
|
+
var days = daysInMonth(0, year + 1);
|
1166
|
+
return (days - date) + 1;
|
1167
|
+
}
|
1168
|
+
return date;
|
1169
|
+
},
|
1170
|
+
getUTCFullYear: function getUTCFullYear() {
|
1171
|
+
if (!this || !(this instanceof Date)) {
|
1172
|
+
throw new TypeError('this is not a Date object.');
|
1173
|
+
}
|
1174
|
+
var year = originalGetUTCFullYear(this);
|
1175
|
+
if (year < 0 && originalGetUTCMonth(this) > 11) {
|
1176
|
+
return year + 1;
|
1177
|
+
}
|
1178
|
+
return year;
|
1179
|
+
},
|
1180
|
+
getUTCMonth: function getUTCMonth() {
|
1181
|
+
if (!this || !(this instanceof Date)) {
|
1182
|
+
throw new TypeError('this is not a Date object.');
|
1183
|
+
}
|
1184
|
+
var year = originalGetUTCFullYear(this);
|
1185
|
+
var month = originalGetUTCMonth(this);
|
1186
|
+
if (year < 0 && month > 11) {
|
1187
|
+
return 0;
|
1188
|
+
}
|
1189
|
+
return month;
|
1190
|
+
},
|
1191
|
+
getUTCDate: function getUTCDate() {
|
1192
|
+
if (!this || !(this instanceof Date)) {
|
1193
|
+
throw new TypeError('this is not a Date object.');
|
1194
|
+
}
|
1195
|
+
var year = originalGetUTCFullYear(this);
|
1196
|
+
var month = originalGetUTCMonth(this);
|
1197
|
+
var date = originalGetUTCDate(this);
|
1198
|
+
if (year < 0 && month > 11) {
|
1199
|
+
if (month === 12) {
|
1200
|
+
return date;
|
1201
|
+
}
|
1202
|
+
var days = daysInMonth(0, year + 1);
|
1203
|
+
return (days - date) + 1;
|
1204
|
+
}
|
1205
|
+
return date;
|
1206
|
+
}
|
1207
|
+
}, hasNegativeMonthYearBug);
|
1208
|
+
|
1209
|
+
defineProperties(Date.prototype, {
|
1210
|
+
toUTCString: function toUTCString() {
|
1211
|
+
if (!this || !(this instanceof Date)) {
|
1212
|
+
throw new TypeError('this is not a Date object.');
|
1213
|
+
}
|
1214
|
+
var day = originalGetUTCDay(this);
|
1215
|
+
var date = originalGetUTCDate(this);
|
1216
|
+
var month = originalGetUTCMonth(this);
|
1217
|
+
var year = originalGetUTCFullYear(this);
|
1218
|
+
var hour = originalGetUTCHours(this);
|
1219
|
+
var minute = originalGetUTCMinutes(this);
|
1220
|
+
var second = originalGetUTCSeconds(this);
|
1221
|
+
return dayName[day] + ', ' +
|
1222
|
+
(date < 10 ? '0' + date : date) + ' ' +
|
1223
|
+
monthName[month] + ' ' +
|
1224
|
+
year + ' ' +
|
1225
|
+
(hour < 10 ? '0' + hour : hour) + ':' +
|
1226
|
+
(minute < 10 ? '0' + minute : minute) + ':' +
|
1227
|
+
(second < 10 ? '0' + second : second) + ' GMT';
|
1228
|
+
}
|
1229
|
+
}, hasNegativeMonthYearBug || hasToUTCStringFormatBug);
|
1230
|
+
|
1231
|
+
// Opera 12 has `,`
|
1232
|
+
defineProperties(Date.prototype, {
|
1233
|
+
toDateString: function toDateString() {
|
1234
|
+
if (!this || !(this instanceof Date)) {
|
1235
|
+
throw new TypeError('this is not a Date object.');
|
1236
|
+
}
|
1237
|
+
var day = this.getDay();
|
1238
|
+
var date = this.getDate();
|
1239
|
+
var month = this.getMonth();
|
1240
|
+
var year = this.getFullYear();
|
1241
|
+
return dayName[day] + ' ' +
|
1242
|
+
monthName[month] + ' ' +
|
1243
|
+
(date < 10 ? '0' + date : date) + ' ' +
|
1244
|
+
year;
|
1245
|
+
}
|
1246
|
+
}, hasNegativeMonthYearBug || hasToDateStringFormatBug);
|
1247
|
+
|
1248
|
+
// can't use defineProperties here because of toString enumeration issue in IE <= 8
|
1249
|
+
if (hasNegativeMonthYearBug || hasToStringFormatBug) {
|
1250
|
+
Date.prototype.toString = function toString() {
|
1251
|
+
if (!this || !(this instanceof Date)) {
|
1252
|
+
throw new TypeError('this is not a Date object.');
|
1253
|
+
}
|
1254
|
+
var day = this.getDay();
|
1255
|
+
var date = this.getDate();
|
1256
|
+
var month = this.getMonth();
|
1257
|
+
var year = this.getFullYear();
|
1258
|
+
var hour = this.getHours();
|
1259
|
+
var minute = this.getMinutes();
|
1260
|
+
var second = this.getSeconds();
|
1261
|
+
var timezoneOffset = this.getTimezoneOffset();
|
1262
|
+
var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60);
|
1263
|
+
var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60);
|
1264
|
+
return dayName[day] + ' ' +
|
1265
|
+
monthName[month] + ' ' +
|
1266
|
+
(date < 10 ? '0' + date : date) + ' ' +
|
1267
|
+
year + ' ' +
|
1268
|
+
(hour < 10 ? '0' + hour : hour) + ':' +
|
1269
|
+
(minute < 10 ? '0' + minute : minute) + ':' +
|
1270
|
+
(second < 10 ? '0' + second : second) + ' GMT' +
|
1271
|
+
(timezoneOffset > 0 ? '-' : '+') +
|
1272
|
+
(hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) +
|
1273
|
+
(minutesOffset < 10 ? '0' + minutesOffset : minutesOffset);
|
1274
|
+
};
|
1275
|
+
if (supportsDescriptors) {
|
1276
|
+
$Object.defineProperty(Date.prototype, 'toString', {
|
1277
|
+
configurable: true,
|
1278
|
+
enumerable: false,
|
1279
|
+
writable: true
|
1280
|
+
});
|
1281
|
+
}
|
1282
|
+
}
|
1283
|
+
|
1284
|
+
// ES5 15.9.5.43
|
1285
|
+
// http://es5.github.com/#x15.9.5.43
|
1286
|
+
// This function returns a String value represent the instance in time
|
1287
|
+
// represented by this Date object. The format of the String is the Date Time
|
1288
|
+
// string format defined in 15.9.1.15. All fields are present in the String.
|
1289
|
+
// The time zone is always UTC, denoted by the suffix Z. If the time value of
|
1290
|
+
// this object is not a finite Number a RangeError exception is thrown.
|
1291
|
+
var negativeDate = -62198755200000;
|
1292
|
+
var negativeYearString = '-000001';
|
1293
|
+
var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
|
1294
|
+
var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z';
|
1295
|
+
|
1296
|
+
defineProperties(Date.prototype, {
|
1297
|
+
toISOString: function toISOString() {
|
1298
|
+
if (!isFinite(this)) {
|
1299
|
+
throw new RangeError('Date.prototype.toISOString called on non-finite value.');
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
var year = originalGetUTCFullYear(this);
|
1303
|
+
|
1304
|
+
var month = originalGetUTCMonth(this);
|
1305
|
+
// see https://github.com/es-shims/es5-shim/issues/111
|
1306
|
+
year += Math.floor(month / 12);
|
1307
|
+
month = (month % 12 + 12) % 12;
|
1308
|
+
|
1309
|
+
// the date time string format is specified in 15.9.1.15.
|
1310
|
+
var result = [month + 1, originalGetUTCDate(this), originalGetUTCHours(this), originalGetUTCMinutes(this), originalGetUTCSeconds(this)];
|
1311
|
+
year = (
|
1312
|
+
(year < 0 ? '-' : (year > 9999 ? '+' : '')) +
|
1313
|
+
strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6)
|
1314
|
+
);
|
1315
|
+
|
1316
|
+
for (var i = 0; i < result.length; ++i) {
|
1317
|
+
// pad months, days, hours, minutes, and seconds to have two digits.
|
1318
|
+
result[i] = strSlice('00' + result[i], -2);
|
1319
|
+
}
|
1320
|
+
// pad milliseconds to have three digits.
|
1321
|
+
return (
|
1322
|
+
year + '-' + arraySlice(result, 0, 2).join('-') +
|
1323
|
+
'T' + arraySlice(result, 2).join(':') + '.' +
|
1324
|
+
strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z'
|
1325
|
+
);
|
1326
|
+
}
|
1327
|
+
}, hasNegativeDateBug || hasSafari51DateBug);
|
1328
|
+
|
1329
|
+
// ES5 15.9.5.44
|
1330
|
+
// http://es5.github.com/#x15.9.5.44
|
1331
|
+
// This function provides a String representation of a Date object for use by
|
1332
|
+
// JSON.stringify (15.12.3).
|
1333
|
+
var dateToJSONIsSupported = (function () {
|
1334
|
+
try {
|
1335
|
+
return Date.prototype.toJSON &&
|
1336
|
+
new Date(NaN).toJSON() === null &&
|
1337
|
+
new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
|
1338
|
+
Date.prototype.toJSON.call({ // generic
|
1339
|
+
toISOString: function () { return true; }
|
1340
|
+
});
|
1341
|
+
} catch (e) {
|
1342
|
+
return false;
|
1343
|
+
}
|
1344
|
+
}());
|
1345
|
+
if (!dateToJSONIsSupported) {
|
1346
|
+
Date.prototype.toJSON = function toJSON(key) {
|
1347
|
+
// When the toJSON method is called with argument key, the following
|
1348
|
+
// steps are taken:
|
1349
|
+
|
1350
|
+
// 1. Let O be the result of calling ToObject, giving it the this
|
1351
|
+
// value as its argument.
|
1352
|
+
// 2. Let tv be ES.ToPrimitive(O, hint Number).
|
1353
|
+
var O = $Object(this);
|
1354
|
+
var tv = ES.ToPrimitive(O);
|
1355
|
+
// 3. If tv is a Number and is not finite, return null.
|
1356
|
+
if (typeof tv === 'number' && !isFinite(tv)) {
|
1357
|
+
return null;
|
1358
|
+
}
|
1359
|
+
// 4. Let toISO be the result of calling the [[Get]] internal method of
|
1360
|
+
// O with argument "toISOString".
|
1361
|
+
var toISO = O.toISOString;
|
1362
|
+
// 5. If IsCallable(toISO) is false, throw a TypeError exception.
|
1363
|
+
if (!isCallable(toISO)) {
|
1364
|
+
throw new TypeError('toISOString property is not callable');
|
1365
|
+
}
|
1366
|
+
// 6. Return the result of calling the [[Call]] internal method of
|
1367
|
+
// toISO with O as the this value and an empty argument list.
|
1368
|
+
return toISO.call(O);
|
1369
|
+
|
1370
|
+
// NOTE 1 The argument is ignored.
|
1371
|
+
|
1372
|
+
// NOTE 2 The toJSON function is intentionally generic; it does not
|
1373
|
+
// require that its this value be a Date object. Therefore, it can be
|
1374
|
+
// transferred to other kinds of objects for use as a method. However,
|
1375
|
+
// it does require that any such object have a toISOString method. An
|
1376
|
+
// object is free to use the argument key to filter its
|
1377
|
+
// stringification.
|
1378
|
+
};
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
// ES5 15.9.4.2
|
1382
|
+
// http://es5.github.com/#x15.9.4.2
|
1383
|
+
// based on work shared by Daniel Friesen (dantman)
|
1384
|
+
// http://gist.github.com/303249
|
1385
|
+
var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
|
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'));
|
1387
|
+
var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z'));
|
1388
|
+
if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
|
1389
|
+
// XXX global assignment won't work in embeddings that use
|
1390
|
+
// an alternate object for the context.
|
1391
|
+
/* global Date: true */
|
1392
|
+
/* eslint-disable no-undef */
|
1393
|
+
var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1;
|
1394
|
+
var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime());
|
1395
|
+
Date = (function (NativeDate) {
|
1396
|
+
/* eslint-enable no-undef */
|
1397
|
+
// Date.length === 7
|
1398
|
+
var DateShim = function Date(Y, M, D, h, m, s, ms) {
|
1399
|
+
var length = arguments.length;
|
1400
|
+
var date;
|
1401
|
+
if (this instanceof NativeDate) {
|
1402
|
+
var seconds = s;
|
1403
|
+
var millis = ms;
|
1404
|
+
if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) {
|
1405
|
+
// work around a Safari 8/9 bug where it treats the seconds as signed
|
1406
|
+
var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
|
1407
|
+
var sToShift = Math.floor(msToShift / 1e3);
|
1408
|
+
seconds += sToShift;
|
1409
|
+
millis -= sToShift * 1e3;
|
1410
|
+
}
|
1411
|
+
date = length === 1 && $String(Y) === Y ? // isString(Y)
|
1412
|
+
// We explicitly pass it through parse:
|
1413
|
+
new NativeDate(DateShim.parse(Y)) :
|
1414
|
+
// We have to manually make calls depending on argument
|
1415
|
+
// length here
|
1416
|
+
length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) :
|
1417
|
+
length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) :
|
1418
|
+
length >= 5 ? new NativeDate(Y, M, D, h, m) :
|
1419
|
+
length >= 4 ? new NativeDate(Y, M, D, h) :
|
1420
|
+
length >= 3 ? new NativeDate(Y, M, D) :
|
1421
|
+
length >= 2 ? new NativeDate(Y, M) :
|
1422
|
+
length >= 1 ? new NativeDate(Y) :
|
1423
|
+
new NativeDate();
|
1424
|
+
} else {
|
1425
|
+
date = NativeDate.apply(this, arguments);
|
1426
|
+
}
|
1427
|
+
if (!isPrimitive(date)) {
|
1428
|
+
// Prevent mixups with unfixed Date object
|
1429
|
+
defineProperties(date, { constructor: DateShim }, true);
|
1430
|
+
}
|
1431
|
+
return date;
|
1432
|
+
};
|
1433
|
+
|
1434
|
+
// 15.9.1.15 Date Time String Format.
|
1435
|
+
var isoDateExpression = new RegExp('^' +
|
1436
|
+
'(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign +
|
1437
|
+
// 6-digit extended year
|
1438
|
+
'(?:-(\\d{2})' + // optional month capture
|
1439
|
+
'(?:-(\\d{2})' + // optional day capture
|
1440
|
+
'(?:' + // capture hours:minutes:seconds.milliseconds
|
1441
|
+
'T(\\d{2})' + // hours capture
|
1442
|
+
':(\\d{2})' + // minutes capture
|
1443
|
+
'(?:' + // optional :seconds.milliseconds
|
1444
|
+
':(\\d{2})' + // seconds capture
|
1445
|
+
'(?:(\\.\\d{1,}))?' + // milliseconds capture
|
1446
|
+
')?' +
|
1447
|
+
'(' + // capture UTC offset component
|
1448
|
+
'Z|' + // UTC capture
|
1449
|
+
'(?:' + // offset specifier +/-hours:minutes
|
1450
|
+
'([-+])' + // sign capture
|
1451
|
+
'(\\d{2})' + // hours offset capture
|
1452
|
+
':(\\d{2})' + // minutes offset capture
|
1453
|
+
')' +
|
1454
|
+
')?)?)?)?' +
|
1455
|
+
'$');
|
1456
|
+
|
1457
|
+
var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
|
1458
|
+
|
1459
|
+
var dayFromMonth = function dayFromMonth(year, month) {
|
1460
|
+
var t = month > 1 ? 1 : 0;
|
1461
|
+
return (
|
1462
|
+
months[month] +
|
1463
|
+
Math.floor((year - 1969 + t) / 4) -
|
1464
|
+
Math.floor((year - 1901 + t) / 100) +
|
1465
|
+
Math.floor((year - 1601 + t) / 400) +
|
1466
|
+
365 * (year - 1970)
|
1467
|
+
);
|
1468
|
+
};
|
1469
|
+
|
1470
|
+
var toUTC = function toUTC(t) {
|
1471
|
+
var s = 0;
|
1472
|
+
var ms = t;
|
1473
|
+
if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) {
|
1474
|
+
// work around a Safari 8/9 bug where it treats the seconds as signed
|
1475
|
+
var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
|
1476
|
+
var sToShift = Math.floor(msToShift / 1e3);
|
1477
|
+
s += sToShift;
|
1478
|
+
ms -= sToShift * 1e3;
|
1479
|
+
}
|
1480
|
+
return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms));
|
1481
|
+
};
|
1482
|
+
|
1483
|
+
// Copy any custom methods a 3rd party library may have added
|
1484
|
+
for (var key in NativeDate) {
|
1485
|
+
if (owns(NativeDate, key)) {
|
1486
|
+
DateShim[key] = NativeDate[key];
|
1487
|
+
}
|
1488
|
+
}
|
1489
|
+
|
1490
|
+
// Copy "native" methods explicitly; they may be non-enumerable
|
1491
|
+
defineProperties(DateShim, {
|
1492
|
+
now: NativeDate.now,
|
1493
|
+
UTC: NativeDate.UTC
|
1494
|
+
}, true);
|
1495
|
+
DateShim.prototype = NativeDate.prototype;
|
1496
|
+
defineProperties(DateShim.prototype, {
|
1497
|
+
constructor: DateShim
|
1498
|
+
}, true);
|
1499
|
+
|
1500
|
+
// Upgrade Date.parse to handle simplified ISO 8601 strings
|
1501
|
+
var parseShim = function parse(string) {
|
1502
|
+
var match = isoDateExpression.exec(string);
|
1503
|
+
if (match) {
|
1504
|
+
// parse months, days, hours, minutes, seconds, and milliseconds
|
1505
|
+
// provide default values if necessary
|
1506
|
+
// parse the UTC offset component
|
1507
|
+
var year = $Number(match[1]),
|
1508
|
+
month = $Number(match[2] || 1) - 1,
|
1509
|
+
day = $Number(match[3] || 1) - 1,
|
1510
|
+
hour = $Number(match[4] || 0),
|
1511
|
+
minute = $Number(match[5] || 0),
|
1512
|
+
second = $Number(match[6] || 0),
|
1513
|
+
millisecond = Math.floor($Number(match[7] || 0) * 1000),
|
1514
|
+
// When time zone is missed, local offset should be used
|
1515
|
+
// (ES 5.1 bug)
|
1516
|
+
// see https://bugs.ecmascript.org/show_bug.cgi?id=112
|
1517
|
+
isLocalTime = Boolean(match[4] && !match[8]),
|
1518
|
+
signOffset = match[9] === '-' ? 1 : -1,
|
1519
|
+
hourOffset = $Number(match[10] || 0),
|
1520
|
+
minuteOffset = $Number(match[11] || 0),
|
1521
|
+
result;
|
1522
|
+
var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0;
|
1523
|
+
if (
|
1524
|
+
hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) &&
|
1525
|
+
minute < 60 && second < 60 && millisecond < 1000 &&
|
1526
|
+
month > -1 && month < 12 && hourOffset < 24 &&
|
1527
|
+
minuteOffset < 60 && // detect invalid offsets
|
1528
|
+
day > -1 &&
|
1529
|
+
day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month))
|
1530
|
+
) {
|
1531
|
+
result = (
|
1532
|
+
(dayFromMonth(year, month) + day) * 24 +
|
1533
|
+
hour +
|
1534
|
+
hourOffset * signOffset
|
1535
|
+
) * 60;
|
1536
|
+
result = (
|
1537
|
+
(result + minute + minuteOffset * signOffset) * 60 +
|
1538
|
+
second
|
1539
|
+
) * 1000 + millisecond;
|
1540
|
+
if (isLocalTime) {
|
1541
|
+
result = toUTC(result);
|
1542
|
+
}
|
1543
|
+
if (-8.64e15 <= result && result <= 8.64e15) {
|
1544
|
+
return result;
|
1545
|
+
}
|
1546
|
+
}
|
1547
|
+
return NaN;
|
1548
|
+
}
|
1549
|
+
return NativeDate.parse.apply(this, arguments);
|
1550
|
+
};
|
1551
|
+
defineProperties(DateShim, { parse: parseShim });
|
1552
|
+
|
1553
|
+
return DateShim;
|
1554
|
+
}(Date));
|
1555
|
+
/* global Date: false */
|
1556
|
+
}
|
1557
|
+
|
1558
|
+
// ES5 15.9.4.4
|
1559
|
+
// http://es5.github.com/#x15.9.4.4
|
1560
|
+
if (!Date.now) {
|
1561
|
+
Date.now = function now() {
|
1562
|
+
return new Date().getTime();
|
1563
|
+
};
|
1564
|
+
}
|
1565
|
+
|
1566
|
+
//
|
1567
|
+
// Number
|
1568
|
+
// ======
|
1569
|
+
//
|
1570
|
+
|
1571
|
+
// ES5.1 15.7.4.5
|
1572
|
+
// http://es5.github.com/#x15.7.4.5
|
1573
|
+
var hasToFixedBugs = NumberPrototype.toFixed && (
|
1574
|
+
(0.00008).toFixed(3) !== '0.000' ||
|
1575
|
+
(0.9).toFixed(0) !== '1' ||
|
1576
|
+
(1.255).toFixed(2) !== '1.25' ||
|
1577
|
+
(1000000000000000128).toFixed(0) !== '1000000000000000128'
|
1578
|
+
);
|
1579
|
+
|
1580
|
+
var toFixedHelpers = {
|
1581
|
+
base: 1e7,
|
1582
|
+
size: 6,
|
1583
|
+
data: [0, 0, 0, 0, 0, 0],
|
1584
|
+
multiply: function multiply(n, c) {
|
1585
|
+
var i = -1;
|
1586
|
+
var c2 = c;
|
1587
|
+
while (++i < toFixedHelpers.size) {
|
1588
|
+
c2 += n * toFixedHelpers.data[i];
|
1589
|
+
toFixedHelpers.data[i] = c2 % toFixedHelpers.base;
|
1590
|
+
c2 = Math.floor(c2 / toFixedHelpers.base);
|
1591
|
+
}
|
1592
|
+
},
|
1593
|
+
divide: function divide(n) {
|
1594
|
+
var i = toFixedHelpers.size, c = 0;
|
1595
|
+
while (--i >= 0) {
|
1596
|
+
c += toFixedHelpers.data[i];
|
1597
|
+
toFixedHelpers.data[i] = Math.floor(c / n);
|
1598
|
+
c = (c % n) * toFixedHelpers.base;
|
1599
|
+
}
|
1600
|
+
},
|
1601
|
+
numToString: function numToString() {
|
1602
|
+
var i = toFixedHelpers.size;
|
1603
|
+
var s = '';
|
1604
|
+
while (--i >= 0) {
|
1605
|
+
if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) {
|
1606
|
+
var t = $String(toFixedHelpers.data[i]);
|
1607
|
+
if (s === '') {
|
1608
|
+
s = t;
|
1609
|
+
} else {
|
1610
|
+
s += strSlice('0000000', 0, 7 - t.length) + t;
|
1611
|
+
}
|
1612
|
+
}
|
1613
|
+
}
|
1614
|
+
return s;
|
1615
|
+
},
|
1616
|
+
pow: function pow(x, n, acc) {
|
1617
|
+
return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
|
1618
|
+
},
|
1619
|
+
log: function log(x) {
|
1620
|
+
var n = 0;
|
1621
|
+
var x2 = x;
|
1622
|
+
while (x2 >= 4096) {
|
1623
|
+
n += 12;
|
1624
|
+
x2 /= 4096;
|
1625
|
+
}
|
1626
|
+
while (x2 >= 2) {
|
1627
|
+
n += 1;
|
1628
|
+
x2 /= 2;
|
1629
|
+
}
|
1630
|
+
return n;
|
1631
|
+
}
|
1632
|
+
};
|
1633
|
+
|
1634
|
+
var toFixedShim = function toFixed(fractionDigits) {
|
1635
|
+
var f, x, s, m, e, z, j, k;
|
1636
|
+
|
1637
|
+
// Test for NaN and round fractionDigits down
|
1638
|
+
f = $Number(fractionDigits);
|
1639
|
+
f = isActualNaN(f) ? 0 : Math.floor(f);
|
1640
|
+
|
1641
|
+
if (f < 0 || f > 20) {
|
1642
|
+
throw new RangeError('Number.toFixed called with invalid number of decimals');
|
1643
|
+
}
|
1644
|
+
|
1645
|
+
x = $Number(this);
|
1646
|
+
|
1647
|
+
if (isActualNaN(x)) {
|
1648
|
+
return 'NaN';
|
1649
|
+
}
|
1650
|
+
|
1651
|
+
// If it is too big or small, return the string value of the number
|
1652
|
+
if (x <= -1e21 || x >= 1e21) {
|
1653
|
+
return $String(x);
|
1654
|
+
}
|
1655
|
+
|
1656
|
+
s = '';
|
1657
|
+
|
1658
|
+
if (x < 0) {
|
1659
|
+
s = '-';
|
1660
|
+
x = -x;
|
1661
|
+
}
|
1662
|
+
|
1663
|
+
m = '0';
|
1664
|
+
|
1665
|
+
if (x > 1e-21) {
|
1666
|
+
// 1e-21 < x < 1e21
|
1667
|
+
// -70 < log2(x) < 70
|
1668
|
+
e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69;
|
1669
|
+
z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
|
1670
|
+
z *= 0x10000000000000; // Math.pow(2, 52);
|
1671
|
+
e = 52 - e;
|
1672
|
+
|
1673
|
+
// -18 < e < 122
|
1674
|
+
// x = z / 2 ^ e
|
1675
|
+
if (e > 0) {
|
1676
|
+
toFixedHelpers.multiply(0, z);
|
1677
|
+
j = f;
|
1678
|
+
|
1679
|
+
while (j >= 7) {
|
1680
|
+
toFixedHelpers.multiply(1e7, 0);
|
1681
|
+
j -= 7;
|
1682
|
+
}
|
1683
|
+
|
1684
|
+
toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0);
|
1685
|
+
j = e - 1;
|
1686
|
+
|
1687
|
+
while (j >= 23) {
|
1688
|
+
toFixedHelpers.divide(1 << 23);
|
1689
|
+
j -= 23;
|
1690
|
+
}
|
1691
|
+
|
1692
|
+
toFixedHelpers.divide(1 << j);
|
1693
|
+
toFixedHelpers.multiply(1, 1);
|
1694
|
+
toFixedHelpers.divide(2);
|
1695
|
+
m = toFixedHelpers.numToString();
|
1696
|
+
} else {
|
1697
|
+
toFixedHelpers.multiply(0, z);
|
1698
|
+
toFixedHelpers.multiply(1 << (-e), 0);
|
1699
|
+
m = toFixedHelpers.numToString() + strSlice('0.00000000000000000000', 2, 2 + f);
|
1700
|
+
}
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
if (f > 0) {
|
1704
|
+
k = m.length;
|
1705
|
+
|
1706
|
+
if (k <= f) {
|
1707
|
+
m = s + strSlice('0.0000000000000000000', 0, f - k + 2) + m;
|
1708
|
+
} else {
|
1709
|
+
m = s + strSlice(m, 0, k - f) + '.' + strSlice(m, k - f);
|
1710
|
+
}
|
1711
|
+
} else {
|
1712
|
+
m = s + m;
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
return m;
|
1716
|
+
};
|
1717
|
+
defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs);
|
1718
|
+
|
1719
|
+
var hasToPrecisionUndefinedBug = (function () {
|
1720
|
+
try {
|
1721
|
+
return 1.0.toPrecision(undefined) === '1';
|
1722
|
+
} catch (e) {
|
1723
|
+
return true;
|
1724
|
+
}
|
1725
|
+
}());
|
1726
|
+
var originalToPrecision = NumberPrototype.toPrecision;
|
1727
|
+
defineProperties(NumberPrototype, {
|
1728
|
+
toPrecision: function toPrecision(precision) {
|
1729
|
+
return typeof precision === 'undefined' ? originalToPrecision.call(this) : originalToPrecision.call(this, precision);
|
1730
|
+
}
|
1731
|
+
}, hasToPrecisionUndefinedBug);
|
1732
|
+
|
1733
|
+
//
|
1734
|
+
// String
|
1735
|
+
// ======
|
1736
|
+
//
|
1737
|
+
|
1738
|
+
// ES5 15.5.4.14
|
1739
|
+
// http://es5.github.com/#x15.5.4.14
|
1740
|
+
|
1741
|
+
// [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
|
1742
|
+
// Many browsers do not split properly with regular expressions or they
|
1743
|
+
// do not perform the split correctly under obscure conditions.
|
1744
|
+
// See http://blog.stevenlevithan.com/archives/cross-browser-split
|
1745
|
+
// I've tested in many browsers and this seems to cover the deviant ones:
|
1746
|
+
// 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
|
1747
|
+
// '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
|
1748
|
+
// 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
|
1749
|
+
// [undefined, "t", undefined, "e", ...]
|
1750
|
+
// ''.split(/.?/) should be [], not [""]
|
1751
|
+
// '.'.split(/()()/) should be ["."], not ["", "", "."]
|
1752
|
+
|
1753
|
+
if (
|
1754
|
+
'ab'.split(/(?:ab)*/).length !== 2 ||
|
1755
|
+
'.'.split(/(.?)(.?)/).length !== 4 ||
|
1756
|
+
'tesst'.split(/(s)*/)[1] === 't' ||
|
1757
|
+
'test'.split(/(?:)/, -1).length !== 4 ||
|
1758
|
+
''.split(/.?/).length ||
|
1759
|
+
'.'.split(/()()/).length > 1
|
1760
|
+
) {
|
1761
|
+
(function () {
|
1762
|
+
var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group
|
1763
|
+
var maxSafe32BitInt = Math.pow(2, 32) - 1;
|
1764
|
+
|
1765
|
+
StringPrototype.split = function (separator, limit) {
|
1766
|
+
var string = String(this);
|
1767
|
+
if (typeof separator === 'undefined' && limit === 0) {
|
1768
|
+
return [];
|
1769
|
+
}
|
1770
|
+
|
1771
|
+
// If `separator` is not a regex, use native split
|
1772
|
+
if (!isRegex(separator)) {
|
1773
|
+
return strSplit(this, separator, limit);
|
1774
|
+
}
|
1775
|
+
|
1776
|
+
var output = [];
|
1777
|
+
var flags = (separator.ignoreCase ? 'i' : '') +
|
1778
|
+
(separator.multiline ? 'm' : '') +
|
1779
|
+
(separator.unicode ? 'u' : '') + // in ES6
|
1780
|
+
(separator.sticky ? 'y' : ''), // Firefox 3+ and ES6
|
1781
|
+
lastLastIndex = 0,
|
1782
|
+
// Make `global` and avoid `lastIndex` issues by working with a copy
|
1783
|
+
separator2, match, lastIndex, lastLength;
|
1784
|
+
var separatorCopy = new RegExp(separator.source, flags + 'g');
|
1785
|
+
if (!compliantExecNpcg) {
|
1786
|
+
// Doesn't need flags gy, but they don't hurt
|
1787
|
+
separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
|
1788
|
+
}
|
1789
|
+
/* Values for `limit`, per the spec:
|
1790
|
+
* If undefined: 4294967295 // maxSafe32BitInt
|
1791
|
+
* If 0, Infinity, or NaN: 0
|
1792
|
+
* If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
|
1793
|
+
* If negative number: 4294967296 - Math.floor(Math.abs(limit))
|
1794
|
+
* If other: Type-convert, then use the above rules
|
1795
|
+
*/
|
1796
|
+
var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit);
|
1797
|
+
match = separatorCopy.exec(string);
|
1798
|
+
while (match) {
|
1799
|
+
// `separatorCopy.lastIndex` is not reliable cross-browser
|
1800
|
+
lastIndex = match.index + match[0].length;
|
1801
|
+
if (lastIndex > lastLastIndex) {
|
1802
|
+
pushCall(output, strSlice(string, lastLastIndex, match.index));
|
1803
|
+
// Fix browsers whose `exec` methods don't consistently return `undefined` for
|
1804
|
+
// nonparticipating capturing groups
|
1805
|
+
if (!compliantExecNpcg && match.length > 1) {
|
1806
|
+
/* eslint-disable no-loop-func */
|
1807
|
+
match[0].replace(separator2, function () {
|
1808
|
+
for (var i = 1; i < arguments.length - 2; i++) {
|
1809
|
+
if (typeof arguments[i] === 'undefined') {
|
1810
|
+
match[i] = void 0;
|
1811
|
+
}
|
1812
|
+
}
|
1813
|
+
});
|
1814
|
+
/* eslint-enable no-loop-func */
|
1815
|
+
}
|
1816
|
+
if (match.length > 1 && match.index < string.length) {
|
1817
|
+
array_push.apply(output, arraySlice(match, 1));
|
1818
|
+
}
|
1819
|
+
lastLength = match[0].length;
|
1820
|
+
lastLastIndex = lastIndex;
|
1821
|
+
if (output.length >= splitLimit) {
|
1822
|
+
break;
|
1823
|
+
}
|
1824
|
+
}
|
1825
|
+
if (separatorCopy.lastIndex === match.index) {
|
1826
|
+
separatorCopy.lastIndex++; // Avoid an infinite loop
|
1827
|
+
}
|
1828
|
+
match = separatorCopy.exec(string);
|
1829
|
+
}
|
1830
|
+
if (lastLastIndex === string.length) {
|
1831
|
+
if (lastLength || !separatorCopy.test('')) {
|
1832
|
+
pushCall(output, '');
|
1833
|
+
}
|
1834
|
+
} else {
|
1835
|
+
pushCall(output, strSlice(string, lastLastIndex));
|
1836
|
+
}
|
1837
|
+
return output.length > splitLimit ? strSlice(output, 0, splitLimit) : output;
|
1838
|
+
};
|
1839
|
+
}());
|
1840
|
+
|
1841
|
+
// [bugfix, chrome]
|
1842
|
+
// If separator is undefined, then the result array contains just one String,
|
1843
|
+
// which is the this value (converted to a String). If limit is not undefined,
|
1844
|
+
// then the output array is truncated so that it contains no more than limit
|
1845
|
+
// elements.
|
1846
|
+
// "0".split(undefined, 0) -> []
|
1847
|
+
} else if ('0'.split(void 0, 0).length) {
|
1848
|
+
StringPrototype.split = function split(separator, limit) {
|
1849
|
+
if (typeof separator === 'undefined' && limit === 0) { return []; }
|
1850
|
+
return strSplit(this, separator, limit);
|
1851
|
+
};
|
1852
|
+
}
|
1853
|
+
|
1854
|
+
var str_replace = StringPrototype.replace;
|
1855
|
+
var replaceReportsGroupsCorrectly = (function () {
|
1856
|
+
var groups = [];
|
1857
|
+
'x'.replace(/x(.)?/g, function (match, group) {
|
1858
|
+
pushCall(groups, group);
|
1859
|
+
});
|
1860
|
+
return groups.length === 1 && typeof groups[0] === 'undefined';
|
1861
|
+
}());
|
1862
|
+
|
1863
|
+
if (!replaceReportsGroupsCorrectly) {
|
1864
|
+
StringPrototype.replace = function replace(searchValue, replaceValue) {
|
1865
|
+
var isFn = isCallable(replaceValue);
|
1866
|
+
var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
|
1867
|
+
if (!isFn || !hasCapturingGroups) {
|
1868
|
+
return str_replace.call(this, searchValue, replaceValue);
|
1869
|
+
} else {
|
1870
|
+
var wrappedReplaceValue = function (match) {
|
1871
|
+
var length = arguments.length;
|
1872
|
+
var originalLastIndex = searchValue.lastIndex;
|
1873
|
+
searchValue.lastIndex = 0;
|
1874
|
+
var args = searchValue.exec(match) || [];
|
1875
|
+
searchValue.lastIndex = originalLastIndex;
|
1876
|
+
pushCall(args, arguments[length - 2], arguments[length - 1]);
|
1877
|
+
return replaceValue.apply(this, args);
|
1878
|
+
};
|
1879
|
+
return str_replace.call(this, searchValue, wrappedReplaceValue);
|
1880
|
+
}
|
1881
|
+
};
|
1882
|
+
}
|
1883
|
+
|
1884
|
+
// ECMA-262, 3rd B.2.3
|
1885
|
+
// Not an ECMAScript standard, although ECMAScript 3rd Edition has a
|
1886
|
+
// non-normative section suggesting uniform semantics and it should be
|
1887
|
+
// normalized across all browsers
|
1888
|
+
// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
|
1889
|
+
var string_substr = StringPrototype.substr;
|
1890
|
+
var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b';
|
1891
|
+
defineProperties(StringPrototype, {
|
1892
|
+
substr: function substr(start, length) {
|
1893
|
+
var normalizedStart = start;
|
1894
|
+
if (start < 0) {
|
1895
|
+
normalizedStart = max(this.length + start, 0);
|
1896
|
+
}
|
1897
|
+
return string_substr.call(this, normalizedStart, length);
|
1898
|
+
}
|
1899
|
+
}, hasNegativeSubstrBug);
|
1900
|
+
|
1901
|
+
// ES5 15.5.4.20
|
1902
|
+
// whitespace from: http://es5.github.io/#x15.5.4.20
|
1903
|
+
var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
|
1904
|
+
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
|
1905
|
+
'\u2029\uFEFF';
|
1906
|
+
var zeroWidth = '\u200b';
|
1907
|
+
var wsRegexChars = '[' + ws + ']';
|
1908
|
+
var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*');
|
1909
|
+
var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$');
|
1910
|
+
var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim());
|
1911
|
+
defineProperties(StringPrototype, {
|
1912
|
+
// http://blog.stevenlevithan.com/archives/faster-trim-javascript
|
1913
|
+
// http://perfectionkills.com/whitespace-deviations/
|
1914
|
+
trim: function trim() {
|
1915
|
+
if (typeof this === 'undefined' || this === null) {
|
1916
|
+
throw new TypeError("can't convert " + this + ' to object');
|
1917
|
+
}
|
1918
|
+
return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
|
1919
|
+
}
|
1920
|
+
}, hasTrimWhitespaceBug);
|
1921
|
+
var trim = call.bind(String.prototype.trim);
|
1922
|
+
|
1923
|
+
var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1;
|
1924
|
+
defineProperties(StringPrototype, {
|
1925
|
+
lastIndexOf: function lastIndexOf(searchString) {
|
1926
|
+
if (typeof this === 'undefined' || this === null) {
|
1927
|
+
throw new TypeError("can't convert " + this + ' to object');
|
1928
|
+
}
|
1929
|
+
var S = $String(this);
|
1930
|
+
var searchStr = $String(searchString);
|
1931
|
+
var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN;
|
1932
|
+
var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos);
|
1933
|
+
var start = min(max(pos, 0), S.length);
|
1934
|
+
var searchLen = searchStr.length;
|
1935
|
+
var k = start + searchLen;
|
1936
|
+
while (k > 0) {
|
1937
|
+
k = max(0, k - searchLen);
|
1938
|
+
var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr);
|
1939
|
+
if (index !== -1) {
|
1940
|
+
return k + index;
|
1941
|
+
}
|
1942
|
+
}
|
1943
|
+
return -1;
|
1944
|
+
}
|
1945
|
+
}, hasLastIndexBug);
|
1946
|
+
|
1947
|
+
var originalLastIndexOf = StringPrototype.lastIndexOf;
|
1948
|
+
defineProperties(StringPrototype, {
|
1949
|
+
lastIndexOf: function lastIndexOf(searchString) {
|
1950
|
+
return originalLastIndexOf.apply(this, arguments);
|
1951
|
+
}
|
1952
|
+
}, StringPrototype.lastIndexOf.length !== 1);
|
1953
|
+
|
1954
|
+
// ES-5 15.1.2.2
|
1955
|
+
/* eslint-disable radix */
|
1956
|
+
if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
|
1957
|
+
/* eslint-enable radix */
|
1958
|
+
/* global parseInt: true */
|
1959
|
+
parseInt = (function (origParseInt) {
|
1960
|
+
var hexRegex = /^[\-+]?0[xX]/;
|
1961
|
+
return function parseInt(str, radix) {
|
1962
|
+
var string = trim(str);
|
1963
|
+
var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10);
|
1964
|
+
return origParseInt(string, defaultedRadix);
|
1965
|
+
};
|
1966
|
+
}(parseInt));
|
1967
|
+
}
|
1968
|
+
|
1969
|
+
// https://es5.github.io/#x15.1.2.3
|
1970
|
+
if (1 / parseFloat('-0') !== -Infinity) {
|
1971
|
+
/* global parseFloat: true */
|
1972
|
+
parseFloat = (function (origParseFloat) {
|
1973
|
+
return function parseFloat(string) {
|
1974
|
+
var inputString = trim(string);
|
1975
|
+
var result = origParseFloat(inputString);
|
1976
|
+
return result === 0 && strSlice(inputString, 0, 1) === '-' ? -0 : result;
|
1977
|
+
};
|
1978
|
+
}(parseFloat));
|
1979
|
+
}
|
1980
|
+
|
1981
|
+
if (String(new RangeError('test')) !== 'RangeError: test') {
|
1982
|
+
var errorToStringShim = function toString() {
|
1983
|
+
if (typeof this === 'undefined' || this === null) {
|
1984
|
+
throw new TypeError("can't convert " + this + ' to object');
|
1985
|
+
}
|
1986
|
+
var name = this.name;
|
1987
|
+
if (typeof name === 'undefined') {
|
1988
|
+
name = 'Error';
|
1989
|
+
} else if (typeof name !== 'string') {
|
1990
|
+
name = $String(name);
|
1991
|
+
}
|
1992
|
+
var msg = this.message;
|
1993
|
+
if (typeof msg === 'undefined') {
|
1994
|
+
msg = '';
|
1995
|
+
} else if (typeof msg !== 'string') {
|
1996
|
+
msg = $String(msg);
|
1997
|
+
}
|
1998
|
+
if (!name) {
|
1999
|
+
return msg;
|
2000
|
+
}
|
2001
|
+
if (!msg) {
|
2002
|
+
return name;
|
2003
|
+
}
|
2004
|
+
return name + ': ' + msg;
|
2005
|
+
};
|
2006
|
+
// can't use defineProperties here because of toString enumeration issue in IE <= 8
|
2007
|
+
Error.prototype.toString = errorToStringShim;
|
2008
|
+
}
|
2009
|
+
|
2010
|
+
if (supportsDescriptors) {
|
2011
|
+
var ensureNonEnumerable = function (obj, prop) {
|
2012
|
+
if (isEnum(obj, prop)) {
|
2013
|
+
var desc = Object.getOwnPropertyDescriptor(obj, prop);
|
2014
|
+
desc.enumerable = false;
|
2015
|
+
Object.defineProperty(obj, prop, desc);
|
2016
|
+
}
|
2017
|
+
};
|
2018
|
+
ensureNonEnumerable(Error.prototype, 'message');
|
2019
|
+
if (Error.prototype.message !== '') {
|
2020
|
+
Error.prototype.message = '';
|
2021
|
+
}
|
2022
|
+
ensureNonEnumerable(Error.prototype, 'name');
|
2023
|
+
}
|
2024
|
+
|
2025
|
+
if (String(/a/mig) !== '/a/gim') {
|
2026
|
+
var regexToString = function toString() {
|
2027
|
+
var str = '/' + this.source + '/';
|
2028
|
+
if (this.global) {
|
2029
|
+
str += 'g';
|
2030
|
+
}
|
2031
|
+
if (this.ignoreCase) {
|
2032
|
+
str += 'i';
|
2033
|
+
}
|
2034
|
+
if (this.multiline) {
|
2035
|
+
str += 'm';
|
2036
|
+
}
|
2037
|
+
return str;
|
2038
|
+
};
|
2039
|
+
// can't use defineProperties here because of toString enumeration issue in IE <= 8
|
2040
|
+
RegExp.prototype.toString = regexToString;
|
2041
|
+
}
|
2042
|
+
|
2043
|
+
}));
|
2044
|
+
|
2045
|
+
/*!
|
2046
|
+
* https://github.com/es-shims/es5-shim
|
2047
|
+
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
|
2048
|
+
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
|
2049
|
+
*/
|
2050
|
+
|
2051
|
+
// vim: ts=4 sts=4 sw=4 expandtab
|
2052
|
+
|
2053
|
+
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
|
2054
|
+
;
|
2055
|
+
|
2056
|
+
// UMD (Universal Module Definition)
|
2057
|
+
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
|
2058
|
+
(function (root, factory) {
|
2059
|
+
'use strict';
|
2060
|
+
|
2061
|
+
/* global define, exports, module */
|
2062
|
+
if (typeof define === 'function' && define.amd) {
|
2063
|
+
// AMD. Register as an anonymous module.
|
2064
|
+
define(factory);
|
2065
|
+
} else if (typeof exports === 'object') {
|
2066
|
+
// Node. Does not work with strict CommonJS, but
|
2067
|
+
// only CommonJS-like enviroments that support module.exports,
|
2068
|
+
// like Node.
|
2069
|
+
module.exports = factory();
|
2070
|
+
} else {
|
2071
|
+
// Browser globals (root is window)
|
2072
|
+
root.returnExports = factory();
|
2073
|
+
}
|
2074
|
+
}(this, function () {
|
2075
|
+
|
2076
|
+
var call = Function.call;
|
2077
|
+
var prototypeOfObject = Object.prototype;
|
2078
|
+
var owns = call.bind(prototypeOfObject.hasOwnProperty);
|
2079
|
+
var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);
|
2080
|
+
var toStr = call.bind(prototypeOfObject.toString);
|
2081
|
+
|
2082
|
+
// If JS engine supports accessors creating shortcuts.
|
2083
|
+
var defineGetter;
|
2084
|
+
var defineSetter;
|
2085
|
+
var lookupGetter;
|
2086
|
+
var lookupSetter;
|
2087
|
+
var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
|
2088
|
+
if (supportsAccessors) {
|
2089
|
+
/* eslint-disable no-underscore-dangle */
|
2090
|
+
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
|
2091
|
+
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
|
2092
|
+
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
|
2093
|
+
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
|
2094
|
+
/* eslint-enable no-underscore-dangle */
|
2095
|
+
}
|
2096
|
+
|
2097
|
+
// ES5 15.2.3.2
|
2098
|
+
// http://es5.github.com/#x15.2.3.2
|
2099
|
+
if (!Object.getPrototypeOf) {
|
2100
|
+
// https://github.com/es-shims/es5-shim/issues#issue/2
|
2101
|
+
// http://ejohn.org/blog/objectgetprototypeof/
|
2102
|
+
// recommended by fschaefer on github
|
2103
|
+
//
|
2104
|
+
// sure, and webreflection says ^_^
|
2105
|
+
// ... this will nerever possibly return null
|
2106
|
+
// ... Opera Mini breaks here with infinite loops
|
2107
|
+
Object.getPrototypeOf = function getPrototypeOf(object) {
|
2108
|
+
/* eslint-disable no-proto */
|
2109
|
+
var proto = object.__proto__;
|
2110
|
+
/* eslint-enable no-proto */
|
2111
|
+
if (proto || proto === null) {
|
2112
|
+
return proto;
|
2113
|
+
} else if (toStr(object.constructor) === '[object Function]') {
|
2114
|
+
return object.constructor.prototype;
|
2115
|
+
} else if (object instanceof Object) {
|
2116
|
+
return prototypeOfObject;
|
2117
|
+
} else {
|
2118
|
+
// Correctly return null for Objects created with `Object.create(null)`
|
2119
|
+
// (shammed or native) or `{ __proto__: null}`. Also returns null for
|
2120
|
+
// cross-realm objects on browsers that lack `__proto__` support (like
|
2121
|
+
// IE <11), but that's the best we can do.
|
2122
|
+
return null;
|
2123
|
+
}
|
2124
|
+
};
|
2125
|
+
}
|
2126
|
+
|
2127
|
+
// ES5 15.2.3.3
|
2128
|
+
// http://es5.github.com/#x15.2.3.3
|
2129
|
+
|
2130
|
+
var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
|
2131
|
+
try {
|
2132
|
+
object.sentinel = 0;
|
2133
|
+
return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
|
2134
|
+
} catch (exception) {
|
2135
|
+
return false;
|
2136
|
+
}
|
2137
|
+
};
|
2138
|
+
|
2139
|
+
// check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
|
2140
|
+
if (Object.defineProperty) {
|
2141
|
+
var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
|
2142
|
+
var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' ||
|
2143
|
+
doesGetOwnPropertyDescriptorWork(document.createElement('div'));
|
2144
|
+
if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
|
2145
|
+
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
|
2146
|
+
}
|
2147
|
+
}
|
2148
|
+
|
2149
|
+
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
|
2150
|
+
var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
|
2151
|
+
|
2152
|
+
/* eslint-disable no-proto */
|
2153
|
+
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
|
2154
|
+
if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
|
2155
|
+
throw new TypeError(ERR_NON_OBJECT + object);
|
2156
|
+
}
|
2157
|
+
|
2158
|
+
// make a valiant attempt to use the real getOwnPropertyDescriptor
|
2159
|
+
// for I8's DOM elements.
|
2160
|
+
if (getOwnPropertyDescriptorFallback) {
|
2161
|
+
try {
|
2162
|
+
return getOwnPropertyDescriptorFallback.call(Object, object, property);
|
2163
|
+
} catch (exception) {
|
2164
|
+
// try the shim if the real one doesn't work
|
2165
|
+
}
|
2166
|
+
}
|
2167
|
+
|
2168
|
+
var descriptor;
|
2169
|
+
|
2170
|
+
// If object does not owns property return undefined immediately.
|
2171
|
+
if (!owns(object, property)) {
|
2172
|
+
return descriptor;
|
2173
|
+
}
|
2174
|
+
|
2175
|
+
// If object has a property then it's for sure `configurable`, and
|
2176
|
+
// probably `enumerable`. Detect enumerability though.
|
2177
|
+
descriptor = {
|
2178
|
+
enumerable: isEnumerable(object, property),
|
2179
|
+
configurable: true
|
2180
|
+
};
|
2181
|
+
|
2182
|
+
// If JS engine supports accessor properties then property may be a
|
2183
|
+
// getter or setter.
|
2184
|
+
if (supportsAccessors) {
|
2185
|
+
// Unfortunately `__lookupGetter__` will return a getter even
|
2186
|
+
// if object has own non getter property along with a same named
|
2187
|
+
// inherited getter. To avoid misbehavior we temporary remove
|
2188
|
+
// `__proto__` so that `__lookupGetter__` will return getter only
|
2189
|
+
// if it's owned by an object.
|
2190
|
+
var prototype = object.__proto__;
|
2191
|
+
var notPrototypeOfObject = object !== prototypeOfObject;
|
2192
|
+
// avoid recursion problem, breaking in Opera Mini when
|
2193
|
+
// Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
|
2194
|
+
// or any other Object.prototype accessor
|
2195
|
+
if (notPrototypeOfObject) {
|
2196
|
+
object.__proto__ = prototypeOfObject;
|
2197
|
+
}
|
2198
|
+
|
2199
|
+
var getter = lookupGetter(object, property);
|
2200
|
+
var setter = lookupSetter(object, property);
|
2201
|
+
|
2202
|
+
if (notPrototypeOfObject) {
|
2203
|
+
// Once we have getter and setter we can put values back.
|
2204
|
+
object.__proto__ = prototype;
|
2205
|
+
}
|
2206
|
+
|
2207
|
+
if (getter || setter) {
|
2208
|
+
if (getter) {
|
2209
|
+
descriptor.get = getter;
|
2210
|
+
}
|
2211
|
+
if (setter) {
|
2212
|
+
descriptor.set = setter;
|
2213
|
+
}
|
2214
|
+
// If it was accessor property we're done and return here
|
2215
|
+
// in order to avoid adding `value` to the descriptor.
|
2216
|
+
return descriptor;
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
|
2220
|
+
// If we got this far we know that object has an own property that is
|
2221
|
+
// not an accessor so we set it as a value and return descriptor.
|
2222
|
+
descriptor.value = object[property];
|
2223
|
+
descriptor.writable = true;
|
2224
|
+
return descriptor;
|
2225
|
+
};
|
2226
|
+
/* eslint-enable no-proto */
|
2227
|
+
}
|
2228
|
+
|
2229
|
+
// ES5 15.2.3.4
|
2230
|
+
// http://es5.github.com/#x15.2.3.4
|
2231
|
+
if (!Object.getOwnPropertyNames) {
|
2232
|
+
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
|
2233
|
+
return Object.keys(object);
|
2234
|
+
};
|
2235
|
+
}
|
2236
|
+
|
2237
|
+
// ES5 15.2.3.5
|
2238
|
+
// http://es5.github.com/#x15.2.3.5
|
2239
|
+
if (!Object.create) {
|
2240
|
+
|
2241
|
+
// Contributed by Brandon Benvie, October, 2012
|
2242
|
+
var createEmpty;
|
2243
|
+
var supportsProto = !({ __proto__: null } instanceof Object);
|
2244
|
+
// the following produces false positives
|
2245
|
+
// in Opera Mini => not a reliable check
|
2246
|
+
// Object.prototype.__proto__ === null
|
2247
|
+
|
2248
|
+
// Check for document.domain and active x support
|
2249
|
+
// No need to use active x approach when document.domain is not set
|
2250
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2251
|
+
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
2252
|
+
/* global ActiveXObject */
|
2253
|
+
var shouldUseActiveX = function shouldUseActiveX() {
|
2254
|
+
// return early if document.domain not set
|
2255
|
+
if (!document.domain) {
|
2256
|
+
return false;
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
try {
|
2260
|
+
return !!new ActiveXObject('htmlfile');
|
2261
|
+
} catch (exception) {
|
2262
|
+
return false;
|
2263
|
+
}
|
2264
|
+
};
|
2265
|
+
|
2266
|
+
// This supports IE8 when document.domain is used
|
2267
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2268
|
+
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
2269
|
+
var getEmptyViaActiveX = function getEmptyViaActiveX() {
|
2270
|
+
var empty;
|
2271
|
+
var xDoc;
|
2272
|
+
|
2273
|
+
xDoc = new ActiveXObject('htmlfile');
|
2274
|
+
|
2275
|
+
xDoc.write('<script><\/script>');
|
2276
|
+
xDoc.close();
|
2277
|
+
|
2278
|
+
empty = xDoc.parentWindow.Object.prototype;
|
2279
|
+
xDoc = null;
|
2280
|
+
|
2281
|
+
return empty;
|
2282
|
+
};
|
2283
|
+
|
2284
|
+
// The original implementation using an iframe
|
2285
|
+
// before the activex approach was added
|
2286
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2287
|
+
var getEmptyViaIFrame = function getEmptyViaIFrame() {
|
2288
|
+
var iframe = document.createElement('iframe');
|
2289
|
+
var parent = document.body || document.documentElement;
|
2290
|
+
var empty;
|
2291
|
+
|
2292
|
+
iframe.style.display = 'none';
|
2293
|
+
parent.appendChild(iframe);
|
2294
|
+
/* eslint-disable no-script-url */
|
2295
|
+
iframe.src = 'javascript:';
|
2296
|
+
/* eslint-enable no-script-url */
|
2297
|
+
|
2298
|
+
empty = iframe.contentWindow.Object.prototype;
|
2299
|
+
parent.removeChild(iframe);
|
2300
|
+
iframe = null;
|
2301
|
+
|
2302
|
+
return empty;
|
2303
|
+
};
|
2304
|
+
|
2305
|
+
/* global document */
|
2306
|
+
if (supportsProto || typeof document === 'undefined') {
|
2307
|
+
createEmpty = function () {
|
2308
|
+
return { __proto__: null };
|
2309
|
+
};
|
2310
|
+
} else {
|
2311
|
+
// In old IE __proto__ can't be used to manually set `null`, nor does
|
2312
|
+
// any other method exist to make an object that inherits from nothing,
|
2313
|
+
// aside from Object.prototype itself. Instead, create a new global
|
2314
|
+
// object and *steal* its Object.prototype and strip it bare. This is
|
2315
|
+
// used as the prototype to create nullary objects.
|
2316
|
+
createEmpty = function () {
|
2317
|
+
// Determine which approach to use
|
2318
|
+
// see https://github.com/es-shims/es5-shim/issues/150
|
2319
|
+
var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
|
2320
|
+
|
2321
|
+
delete empty.constructor;
|
2322
|
+
delete empty.hasOwnProperty;
|
2323
|
+
delete empty.propertyIsEnumerable;
|
2324
|
+
delete empty.isPrototypeOf;
|
2325
|
+
delete empty.toLocaleString;
|
2326
|
+
delete empty.toString;
|
2327
|
+
delete empty.valueOf;
|
2328
|
+
|
2329
|
+
var Empty = function Empty() {};
|
2330
|
+
Empty.prototype = empty;
|
2331
|
+
// short-circuit future calls
|
2332
|
+
createEmpty = function () {
|
2333
|
+
return new Empty();
|
2334
|
+
};
|
2335
|
+
return new Empty();
|
2336
|
+
};
|
2337
|
+
}
|
2338
|
+
|
2339
|
+
Object.create = function create(prototype, properties) {
|
2340
|
+
|
2341
|
+
var object;
|
2342
|
+
var Type = function Type() {}; // An empty constructor.
|
2343
|
+
|
2344
|
+
if (prototype === null) {
|
2345
|
+
object = createEmpty();
|
2346
|
+
} else {
|
2347
|
+
if (typeof prototype !== 'object' && typeof prototype !== 'function') {
|
2348
|
+
// In the native implementation `parent` can be `null`
|
2349
|
+
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
|
2350
|
+
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
|
2351
|
+
// like they are in modern browsers. Using `Object.create` on DOM elements
|
2352
|
+
// is...err...probably inappropriate, but the native version allows for it.
|
2353
|
+
throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
|
2354
|
+
}
|
2355
|
+
Type.prototype = prototype;
|
2356
|
+
object = new Type();
|
2357
|
+
// IE has no built-in implementation of `Object.getPrototypeOf`
|
2358
|
+
// neither `__proto__`, but this manually setting `__proto__` will
|
2359
|
+
// guarantee that `Object.getPrototypeOf` will work as expected with
|
2360
|
+
// objects created using `Object.create`
|
2361
|
+
/* eslint-disable no-proto */
|
2362
|
+
object.__proto__ = prototype;
|
2363
|
+
/* eslint-enable no-proto */
|
2364
|
+
}
|
2365
|
+
|
2366
|
+
if (properties !== void 0) {
|
2367
|
+
Object.defineProperties(object, properties);
|
2368
|
+
}
|
2369
|
+
|
2370
|
+
return object;
|
2371
|
+
};
|
2372
|
+
}
|
2373
|
+
|
2374
|
+
// ES5 15.2.3.6
|
2375
|
+
// http://es5.github.com/#x15.2.3.6
|
2376
|
+
|
2377
|
+
// Patch for WebKit and IE8 standard mode
|
2378
|
+
// Designed by hax <hax.github.com>
|
2379
|
+
// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
|
2380
|
+
// IE8 Reference:
|
2381
|
+
// http://msdn.microsoft.com/en-us/library/dd282900.aspx
|
2382
|
+
// http://msdn.microsoft.com/en-us/library/dd229916.aspx
|
2383
|
+
// WebKit Bugs:
|
2384
|
+
// https://bugs.webkit.org/show_bug.cgi?id=36423
|
2385
|
+
|
2386
|
+
var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
|
2387
|
+
try {
|
2388
|
+
Object.defineProperty(object, 'sentinel', {});
|
2389
|
+
return 'sentinel' in object;
|
2390
|
+
} catch (exception) {
|
2391
|
+
return false;
|
2392
|
+
}
|
2393
|
+
};
|
2394
|
+
|
2395
|
+
// check whether defineProperty works if it's given. Otherwise,
|
2396
|
+
// shim partially.
|
2397
|
+
if (Object.defineProperty) {
|
2398
|
+
var definePropertyWorksOnObject = doesDefinePropertyWork({});
|
2399
|
+
var definePropertyWorksOnDom = typeof document === 'undefined' ||
|
2400
|
+
doesDefinePropertyWork(document.createElement('div'));
|
2401
|
+
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
|
2402
|
+
var definePropertyFallback = Object.defineProperty,
|
2403
|
+
definePropertiesFallback = Object.defineProperties;
|
2404
|
+
}
|
2405
|
+
}
|
2406
|
+
|
2407
|
+
if (!Object.defineProperty || definePropertyFallback) {
|
2408
|
+
var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
|
2409
|
+
var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
|
2410
|
+
var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
|
2411
|
+
|
2412
|
+
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
2413
|
+
if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
|
2414
|
+
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
|
2415
|
+
}
|
2416
|
+
if ((typeof descriptor !== 'object' && typeof descriptor !== 'function') || descriptor === null) {
|
2417
|
+
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
|
2418
|
+
}
|
2419
|
+
// make a valiant attempt to use the real defineProperty
|
2420
|
+
// for I8's DOM elements.
|
2421
|
+
if (definePropertyFallback) {
|
2422
|
+
try {
|
2423
|
+
return definePropertyFallback.call(Object, object, property, descriptor);
|
2424
|
+
} catch (exception) {
|
2425
|
+
// try the shim if the real one doesn't work
|
2426
|
+
}
|
2427
|
+
}
|
2428
|
+
|
2429
|
+
// If it's a data property.
|
2430
|
+
if ('value' in descriptor) {
|
2431
|
+
// fail silently if 'writable', 'enumerable', or 'configurable'
|
2432
|
+
// are requested but not supported
|
2433
|
+
/*
|
2434
|
+
// alternate approach:
|
2435
|
+
if ( // can't implement these features; allow false but not true
|
2436
|
+
('writable' in descriptor && !descriptor.writable) ||
|
2437
|
+
('enumerable' in descriptor && !descriptor.enumerable) ||
|
2438
|
+
('configurable' in descriptor && !descriptor.configurable)
|
2439
|
+
))
|
2440
|
+
throw new RangeError(
|
2441
|
+
'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
|
2442
|
+
);
|
2443
|
+
*/
|
2444
|
+
|
2445
|
+
if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
|
2446
|
+
// As accessors are supported only on engines implementing
|
2447
|
+
// `__proto__` we can safely override `__proto__` while defining
|
2448
|
+
// a property to make sure that we don't hit an inherited
|
2449
|
+
// accessor.
|
2450
|
+
/* eslint-disable no-proto */
|
2451
|
+
var prototype = object.__proto__;
|
2452
|
+
object.__proto__ = prototypeOfObject;
|
2453
|
+
// Deleting a property anyway since getter / setter may be
|
2454
|
+
// defined on object itself.
|
2455
|
+
delete object[property];
|
2456
|
+
object[property] = descriptor.value;
|
2457
|
+
// Setting original `__proto__` back now.
|
2458
|
+
object.__proto__ = prototype;
|
2459
|
+
/* eslint-enable no-proto */
|
2460
|
+
} else {
|
2461
|
+
object[property] = descriptor.value;
|
2462
|
+
}
|
2463
|
+
} else {
|
2464
|
+
if (!supportsAccessors && (('get' in descriptor) || ('set' in descriptor))) {
|
2465
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
2466
|
+
}
|
2467
|
+
// If we got that far then getters and setters can be defined !!
|
2468
|
+
if ('get' in descriptor) {
|
2469
|
+
defineGetter(object, property, descriptor.get);
|
2470
|
+
}
|
2471
|
+
if ('set' in descriptor) {
|
2472
|
+
defineSetter(object, property, descriptor.set);
|
2473
|
+
}
|
2474
|
+
}
|
2475
|
+
return object;
|
2476
|
+
};
|
2477
|
+
}
|
2478
|
+
|
2479
|
+
// ES5 15.2.3.7
|
2480
|
+
// http://es5.github.com/#x15.2.3.7
|
2481
|
+
if (!Object.defineProperties || definePropertiesFallback) {
|
2482
|
+
Object.defineProperties = function defineProperties(object, properties) {
|
2483
|
+
// make a valiant attempt to use the real defineProperties
|
2484
|
+
if (definePropertiesFallback) {
|
2485
|
+
try {
|
2486
|
+
return definePropertiesFallback.call(Object, object, properties);
|
2487
|
+
} catch (exception) {
|
2488
|
+
// try the shim if the real one doesn't work
|
2489
|
+
}
|
2490
|
+
}
|
2491
|
+
|
2492
|
+
Object.keys(properties).forEach(function (property) {
|
2493
|
+
if (property !== '__proto__') {
|
2494
|
+
Object.defineProperty(object, property, properties[property]);
|
2495
|
+
}
|
2496
|
+
});
|
2497
|
+
return object;
|
2498
|
+
};
|
2499
|
+
}
|
2500
|
+
|
2501
|
+
// ES5 15.2.3.8
|
2502
|
+
// http://es5.github.com/#x15.2.3.8
|
2503
|
+
if (!Object.seal) {
|
2504
|
+
Object.seal = function seal(object) {
|
2505
|
+
if (Object(object) !== object) {
|
2506
|
+
throw new TypeError('Object.seal can only be called on Objects.');
|
2507
|
+
}
|
2508
|
+
// this is misleading and breaks feature-detection, but
|
2509
|
+
// allows "securable" code to "gracefully" degrade to working
|
2510
|
+
// but insecure code.
|
2511
|
+
return object;
|
2512
|
+
};
|
2513
|
+
}
|
2514
|
+
|
2515
|
+
// ES5 15.2.3.9
|
2516
|
+
// http://es5.github.com/#x15.2.3.9
|
2517
|
+
if (!Object.freeze) {
|
2518
|
+
Object.freeze = function freeze(object) {
|
2519
|
+
if (Object(object) !== object) {
|
2520
|
+
throw new TypeError('Object.freeze can only be called on Objects.');
|
2521
|
+
}
|
2522
|
+
// this is misleading and breaks feature-detection, but
|
2523
|
+
// allows "securable" code to "gracefully" degrade to working
|
2524
|
+
// but insecure code.
|
2525
|
+
return object;
|
2526
|
+
};
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
// detect a Rhino bug and patch it
|
2530
|
+
try {
|
2531
|
+
Object.freeze(function () {});
|
2532
|
+
} catch (exception) {
|
2533
|
+
Object.freeze = (function (freezeObject) {
|
2534
|
+
return function freeze(object) {
|
2535
|
+
if (typeof object === 'function') {
|
2536
|
+
return object;
|
2537
|
+
} else {
|
2538
|
+
return freezeObject(object);
|
2539
|
+
}
|
2540
|
+
};
|
2541
|
+
}(Object.freeze));
|
2542
|
+
}
|
2543
|
+
|
2544
|
+
// ES5 15.2.3.10
|
2545
|
+
// http://es5.github.com/#x15.2.3.10
|
2546
|
+
if (!Object.preventExtensions) {
|
2547
|
+
Object.preventExtensions = function preventExtensions(object) {
|
2548
|
+
if (Object(object) !== object) {
|
2549
|
+
throw new TypeError('Object.preventExtensions can only be called on Objects.');
|
2550
|
+
}
|
2551
|
+
// this is misleading and breaks feature-detection, but
|
2552
|
+
// allows "securable" code to "gracefully" degrade to working
|
2553
|
+
// but insecure code.
|
2554
|
+
return object;
|
2555
|
+
};
|
2556
|
+
}
|
2557
|
+
|
2558
|
+
// ES5 15.2.3.11
|
2559
|
+
// http://es5.github.com/#x15.2.3.11
|
2560
|
+
if (!Object.isSealed) {
|
2561
|
+
Object.isSealed = function isSealed(object) {
|
2562
|
+
if (Object(object) !== object) {
|
2563
|
+
throw new TypeError('Object.isSealed can only be called on Objects.');
|
2564
|
+
}
|
2565
|
+
return false;
|
2566
|
+
};
|
2567
|
+
}
|
2568
|
+
|
2569
|
+
// ES5 15.2.3.12
|
2570
|
+
// http://es5.github.com/#x15.2.3.12
|
2571
|
+
if (!Object.isFrozen) {
|
2572
|
+
Object.isFrozen = function isFrozen(object) {
|
2573
|
+
if (Object(object) !== object) {
|
2574
|
+
throw new TypeError('Object.isFrozen can only be called on Objects.');
|
2575
|
+
}
|
2576
|
+
return false;
|
2577
|
+
};
|
2578
|
+
}
|
2579
|
+
|
2580
|
+
// ES5 15.2.3.13
|
2581
|
+
// http://es5.github.com/#x15.2.3.13
|
2582
|
+
if (!Object.isExtensible) {
|
2583
|
+
Object.isExtensible = function isExtensible(object) {
|
2584
|
+
// 1. If Type(O) is not Object throw a TypeError exception.
|
2585
|
+
if (Object(object) !== object) {
|
2586
|
+
throw new TypeError('Object.isExtensible can only be called on Objects.');
|
2587
|
+
}
|
2588
|
+
// 2. Return the Boolean value of the [[Extensible]] internal property of O.
|
2589
|
+
var name = '';
|
2590
|
+
while (owns(object, name)) {
|
2591
|
+
name += '?';
|
2592
|
+
}
|
2593
|
+
object[name] = true;
|
2594
|
+
var returnValue = owns(object, name);
|
2595
|
+
delete object[name];
|
2596
|
+
return returnValue;
|
2597
|
+
};
|
2598
|
+
}
|
2599
|
+
|
2600
|
+
}));
|