├── .eslintrc
├── .gitattributes
├── .github
└── workflows
│ ├── node-aught.yml
│ ├── node-pretest.yml
│ ├── node-tens.yml
│ ├── rebase.yml
│ └── require-allow-edits.yml
├── .gitignore
├── .npmrc
├── .nycrc
├── CHANGELOG.md
├── CONTRIBUTORS.md
├── LICENSE
├── README.md
├── bower.json
├── component.json
├── es5-sham.js
├── es5-sham.map
├── es5-sham.min.js
├── es5-shim.js
├── es5-shim.map
├── es5-shim.min.js
├── package.json
├── shims.json
└── tests
├── helpers
└── h-matchers.js
├── index.html
├── index.min.html
├── lib
├── jasmine-html.js
├── jasmine.css
└── jasmine.js
├── native.html
└── spec
├── s-array.js
├── s-date.js
├── s-error.js
├── s-function.js
├── s-global.js
├── s-number.js
├── s-object.js
├── s-regexp.js
└── s-string.js
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 |
4 | "extends": "@ljharb",
5 |
6 | "ignorePatterns": [
7 | "*.min.js",
8 | "tests/lib/*",
9 | ],
10 |
11 | "rules": {
12 | "array-bracket-newline": 0,
13 | "object-curly-newline": 0,
14 | "camelcase": [0],
15 | "complexity": [0],
16 | "eqeqeq": [2, "allow-null"],
17 | "func-name-matching": 0,
18 | "id-length": [2, { "min": 1, "max": 40 }],
19 | "indent": [2, 4],
20 | "max-lines": 0,
21 | "max-lines-per-function": 0,
22 | "max-nested-callbacks": [2, 5],
23 | "max-params": [2, 7],
24 | "max-statements": [1, 30],
25 | "new-cap": [2, { "capIsNewExceptions": ["ToInteger", "ToObject", "ToPrimitive", "ToUint32"] }],
26 | "no-constant-condition": [1],
27 | "no-extend-native": [2, {"exceptions": ["Date", "Error", "RegExp"]}],
28 | "no-extra-parens": [0],
29 | "no-extra-semi": [1],
30 | "no-func-assign": [1],
31 | "no-implicit-coercion": [2, {
32 | "boolean": false,
33 | "number": false,
34 | "string": true,
35 | "disallowTemplateShorthand": false,
36 | "allow": []
37 | }],
38 | "no-invalid-this": [0],
39 | "no-magic-numbers": [0],
40 | "no-native-reassign": [2, {"exceptions": ["Date", "parseInt"]}],
41 | "no-new-func": [1],
42 | "no-plusplus": [1],
43 | "no-restricted-syntax": [2, "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"],
44 | "no-shadow": [1],
45 | "no-unused-vars": [1, { "vars": "all", "args": "after-used" }],
46 | "operator-linebreak": [2, "before"],
47 | "sort-keys": [0],
48 | "spaced-comment": [0],
49 | "strict": [0],
50 |
51 | "multiline-comment-style": 0,
52 | },
53 |
54 | "overrides": [
55 | {
56 | "files": "tests/**",
57 | "rules": {
58 | "max-len": 0,
59 | "max-statements-per-line": [2, { "max": 2 }],
60 | },
61 | "env": {
62 | "jasmine": true
63 | },
64 | },
65 | ],
66 | }
67 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.min.js -diff merge=ours
2 | *.map -diff merge=ours
3 |
--------------------------------------------------------------------------------
/.github/workflows/node-aught.yml:
--------------------------------------------------------------------------------
1 | name: 'Tests: node.js < 10'
2 |
3 | on: [pull_request, push]
4 |
5 | jobs:
6 | tests:
7 | uses: ljharb/actions/.github/workflows/node.yml@main
8 | with:
9 | range: '< 10'
10 | type: minors
11 | command: npm run tests-only
12 |
13 | node:
14 | name: 'node < 10'
15 | needs: [tests]
16 | runs-on: ubuntu-latest
17 | steps:
18 | - run: 'echo tests completed'
19 |
--------------------------------------------------------------------------------
/.github/workflows/node-pretest.yml:
--------------------------------------------------------------------------------
1 | name: 'Tests: pretest/posttest'
2 |
3 | on: [pull_request, push]
4 |
5 | jobs:
6 | tests:
7 | uses: ljharb/actions/.github/workflows/pretest.yml@main
8 |
--------------------------------------------------------------------------------
/.github/workflows/node-tens.yml:
--------------------------------------------------------------------------------
1 | name: 'Tests: node.js >= 10'
2 |
3 | on: [pull_request, push]
4 |
5 | jobs:
6 | tests:
7 | uses: ljharb/actions/.github/workflows/node.yml@main
8 | with:
9 | range: '>= 10'
10 | type: minors
11 | command: npm run tests-only
12 |
13 | node:
14 | name: 'node >= 10'
15 | needs: [tests]
16 | runs-on: ubuntu-latest
17 | steps:
18 | - run: 'echo tests completed'
19 |
--------------------------------------------------------------------------------
/.github/workflows/rebase.yml:
--------------------------------------------------------------------------------
1 | name: Automatic Rebase
2 |
3 | on: [pull_request_target]
4 |
5 | jobs:
6 | _:
7 | uses: ljharb/actions/.github/workflows/rebase.yml@main
8 | secrets:
9 | token: ${{ secrets.GITHUB_TOKEN }}
10 |
--------------------------------------------------------------------------------
/.github/workflows/require-allow-edits.yml:
--------------------------------------------------------------------------------
1 | name: Require “Allow Edits”
2 |
3 | on: [pull_request_target]
4 |
5 | jobs:
6 | _:
7 | name: "Require “Allow Edits”"
8 |
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: ljharb/require-allow-edits@main
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # gitignore
2 | node_modules
3 | .DS_Store
4 |
5 | # Only apps should have lockfiles
6 | npm-shrinkwrap.json
7 | package-lock.json
8 | yarn.lock
9 |
10 | # coverage data
11 | coverage/
12 | .nyc_output/
13 |
14 | .npmignore
15 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/.nycrc:
--------------------------------------------------------------------------------
1 | {
2 | "all": true,
3 | "check-coverage": false,
4 | "reporter": ["text-summary", "text", "html", "json"],
5 | "exclude": [
6 | "coverage",
7 | "test",
8 | "*.map",
9 | "*.min.js"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | 4.6.7
2 | - [Fix] `parseInt`, `String#trim`: properly consider Mongolian Vowel Separator
3 | - [Robustness] `substr`: call-bind original substr method
4 | - [Tests] ensure only the actual shims are included in tests
5 |
6 | 4.6.6
7 | - [Fix] `splice`: IE 8: upgrade ES5 impls to ES6 default argument behavior
8 | - [Fix] `toExponential`: IE 6 native toExponential does not throw with infinite fractionDigits
9 | - [Fix] `Date`: fix a bug in modern Safari (#481)
10 | - [Fix] ensure `parseInt` replacements are not constructible
11 | - [readme] add standalone shims
12 | - [readme] add `Array.prototype.splice` and standalone shim
13 | - [Tests] fix a test failure with a custom matcher in IE 6
14 | - [Tests] pave over Firefox’s increased getMinutes precision
15 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`
16 |
17 | 4.6.5
18 | - [Fix] IE 8 has a broken `Object.defineProperty`
19 | - [patch] replace dead link in comment with archive.org link
20 | - [Docs] update all possible http: links to https:
21 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`
22 |
23 | 4.6.4
24 | - [Fix] `Object.defineProperty`: when shimmed in Chrome <= 36, properly handle writability
25 | - [Tests] add some additional tests
26 |
27 | 4.6.3
28 | - [Fix] `Object.defineProperty`: Chrome <= 36 has a broken dP when setting "prototype" while changing writability
29 | - [Fix] `toExponential`: use `thisNumberValue` instead of `Number()`
30 | - [readme] fix badges
31 | - [readme] add standalone shims
32 | - [actions] reuse common workflows
33 | - [actions] update codecov uploader
34 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`
35 | - [Tests] avoid loading coverage data when running tests
36 |
37 | 4.6.2
38 | - [Fix] IE 6-8 fails to throw on infinite fractional digits
39 |
40 | 4.6.1
41 | - [Fix] `Math.log10` does not exist in older engines, oops
42 | - [Fix] `toExponential`: start from 16 instead of 22
43 | - [Fix] `toExponential`: ensure ToNumber is only called once on the receiver
44 | - [Robustness] `toExponential`, `toPrecision`: ensure things do not break with later builtin modification
45 |
46 | 4.6.0
47 | - [New] detect and patch `Number#toExponential` in Edge 15-18, which rounds incorrectly
48 | - [Fix] `parseInt`: fails to throw on boxed Symbols in Edge 15-18
49 | - [eslint] ensure autofix makes no further changes
50 | - [readme] remove travis badge
51 | - [meta] use `prepublishOnly`, for npm 7+
52 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`
53 | - [tests] use `ljharb/actions/node/install` instead of `ljharb/actions/node/run`; use codecov action
54 | - [actions] update workflows
55 |
56 | 4.5.15
57 | - [Fix] `es5-sham`: `getPrototypeOf`: avoid infinite loop in pre-`__proto__` browsers
58 | - [Fix] `split`: add a function name to the "broken capturing groups" shim
59 | - [Robustness] cache Math methods
60 | - [readme] add standalone shims
61 | - [meta] add `in-publish` to avoid running the minifier on install
62 | - [meta] run `aud` in `posttest`
63 | - [Tests] migrate tests to Github Actions (#474)
64 | - [Tests] run `nyc` on all tests
65 | - [actions] add "Allow Edits" workflow
66 | - [actions] switch Automatic Rebase workflow to `pull_request_target` event
67 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`
68 |
69 | 4.5.14
70 | - [Fix] handle no `deleteCount` to `splice()` in Opera (#465)
71 | - [Refactor] remove unnecessary comparison
72 | - [meta] remove unused Makefile and associated utilities
73 | - [meta] add `funding` field
74 | - [meta] Rename CHANGES to CHANGELOG.md
75 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `replace`, `semver`; add `safe-publish-latest`
76 | - [Tests] fix negative Date tests to handle TZData
77 | - [Tests] use shared travis-ci configs
78 | - [Tests] remove `jscs`
79 | - [Tests] clarify toPrecision's range increased in ES2018
80 | - [actions] add automatic rebasing / merge commit blocking
81 |
82 | 4.5.13
83 | - [Fix] exclude deprecated Firefox keys (#460)
84 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jasmine-node`, `replace`, `semver`
85 |
86 | 4.5.12
87 | - [meta] republish broken 4.5.11
88 |
89 | 4.5.11
90 | - [Fix] sync Object.keys excluded list from object-keys (#456)
91 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jasmine-node`, `replace`, `semver`
92 | - [Tests] pin jasmine-node to ~1.13
93 |
94 | 4.5.10
95 | - [Fix] Safari 11 throws on `.sort({})`, but not on `.sort(null)`
96 | - [Fix] ensure the shimmed parseInt throws with Symbols (#450)
97 | - [Fix] skip over `localStorage`, which can’t be accessed on file://
98 | - [Fix] Accessing window.top.{constructor|prototype} throws error in iOS (#445)
99 | - [Fix] avoid `width` and `height` on `window`, to prevent reflow (https://github.com/ljharb/object-keys/issues/31)
100 | - [Fix] ensure minified literal of `1000000000000000128` stays as that literal (#441)
101 | - [Robustness] always prefer `String(x)` over `x.toString()`
102 | - [Tests] up to `node` `v9.3`, `v8.9`, `v7.10`, `v6.12`, `v5.12`, `v4.8`; improve test matrix; use `nvm install-latest-npm`; comment out OS X builds; pin included builds to LTS
103 | - [Tests] `parseInt`: add another test for NaN parsing (#433)
104 | - [Dev Deps] `uglify-js`: add `--support-ie8` and peg to v2.7.x since it doesn’t follow semver
105 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `semver`; remove `concurrently` (#421)
106 |
107 | 4.5.9
108 | - [Fix] parseInt and parseFloat should both accept null/undefined (#402)
109 | - [Tests] up to `node` `v6.2`
110 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `concurrently`
111 |
112 | 4.5.8
113 | - [Fix] Check if property descriptor is configurable before re-defining it (#394, #373)
114 | - [Dev Deps] update `eslint`, `jscs`, `@ljharb/eslint-config`
115 | - [Tests] up to `node` `v5.10`, `v4.4`
116 | - [Tests] Use `concurrently` instead of `parallelshell`
117 | - [Tests] use `pretest` to run the linter
118 |
119 | 4.5.7
120 | - [Fix] `bind` in IE 8: Update `is-callable` implementation to v1.1.3 (#390)
121 |
122 | 4.5.6
123 | - [Fix] `new Date(new Date())` should work in IE 8 (#389)
124 | - [Tests] on `node` `v5.7`
125 | - [Dev Deps] update `uglify-js`
126 |
127 | 4.5.5
128 | - [Fix] Adobe Photoshop’s JS engine bizarrely can have `+date !== date.getTime()` (#365)
129 | - [Dev Deps] update `eslint`
130 | - [Refactor] Update `is-callable` implementation to match latest
131 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
132 |
133 | 4.5.4
134 | - [Fix] careless error from 5cf99aca49e59bae03b5d542381424bb1b13ec42
135 |
136 | 4.5.3
137 | - [Fix] Saturday is a day in the week (#386)
138 | - [Robustness] improve Function#bind (#381)
139 | - [Tests] on `node` `v5.6`, `v4.3`
140 | - [Tests] use json3 (#382)
141 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`
142 | - [Docs] add note about script order (#379)
143 |
144 | 4.5.2
145 | - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
146 |
147 | 4.5.1
148 | - [Fix] Make sure preexisting + broken `Array#` methods that throw don’t break the runtime (#377)
149 | - [Dev Deps] update `jscs`
150 |
151 | 4.5.0
152 | - [New] `parseFloat('-0')` should return -0 in Opera 12 (#371)
153 | - [New] Provide and replace Date UTC methods (#360)
154 | - [Robustness] cache `Date` getUTC methods so that `Date#toISOString` doesn’t observably look them up on the receiver
155 | - [Robustness] use a cached and shimmed `String#trim`
156 | - [Tests] up to `node` `v5.5`
157 | - [Tests] add `parallelshell` and use it in a few tasks
158 | - [Refactor] rename cached methods to avoid linter warnings
159 | - [Dev Deps] update `eslint`, `jscs`, '@ljharb/eslint-config'
160 | - [Docs] Update license year to 2016 (#374)
161 |
162 | 4.4.2
163 | - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
164 |
165 | 4.4.1
166 | - [Fix] ensure that IE 11 in compatibility mode doesn't throw (#370)
167 | - [Docs] add missing shimmed things
168 |
169 | 4.4.0
170 | - [New] Detect and patch `RegExp#toString` in IE 8, which returns flags in the wrong order (#364)
171 | - [Fix] Patch `Array#sort` on {Chrome, Safari, IE < 9, FF 4} that throws improperly, per ES5 (#354)
172 | - [Fix] In IE 6, `window.external` makes `Object.keys` throw
173 | - [Fix] `Array#slice`: boxed string access on IE <= 8 (#349)
174 | - [Fix] `Array#join`: fix IE 6-8 join called on string literal (#352)
175 | - [Fix] Ensure that `Error#message` and `Error#name` are non-enumerable (#358)
176 | - [Fix: sham] `Object.getOwnPropertyDescriptor`: In Opera 11.6, `propertyIsEnumerable` is a nonshadowable global, like `toString`
177 | - [Robustness] Use a bound form of `Array#slice.call`
178 | - [Tests] Properly check for descriptor support in IE <= 8
179 | - [Tests] on `node` `v5.1`
180 | - [Tests] Add `Array#slice` tests (#346)
181 | - [Dev Deps] update `uglify-js`, `eslint`, `jscs`, `uglify-js`, `semver`
182 | - [Docs] Fix broken UMD links (#344)
183 |
184 | 4.3.2
185 | - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
186 |
187 | 4.3.1
188 | - [Fix] `String#split`: revert part of dcce96ae21185a69d2d40e67416e7496b73e8e47 which broke in older browsers (#342)
189 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
190 | - [Tests] Firefox allows `Number#toPrecision` values of [1,100], which the spec permits
191 |
192 | 4.3.0
193 | - [New] `Array#push`: in IE <= 7, `Array#push` was not generic (#336)
194 | - [New] `Array#push` in Opera `10.6` has a super weird bug when pushing `undefined`
195 | - [New] `Array#join`: In IE <= 7, passing `undefined` didn't use the default separator (#333)
196 | - [New] `Error#toString`: prints out the proper message in IE 7 and below (#334)
197 | - [New] `Number#toPrecision`: IE 7 and below incorrectly throw when an explicit `undefined` precision is passed (#340)
198 | - [Fix] `String#lastIndexOf`: ensure the correct length in IE 8
199 | - [Fix] ensure `parseInt` accepts negative and plus-prefixed hex values (#332)
200 | - [Robustness] Use a bound `Array#push` instead of relying on `Function#call`
201 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
202 | - [Tests] Add some conditionals to avoid impossible-to-fix test failures in IE 6-8, due to it being unable to distinguish between `undefined` and an absent index (#114)
203 | - [Tests] Fix false negatives in IE 6-8 with jasmine comparing arrays to arraylikes (#114)
204 | - [Tests] add additional `Array#shift` tests (#337)
205 | - [Tests] Add additional `Array#splice` tests (#339)
206 | - [Tests] Add `Array#pop` tests, just in case (#338)
207 | - [Tests] include `global` tests in HTML test files
208 | - [Tests] Make sure the HTML tests run with the right charset
209 | - [Tests] ensure `node` `v0.8` tests stay passing.
210 | - [Tests] Prevent nondeterminism in the tests - this sometime produced values that are one ms off
211 | - [Tests] on `node` `v5.0`
212 | - [Tests] fix npm upgrades for older nodes
213 |
214 | 4.2.1
215 | - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
216 |
217 | 4.2.0
218 | - [shim: new] Overwrite `String#lastIndexOf` in IE 9, 10, 11, and Edge, so it has proper unicode support.
219 | - [Dev Deps] update `eslint`, `jscs`
220 |
221 | 4.1.16
222 | - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
223 |
224 | 4.1.15
225 | - [shim: fix] new Date + Date.parse: Fix a Safari 8 & 9 bug where the `ms` arg is treated as a signed instead of unsigned int (#329)
226 | - [shim: fix] add 'frame' to blacklisted keys (#330)
227 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`
228 | - [Tests] on `node` `v4.2`
229 | - [Tests] Date: prevent nondeterminism in the tests - this sometime produced values that are one ms off
230 |
231 | 4.1.14
232 | - [shim: fix] Wrap more things in a try/catch, because IE sucks and sometimes throws on [[Get]] of window.localStorage (#327)
233 | - [Refactor] Use `ES.ToUint32` instead of inline `>>>`
234 | - [Tests] up to `node` `v4.1`
235 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver`, `jscs`
236 |
237 | 4.1.13
238 | - [shim: fix] Fix a bug where `Date(x)` threw instead of equalling `String(Date(x))` (#326)
239 |
240 | 4.1.12
241 | - [fix] Make sure uglify doesn't remove function names
242 | - [shim: fix] Use `is-arguments` implementation; don't call down legacy code path in modern engines (#325)
243 | - [Tests] up to `io.js` `v3.3`
244 | - [Dev Deps] update `eslint`, `@ljharb/eslint-config`
245 |
246 | 4.1.11
247 | - [shim: fix] Object.keys in Safari 9 has some bugs. (Already fixed in Webkit Nightly)
248 | - [shim: fix] Omit !Date.parse check in the if statement (#323)
249 | - [sham: fix] Fix Object.create sham to not set __proto__ (#301)
250 | - [sham: fix] Add a typeof check to Object.getPrototypeOf (#319, #320)
251 | - [Tests] up to `io.js` `v3.1`
252 | - [Tests] Make sure `Object.getPrototypeOf` tests don't fail when engines implement ES6 semantics
253 | - [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG (#318)
254 | - [Dev Deps] Update `eslint`, `uglify-js`, `jscs`; use my personal shared `eslint` config
255 |
256 | 4.1.10
257 | - [Fix] Fix IE 8 issue with `window.frameElement` access in a child iframe (#322)
258 | - [Tests] Consolidating `Date.parse` extended year tests
259 | - [Tests] Account for a `Date.parse` precision variance in Safari 8
260 | - [Tests] DRY up some Date.parse tests
261 | - [Tests] Don't create globals in Date tests
262 | - [Tests] Better failure output when an invalid date's toJSON throws
263 | - [Tests] Also compare lengths of array-likes
264 | - [Tests] Extra check on Object.keys(arguments)
265 | - [Tests] Skip appropriate tests when objects aren't extensible/freezeable/sealable
266 |
267 | 4.1.9
268 | - [Fix] Remove "extended", add "unicode" in `String#split` shim, to match ES6
269 | - [Fix] Object.keys: Preserve the IE 8 dontEnum bugfix, and the automation equality bugfix.
270 | - [Fix] Object.keys: Prevent a deprecation message from showing up in Chrome.
271 | - [Performance] Speed up blacklisted key check for Object.keys automation equality bug.
272 | - [Tests] Test on `io.js` `v2.4`
273 | - [Dev Deps] Update `eslint`, `semver`
274 |
275 | 4.1.8
276 | - [Fix] Fix an `Object.keys` IE 8 bug where `localStorage.prototype.constructor === localStorage` would throw (#275)
277 | - [Fix] Shimmed `Object.defineProperty` should not throw for an empty descriptor (#315)
278 | - [Fix] Fix `Date#toISOString` in Safari 5.1 (#243)
279 | - [Fix] Use `Object#propertyIsEnumerable` to default the initial "enumerable" value in `Object.getOwnPropertyDescriptor` sham (#289)
280 | - [Fix] Fix `Array#splice` with large sparse arrays in Safari 7/8, and Opera 12.15 (#295)
281 | - [Robustness] Safely use and reference many builtins internally (also see #313)
282 | - [Tests] Add `Date#{getUTCDate,getUTCMonth}` tests to expose Opera 10.6/11.61/12 `Date` bugs
283 | - [Dev Deps] Update `eslint`
284 |
285 | 4.1.7
286 | - Make sure `Date.parse` is not enumerable (#310)
287 |
288 | 4.1.6
289 | - Support IE 8 when `document.domain` is set (#306, #150)
290 | - Remove version from `bower.json` (#307)
291 |
292 | 4.1.5
293 | - Add a failing runtime check for Safari 8 `Date.parse`
294 | - Update `eslint`, `semver`
295 | - Test on `io.js` `v2.2`
296 |
297 | 4.1.4
298 | - Make sure copied `Date` properties remain non-enumerable.
299 | - Using a more reliable check for supported property descriptors in non-IE ES3
300 | - Fix 'constructor' in Object.defineProperties sham in ES3 (#252, #305)
301 | - Use a reference to `Array#concat` rather than relying on the runtime environment's `concat`.
302 | - Test on `io.js` `v2.1`
303 | - Clean up `Array.prototype` iteration methods
304 |
305 | 4.1.3
306 | - Update `license` in `package.json` per https://docs.npmjs.com/files/package.json#license
307 | - Update `uglify-js`, `eslint`
308 |
309 | 4.1.2
310 | - In IE 6-8, `Date` inside the function expression does not reference `DateShim` (#303)
311 | - Date: Ensure all code paths have the correct `constructor` property
312 | - Date: Don't copy non-own properties from original `Date`
313 | - Test up to `io.js` `v2.0.0`
314 | - Simplify `isPrimitive` check.
315 | - Adding sanity check tests for ES5 `Number` constants.
316 | - Update `uglify-js`, `eslint`, `semver`
317 |
318 | 4.1.1
319 | - Fix name of `parseInt` replacement.
320 | - Update copyright year
321 | - Update `eslint`, `jscs`
322 | - Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change.
323 | - All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`.
324 | - Run `travis-ci` tests on latest `node` and `iojs`; speed up builds; allow 0.8 failures.
325 | - Ensure some Object tests don't fail in ES6
326 | - Make sure `Date` instances don't have an enumerable `constructor` property, when possible.
327 |
328 | 4.1.0
329 | - Update `eslint`
330 | - Improve type checks: `Array.isArray`, `isRegex`
331 | - Replace `isRegex`/`isString`/`isCallable` checks with inlined versions from npm modules
332 | - Note which ES abstract methods are replaceable via `es-abstract`
333 | - Run `travis-ci` tests on `iojs`!
334 |
335 | 4.0.6
336 | - Update `jscs`, `uglify-js`, add `eslint`
337 | - es5-sham: fix Object.defineProperty to not check for own properties (#211)
338 | - Fix Array#splice bug in Safari 5 (#284)
339 | - Fix `Object.keys` issue with boxed primitives with extra properties in older browsers. (#242, #285)
340 |
341 | 4.0.5
342 | - Update `jscs` so tests pass
343 |
344 | 4.0.4
345 | - Style/indentation/whitespace cleanups.
346 | - README tweaks
347 |
348 | 4.0.3
349 | - Fix keywords (#268)
350 | - add some Date tests
351 | - Note in README that the es5-sham requires the es5-shim (https://github.com/es-shims/es5-shim/issues/256#issuecomment-52875710)
352 |
353 | 4.0.2
354 | - Start including version numbers in minified files (#267)
355 |
356 | 4.0.1
357 | - Fix legacy arguments object detection in Object.keys (#260)
358 |
359 | 4.0.0
360 | - No longer shim the ES5-spec behavior of splice when `deleteCount` is omitted - since no engines implement it, and ES6 changes it. (#255)
361 | - Use Object.defineProperty where available, so that polyfills are non-enumerable when possible (#250)
362 | - lots of internal refactoring
363 | - Fixed a bug referencing String#indexOf and String#lastIndexOf before polyfilling it (#253, #254)
364 |
365 | 3.4.0
366 | - Removed nonstandard SpiderMonkey extension to Array#splice - when `deleteCount` is omitted, it's now treated as 0. (#192, #239)
367 | - Fix Object.keys with Arguments objects in Safari 5.0
368 | - Now shimming String#split in Opera 10.6
369 | - Avoid using "toString" as a variable name, since that breaks Opera
370 | - Internal implementation and test cleanups
371 |
372 | 3.3.2
373 | - Remove an internal "bind" call, which should make the shim a bit faster
374 | - Fix a bug with object boxing in Array#reduceRight that was failing a test in IE 6
375 |
376 | 3.3.1
377 | - Fixing an Array#splice bug in IE 6/7
378 | - cleaning up Array#splice tests
379 |
380 | 3.3.0
381 | - Fix Array#reduceRight in node 0.6 and older browsers (#238)
382 |
383 | 3.2.0
384 | - Fix es5-sham UMD definition to work properly with AMD (#237)
385 | - Ensure that Array methods do not autobox context in strict mode (#233)
386 |
387 | 3.1.1
388 | - Update minified files (#231)
389 |
390 | 3.1.0
391 | - Fix String#replace in Firefox up through 29 (#228)
392 |
393 | 3.0.2
394 | - Fix `Function#bind` in IE 7 and 8 (#224, #225, #226)
395 |
396 | 3.0.1
397 | - Version bump to ensure npm has newest minified assets
398 |
399 | 3.0.0
400 | - es5-sham: fix `Object.getPrototypeOf` and `Object.getOwnPropertyDescriptor` for Opera Mini
401 | - Better override noncompliant native ES5 methods: `Array#forEach`, `Array#map`, `Array#filter`, `Array#every`, `Array#some`, `Array#reduce`, `Date.parse`, `String#trim`
402 | - Added spec-compliant shim for `parseInt`
403 | - Ensure `Object.keys` handles more edge cases with `arguments` objects and boxed primitives
404 | - Improve minification of builds
405 |
406 | 2.3.0
407 | - parseInt is now properly shimmed in ES3 browsers to default the radix
408 | - update URLs to point to the new organization
409 |
410 | 2.2.0
411 | - Function.prototype.bind shim now reports correct length on a bound function
412 | - fix node 0.6.x v8 bug in Array#forEach
413 | - test improvements
414 |
415 | 2.1.0
416 | - Object.create fixes
417 | - tweaks to the Object.defineProperties shim
418 |
419 | 2.0.0
420 | - Separate reliable shims from dubious shims (shams).
421 |
422 | 1.2.10
423 | - Group-effort Style Cleanup
424 | - Took a stab at fixing Object.defineProperty on IE8 without
425 | bad side-effects. (@hax)
426 | - Object.isExtensible no longer fakes it. (@xavierm)
427 | - Date.prototype.toISOString no longer deals with partial
428 | ISO dates, per spec (@kitcambridge)
429 | - More (mostly from @bryanforbes)
430 |
431 | 1.2.9
432 | - Corrections to toISOString by @kitcambridge
433 | - Fixed three bugs in array methods revealed by Jasmine tests.
434 | - Cleaned up Function.prototype.bind with more fixes and tests from
435 | @bryanforbes.
436 |
437 | 1.2.8
438 | - Actually fixed problems with Function.prototype.bind, and regressions
439 | from 1.2.7 (@bryanforbes, @jdalton #36)
440 |
441 | 1.2.7 - REGRESSED
442 | - Fixed problems with Function.prototype.bind when called as a constructor.
443 | (@jdalton #36)
444 |
445 | 1.2.6
446 | - Revised Date.parse to match ES 5.1 (kitcambridge)
447 |
448 | 1.2.5
449 | - Fixed a bug for padding it Date..toISOString (tadfisher issue #33)
450 |
451 | 1.2.4
452 | - Fixed a descriptor bug in Object.defineProperty (raynos)
453 |
454 | 1.2.3
455 | - Cleaned up RequireJS and
179 |
180 |
181 |
182 |
183 |
184 | ```
185 |
186 | [package-url]: https://npmjs.org/package/es5-shim
187 | [npm-version-svg]: https://versionbadg.es/es-shims/es5-shim.svg
188 | [deps-svg]: https://david-dm.org/es-shims/es5-shim.svg
189 | [deps-url]: https://david-dm.org/es-shims/es5-shim
190 | [dev-deps-svg]: https://david-dm.org/es-shims/es5-shim/dev-status.svg
191 | [dev-deps-url]: https://david-dm.org/es-shims/es5-shim#info=devDependencies
192 | [npm-badge-png]: https://nodei.co/npm/es5-shim.png?downloads=true&stars=true
193 | [license-image]: https://img.shields.io/npm/l/es5-shim.svg
194 | [license-url]: LICENSE
195 | [downloads-image]: https://img.shields.io/npm/dm/es5-shim.svg
196 | [downloads-url]: https://npm-stat.com/charts.html?package=es5-shim
197 | [codecov-image]: https://codecov.io/gh/es-shims/es5-shim/branch/main/graphs/badge.svg
198 | [codecov-url]: https://app.codecov.io/gh/es-shims/es5-shim/
199 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/es5-shim
200 | [actions-url]: https://github.com/es-shims/es5-shim/actions
201 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "es5-shim",
3 | "main": "es5-shim.js",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/es-shims/es5-shim"
7 | },
8 | "homepage": "https://github.com/es-shims/es5-shim",
9 | "authors": [
10 | "Kris Kowal (https://github.com/kriskowal/)",
11 | "Sami Samhuri (https://samhuri.net/)",
12 | "Florian Schäfer (https://github.com/fschaefer)",
13 | "Irakli Gozalishvili (https://gozala.io)",
14 | "Kit Cambridge (https://github.com/kitcambridge)",
15 | "Jordan Harband (https://github.com/ljharb/)"
16 | ],
17 | "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
18 | "keywords": [
19 | "shim",
20 | "es5",
21 | "es5 shim",
22 | "javascript",
23 | "ecmascript",
24 | "polyfill"
25 | ],
26 | "license": "MIT",
27 | "ignore": [
28 | "**/.*",
29 | "node_modules",
30 | "bower_components",
31 | "tests"
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/component.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "es5-shim",
3 | "repo": "es-shims/es5-shim",
4 | "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
5 | "version": "v4.5.1",
6 | "keywords": [
7 | "shim",
8 | "es5",
9 | "es5 shim",
10 | "javascript",
11 | "ecmascript",
12 | "polyfill"
13 | ],
14 | "license": "MIT",
15 | "main": "es5-shim.js",
16 | "scripts": [
17 | "es5-shim.js"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/es5-sham.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * https://github.com/es-shims/es5-shim
3 | * @license es5-shim Copyright 2009-2020 by contributors, MIT License
4 | * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
5 | */
6 |
7 | // vim: ts=4 sts=4 sw=4 expandtab
8 |
9 | // Add semicolon to prevent IIFE from being passed as argument to concatenated code.
10 | ; // eslint-disable-line no-extra-semi
11 |
12 | // UMD (Universal Module Definition)
13 | // see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
14 | (function (root, factory) {
15 | 'use strict';
16 |
17 | /* global define */
18 | if (typeof define === 'function' && define.amd) {
19 | // AMD. Register as an anonymous module.
20 | define(factory);
21 | } else if (typeof exports === 'object') {
22 | // Node. Does not work with strict CommonJS, but
23 | // only CommonJS-like enviroments that support module.exports,
24 | // like Node.
25 | module.exports = factory();
26 | } else {
27 | // Browser globals (root is window)
28 | root.returnExports = factory(); // eslint-disable-line no-param-reassign
29 | }
30 | }(this, function () {
31 |
32 | var call = Function.call;
33 | var prototypeOfObject = Object.prototype;
34 | var owns = call.bind(prototypeOfObject.hasOwnProperty);
35 | var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);
36 | var toStr = call.bind(prototypeOfObject.toString);
37 |
38 | // If JS engine supports accessors creating shortcuts.
39 | var defineGetter;
40 | var defineSetter;
41 | var lookupGetter;
42 | var lookupSetter;
43 | var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
44 | if (supportsAccessors) {
45 | /* eslint-disable no-underscore-dangle, no-restricted-properties */
46 | defineGetter = call.bind(prototypeOfObject.__defineGetter__);
47 | defineSetter = call.bind(prototypeOfObject.__defineSetter__);
48 | lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
49 | lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
50 | /* eslint-enable no-underscore-dangle, no-restricted-properties */
51 | }
52 |
53 | var isPrimitive = function isPrimitive(o) {
54 | return o == null || (typeof o !== 'object' && typeof o !== 'function');
55 | };
56 |
57 | // ES5 15.2.3.2
58 | // https://es5.github.io/#x15.2.3.2
59 | if (!Object.getPrototypeOf) {
60 | // https://github.com/es-shims/es5-shim/issues#issue/2
61 | // https://johnresig.com/blog/objectgetprototypeof/
62 | // recommended by fschaefer on github
63 | //
64 | // sure, and webreflection says ^_^
65 | // ... this will nerever possibly return null
66 | // ... Opera Mini breaks here with infinite loops
67 | Object.getPrototypeOf = function getPrototypeOf(object) {
68 | // eslint-disable-next-line no-proto
69 | var proto = object.__proto__;
70 | if (proto || proto == null) { // `undefined` is for pre-proto browsers
71 | return proto;
72 | } else if (toStr(object.constructor) === '[object Function]') {
73 | return object.constructor.prototype;
74 | } else if (object instanceof Object) {
75 | return prototypeOfObject;
76 | }
77 | // Correctly return null for Objects created with `Object.create(null)`
78 | // (shammed or native) or `{ __proto__: null}`. Also returns null for
79 | // cross-realm objects on browsers that lack `__proto__` support (like
80 | // IE <11), but that's the best we can do.
81 | return null;
82 |
83 | };
84 | }
85 |
86 | // ES5 15.2.3.3
87 | // https://es5.github.io/#x15.2.3.3
88 |
89 | // check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
90 | if (Object.defineProperty) {
91 | var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
92 | try {
93 | object.sentinel = 0; // eslint-disable-line no-param-reassign
94 | return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
95 | } catch (exception) {
96 | return false;
97 | }
98 | };
99 | var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
100 | var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined'
101 | || doesGetOwnPropertyDescriptorWork(document.createElement('div'));
102 | if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
103 | var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
104 | }
105 | }
106 |
107 | if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
108 | var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
109 |
110 | /* eslint-disable no-proto */
111 | Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
112 | if (isPrimitive(object)) {
113 | throw new TypeError(ERR_NON_OBJECT + object);
114 | }
115 |
116 | // make a valiant attempt to use the real getOwnPropertyDescriptor
117 | // for I8's DOM elements.
118 | if (getOwnPropertyDescriptorFallback) {
119 | try {
120 | return getOwnPropertyDescriptorFallback.call(Object, object, property);
121 | } catch (exception) {
122 | // try the shim if the real one doesn't work
123 | }
124 | }
125 |
126 | var descriptor;
127 |
128 | // If object does not owns property return undefined immediately.
129 | if (!owns(object, property)) {
130 | return descriptor;
131 | }
132 |
133 | // If object has a property then it's for sure `configurable`, and
134 | // probably `enumerable`. Detect enumerability though.
135 | descriptor = {
136 | enumerable: isEnumerable(object, property),
137 | configurable: true
138 | };
139 |
140 | // If JS engine supports accessor properties then property may be a
141 | // getter or setter.
142 | if (supportsAccessors) {
143 | // Unfortunately `__lookupGetter__` will return a getter even
144 | // if object has own non getter property along with a same named
145 | // inherited getter. To avoid misbehavior we temporary remove
146 | // `__proto__` so that `__lookupGetter__` will return getter only
147 | // if it's owned by an object.
148 | var prototype = object.__proto__;
149 | var notPrototypeOfObject = object !== prototypeOfObject;
150 | // avoid recursion problem, breaking in Opera Mini when
151 | // Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
152 | // or any other Object.prototype accessor
153 | if (notPrototypeOfObject) {
154 | object.__proto__ = prototypeOfObject; // eslint-disable-line no-param-reassign
155 | }
156 |
157 | var getter = lookupGetter(object, property);
158 | var setter = lookupSetter(object, property);
159 |
160 | if (notPrototypeOfObject) {
161 | // Once we have getter and setter we can put values back.
162 | object.__proto__ = prototype; // eslint-disable-line no-param-reassign
163 | }
164 |
165 | if (getter || setter) {
166 | if (getter) {
167 | descriptor.get = getter;
168 | }
169 | if (setter) {
170 | descriptor.set = setter;
171 | }
172 | // If it was accessor property we're done and return here
173 | // in order to avoid adding `value` to the descriptor.
174 | return descriptor;
175 | }
176 | }
177 |
178 | // If we got this far we know that object has an own property that is
179 | // not an accessor so we set it as a value and return descriptor.
180 | descriptor.value = object[property];
181 | descriptor.writable = true;
182 | return descriptor;
183 | };
184 | /* eslint-enable no-proto */
185 | }
186 |
187 | // ES5 15.2.3.4
188 | // https://es5.github.io/#x15.2.3.4
189 | if (!Object.getOwnPropertyNames) {
190 | Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
191 | return Object.keys(object);
192 | };
193 | }
194 |
195 | // ES5 15.2.3.5
196 | // https://es5.github.io/#x15.2.3.5
197 | if (!Object.create) {
198 |
199 | // Contributed by Brandon Benvie, October, 2012
200 | var createEmpty;
201 | var supportsProto = !({ __proto__: null } instanceof Object);
202 | // the following produces false positives
203 | // in Opera Mini => not a reliable check
204 | // Object.prototype.__proto__ === null
205 |
206 | // Check for document.domain and active x support
207 | // No need to use active x approach when document.domain is not set
208 | // see https://github.com/es-shims/es5-shim/issues/150
209 | // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
210 | /* global ActiveXObject */
211 | var shouldUseActiveX = function shouldUseActiveX() {
212 | // return early if document.domain not set
213 | if (!document.domain) {
214 | return false;
215 | }
216 |
217 | try {
218 | return !!new ActiveXObject('htmlfile');
219 | } catch (exception) {
220 | return false;
221 | }
222 | };
223 |
224 | // This supports IE8 when document.domain is used
225 | // see https://github.com/es-shims/es5-shim/issues/150
226 | // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
227 | var getEmptyViaActiveX = function getEmptyViaActiveX() {
228 | var empty;
229 | var xDoc;
230 |
231 | xDoc = new ActiveXObject('htmlfile');
232 |
233 | var script = 'script';
234 | xDoc.write('<' + script + '>' + script + '>');
235 | xDoc.close();
236 |
237 | empty = xDoc.parentWindow.Object.prototype;
238 | xDoc = null;
239 |
240 | return empty;
241 | };
242 |
243 | // The original implementation using an iframe
244 | // before the activex approach was added
245 | // see https://github.com/es-shims/es5-shim/issues/150
246 | var getEmptyViaIFrame = function getEmptyViaIFrame() {
247 | var iframe = document.createElement('iframe');
248 | var parent = document.body || document.documentElement;
249 | var empty;
250 |
251 | iframe.style.display = 'none';
252 | parent.appendChild(iframe);
253 | // eslint-disable-next-line no-script-url
254 | iframe.src = 'javascript:';
255 |
256 | empty = iframe.contentWindow.Object.prototype;
257 | parent.removeChild(iframe);
258 | iframe = null;
259 |
260 | return empty;
261 | };
262 |
263 | /* global document */
264 | if (supportsProto || typeof document === 'undefined') {
265 | createEmpty = function () {
266 | return { __proto__: null };
267 | };
268 | } else {
269 | // In old IE __proto__ can't be used to manually set `null`, nor does
270 | // any other method exist to make an object that inherits from nothing,
271 | // aside from Object.prototype itself. Instead, create a new global
272 | // object and *steal* its Object.prototype and strip it bare. This is
273 | // used as the prototype to create nullary objects.
274 | createEmpty = function () {
275 | // Determine which approach to use
276 | // see https://github.com/es-shims/es5-shim/issues/150
277 | var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
278 |
279 | delete empty.constructor;
280 | delete empty.hasOwnProperty;
281 | delete empty.propertyIsEnumerable;
282 | delete empty.isPrototypeOf;
283 | delete empty.toLocaleString;
284 | delete empty.toString;
285 | delete empty.valueOf;
286 |
287 | var Empty = function Empty() {};
288 | Empty.prototype = empty;
289 | // short-circuit future calls
290 | createEmpty = function () {
291 | return new Empty();
292 | };
293 | return new Empty();
294 | };
295 | }
296 |
297 | Object.create = function create(prototype, properties) {
298 |
299 | var object;
300 | var Type = function Type() {}; // An empty constructor.
301 |
302 | if (prototype === null) {
303 | object = createEmpty();
304 | } else if (isPrimitive(prototype)) {
305 | // In the native implementation `parent` can be `null`
306 | // OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
307 | // Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
308 | // like they are in modern browsers. Using `Object.create` on DOM elements
309 | // is...err...probably inappropriate, but the native version allows for it.
310 | throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
311 | } else {
312 | Type.prototype = prototype;
313 | object = new Type();
314 | // IE has no built-in implementation of `Object.getPrototypeOf`
315 | // neither `__proto__`, but this manually setting `__proto__` will
316 | // guarantee that `Object.getPrototypeOf` will work as expected with
317 | // objects created using `Object.create`
318 | // eslint-disable-next-line no-proto
319 | object.__proto__ = prototype;
320 | }
321 |
322 | if (properties !== void 0) {
323 | Object.defineProperties(object, properties);
324 | }
325 |
326 | return object;
327 | };
328 | }
329 |
330 | // ES5 15.2.3.6
331 | // https://es5.github.io/#x15.2.3.6
332 |
333 | // Patch for WebKit and IE8 standard mode
334 | // Designed by hax
335 | // related issue: https://github.com/es-shims/es5-shim/issues#issue/5
336 | // IE8 Reference:
337 | // https://msdn.microsoft.com/en-us/library/dd282900.aspx
338 | // https://msdn.microsoft.com/en-us/library/dd229916.aspx
339 | // WebKit Bugs:
340 | // https://bugs.webkit.org/show_bug.cgi?id=36423
341 |
342 | var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
343 | try {
344 | Object.defineProperty(object, 'sentinel', {});
345 | return 'sentinel' in object;
346 | } catch (exception) {
347 | return false;
348 | }
349 | };
350 |
351 | // check whether defineProperty works if it's given. Otherwise,
352 | // shim partially.
353 | if (Object.defineProperty) {
354 | var definePropertyWorksOnObject = doesDefinePropertyWork({});
355 | var definePropertyWorksOnDom = typeof document === 'undefined'
356 | || doesDefinePropertyWork(document.createElement('div'));
357 | if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
358 | var definePropertyFallback = Object.defineProperty,
359 | definePropertiesFallback = Object.defineProperties;
360 | }
361 | }
362 |
363 | if (!Object.defineProperty || definePropertyFallback) {
364 | var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
365 | var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
366 | var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
367 |
368 | Object.defineProperty = function defineProperty(object, property, descriptor) {
369 | if (isPrimitive(object)) {
370 | throw new TypeError(ERR_NON_OBJECT_TARGET + object);
371 | }
372 | if (isPrimitive(descriptor)) {
373 | throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
374 | }
375 | // make a valiant attempt to use the real defineProperty
376 | // for I8's DOM elements.
377 | if (definePropertyFallback) {
378 | try {
379 | return definePropertyFallback.call(Object, object, property, descriptor);
380 | } catch (exception) {
381 | // try the shim if the real one doesn't work
382 | }
383 | }
384 |
385 | // If it's a data property.
386 | if ('value' in descriptor) {
387 | // fail silently if 'writable', 'enumerable', or 'configurable'
388 | // are requested but not supported
389 | /*
390 | // alternate approach:
391 | if ( // can't implement these features; allow false but not true
392 | ('writable' in descriptor && !descriptor.writable) ||
393 | ('enumerable' in descriptor && !descriptor.enumerable) ||
394 | ('configurable' in descriptor && !descriptor.configurable)
395 | ))
396 | throw new RangeError(
397 | 'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
398 | );
399 | */
400 |
401 | if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
402 | // As accessors are supported only on engines implementing
403 | // `__proto__` we can safely override `__proto__` while defining
404 | // a property to make sure that we don't hit an inherited
405 | // accessor.
406 | /* eslint-disable no-proto, no-param-reassign */
407 | var prototype = object.__proto__;
408 | object.__proto__ = prototypeOfObject;
409 | // Deleting a property anyway since getter / setter may be
410 | // defined on object itself.
411 | delete object[property];
412 | object[property] = descriptor.value;
413 | // Setting original `__proto__` back now.
414 | object.__proto__ = prototype;
415 | /* eslint-enable no-proto, no-param-reassign */
416 | } else {
417 | object[property] = descriptor.value; // eslint-disable-line no-param-reassign
418 | }
419 | } else {
420 | var hasGetter = 'get' in descriptor;
421 | var hasSetter = 'set' in descriptor;
422 | if (!supportsAccessors && (hasGetter || hasSetter)) {
423 | throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
424 | }
425 | // If we got that far then getters and setters can be defined !!
426 | if (hasGetter) {
427 | defineGetter(object, property, descriptor.get);
428 | }
429 | if (hasSetter) {
430 | defineSetter(object, property, descriptor.set);
431 | }
432 | }
433 | return object;
434 | };
435 | }
436 |
437 | // ES5 15.2.3.7
438 | // https://es5.github.io/#x15.2.3.7
439 | if (!Object.defineProperties || definePropertiesFallback) {
440 | Object.defineProperties = function defineProperties(object, properties) {
441 | // make a valiant attempt to use the real defineProperties
442 | if (definePropertiesFallback) {
443 | try {
444 | return definePropertiesFallback.call(Object, object, properties);
445 | } catch (exception) {
446 | // try the shim if the real one doesn't work
447 | }
448 | }
449 |
450 | Object.keys(properties).forEach(function (property) {
451 | if (property !== '__proto__') {
452 | Object.defineProperty(object, property, properties[property]);
453 | }
454 | });
455 | return object;
456 | };
457 | }
458 |
459 | // ES5 15.2.3.8
460 | // https://es5.github.io/#x15.2.3.8
461 | if (!Object.seal) {
462 | Object.seal = function seal(object) {
463 | if (Object(object) !== object) {
464 | throw new TypeError('Object.seal can only be called on Objects.');
465 | }
466 | // this is misleading and breaks feature-detection, but
467 | // allows "securable" code to "gracefully" degrade to working
468 | // but insecure code.
469 | return object;
470 | };
471 | }
472 |
473 | // ES5 15.2.3.9
474 | // https://es5.github.io/#x15.2.3.9
475 | if (!Object.freeze) {
476 | Object.freeze = function freeze(object) {
477 | if (Object(object) !== object) {
478 | throw new TypeError('Object.freeze can only be called on Objects.');
479 | }
480 | // this is misleading and breaks feature-detection, but
481 | // allows "securable" code to "gracefully" degrade to working
482 | // but insecure code.
483 | return object;
484 | };
485 | }
486 |
487 | // detect a Rhino bug and patch it
488 | try {
489 | Object.freeze(function () {});
490 | } catch (exception) {
491 | Object.freeze = (function (freezeObject) {
492 | return function freeze(object) {
493 | if (typeof object === 'function') {
494 | return object;
495 | }
496 | return freezeObject(object);
497 |
498 | };
499 | }(Object.freeze));
500 | }
501 |
502 | // ES5 15.2.3.10
503 | // https://es5.github.io/#x15.2.3.10
504 | if (!Object.preventExtensions) {
505 | Object.preventExtensions = function preventExtensions(object) {
506 | if (Object(object) !== object) {
507 | throw new TypeError('Object.preventExtensions can only be called on Objects.');
508 | }
509 | // this is misleading and breaks feature-detection, but
510 | // allows "securable" code to "gracefully" degrade to working
511 | // but insecure code.
512 | return object;
513 | };
514 | }
515 |
516 | // ES5 15.2.3.11
517 | // https://es5.github.io/#x15.2.3.11
518 | if (!Object.isSealed) {
519 | Object.isSealed = function isSealed(object) {
520 | if (Object(object) !== object) {
521 | throw new TypeError('Object.isSealed can only be called on Objects.');
522 | }
523 | return false;
524 | };
525 | }
526 |
527 | // ES5 15.2.3.12
528 | // https://es5.github.io/#x15.2.3.12
529 | if (!Object.isFrozen) {
530 | Object.isFrozen = function isFrozen(object) {
531 | if (Object(object) !== object) {
532 | throw new TypeError('Object.isFrozen can only be called on Objects.');
533 | }
534 | return false;
535 | };
536 | }
537 |
538 | // ES5 15.2.3.13
539 | // https://es5.github.io/#x15.2.3.13
540 | if (!Object.isExtensible) {
541 | Object.isExtensible = function isExtensible(object) {
542 | // 1. If Type(O) is not Object throw a TypeError exception.
543 | if (Object(object) !== object) {
544 | throw new TypeError('Object.isExtensible can only be called on Objects.');
545 | }
546 | // 2. Return the Boolean value of the [[Extensible]] internal property of O.
547 | var name = '';
548 | while (owns(object, name)) {
549 | name += '?';
550 | }
551 | object[name] = true; // eslint-disable-line no-param-reassign
552 | var returnValue = owns(object, name);
553 | delete object[name]; // eslint-disable-line no-param-reassign
554 | return returnValue;
555 | };
556 | }
557 |
558 | }));
559 |
--------------------------------------------------------------------------------
/es5-sham.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["es5-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","call","Function","prototypeOfObject","Object","prototype","owns","bind","hasOwnProperty","isEnumerable","propertyIsEnumerable","toStr","toString","defineGetter","defineSetter","lookupGetter","lookupSetter","supportsAccessors","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","isPrimitive","o","getPrototypeOf","object","proto","__proto__","constructor","defineProperty","doesGetOwnPropertyDescriptorWork","sentinel","getOwnPropertyDescriptor","value","exception","getOwnPropertyDescriptorWorksOnObject","getOwnPropertyDescriptorWorksOnDom","document","createElement","getOwnPropertyDescriptorFallback","ERR_NON_OBJECT","property","TypeError","descriptor","enumerable","configurable","notPrototypeOfObject","getter","setter","get","set","writable","getOwnPropertyNames","keys","create","createEmpty","supportsProto","shouldUseActiveX","domain","ActiveXObject","getEmptyViaActiveX","empty","xDoc","script","write","close","parentWindow","getEmptyViaIFrame","iframe","parent","body","documentElement","style","display","appendChild","src","contentWindow","removeChild","isPrototypeOf","toLocaleString","valueOf","Empty","properties","Type","defineProperties","doesDefinePropertyWork","definePropertyWorksOnObject","definePropertyWorksOnDom","definePropertyFallback","definePropertiesFallback","ERR_NON_OBJECT_DESCRIPTOR","ERR_NON_OBJECT_TARGET","ERR_ACCESSORS_NOT_SUPPORTED","hasGetter","hasSetter","forEach","seal","freeze","freezeObject","preventExtensions","isSealed","isFrozen","isExtensible","name","returnValue"],"mappings":";;;;;CAaC,SAAUA,EAAMC,GACb,YAGA,UAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE5CD,OAAOD,OACJ,UAAWG,WAAY,SAAU,CAIpCC,OAAOD,QAAUH,QACd,CAEHD,EAAKM,cAAgBL,OAE3BM,KAAM,WAEJ,GAAIC,GAAOC,SAASD,IACpB,IAAIE,GAAoBC,OAAOC,SAC/B,IAAIC,GAAOL,EAAKM,KAAKJ,EAAkBK,eACvC,IAAIC,GAAeR,EAAKM,KAAKJ,EAAkBO,qBAC/C,IAAIC,GAAQV,EAAKM,KAAKJ,EAAkBS,SAGxC,IAAIC,EACJ,IAAIC,EACJ,IAAIC,EACJ,IAAIC,EACJ,IAAIC,GAAoBX,EAAKH,EAAmB,mBAChD,IAAIc,EAAmB,CAEnBJ,EAAeZ,EAAKM,KAAKJ,EAAkBe,iBAC3CJ,GAAeb,EAAKM,KAAKJ,EAAkBgB,iBAC3CJ,GAAed,EAAKM,KAAKJ,EAAkBiB,iBAC3CJ,GAAef,EAAKM,KAAKJ,EAAkBkB,kBAI/C,GAAIC,GAAc,QAASA,aAAYC,GACnC,MAAOA,IAAK,YAAgBA,KAAM,gBAAmBA,KAAM,WAK/D,KAAKnB,OAAOoB,eAAgB,CAQxBpB,OAAOoB,eAAiB,QAASA,gBAAeC,GAE5C,GAAIC,GAAQD,EAAOE,SACnB,IAAID,GAASA,GAAS,KAAM,CACxB,MAAOA,OACJ,IAAIf,EAAMc,EAAOG,eAAiB,oBAAqB,CAC1D,MAAOH,GAAOG,YAAYvB,cACvB,IAAIoB,YAAkBrB,QAAQ,CACjC,MAAOD,GAMX,MAAO,OASf,GAAIC,OAAOyB,eAAgB,CACvB,GAAIC,GAAmC,QAASA,kCAAiCL,GAC7E,IACIA,EAAOM,SAAW,CAClB,OAAO3B,QAAO4B,yBAAyBP,EAAQ,YAAYQ,QAAU,EACvE,MAAOC,GACL,MAAO,QAGf,IAAIC,GAAwCL,KAC5C,IAAIM,SAA4CC,YAAa,aACtDP,EAAiCO,SAASC,cAAc,OAC/D,KAAKF,IAAuCD,EAAuC,CAC/E,GAAII,GAAmCnC,OAAO4B,0BAItD,IAAK5B,OAAO4B,0BAA4BO,EAAkC,CACtE,GAAIC,GAAiB,0DAGrBpC,QAAO4B,yBAA2B,QAASA,0BAAyBP,EAAQgB,GACxE,GAAInB,EAAYG,GAAS,CACrB,KAAM,IAAIiB,WAAUF,EAAiBf,GAKzC,GAAIc,EAAkC,CAClC,IACI,MAAOA,GAAiCtC,KAAKG,OAAQqB,EAAQgB,GAC/D,MAAOP,KAKb,GAAIS,EAGJ,KAAKrC,EAAKmB,EAAQgB,GAAW,CACzB,MAAOE,GAKXA,GACIC,WAAYnC,EAAagB,EAAQgB,GACjCI,aAAc,KAKlB,IAAI5B,EAAmB,CAMnB,GAAIZ,GAAYoB,EAAOE,SACvB,IAAImB,GAAuBrB,IAAWtB,CAItC,IAAI2C,EAAsB,CACtBrB,EAAOE,UAAYxB,EAGvB,GAAI4C,GAAShC,EAAaU,EAAQgB,EAClC,IAAIO,GAAShC,EAAaS,EAAQgB,EAElC,IAAIK,EAAsB,CAEtBrB,EAAOE,UAAYtB,EAGvB,GAAI0C,GAAUC,EAAQ,CAClB,GAAID,EAAQ,CACRJ,EAAWM,IAAMF,EAErB,GAAIC,EAAQ,CACRL,EAAWO,IAAMF,EAIrB,MAAOL,IAMfA,EAAWV,MAAQR,EAAOgB,EAC1BE,GAAWQ,SAAW,IACtB,OAAOR,IAOf,IAAKvC,OAAOgD,oBAAqB,CAC7BhD,OAAOgD,oBAAsB,QAASA,qBAAoB3B,GACtD,MAAOrB,QAAOiD,KAAK5B,IAM3B,IAAKrB,OAAOkD,OAAQ,CAGhB,GAAIC,EACJ,IAAIC,MAAoB7B,UAAW,eAAkBvB,QAUrD,IAAIqD,GAAmB,QAASA,oBAE5B,IAAKpB,SAASqB,OAAQ,CAClB,MAAO,OAGX,IACI,QAAS,GAAIC,eAAc,YAC7B,MAAOzB,GACL,MAAO,QAOf,IAAI0B,GAAqB,QAASA,sBAC9B,GAAIC,EACJ,IAAIC,EAEJA,GAAO,GAAIH,eAAc,WAEzB,IAAII,GAAS,QACbD,GAAKE,MAAM,IAAMD,EAAS,MAAQA,EAAS,IAC3CD,GAAKG,OAELJ,GAAQC,EAAKI,aAAa9D,OAAOC,SACjCyD,GAAO,IAEP,OAAOD,GAMX,IAAIM,GAAoB,QAASA,qBAC7B,GAAIC,GAAS/B,SAASC,cAAc,SACpC,IAAI+B,GAAShC,SAASiC,MAAQjC,SAASkC,eACvC,IAAIV,EAEJO,GAAOI,MAAMC,QAAU,MACvBJ,GAAOK,YAAYN,EAEnBA,GAAOO,IAAM,aAEbd,GAAQO,EAAOQ,cAAcxE,OAAOC,SACpCgE,GAAOQ,YAAYT,EACnBA,GAAS,IAET,OAAOP,GAIX,IAAIL,SAAwBnB,YAAa,YAAa,CAClDkB,EAAc,WACV,OAAS5B,UAAW,WAErB,CAMH4B,EAAc,WAGV,GAAIM,GAAQJ,IAAqBG,IAAuBO,UAEjDN,GAAMjC,kBACNiC,GAAMrD,qBACNqD,GAAMnD,2BACNmD,GAAMiB,oBACNjB,GAAMkB,qBACNlB,GAAMjD,eACNiD,GAAMmB,OAEb,IAAIC,GAAQ,QAASA,UACrBA,GAAM5E,UAAYwD,CAElBN,GAAc,WACV,MAAO,IAAI0B,GAEf,OAAO,IAAIA,IAInB7E,OAAOkD,OAAS,QAASA,QAAOjD,EAAW6E,GAEvC,GAAIzD,EACJ,IAAI0D,GAAO,QAASA,SAEpB,IAAI9E,IAAc,KAAM,CACpBoB,EAAS8B,QACN,IAAIjC,EAAYjB,GAAY,CAM/B,KAAM,IAAIqC,WAAU,sDACjB,CACHyC,EAAK9E,UAAYA,CACjBoB,GAAS,GAAI0D,EAMb1D,GAAOE,UAAYtB,EAGvB,GAAI6E,QAAoB,GAAG,CACvB9E,OAAOgF,iBAAiB3D,EAAQyD,GAGpC,MAAOzD,IAgBf,GAAI4D,GAAyB,QAASA,wBAAuB5D,GACzD,IACIrB,OAAOyB,eAAeJ,EAAQ,cAC9B,OAAO,YAAcA,GACvB,MAAOS,GACL,MAAO,QAMf,IAAI9B,OAAOyB,eAAgB,CACvB,GAAIyD,GAA8BD,KAClC,IAAIE,SAAkClD,YAAa,aAC5CgD,EAAuBhD,SAASC,cAAc,OACrD,KAAKgD,IAAgCC,EAA0B,CAC3D,GAAIC,GAAyBpF,OAAOyB,eAChC4D,EAA2BrF,OAAOgF,kBAI9C,IAAKhF,OAAOyB,gBAAkB2D,EAAwB,CAClD,GAAIE,GAA4B,0CAChC,IAAIC,GAAwB,8CAC5B,IAAIC,GAA8B,gEAElCxF,QAAOyB,eAAiB,QAASA,gBAAeJ,EAAQgB,EAAUE,GAC9D,GAAIrB,EAAYG,GAAS,CACrB,KAAM,IAAIiB,WAAUiD,EAAwBlE,GAEhD,GAAIH,EAAYqB,GAAa,CACzB,KAAM,IAAID,WAAUgD,EAA4B/C,GAIpD,GAAI6C,EAAwB,CACxB,IACI,MAAOA,GAAuBvF,KAAKG,OAAQqB,EAAQgB,EAAUE,GAC/D,MAAOT,KAMb,GAAI,SAAWS,GAAY,CAevB,GAAI1B,IAAsBF,EAAaU,EAAQgB,IAAazB,EAAaS,EAAQgB,IAAY,CAMzF,GAAIpC,GAAYoB,EAAOE,SACvBF,GAAOE,UAAYxB,QAGZsB,GAAOgB,EACdhB,GAAOgB,GAAYE,EAAWV,KAE9BR,GAAOE,UAAYtB,MAEhB,CACHoB,EAAOgB,GAAYE,EAAWV,WAE/B,CACH,GAAI4D,GAAY,OAASlD,EACzB,IAAImD,GAAY,OAASnD,EACzB,KAAK1B,IAAsB4E,GAAaC,GAAY,CAChD,KAAM,IAAIpD,WAAUkD,GAGxB,GAAIC,EAAW,CACXhF,EAAaY,EAAQgB,EAAUE,EAAWM,KAE9C,GAAI6C,EAAW,CACXhF,EAAaW,EAAQgB,EAAUE,EAAWO,MAGlD,MAAOzB,IAMf,IAAKrB,OAAOgF,kBAAoBK,EAA0B,CACtDrF,OAAOgF,iBAAmB,QAASA,kBAAiB3D,EAAQyD,GAExD,GAAIO,EAA0B,CAC1B,IACI,MAAOA,GAAyBxF,KAAKG,OAAQqB,EAAQyD,GACvD,MAAOhD,KAKb9B,OAAOiD,KAAK6B,GAAYa,QAAQ,SAAUtD,GACtC,GAAIA,IAAa,YAAa,CAC1BrC,OAAOyB,eAAeJ,EAAQgB,EAAUyC,EAAWzC,MAG3D,OAAOhB,IAMf,IAAKrB,OAAO4F,KAAM,CACd5F,OAAO4F,KAAO,QAASA,MAAKvE,GACxB,GAAIrB,OAAOqB,KAAYA,EAAQ,CAC3B,KAAM,IAAIiB,WAAU,8CAKxB,MAAOjB,IAMf,IAAKrB,OAAO6F,OAAQ,CAChB7F,OAAO6F,OAAS,QAASA,QAAOxE,GAC5B,GAAIrB,OAAOqB,KAAYA,EAAQ,CAC3B,KAAM,IAAIiB,WAAU,gDAKxB,MAAOjB,IAKf,IACIrB,OAAO6F,OAAO,cAChB,MAAO/D,GACL9B,OAAO6F,OAAU,SAAUC,GACvB,MAAO,SAASD,QAAOxE,GACnB,SAAWA,KAAW,WAAY,CAC9B,MAAOA,GAEX,MAAOyE,GAAazE,KAG1BrB,OAAO6F,QAKb,IAAK7F,OAAO+F,kBAAmB,CAC3B/F,OAAO+F,kBAAoB,QAASA,mBAAkB1E,GAClD,GAAIrB,OAAOqB,KAAYA,EAAQ,CAC3B,KAAM,IAAIiB,WAAU,2DAKxB,MAAOjB,IAMf,IAAKrB,OAAOgG,SAAU,CAClBhG,OAAOgG,SAAW,QAASA,UAAS3E,GAChC,GAAIrB,OAAOqB,KAAYA,EAAQ,CAC3B,KAAM,IAAIiB,WAAU,kDAExB,MAAO,QAMf,IAAKtC,OAAOiG,SAAU,CAClBjG,OAAOiG,SAAW,QAASA,UAAS5E,GAChC,GAAIrB,OAAOqB,KAAYA,EAAQ,CAC3B,KAAM,IAAIiB,WAAU,kDAExB,MAAO,QAMf,IAAKtC,OAAOkG,aAAc,CACtBlG,OAAOkG,aAAe,QAASA,cAAa7E,GAExC,GAAIrB,OAAOqB,KAAYA,EAAQ,CAC3B,KAAM,IAAIiB,WAAU,sDAGxB,GAAI6D,GAAO,EACX,OAAOjG,EAAKmB,EAAQ8E,GAAO,CACvBA,GAAQ,IAEZ9E,EAAO8E,GAAQ,IACf,IAAIC,GAAclG,EAAKmB,EAAQ8E,SACxB9E,GAAO8E,EACd,OAAOC"}
--------------------------------------------------------------------------------
/es5-sham.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * https://github.com/es-shims/es5-shim
3 | * @license es5-shim Copyright 2009-2020 by contributors, MIT License
4 | * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
5 | */
6 | (function(e,t){"use strict";if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){var e=Function.call;var t=Object.prototype;var r=e.bind(t.hasOwnProperty);var n=e.bind(t.propertyIsEnumerable);var o=e.bind(t.toString);var i;var c;var f;var a;var l=r(t,"__defineGetter__");if(l){i=e.bind(t.__defineGetter__);c=e.bind(t.__defineSetter__);f=e.bind(t.__lookupGetter__);a=e.bind(t.__lookupSetter__)}var u=function isPrimitive(e){return e==null||typeof e!=="object"&&typeof e!=="function"};if(!Object.getPrototypeOf){Object.getPrototypeOf=function getPrototypeOf(e){var r=e.__proto__;if(r||r==null){return r}else if(o(e.constructor)==="[object Function]"){return e.constructor.prototype}else if(e instanceof Object){return t}return null}}if(Object.defineProperty){var p=function doesGetOwnPropertyDescriptorWork(e){try{e.sentinel=0;return Object.getOwnPropertyDescriptor(e,"sentinel").value===0}catch(t){return false}};var s=p({});var b=typeof document==="undefined"||p(document.createElement("div"));if(!b||!s){var O=Object.getOwnPropertyDescriptor}}if(!Object.getOwnPropertyDescriptor||O){var d="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function getOwnPropertyDescriptor(e,o){if(u(e)){throw new TypeError(d+e)}if(O){try{return O.call(Object,e,o)}catch(i){}}var c;if(!r(e,o)){return c}c={enumerable:n(e,o),configurable:true};if(l){var p=e.__proto__;var s=e!==t;if(s){e.__proto__=t}var b=f(e,o);var y=a(e,o);if(s){e.__proto__=p}if(b||y){if(b){c.get=b}if(y){c.set=y}return c}}c.value=e[o];c.writable=true;return c}}if(!Object.getOwnPropertyNames){Object.getOwnPropertyNames=function getOwnPropertyNames(e){return Object.keys(e)}}if(!Object.create){var y;var j=!({__proto__:null}instanceof Object);var v=function shouldUseActiveX(){if(!document.domain){return false}try{return!!new ActiveXObject("htmlfile")}catch(e){return false}};var _=function getEmptyViaActiveX(){var e;var t;t=new ActiveXObject("htmlfile");var r="script";t.write("<"+r+">"+r+">");t.close();e=t.parentWindow.Object.prototype;t=null;return e};var w=function getEmptyViaIFrame(){var e=document.createElement("iframe");var t=document.body||document.documentElement;var r;e.style.display="none";t.appendChild(e);e.src="javascript:";r=e.contentWindow.Object.prototype;t.removeChild(e);e=null;return r};if(j||typeof document==="undefined"){y=function(){return{__proto__:null}}}else{y=function(){var e=v()?_():w();delete e.constructor;delete e.hasOwnProperty;delete e.propertyIsEnumerable;delete e.isPrototypeOf;delete e.toLocaleString;delete e.toString;delete e.valueOf;var t=function Empty(){};t.prototype=e;y=function(){return new t};return new t}}Object.create=function create(e,t){var r;var n=function Type(){};if(e===null){r=y()}else if(u(e)){throw new TypeError("Object prototype may only be an Object or null")}else{n.prototype=e;r=new n;r.__proto__=e}if(t!==void 0){Object.defineProperties(r,t)}return r}}var m=function doesDefinePropertyWork(e){try{Object.defineProperty(e,"sentinel",{});return"sentinel"in e}catch(t){return false}};if(Object.defineProperty){var P=m({});var E=typeof document==="undefined"||m(document.createElement("div"));if(!P||!E){var h=Object.defineProperty,g=Object.defineProperties}}if(!Object.defineProperty||h){var z="Property description must be an object: ";var T="Object.defineProperty called on non-object: ";var x="getters & setters can not be defined on this javascript engine";Object.defineProperty=function defineProperty(e,r,n){if(u(e)){throw new TypeError(T+e)}if(u(n)){throw new TypeError(z+n)}if(h){try{return h.call(Object,e,r,n)}catch(o){}}if("value"in n){if(l&&(f(e,r)||a(e,r))){var p=e.__proto__;e.__proto__=t;delete e[r];e[r]=n.value;e.__proto__=p}else{e[r]=n.value}}else{var s="get"in n;var b="set"in n;if(!l&&(s||b)){throw new TypeError(x)}if(s){i(e,r,n.get)}if(b){c(e,r,n.set)}}return e}}if(!Object.defineProperties||g){Object.defineProperties=function defineProperties(e,t){if(g){try{return g.call(Object,e,t)}catch(r){}}Object.keys(t).forEach(function(r){if(r!=="__proto__"){Object.defineProperty(e,r,t[r])}});return e}}if(!Object.seal){Object.seal=function seal(e){if(Object(e)!==e){throw new TypeError("Object.seal can only be called on Objects.")}return e}}if(!Object.freeze){Object.freeze=function freeze(e){if(Object(e)!==e){throw new TypeError("Object.freeze can only be called on Objects.")}return e}}try{Object.freeze(function(){})}catch(S){Object.freeze=function(e){return function freeze(t){if(typeof t==="function"){return t}return e(t)}}(Object.freeze)}if(!Object.preventExtensions){Object.preventExtensions=function preventExtensions(e){if(Object(e)!==e){throw new TypeError("Object.preventExtensions can only be called on Objects.")}return e}}if(!Object.isSealed){Object.isSealed=function isSealed(e){if(Object(e)!==e){throw new TypeError("Object.isSealed can only be called on Objects.")}return false}}if(!Object.isFrozen){Object.isFrozen=function isFrozen(e){if(Object(e)!==e){throw new TypeError("Object.isFrozen can only be called on Objects.")}return false}}if(!Object.isExtensible){Object.isExtensible=function isExtensible(e){if(Object(e)!==e){throw new TypeError("Object.isExtensible can only be called on Objects.")}var t="";while(r(e,t)){t+="?"}e[t]=true;var n=r(e,t);delete e[t];return n}}});
7 | //# sourceMappingURL=es5-sham.map
8 |
--------------------------------------------------------------------------------
/es5-shim.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * https://github.com/es-shims/es5-shim
3 | * @license es5-shim Copyright 2009-2020 by contributors, MIT License
4 | * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
5 | */
6 | (function(t,e){"use strict";if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){var t=Array;var e=t.prototype;var r=Object;var n=r.prototype;var i=Function;var a=i.prototype;var o=String;var f=o.prototype;var u=Number;var l=u.prototype;var s=e.slice;var c=e.splice;var v=e.push;var p=e.unshift;var h=e.concat;var y=e.join;var d=a.call;var g=a.apply;var b=Math.max;var w=Math.min;var T=Math.floor;var m=Math.abs;var S=Math.pow;var D=Math.round;var x=Math.log;var E=Math.LOG10E;var O=Math.log10||function log10(t){return x(t)*E};var I=n.toString;var j=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var N;var F=Function.prototype.toString,U=/^\s*class /,$=function isES6ClassFn(t){try{var e=F.call(t);var r=e.replace(/\/\/.*\n/g,"");var n=r.replace(/\/\*[.\s\S]*\*\//g,"");var i=n.replace(/\n/gm," ").replace(/ {2}/g," ");return U.test(i)}catch(a){return false}},M=function tryFunctionObject(t){try{if($(t)){return false}F.call(t);return true}catch(e){return false}},C="[object Function]",P="[object GeneratorFunction]",N=function isCallable(t){if(!t){return false}if(typeof t!=="function"&&typeof t!=="object"){return false}if(j){return M(t)}if($(t)){return false}var e=I.call(t);return e===C||e===P};var k;var R=RegExp.prototype.exec,A=function tryRegexExec(t){try{R.call(t);return true}catch(e){return false}},J="[object RegExp]";k=function isRegex(t){if(typeof t!=="object"){return false}return j?A(t):I.call(t)===J};var Y;var z=String.prototype.valueOf,Z=function tryStringObject(t){try{z.call(t);return true}catch(e){return false}},G="[object String]";Y=function isString(t){if(typeof t==="string"){return true}if(typeof t!=="object"){return false}return j?Z(t):I.call(t)===G};var H=r.defineProperty&&function(){try{var t={};r.defineProperty(t,"x",{enumerable:false,value:t});for(var e in t){return false}return t.x===t}catch(n){return false}}();var W=function(t){var e;if(H){e=function(t,e,n,i){if(!i&&e in t){return}r.defineProperty(t,e,{configurable:true,enumerable:false,writable:true,value:n})}}else{e=function(t,e,r,n){if(!n&&e in t){return}t[e]=r}}return function defineProperties(r,n,i){for(var a in n){if(t.call(n,a)){e(r,a,n[a],i)}}}}(n.hasOwnProperty);if(r.defineProperty&&H){var B=function(){};var L={};var X={toString:L};r.defineProperty(B,"prototype",{value:X,writable:false});if((new B).toString!==L){var q=r.defineProperty;var K=r.getOwnPropertyDescriptor;W(r,{defineProperty:function defineProperty(t,e,r){var n=o(e);if(typeof t==="function"&&n==="prototype"){var i=K(t,n);if(i.writable&&!r.writable&&"value"in r){try{t[n]=r.value}catch(a){}}return q(t,n,{configurable:"configurable"in r?r.configurable:i.configurable,enumerable:"enumerable"in r?r.enumerable:i.enumerable,writable:r.writable})}return q(t,n,r)}},true)}}var Q=function isPrimitive(t){var e=typeof t;return t===null||e!=="object"&&e!=="function"};var V=u.isNaN||function isActualNaN(t){return t!==t};var _={ToInteger:function ToInteger(t){var e=+t;if(V(e)){e=0}else if(e!==0&&e!==1/0&&e!==-(1/0)){e=(e>0||-1)*T(m(e))}return e},ToPrimitive:function ToPrimitive(t){var e,r,n;if(Q(t)){return t}r=t.valueOf;if(N(r)){e=r.call(t);if(Q(e)){return e}}n=t.toString;if(N(n)){e=n.call(t);if(Q(e)){return e}}throw new TypeError},ToObject:function(t){if(t==null){throw new TypeError("can't convert "+t+" to object")}return r(t)},ToUint32:function ToUint32(t){return t>>>0}};var tt=function Empty(){};W(a,{bind:function bind(t){var e=this;if(!N(e)){throw new TypeError("Function.prototype.bind called on incompatible "+e)}var n=s.call(arguments,1);var a;var o=function(){if(this instanceof a){var i=g.call(e,this,h.call(n,s.call(arguments)));if(r(i)===i){return i}return this}return g.call(e,t,h.call(n,s.call(arguments)))};var f=b(0,e.length-n.length);var u=[];for(var l=0;l0){e[r]=t[r]}return ft(e,ot(arguments,1))};it=function arraySliceApplyIE(t,e){return ft(nt(t),e)}}}var ut=d.bind(f.slice);var lt=d.bind(f.split);var st=d.bind(f.indexOf);var ct=d.bind(v);var vt=d.bind(n.propertyIsEnumerable);var pt=d.bind(e.sort);var ht=t.isArray||function isArray(t){return rt(t)==="[object Array]"};var yt=[].unshift(0)!==1;W(e,{unshift:function(){p.apply(this,arguments);return this.length}},yt);W(t,{isArray:ht});var dt=r("a");var gt=dt[0]!=="a"||!(0 in dt);var bt=function properlyBoxed(t){var e=true;var r=true;var n=false;if(t){try{t.call("foo",function(t,r,n){if(typeof n!=="object"){e=false}});t.call([1],function(){"use strict";r=typeof this==="string"},"x")}catch(i){n=true}}return!!t&&!n&&e&&r};W(e,{forEach:function forEach(t){var e=_.ToObject(this);var r=gt&&Y(this)?lt(this,""):e;var n=-1;var i=_.ToUint32(r.length);var a;if(arguments.length>1){a=arguments[1]}if(!N(t)){throw new TypeError("Array.prototype.forEach callback must be a function")}while(++n1){o=arguments[1]}if(!N(e)){throw new TypeError("Array.prototype.map callback must be a function")}for(var f=0;f1){o=arguments[1]}if(!N(t)){throw new TypeError("Array.prototype.filter callback must be a function")}for(var f=0;f1){i=arguments[1]}if(!N(t)){throw new TypeError("Array.prototype.every callback must be a function")}for(var a=0;a1){i=arguments[1]}if(!N(t)){throw new TypeError("Array.prototype.some callback must be a function")}for(var a=0;a=2){a=arguments[1]}else{do{if(i in r){a=r[i++];break}if(++i>=n){throw new TypeError("reduce of empty array with no initial value")}}while(true)}for(;i=2){i=arguments[1]}else{do{if(a in r){i=r[a--];break}if(--a<0){throw new TypeError("reduceRight of empty array with no initial value")}}while(true)}if(a<0){return i}do{if(a in r){i=t(i,r[a],a,e)}}while(a--);return i}},!Tt);var mt=e.indexOf&&[0,1].indexOf(1,2)!==-1;W(e,{indexOf:function indexOf(t){var e=gt&&Y(this)?lt(this,""):_.ToObject(this);var r=_.ToUint32(e.length);if(r===0){return-1}var n=0;if(arguments.length>1){n=_.ToInteger(arguments[1])}n=n>=0?n:b(0,r+n);for(;n1){n=w(n,_.ToInteger(arguments[1]))}n=n>=0?n:r-m(n);for(;n>=0;n--){if(n in e&&t===e[n]){return n}}return-1}},St);var Dt=function(){var t=[1,2];var e=t.splice();return t.length===2&&ht(e)&&e.length===0}();W(e,{splice:function splice(t,e){if(arguments.length===0){return[]}return c.apply(this,arguments)}},!Dt);var xt=function(){var t={};e.splice.call(t,0,0,1);return t.length===1}();var Et=[0,1,2].splice(0).length===3;W(e,{splice:function splice(t,e){if(arguments.length===0){return[]}var r=arguments;this.length=b(_.ToInteger(this.length),0);if(arguments.length>0&&typeof e!=="number"){r=nt(arguments);if(r.length<2){ct(r,this.length-t)}else{r[1]=_.ToInteger(e)}}return c.apply(this,r)}},!xt||!Et);var Ot=function(){var e=new t(1e5);e[8]="x";e.splice(1,1);return e.indexOf("x")===7}();var It=function(){var t=256;var e=[];e[t]="a";e.splice(t+1,0,"b");return e[t]==="a"}();W(e,{splice:function splice(t,e){var r=_.ToObject(this);var n=[];var i=_.ToUint32(r.length);var a=_.ToInteger(t);var f=a<0?b(i+a,0):w(a,i);var u=arguments.length===0?0:arguments.length===1?i-f:w(b(_.ToInteger(e),0),i-f);var l=0;var s;while(ly){delete r[l-1];l-=1}}else if(v>u){l=i-u;while(l>f){s=o(l+u-1);p=o(l+v-1);if(et(r,s)){r[p]=r[s]}else{delete r[p]}l-=1}}l=f;for(var d=0;d=0&&!ht(t)&&N(t.callee)};var Xt=Bt(arguments)?Bt:Lt;W(r,{keys:function keys(t){var e=N(t);var r=Xt(t);var n=t!==null&&typeof t==="object";var i=n&&Y(t);if(!n&&!e&&!r){throw new TypeError("Object.keys called on a non-object")}var a=[];var f=At&&e;if(i&&Jt||r){for(var u=0;u11){return t+1}return t},getMonth:function getMonth(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=ae(this);var e=oe(this);if(t<0&&e>11){return 0}return e},getDate:function getDate(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=ae(this);var e=oe(this);var r=fe(this);if(t<0&&e>11){if(e===12){return r}var n=be(0,t+1);return n-r+1}return r},getUTCFullYear:function getUTCFullYear(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=ue(this);if(t<0&&le(this)>11){return t+1}return t},getUTCMonth:function getUTCMonth(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=ue(this);var e=le(this);if(t<0&&e>11){return 0}return e},getUTCDate:function getUTCDate(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=ue(this);var e=le(this);var r=se(this);if(t<0&&e>11){if(e===12){return r}var n=be(0,t+1);return n-r+1}return r}},Vt);W(Date.prototype,{toUTCString:function toUTCString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=ce(this);var e=se(this);var r=le(this);var n=ue(this);var i=ve(this);var a=pe(this);var o=he(this);return de[t]+", "+(e<10?"0"+e:e)+" "+ge[r]+" "+n+" "+(i<10?"0"+i:i)+":"+(a<10?"0"+a:a)+":"+(o<10?"0"+o:o)+" GMT"}},Vt||ee);W(Date.prototype,{toDateString:function toDateString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=this.getDay();var e=this.getDate();var r=this.getMonth();var n=this.getFullYear();return de[t]+" "+ge[r]+" "+(e<10?"0"+e:e)+" "+n}},Vt||re);if(Vt||ne){Date.prototype.toString=function toString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=this.getDay();var e=this.getDate();var r=this.getMonth();var n=this.getFullYear();var i=this.getHours();var a=this.getMinutes();var o=this.getSeconds();var f=this.getTimezoneOffset();var u=T(m(f)/60);var l=T(m(f)%60);return de[t]+" "+ge[r]+" "+(e<10?"0"+e:e)+" "+n+" "+(i<10?"0"+i:i)+":"+(a<10?"0"+a:a)+":"+(o<10?"0"+o:o)+" GMT"+(f>0?"-":"+")+(u<10?"0"+u:u)+(l<10?"0"+l:l)};if(H){r.defineProperty(Date.prototype,"toString",{configurable:true,enumerable:false,writable:true})}}var we=-621987552e5;var Te="-000001";var me=Date.prototype.toISOString&&new Date(we).toISOString().indexOf(Te)===-1;var Se=Date.prototype.toISOString&&new Date(-1).toISOString()!=="1969-12-31T23:59:59.999Z";var De=d.bind(Date.prototype.getTime);W(Date.prototype,{toISOString:function toISOString(){if(!isFinite(this)||!isFinite(De(this))){throw new RangeError("Date.prototype.toISOString called on non-finite value.")}var t=ue(this);var e=le(this);t+=T(e/12);e=(e%12+12)%12;var r=[e+1,se(this),ve(this),pe(this),he(this)];t=(t<0?"-":t>9999?"+":"")+ut("00000"+m(t),0<=t&&t<=9999?-4:-6);for(var n=0;n=7&&l>je){var h=T(l/je)*je;var y=T(h/1e3);v+=y;p-=y*1e3}var d=e.parse(r);var g=isNaN(d);c=s===1&&o(r)===r&&!g?new t(d):s>=7?new t(r,n,i,a,f,v,p):s>=6?new t(r,n,i,a,f,v):s>=5?new t(r,n,i,a,f):s>=4?new t(r,n,i,a):s>=3?new t(r,n,i):s>=2?new t(r,n):s>=1?new t(r instanceof t?+r:r):new t}else{c=t.apply(this,arguments)}if(!Q(c)){W(c,{constructor:e},true)}return c};var r=new RegExp("^"+"(\\d{4}|[+-]\\d{6})"+"(?:-(\\d{2})"+"(?:-(\\d{2})"+"(?:"+"T(\\d{2})"+":(\\d{2})"+"(?:"+":(\\d{2})"+"(?:(\\.\\d{1,}))?"+")?"+"("+"Z|"+"(?:"+"([-+])"+"(\\d{2})"+":(\\d{2})"+")"+")?)?)?)?"+"$");var n=[0,31,59,90,120,151,181,212,243,273,304,334,365];var i=function dayFromMonth(t,e){var r=e>1?1:0;return n[e]+T((t-1969+r)/4)-T((t-1901+r)/100)+T((t-1601+r)/400)+365*(t-1970)};var a=function toUTC(e){var r=0;var n=e;if(Ne&&n>je){var i=T(n/je)*je;var a=T(i/1e3);r+=a;n-=a*1e3}return u(new t(1970,0,1,0,0,r,n))};for(var f in t){if(et(t,f)){e[f]=t[f]}}W(e,{now:t.now,UTC:t.UTC},true);e.prototype=t.prototype;W(e.prototype,{constructor:e},true);var l=function parse(e){var n=r.exec(e);if(n){var o=u(n[1]),f=u(n[2]||1)-1,l=u(n[3]||1)-1,s=u(n[4]||0),c=u(n[5]||0),v=u(n[6]||0),p=T(u(n[7]||0)*1e3),h=Boolean(n[4]&&!n[8]),y=n[9]==="-"?1:-1,d=u(n[10]||0),g=u(n[11]||0),b;var w=c>0||v>0||p>0;if(s<(w?24:25)&&c<60&&v<60&&p<1e3&&f>-1&&f<12&&d<24&&g<60&&l>-1&&l=0){r+=Ue.data[e];Ue.data[e]=T(r/t);r=r%t*Ue.base}},numToString:function numToString(){var t=Ue.size;var e="";while(--t>=0){if(e!==""||t===0||Ue.data[t]!==0){var r=o(Ue.data[t]);if(e===""){e=r}else{e+=ut("0000000",0,7-r.length)+r}}}return e},pow:function pow(t,e,r){return e===0?r:e%2===1?pow(t,e-1,r*t):pow(t*t,e/2,r)},log:function log(t){var e=0;var r=t;while(r>=4096){e+=12;r/=4096}while(r>=2){e+=1;r/=2}return e}};var $e=function toFixed(t){var e,r,n,i,a,f,l,s;e=u(t);e=V(e)?0:T(e);if(e<0||e>20){throw new RangeError("Number.toFixed called with invalid number of decimals")}r=u(this);if(V(r)){return"NaN"}if(r<=-1e21||r>=1e21){return o(r)}n="";if(r<0){n="-";r=-r}i="0";if(r>1e-21){a=Ue.log(r*Ue.pow(2,69,1))-69;f=a<0?r*Ue.pow(2,-a,1):r/Ue.pow(2,a,1);f*=4503599627370496;a=52-a;if(a>0){Ue.multiply(0,f);l=e;while(l>=7){Ue.multiply(1e7,0);l-=7}Ue.multiply(Ue.pow(10,l,1),0);l=a-1;while(l>=23){Ue.divide(1<<23);l-=23}Ue.divide(1<0){s=i.length;if(s<=e){i=n+ut("0.0000000000000000000",0,e-s+2)+i}else{i=n+ut(i,0,s-e)+"."+ut(i,s-e)}}else{i=n+i}return i};W(l,{toFixed:$e},Fe);var Me=function(){try{return(-6.9e-11).toExponential(4)!=="-6.9000e-11"}catch(t){return false}}();var Ce=function(){try{1..toExponential(Infinity);1..toExponential(-Infinity);return true}catch(t){return false}}();var Pe=d.bind(l.toExponential);var ke=d.bind(l.toString);var Re=d.bind(l.valueOf);W(l,{toExponential:function toExponential(t){var e=Re(this);if(typeof t==="undefined"){return Pe(e)}var r=_.ToInteger(t);if(V(e)){return"NaN"}if(r<0||r>20){if(!isFinite(r)){throw new RangeError("toExponential() argument must be between 0 and 20")}return Pe(e,r)}var n="";if(e<0){n="-";e=-e}if(e===Infinity){return n+"Infinity"}if(typeof t!=="undefined"&&(r<0||r>20)){throw new RangeError("Fraction digits "+t+" out of range")}var i="";var a=0;var o="";var f="";if(e===0){a=0;r=0;i="0"}else{var u=O(e);a=T(u);var l=0;if(typeof t!=="undefined"){var s=S(10,a-r);l=D(e/s);if(2*e>=(2*l+1)*s){l+=1}if(l>=S(10,r+1)){l/=10;a+=1}}else{r=16;var c=D(S(10,u-a+r));var v=r;while(r-- >0){c=D(S(10,u-a+r));if(m(c*S(10,a-r)-e)<=m(l*S(10,a-v)-e)){v=r;l=c}}}i=ke(l,10);if(typeof t==="undefined"){while(ut(i,-1)==="0"){i=ut(i,0,-1);f+=1}}}if(r!==0){i=ut(i,0,1)+"."+ut(i,1)}if(a===0){o="+";f="0"}else{o=a>0?"+":"-";f=ke(m(a),10)}i+="e"+o+f;return n+i}},Me||Ce);var Ae=function(){try{return 1..toPrecision(undefined)==="1"}catch(t){return true}}();var Je=d.bind(l.toPrecision);W(l,{toPrecision:function toPrecision(t){return typeof t==="undefined"?Je(this):Je(this,t)}},Ae);if("ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||"tesst".split(/(s)*/)[1]==="t"||"test".split(/(?:)/,-1).length!==4||"".split(/.?/).length||".".split(/()()/).length>1){(function(){var t=typeof/()??/.exec("")[1]==="undefined";var e=S(2,32)-1;f.split=function split(r,n){var i=String(this);if(typeof r==="undefined"&&n===0){return[]}if(!k(r)){return lt(this,r,n)}var a=[];var o=(r.ignoreCase?"i":"")+(r.multiline?"m":"")+(r.unicode?"u":"")+(r.sticky?"y":""),f=0,u,l,s,c;var p=new RegExp(r.source,o+"g");if(!t){u=new RegExp("^"+p.source+"$(?!\\s)",o)}var h=typeof n==="undefined"?e:_.ToUint32(n);l=p.exec(i);while(l){s=l.index+l[0].length;if(s>f){ct(a,ut(i,f,l.index));if(!t&&l.length>1){l[0].replace(u,function(){for(var t=1;t1&&l.index=h){break}}if(p.lastIndex===l.index){p.lastIndex++}l=p.exec(i)}if(f===i.length){if(c||!p.test("")){ct(a,"")}}else{ct(a,ut(i,f))}return a.length>h?nt(a,0,h):a}})()}else if("0".split(void 0,0).length){f.split=function split(t,e){if(typeof t==="undefined"&&e===0){return[]}return lt(this,t,e)}}var Ye=f.replace;var ze=function(){var t=[];"x".replace(/x(.)?/g,function(e,r){ct(t,r)});return t.length===1&&typeof t[0]==="undefined"}();if(!ze){f.replace=function replace(t,e){var r=N(e);var n=k(t)&&/\)[*?]/.test(t.source);if(!r||!n){return Ye.call(this,t,e)}var i=function(r){var n=arguments.length;var i=t.lastIndex;t.lastIndex=0;var a=t.exec(r)||[];t.lastIndex=i;ct(a,arguments[n-2],arguments[n-1]);return e.apply(this,a)};return Ye.call(this,t,i)}}var Ze="".substr&&"0b".substr(-1)!=="b";var Ge=Ze&&d.bind(f.substr);W(f,{substr:function substr(t,e){var r=t;if(t<0){r=b(this.length+t,0)}return Ge(this,r,e)}},Ze);var He="\u180e";var We=/\s/.test(He);var Be="\t\n\x0B\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff".replace(/\S/g,"");var Le="\u200b";var Xe="["+Be+"]";var qe=new RegExp("^"+Xe+Xe+"*");var Ke=new RegExp(Xe+Xe+"*$");var Qe=f.trim&&(Be.trim()!==""||Le.trim()===""||He.trim()!==(We?"":He));W(f,{trim:function trim(){"use strict";if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}return o(this).replace(qe,"").replace(Ke,"")}},Qe);var Ve=d.bind(String.prototype.trim);var _e=f.lastIndexOf&&"abc\u3042\u3044".lastIndexOf("\u3042\u3044",2)!==-1;W(f,{lastIndexOf:function lastIndexOf(t){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}var e=o(this);var r=o(t);var n=arguments.length>1?u(arguments[1]):NaN;var i=V(n)?Infinity:_.ToInteger(n);var a=w(b(i,0),e.length);var f=r.length;var l=a+f;while(l>0){l=b(0,l-f);var s=st(ut(e,l,a+f),r);if(s!==-1){return l+s}}return-1}},_e);var tr=f.lastIndexOf;W(f,{lastIndexOf:function lastIndexOf(t){return tr.apply(this,arguments)}},f.lastIndexOf.length!==1);var er=/^[-+]?0[xX]/;if(parseInt(Be+"08")!==8||parseInt(Be+"0x16")!==22||(We?parseInt(He+1)!==1:!isNaN(parseInt(He+1)))){parseInt=function(t){return function parseInt(e,r){if(this instanceof parseInt){new t}var n=Ve(String(e));var i=u(r)||(er.test(n)?16:10);return t(n,i)}}(parseInt)}var rr=function(){if(typeof Symbol!=="function"){return false}try{parseInt(Object(Symbol.iterator));return true}catch(t){}try{parseInt(Symbol.iterator);return true}catch(t){}return false}();if(rr){var nr=Symbol.prototype.valueOf;parseInt=function(t){return function parseInt(e,r){if(this instanceof parseInt){new t}var n=typeof e==="symbol";if(!n&&e&&typeof e==="object"){try{nr.call(e);n=true}catch(i){}}if(n){""+e}var a=Ve(String(e));var o=u(r)||(er.test(a)?16:10);return t(a,o)}}(parseInt)}if(1/parseFloat("-0")!==-Infinity){parseFloat=function(t){return function parseFloat(e){var r=Ve(String(e));var n=t(r);return n===0&&ut(r,0,1)==="-"?-0:n}}(parseFloat)}if(String(new RangeError("test"))!=="RangeError: test"){var ir=function toString(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}var t=this.name;if(typeof t==="undefined"){t="Error"}else if(typeof t!=="string"){t=o(t)}var e=this.message;if(typeof e==="undefined"){e=""}else if(typeof e!=="string"){e=o(e)}if(!t){return e}if(!e){return t}return t+": "+e};Error.prototype.toString=ir}if(H){var ar=function(t,e){if(vt(t,e)){var r=Object.getOwnPropertyDescriptor(t,e);if(r.configurable){r.enumerable=false;Object.defineProperty(t,e,r)}}};ar(Error.prototype,"message");if(Error.prototype.message!==""){Error.prototype.message=""}ar(Error.prototype,"name")}if(String(/a/gim)!=="/a/gim"){var or=function toString(){var t="/"+this.source+"/";if(this.global){t+="g"}if(this.ignoreCase){t+="i"}if(this.multiline){t+="m"}return t};RegExp.prototype.toString=or}});
7 | //# sourceMappingURL=es5-shim.map
8 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "es5-shim",
3 | "version": "4.6.7",
4 | "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
5 | "homepage": "https://github.com/es-shims/es5-shim/",
6 | "contributors": [
7 | "Kris Kowal (https://github.com/kriskowal/)",
8 | "Sami Samhuri (https://samhuri.net/)",
9 | "Florian Schäfer (https://github.com/fschaefer)",
10 | "Irakli Gozalishvili (https://gozala.io)",
11 | "Kit Cambridge (https://github.com/kitcambridge)",
12 | "Jordan Harband (https://github.com/ljharb/)"
13 | ],
14 | "bugs": {
15 | "mail": "ljharb@gmail.com",
16 | "url": "https://github.com/es-shims/es5-shim/issues"
17 | },
18 | "license": "MIT",
19 | "main": "es5-shim.js",
20 | "repository": {
21 | "type": "git",
22 | "url": "https://github.com/es-shims/es5-shim.git"
23 | },
24 | "scripts": {
25 | "prepack": "npmignore --auto --commentLines=autogenerated",
26 | "prepublish": "not-in-publish || npm run prepublishOnly",
27 | "prepublishOnly": "safe-publish-latest && npm run minify",
28 | "minify": "npm run --silent minify-shim && npm run --silent minify-sham",
29 | "minify-shim": "uglifyjs es5-shim.js --support-ie8 --keep-fnames --comments --source-map=es5-shim.map -m -b ascii_only=true,beautify=false | sed 's/0xde0b6b3a7640080/1000000000000000128/' > es5-shim.min.js",
30 | "minify-sham": "uglifyjs es5-sham.js --support-ie8 --keep-fnames --comments --source-map=es5-sham.map -m -b ascii_only=true,beautify=false > es5-sham.min.js",
31 | "pretest": "npm run --silent lint",
32 | "test": "npm run tests-only",
33 | "posttest": "aud --production",
34 | "tests-only": "nyc jasmine-node --matchall es5-sh*m.js tests/helpers/ tests/spec/",
35 | "tests-native": "jasmine-node --matchall tests/helpers/ tests/spec/",
36 | "lint": "eslint ."
37 | },
38 | "devDependencies": {
39 | "@ljharb/eslint-config": "^21.0.0",
40 | "aud": "^2.0.1",
41 | "eslint": "=8.8.0",
42 | "in-publish": "^2.0.1",
43 | "jasmine-node": "^1.16.2",
44 | "npmignore": "^0.3.0",
45 | "nyc": "^10.3.2",
46 | "safe-publish-latest": "^2.0.0",
47 | "uglify-js": "2.7.3"
48 | },
49 | "engines": {
50 | "node": ">=0.4.0"
51 | },
52 | "testling": {
53 | "browsers": [
54 | "iexplore/6.0..latest",
55 | "firefox/3.0..6.0",
56 | "firefox/18.0..latest",
57 | "firefox/nightly",
58 | "chrome/4.0..10.0",
59 | "chrome/25.0..latest",
60 | "chrome/canary",
61 | "opera/10.0..latest",
62 | "opera/next",
63 | "safari/4.0..latest",
64 | "ipad/6.0..latest",
65 | "iphone/6.0..latest",
66 | "android-browser/4.2"
67 | ]
68 | },
69 | "keywords": [
70 | "shim",
71 | "es5",
72 | "es5 shim",
73 | "javascript",
74 | "ecmascript",
75 | "polyfill"
76 | ],
77 | "publishConfig": {
78 | "ignore": [
79 | ".github/workflows"
80 | ]
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/shims.json:
--------------------------------------------------------------------------------
1 | {
2 | "Object": {
3 | "prototype": {},
4 | "keys": "object-keys"
5 | }
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/tests/helpers/h-matchers.js:
--------------------------------------------------------------------------------
1 | var has = Object.prototype.hasOwnProperty;
2 | var getKeys = function (o) {
3 | 'use strict';
4 |
5 | var key;
6 | var a = [];
7 | for (key in o) {
8 | if (has.call(o, key)) {
9 | a.push(key);
10 | }
11 | }
12 | a.sort();
13 | return a;
14 | };
15 |
16 | beforeEach(function () {
17 | 'use strict';
18 |
19 | this.addMatchers({
20 | toExactlyMatch: function (expected) {
21 | var a1, a2, l, i, key;
22 | var actual = this.actual;
23 |
24 | a1 = getKeys(actual);
25 | a2 = getKeys(expected);
26 |
27 | l = a1.length;
28 | if (l !== a2.length) {
29 | return false;
30 | }
31 | for (i = 0; i < l; i++) {
32 | key = a1[i];
33 | expect(key).toEqual(a2[i]);
34 | expect(actual[key]).toEqual(expected[key]);
35 | }
36 |
37 | return true;
38 | }
39 | });
40 | });
41 |
--------------------------------------------------------------------------------
/tests/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/tests/index.min.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Jasmine Spec Runner
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/tests/lib/jasmine-html.js:
--------------------------------------------------------------------------------
1 | jasmine.TrivialReporter = function(doc) {
2 | this.document = doc || document;
3 | this.suiteDivs = {};
4 | this.logRunningSpecs = false;
5 | };
6 |
7 | jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
8 | var el = document.createElement(type);
9 |
10 | for (var i = 2; i < arguments.length; i++) {
11 | var child = arguments[i];
12 |
13 | if (typeof child === 'string') {
14 | el.appendChild(document.createTextNode(child));
15 | } else {
16 | if (child) { el.appendChild(child); }
17 | }
18 | }
19 |
20 | for (var attr in attrs) {
21 | if (attr == "className") {
22 | el[attr] = attrs[attr];
23 | } else {
24 | el.setAttribute(attr, attrs[attr]);
25 | }
26 | }
27 |
28 | return el;
29 | };
30 |
31 | jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
32 | var showPassed, showSkipped;
33 |
34 | this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
35 | this.createDom('div', { className: 'banner' },
36 | this.createDom('div', { className: 'logo' },
37 | this.createDom('span', { className: 'title' }, "Jasmine"),
38 | this.createDom('span', { className: 'version' }, runner.env.versionString())),
39 | this.createDom('div', { className: 'options' },
40 | "Show ",
41 | showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
42 | this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
43 | showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
44 | this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
45 | )
46 | ),
47 |
48 | this.runnerDiv = this.createDom('div', { className: 'runner running' },
49 | this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
50 | this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
51 | this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
52 | );
53 |
54 | this.document.body.appendChild(this.outerDiv);
55 |
56 | var suites = runner.suites();
57 | for (var i = 0; i < suites.length; i++) {
58 | var suite = suites[i];
59 | var suiteDiv = this.createDom('div', { className: 'suite' },
60 | this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
61 | this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
62 | this.suiteDivs[suite.id] = suiteDiv;
63 | var parentDiv = this.outerDiv;
64 | if (suite.parentSuite) {
65 | parentDiv = this.suiteDivs[suite.parentSuite.id];
66 | }
67 | parentDiv.appendChild(suiteDiv);
68 | }
69 |
70 | this.startedAt = new Date();
71 |
72 | var self = this;
73 | showPassed.onclick = function(evt) {
74 | if (showPassed.checked) {
75 | self.outerDiv.className += ' show-passed';
76 | } else {
77 | self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
78 | }
79 | };
80 |
81 | showSkipped.onclick = function(evt) {
82 | if (showSkipped.checked) {
83 | self.outerDiv.className += ' show-skipped';
84 | } else {
85 | self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
86 | }
87 | };
88 | };
89 |
90 | jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
91 | var results = runner.results();
92 | var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
93 | this.runnerDiv.setAttribute("class", className);
94 | //do it twice for IE
95 | this.runnerDiv.setAttribute("className", className);
96 | var specs = runner.specs();
97 | var specCount = 0;
98 | for (var i = 0; i < specs.length; i++) {
99 | if (this.specFilter(specs[i])) {
100 | specCount++;
101 | }
102 | }
103 | var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
104 | message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
105 | this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
106 |
107 | this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
108 | };
109 |
110 | jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
111 | var results = suite.results();
112 | var status = results.passed() ? 'passed' : 'failed';
113 | if (results.totalCount === 0) { // todo: change this to check results.skipped
114 | status = 'skipped';
115 | }
116 | this.suiteDivs[suite.id].className += " " + status;
117 | };
118 |
119 | jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
120 | if (this.logRunningSpecs) {
121 | this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
122 | }
123 | };
124 |
125 | jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
126 | var results = spec.results();
127 | var status = results.passed() ? 'passed' : 'failed';
128 | if (results.skipped) {
129 | status = 'skipped';
130 | }
131 | var specDiv = this.createDom('div', { className: 'spec ' + status },
132 | this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
133 | this.createDom('a', {
134 | className: 'description',
135 | href: '?spec=' + encodeURIComponent(spec.getFullName()),
136 | title: spec.getFullName()
137 | }, spec.description));
138 |
139 |
140 | var resultItems = results.getItems();
141 | var messagesDiv = this.createDom('div', { className: 'messages' });
142 | for (var i = 0; i < resultItems.length; i++) {
143 | var result = resultItems[i];
144 |
145 | if (result.type == 'log') {
146 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
147 | } else if (result.type == 'expect' && result.passed && !result.passed()) {
148 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
149 |
150 | if (result.trace.stack) {
151 | messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
152 | }
153 | }
154 | }
155 |
156 | if (messagesDiv.childNodes.length > 0) {
157 | specDiv.appendChild(messagesDiv);
158 | }
159 |
160 | this.suiteDivs[spec.suite.id].appendChild(specDiv);
161 | };
162 |
163 | jasmine.TrivialReporter.prototype.log = function() {
164 | var console = jasmine.getGlobal().console;
165 | if (console && console.log) {
166 | if (console.log.apply) {
167 | console.log.apply(console, arguments);
168 | } else {
169 | console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
170 | }
171 | }
172 | };
173 |
174 | jasmine.TrivialReporter.prototype.getLocation = function() {
175 | return this.document.location;
176 | };
177 |
178 | jasmine.TrivialReporter.prototype.specFilter = function(spec) {
179 | var paramMap = {};
180 | var params = this.getLocation().search.substring(1).split('&');
181 | for (var i = 0; i < params.length; i++) {
182 | var p = params[i].split('=');
183 | paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
184 | }
185 |
186 | if (!paramMap.spec) {
187 | return true;
188 | }
189 | return spec.getFullName().indexOf(paramMap.spec) === 0;
190 | };
191 |
--------------------------------------------------------------------------------
/tests/lib/jasmine.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
3 | }
4 |
5 |
6 | .jasmine_reporter a:visited, .jasmine_reporter a {
7 | color: #303;
8 | }
9 |
10 | .jasmine_reporter a:hover, .jasmine_reporter a:active {
11 | color: blue;
12 | }
13 |
14 | .run_spec {
15 | float:right;
16 | padding-right: 5px;
17 | font-size: .8em;
18 | text-decoration: none;
19 | }
20 |
21 | .jasmine_reporter {
22 | margin: 0 5px;
23 | }
24 |
25 | .banner {
26 | color: #303;
27 | background-color: #fef;
28 | padding: 5px;
29 | }
30 |
31 | .logo {
32 | float: left;
33 | font-size: 1.1em;
34 | padding-left: 5px;
35 | }
36 |
37 | .logo .version {
38 | font-size: .6em;
39 | padding-left: 1em;
40 | }
41 |
42 | .runner.running {
43 | background-color: yellow;
44 | }
45 |
46 |
47 | .options {
48 | text-align: right;
49 | font-size: .8em;
50 | }
51 |
52 |
53 |
54 |
55 | .suite {
56 | border: 1px outset gray;
57 | margin: 5px 0;
58 | padding-left: 1em;
59 | }
60 |
61 | .suite .suite {
62 | margin: 5px;
63 | }
64 |
65 | .suite.passed {
66 | background-color: #dfd;
67 | }
68 |
69 | .suite.failed {
70 | background-color: #fdd;
71 | }
72 |
73 | .spec {
74 | margin: 5px;
75 | padding-left: 1em;
76 | clear: both;
77 | }
78 |
79 | .spec.failed, .spec.passed, .spec.skipped {
80 | padding-bottom: 5px;
81 | border: 1px solid gray;
82 | }
83 |
84 | .spec.failed {
85 | background-color: #fbb;
86 | border-color: red;
87 | }
88 |
89 | .spec.passed {
90 | background-color: #bfb;
91 | border-color: green;
92 | }
93 |
94 | .spec.skipped {
95 | background-color: #bbb;
96 | }
97 |
98 | .messages {
99 | border-left: 1px dashed gray;
100 | padding-left: 1em;
101 | padding-right: 1em;
102 | }
103 |
104 | .passed {
105 | background-color: #cfc;
106 | display: none;
107 | }
108 |
109 | .failed {
110 | background-color: #fbb;
111 | }
112 |
113 | .skipped {
114 | color: #777;
115 | background-color: #eee;
116 | display: none;
117 | }
118 |
119 |
120 | /*.resultMessage {*/
121 | /*white-space: pre;*/
122 | /*}*/
123 |
124 | .resultMessage span.result {
125 | display: block;
126 | line-height: 2em;
127 | color: black;
128 | }
129 |
130 | .resultMessage .mismatch {
131 | color: black;
132 | }
133 |
134 | .stackTrace {
135 | white-space: pre;
136 | font-size: .8em;
137 | margin-left: 10px;
138 | max-height: 5em;
139 | overflow: auto;
140 | border: 1px inset red;
141 | padding: 1em;
142 | background: #eef;
143 | }
144 |
145 | .finished-at {
146 | padding-left: 1em;
147 | font-size: .6em;
148 | }
149 |
150 | .show-passed .passed,
151 | .show-skipped .skipped {
152 | display: block;
153 | }
154 |
155 |
156 | #jasmine_content {
157 | position:fixed;
158 | right: 100%;
159 | }
160 |
161 | .runner {
162 | border: 1px solid gray;
163 | display: block;
164 | margin: 5px 0;
165 | padding: 2px 0 2px 10px;
166 | }
167 |
--------------------------------------------------------------------------------
/tests/native.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/tests/spec/s-date.js:
--------------------------------------------------------------------------------
1 | describe('Date', function () {
2 | 'use strict';
3 |
4 | var supportsDescriptors = Object.defineProperty && (function () {
5 | try {
6 | var obj = {};
7 | Object.defineProperty(obj, 'x', {
8 | enumerable: false,
9 | value: obj
10 | });
11 | // eslint-disable-next-line no-unreachable-loop
12 | for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables
13 | return obj.x === obj;
14 | } catch (e) { /* this is ES3 */
15 | return false;
16 | }
17 | }());
18 | var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit;
19 | var has = Object.prototype.hasOwnProperty;
20 |
21 | var negativeDate;
22 | beforeEach(function () {
23 | var negativeCanned = [
24 | {
25 | getTime: -3509827329600292,
26 | getUTCDay: 4,
27 | getDay: 4,
28 | dim: 31
29 | },
30 | {
31 | getTime: -3509824651200292,
32 | getUTCDay: 0,
33 | getDay: 0,
34 | dim: 29
35 | },
36 | {
37 | getTime: -3509822145600292,
38 | getUTCDay: 1,
39 | getDay: 1,
40 | dim: 31
41 | },
42 | {
43 | getTime: -3509819467200292,
44 | getUTCDay: 4,
45 | getDay: 4,
46 | dim: 30
47 | },
48 | {
49 | getTime: -3509816875200292,
50 | getUTCDay: 6,
51 | getDay: 6,
52 | dim: 31
53 | },
54 | {
55 | getTime: -3509814196800292,
56 | getUTCDay: 2,
57 | getDay: 2,
58 | dim: 30
59 | },
60 | {
61 | getTime: -3509811604800292,
62 | getUTCDay: 4,
63 | getDay: 4,
64 | dim: 31
65 | },
66 | {
67 | getTime: -3509808926400292,
68 | getUTCDay: 0,
69 | getDay: 0,
70 | dim: 31
71 | },
72 | {
73 | getTime: -3509806248000292,
74 | getUTCDay: 3,
75 | getDay: 3,
76 | dim: 30
77 | },
78 | {
79 | getTime: -3509803656000292,
80 | getUTCDay: 5,
81 | getDay: 5,
82 | dim: 31
83 | },
84 | {
85 | getTime: -3509800977600292,
86 | getUTCDay: 1,
87 | getDay: 1,
88 | dim: 30
89 | },
90 | {
91 | getTime: -3509798385600292,
92 | getUTCDay: 3,
93 | getDay: 3,
94 | dim: 31
95 | }
96 | ];
97 | negativeDate = negativeCanned.map(function (item) {
98 | var dateFirst = new Date(item.getTime);
99 | var dateLast = new Date(item.getTime + ((item.dim - 1) * 86400000));
100 | return {
101 | dates: [dateFirst, dateLast],
102 | days: [1, item.dim],
103 | getUTCDay: [item.getUTCDay, (item.getUTCDay + item.dim - 1) % 7],
104 | getDay: [item.getDay, (item.getDay + item.dim - 1) % 7]
105 | };
106 | });
107 | });
108 |
109 | describe('.now()', function () {
110 | it('should be the current time', function () {
111 | var before = (new Date()).getTime();
112 | var middle = Date.now();
113 | var after = (new Date()).getTime();
114 | expect(middle).not.toBeLessThan(before);
115 | expect(middle).not.toBeGreaterThan(after);
116 | });
117 | });
118 |
119 | describe('constructor', function () {
120 | it('works with standard formats', function () {
121 | // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
122 | expect(+new Date('2012-12-31T23:59:59.000Z')).toBe(1356998399000); // 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000
123 | expect(+new Date('2012-04-04T05:02:02.170Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
124 | expect(+new Date('2012-04-04T05:02:02.170999Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
125 | expect(+new Date('2012-04-04T05:02:02.17Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
126 | expect(+new Date('2012-04-04T05:02:02.1Z')).toBe(1333515722100); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
127 | expect(+new Date('2012-04-04T24:00:00.000Z')).toBe(1333584000000); // NaN 1333584000000 1333584000000 1333584000000 1333584000000
128 | expect(+new Date('2012-02-29T12:00:00.000Z')).toBe(1330516800000); // 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000
129 | expect(+new Date('2011-03-01T12:00:00.000Z')).toBe(1298980800000); // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
130 |
131 | // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
132 | expect(new Date('2034-03-01T00:00:00.000Z')
133 | - new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
134 |
135 | });
136 |
137 | ifSupportsDescriptorsIt('is not enumerable', function () {
138 | expect(Object.keys(new Date())).not.toContain('constructor');
139 | });
140 |
141 | it('works as a function', function () {
142 | var zeroDate = Date(0);
143 | expect(zeroDate).toBe(String(zeroDate));
144 | var value = Date(1441705534578);
145 | expect(value).toBe(String(value));
146 | });
147 |
148 | it('fixes this Safari 8/9 bug', function () {
149 | var offset = new Date(1970).getTimezoneOffset() * 60e3;
150 |
151 | var timestamp = 2147483647; // Math.pow(2, 31) - 1
152 | var date = new Date(1970, 0, 1, 0, 0, 0, timestamp);
153 | var expectedTimestamp = timestamp + offset;
154 | expect(date.getTime()).toBe(expectedTimestamp);
155 |
156 | var brokenTimestamp = 2147483648; // Math.pow(2, 31)
157 | var brokenDate = new Date(1970, 0, 1, 0, 0, 0, brokenTimestamp);
158 | var expectedBrokenTimestamp = brokenTimestamp + offset;
159 | expect(brokenDate.getTime()).toBe(expectedBrokenTimestamp); // NaN in Safari 8/9
160 |
161 | var veryBrokenTS = 1435734000000;
162 | var veryBrokenDate = new Date(1970, 0, 1, 0, 0, 0, veryBrokenTS);
163 | var largeDate = new Date('Wed Jul 01 2015 07:00:00 GMT-0700 (PDT)');
164 | var expectedVeryBrokenTS = veryBrokenTS + (largeDate.getTimezoneOffset() * 60e3);
165 | expect(veryBrokenDate.getTime()).toBe(expectedVeryBrokenTS); // NaN in Safari 8/9
166 | });
167 |
168 | it('works with a Date object', function () {
169 | var date = new Date(1456297712984);
170 | var copiedDate = new Date(date);
171 | expect(date).not.toBe(copiedDate);
172 | expect(copiedDate.getTime()).toBe(date.getTime());
173 | expect(+copiedDate).toBe(+date);
174 | expect(String(copiedDate)).toBe(String(date));
175 | });
176 | });
177 |
178 | describe('.parse()', function () {
179 | // TODO: Write the rest of the test.
180 |
181 | ifSupportsDescriptorsIt('is not enumerable', function () {
182 | expect(Object.getOwnPropertyDescriptor(Date, 'parse').enumerable).toBe(false);
183 | });
184 |
185 | it('should be an invalid date', function () {
186 | // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
187 | expect(Date.parse('2012-11-31T23:59:59.000Z')).toBeFalsy(); // 1354406399000 NaN NaN 1354406399000 NaN
188 | expect(Date.parse('2012-12-31T23:59:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356998400000
189 | expect(Date.parse('2012-04-04T24:00:00.500Z')).toBeFalsy(); // NaN NaN 1333584000500 1333584000500 NaN
190 | expect(Date.parse('2012-12-31T10:08:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356948540000
191 | expect(Date.parse('2012-13-01T12:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
192 | expect(Date.parse('2012-12-32T12:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
193 | expect(Date.parse('2012-12-31T25:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
194 | expect(Date.parse('2012-12-31T24:01:00.000Z')).toBeFalsy(); // NaN NaN NaN 1356998460000 NaN
195 | expect(Date.parse('2012-12-31T12:60:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
196 | expect(Date.parse('2012-12-31T12:00:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356955260000
197 | expect(Date.parse('2012-00-31T23:59:59.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
198 | expect(Date.parse('2012-12-00T23:59:59.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
199 | expect(Date.parse('2011-02-29T12:00:00.000Z')).toBeFalsy(); // 1298980800000 NaN NaN 1298980800000 NaN
200 | });
201 |
202 | it('should work', function () {
203 | var dates = {
204 | // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1 Safari 8
205 | '2012-12-31T23:59:59.000Z': 1356998399000, // 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000
206 | '2012-04-04T05:02:02.170Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
207 | '2012-04-04T05:02:02.170999Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170.999
208 | '2012-04-04T05:02:02.17Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
209 | '2012-04-04T05:02:02.1Z': 1333515722100, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
210 | '2012-04-04T24:00:00.000Z': 1333584000000, // NaN 1333584000000 1333584000000 1333584000000 1333584000000 1333584000000
211 | '2012-02-29T12:00:00.000Z': 1330516800000, // 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000
212 | '2011-03-01T12:00:00.000Z': 1298980800000 // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
213 | };
214 | for (var str in dates) {
215 | if (has.call(dates, str)) {
216 | expect(Math.floor(Date.parse(str))).toBe(dates[str]);
217 | }
218 | }
219 |
220 | // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
221 | expect(Date.parse('2034-03-01T00:00:00.000Z')
222 | - Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
223 |
224 | });
225 |
226 | it('fixes a Safari 8/9 bug with parsing in UTC instead of local time', function () {
227 | var offset = new Date('2015-07-01').getTimezoneOffset() * 60e3;
228 | expect(Date.parse('2015-07-01T00:00:00')).toBe(1435708800000 + offset); // Safari 8/9 give NaN
229 | });
230 |
231 | it('should support extended years', function () {
232 | // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
233 | expect(Date.parse('0000-01-01T00:00:00.000Z')).toBe(-621672192e5); // -621672192e5 -621672192e5 -621672192e5 -621672192e5 -621672192e5
234 | expect(Date.parse('0001-01-01T00:00:00Z')).toBe(-621355968e5); // -621355968e5 -621355968e5 -621355968e5 8.64e15 -621355968e5
235 | expect(Date.parse('+275760-09-13T00:00:00.000Z')).toBe(8.64e15); // 8.64e15 NaN 8.64e15 8.64e15 8.64e15
236 | expect(Date.parse('-271821-04-20T00:00:00.000Z')).toBe(-8.64e15); // -8.64e15 NaN -8.64e15 -8.64e15 -8.6400000864e15
237 | expect(Date.parse('+275760-09-13T00:00:00.001Z')).toBeFalsy(); // NaN NaN NaN 8.64e15 + 1 8.64e15 + 1
238 | expect(Date.parse('-271821-04-19T23:59:59.999Z')).toBeFalsy(); // NaN NaN NaN -8.64e15 - 1 -8.6400000864e15 - 1
239 | expect(Date.parse('+033658-09-27T01:46:40.000Z')).toBe(1e15); // 1e15 NaN 1e15 1e15 9999999136e5
240 | expect(Date.parse('-000001-01-01T00:00:00Z')).toBe(-621987552e5); // -621987552e5 NaN -621987552e5 -621987552e5 -621987552e5
241 | expect(Date.parse('+002009-12-15T00:00:00Z')).toBe(12608352e5); // 12608352e5 NaN 12608352e5 12608352e5 12608352e5
242 | });
243 |
244 | it('works with timezone offsets', function () {
245 | // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
246 | expect(Date.parse('2012-01-29T12:00:00.000+01:00')).toBe(132783480e4); // 132783480e4 132783480e4 132783480e4 132783480e4 132783480e4
247 | expect(Date.parse('2012-01-29T12:00:00.000-00:00')).toBe(132783840e4); // 132783840e4 132783840e4 132783840e4 132783840e4 132783840e4
248 | expect(Date.parse('2012-01-29T12:00:00.000+00:00')).toBe(132783840e4); // 132783840e4 132783840e4 132783840e4 132783840e4 132783840e4
249 | expect(Date.parse('2012-01-29T12:00:00.000+23:59')).toBe(132775206e4); // 132775206e4 132775206e4 132775206e4 132775206e4 132775206e4
250 | expect(Date.parse('2012-01-29T12:00:00.000-23:59')).toBe(132792474e4); // 132792474e4 132792474e4 132792474e4 132792474e4 132792474e4
251 | expect(Date.parse('2012-01-29T12:00:00.000+24:00')).toBeFalsy(); // NaN 1327752e6 NaN 1327752000000 1327752000000
252 | expect(Date.parse('2012-01-29T12:00:00.000+24:01')).toBeFalsy(); // NaN NaN NaN 1327751940000 1327751940000
253 | expect(Date.parse('2012-01-29T12:00:00.000+24:59')).toBeFalsy(); // NaN NaN NaN 1327748460000 1327748460000
254 | expect(Date.parse('2012-01-29T12:00:00.000+25:00')).toBeFalsy(); // NaN NaN NaN NaN NaN
255 | expect(Date.parse('2012-01-29T12:00:00.000+00:60')).toBeFalsy(); // NaN NaN NaN NaN NaN
256 | expect(Date.parse('-271821-04-20T00:00:00.000+00:01')).toBeFalsy(); // NaN NaN NaN -864000000006e4 -864000008646e4
257 | expect(Date.parse('-271821-04-20T00:01:00.000+00:01')).toBe(-8.64e15); // -8.64e15 NaN -8.64e15 -8.64e15 -864000008640e4
258 |
259 | // When time zone is missed, local offset should be used (ES 5.1 bug)
260 | // see https://bugs.ecmascript.org/show_bug.cgi?id=112
261 | var tzOffset = Number(new Date(1970, 0));
262 | // same as (new Date().getTimezoneOffset() * 60000)
263 | expect(Date.parse('1970-01-01T00:00:00')).toBe(tzOffset); // tzOffset 0 0 0 NaN
264 | });
265 |
266 | it('should be able to coerce to a number', function () {
267 | var actual = Number(new Date(1970, 0));
268 | var expected = parseInt(actual, 10);
269 | expect(actual).toBeDefined();
270 | expect(actual).toBe(expected);
271 | expect(isNaN(actual)).toBeFalsy();
272 | });
273 |
274 | it('matches web reality', function () {
275 | var actual = Number(new Date('1900-01-01T00:00:00.000'));
276 | var upperBound = -2208988800000; // safari 6.2 - 13.1
277 | var expected = -2208960000000;
278 |
279 | expect(actual).toBeDefined();
280 | expect(actual).toBeGreaterThan(upperBound - 1);
281 | expect(actual).toBeLessThan(expected + 1);
282 | // expect(actual).toBe(expected); // TODO: figure out if `upperBound` is a bug or just a difference
283 | expect(isNaN(actual)).toBeFalsy();
284 | });
285 | });
286 |
287 | describe('#toString()', function () {
288 | var actual;
289 |
290 | beforeEach(function () {
291 | actual = (new Date(1970, 0)).toString();
292 | });
293 |
294 | it('should show correct date info for ' + actual, function () {
295 | expect(actual).toMatch(/1970/);
296 | expect(actual).toMatch(/jan/i);
297 | expect(actual).toMatch(/thu/i);
298 | expect(actual).toMatch(/00:00:00/);
299 | });
300 | });
301 |
302 | describe('#valueOf()', function () {
303 | // Note that new Date(1970, 0).valueOf() is 0 in UTC timezone.
304 | // Check check that it's a number (and an int), not that it's "truthy".
305 | var actual;
306 |
307 | beforeEach(function () {
308 | actual = (new Date(1970, 0)).valueOf();
309 | });
310 | it('should give a numeric value', function () {
311 | expect(typeof actual).toBe('number');
312 | });
313 | it('should not be NaN', function () {
314 | expect(isNaN(actual)).toBe(false);
315 | });
316 | it('should give an int value', function () {
317 | expect(actual).toBe(Math.floor(actual));
318 | });
319 | });
320 |
321 | describe('#getUTCDate()', function () {
322 | it('should return the right value for negative dates', function () {
323 | // Opera 10.6/11.61/Opera 12 bug
324 | negativeDate.forEach(function (item) {
325 | item.dates.forEach(function (date, index) {
326 | expect(date.getUTCDate()).toBe(item.days[index], date);
327 | });
328 | });
329 | });
330 | });
331 |
332 | describe('#getUTCDay()', function () {
333 | it('should return the right value for negative dates', function () {
334 | negativeDate.forEach(function (item) {
335 | item.dates.forEach(function (date, index) {
336 | expect(date.getUTCDay()).toBe(item.getUTCDay[index]);
337 | });
338 | });
339 | });
340 | });
341 |
342 | describe('#getUTCFullYear()', function () {
343 | it('should return the right value for negative dates', function () {
344 | // Opera 10.6/11.61/Opera 12 bug
345 | negativeDate.forEach(function (item) {
346 | item.dates.forEach(function (date) {
347 | expect(date.getUTCFullYear()).toBe(-109252);
348 | });
349 | });
350 | });
351 | });
352 |
353 | describe('#getUTCMonth()', function () {
354 | it('should return the right value for negative dates', function () {
355 | // Opera 10.6/11.61/Opera 12 bug
356 | negativeDate.forEach(function (item, index) {
357 | item.dates.forEach(function (date) {
358 | expect(date.getUTCMonth()).toBe(index);
359 | });
360 | });
361 | });
362 |
363 | it('should return correct values', function () {
364 | expect(new Date(8.64e15).getUTCMonth()).toBe(8);
365 | expect(new Date(0).getUTCMonth()).toBe(0);
366 | });
367 | });
368 |
369 | describe('#getUTCHours()', function () {
370 | it('should return the right value for negative dates', function () {
371 | negativeDate.forEach(function (item) {
372 | item.dates.forEach(function (date) {
373 | expect(date.getUTCHours()).toBe(11);
374 | });
375 | });
376 | });
377 | });
378 |
379 | describe('#getUTCMinutes()', function () {
380 | it('should return the right value for negative dates', function () {
381 | negativeDate.forEach(function (item) {
382 | item.dates.forEach(function (date) {
383 | expect(date.getUTCMinutes()).toBe(59);
384 | });
385 | });
386 | });
387 | });
388 |
389 | describe('#getUTCSeconds()', function () {
390 | it('should return the right value for negative dates', function () {
391 | negativeDate.forEach(function (item) {
392 | item.dates.forEach(function (date) {
393 | expect(date.getUTCSeconds()).toBe(59);
394 | });
395 | });
396 | });
397 | });
398 |
399 | describe('#getUTCMilliseconds()', function () {
400 | it('should return the right value for negative dates', function () {
401 | // Opera 10.6/11.61/Opera 12 bug
402 | negativeDate.forEach(function (item) {
403 | item.dates.forEach(function (date) {
404 | expect(date.getUTCMilliseconds()).toBe(708);
405 | });
406 | });
407 | });
408 | });
409 |
410 | describe('#getDate()', function () {
411 | it('should return the right value for negative dates', function () {
412 | negativeDate.forEach(function (item) {
413 | item.dates.forEach(function (date, index) {
414 | expect(date.getDate()).toBe(item.days[index]);
415 | });
416 | });
417 | });
418 | });
419 |
420 | describe('#getDay()', function () {
421 | it('should return the right value for negative dates', function () {
422 | negativeDate.forEach(function (item) {
423 | item.dates.forEach(function (date, index) {
424 | expect(date.getDay()).toBe(item.getDay[index]);
425 | });
426 | });
427 | });
428 | });
429 |
430 | describe('#getFullYear()', function () {
431 | it('should return the right value for negative dates', function () {
432 | // Opera 10.6/11.61/Opera 12 bug
433 | negativeDate.forEach(function (item) {
434 | item.dates.forEach(function (date) {
435 | expect(date.getFullYear()).toBe(-109252);
436 | });
437 | });
438 | });
439 | });
440 |
441 | describe('#getMonth()', function () {
442 | it('should return the right value for negative dates', function () {
443 | // Opera 10.6/11.61/Opera 12 bug
444 | negativeDate.forEach(function (item, index) {
445 | item.dates.forEach(function (date) {
446 | expect(date.getMonth()).toBe(index);
447 | });
448 | });
449 | });
450 | });
451 |
452 | describe('#getHours()', function () {
453 | it('should return the right value for negative dates', function () {
454 | negativeDate.forEach(function (item) {
455 | item.dates.forEach(function (date) {
456 | expect(date.getHours() + Math.floor(date.getTimezoneOffset() / 60)).toBe(11);
457 | });
458 | });
459 | });
460 | });
461 |
462 | describe('#getMinutes()', function () {
463 | it('should return the right value for negative dates', function () {
464 | negativeDate.forEach(function (item) {
465 | item.dates.forEach(function (date) {
466 | var off = date.getTimezoneOffset();
467 | var offHours = Math.floor(off / 60);
468 | var offMins = off - (offHours * 60);
469 | var result = date.getMinutes() + offMins;
470 | // ceil/floor is for Firefox
471 | expect(result < 0 ? Math.ceil(result) : Math.floor(result)).toBe(59);
472 | });
473 | });
474 | });
475 | });
476 |
477 | describe('#getSeconds()', function () {
478 | it('should return the right value for negative dates', function () {
479 | negativeDate.forEach(function (item) {
480 | item.dates.forEach(function (date, i) {
481 | // the regex here is because in UTC, it's 59, but with TZData applied,
482 | // which can have fractional hour offsets, it'll be 1.
483 | expect(i + ':' + date.getSeconds()).toMatch(new RegExp(i + ':(?:' + 59 + '|' + 1 + ')'));
484 | });
485 | });
486 | });
487 | });
488 |
489 | describe('#getMilliseconds()', function () {
490 | it('should return the right value for negative dates', function () {
491 | // Opera 10.6/11.61/Opera 12 bug
492 | negativeDate.forEach(function (item) {
493 | item.dates.forEach(function (date) {
494 | expect(date.getMilliseconds()).toBe(708);
495 | });
496 | });
497 | });
498 | });
499 |
500 | describe('#toISOString()', function () {
501 | // TODO: write the rest of the test.
502 |
503 | it('should support extended years', function () {
504 | expect(new Date(-62198755200000).toISOString().indexOf('-000001-01-01')).toBe(0);
505 | expect(new Date(8.64e15).toISOString().indexOf('+275760-09-13')).toBe(0);
506 | });
507 |
508 | it('should return correct dates', function () {
509 | expect(new Date(-1).toISOString()).toBe('1969-12-31T23:59:59.999Z'); // Safari 5.1.5 "1969-12-31T23:59:59.-01Z"
510 | negativeDate.forEach(function (item, index) {
511 | var m = index + 1;
512 | item.dates.forEach(function (date, idx) {
513 | var d = item.days[idx];
514 | expect(date.toISOString()).toBe('-109252-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + 'T11:59:59.708Z'); // Opera 11.61/Opera 12 bug with Date#getUTCMonth
515 | });
516 | });
517 | });
518 |
519 | });
520 |
521 | describe('#toUTCString()', function () {
522 | it('should return correct dates', function () {
523 | expect(new Date(-1509842289600292).toUTCString()).toBe('Mon, 01 Jan -45875 11:59:59 GMT');
524 | });
525 | });
526 |
527 | describe('#toDateString()', function () {
528 | it('should return correct dates', function () {
529 | expect(new Date(-1509842289600292).toDateString()).toBe('Mon Jan 01 -45875');
530 | });
531 | });
532 |
533 | describe('#toString()', function () {
534 | it('should return correct dates', function () {
535 | var actual = new Date(1449662400000).toString();
536 | var re = /^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/;
537 | expect(re.test(actual)).toBe(true, actual);
538 | });
539 | });
540 |
541 | describe('#toJSON()', function () {
542 |
543 | // Opera 11.6x/12 bug
544 | it('should call toISOString', function () {
545 | var date = new Date(0);
546 | date.toISOString = function () {
547 | return 1;
548 | };
549 | expect(date.toJSON()).toBe(1);
550 | });
551 |
552 | it('should return null for not finite dates', function () {
553 | var date = new Date(NaN),
554 | json;
555 | try {
556 | json = date.toJSON();
557 | } catch (e) {
558 | /* invalid json */
559 | expect(e).not.toEqual(jasmine.any(Error));
560 | }
561 | expect(json).toBe(null);
562 | });
563 |
564 | it('should return the isoString when stringified', function () {
565 | var date = new Date();
566 | expect(JSON.stringify(date.toISOString())).toBe(JSON.stringify(date));
567 | });
568 | });
569 |
570 | });
571 |
--------------------------------------------------------------------------------
/tests/spec/s-error.js:
--------------------------------------------------------------------------------
1 | describe('Error', function () {
2 | 'use strict';
3 |
4 | var supportsDescriptors = Object.defineProperty && (function () {
5 | try {
6 | var obj = {};
7 | Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
8 | // eslint-disable-next-line no-unreachable-loop
9 | for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables
10 | return obj.x === obj;
11 | } catch (e) { /* this is ES3 */
12 | return false;
13 | }
14 | }());
15 | var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit;
16 |
17 | describe('#toString()', function () {
18 | it('stringifies a newed error properly', function () {
19 | var msg = 'test';
20 | var error = new RangeError(msg);
21 | expect(error.name).toBe('RangeError');
22 | expect(error.message).toBe(msg);
23 | expect(String(error)).toBe(error.name + ': ' + msg);
24 | });
25 |
26 | it('stringifies a thrown error properly', function () {
27 | var msg = 'test';
28 | var error;
29 | try {
30 | throw new RangeError(msg);
31 | } catch (e) {
32 | error = e;
33 | }
34 | expect(error.name).toBe('RangeError');
35 | expect(error.message).toBe(msg);
36 | expect(String(error)).toBe(error.name + ': ' + msg);
37 | });
38 | });
39 |
40 | describe('enumerability of prototype properties', function () {
41 | ifSupportsDescriptorsIt('#message', function () {
42 | expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'message')).toBe(false);
43 | });
44 |
45 | ifSupportsDescriptorsIt('#name', function () {
46 | expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'name')).toBe(false);
47 | });
48 | });
49 | });
50 |
--------------------------------------------------------------------------------
/tests/spec/s-function.js:
--------------------------------------------------------------------------------
1 | describe('Function', function () {
2 | 'use strict';
3 |
4 | describe('#apply()', function () {
5 | it('works with arraylike objects', function () {
6 | var arrayLike = { length: 4, 0: 1, 2: 4, 3: true };
7 | var expectedArray = [1, undefined, 4, true];
8 | var actualArray = (function () {
9 | return Array.prototype.slice.apply(arguments);
10 | }.apply(null, arrayLike));
11 | expect(actualArray).toEqual(expectedArray);
12 | });
13 | });
14 |
15 | describe('#bind()', function () {
16 | var actual;
17 |
18 | var testSubject = {
19 | push: function (o) {
20 | this.a.push(o);
21 | }
22 | };
23 |
24 | var func = function func() {
25 | Array.prototype.forEach.call(arguments, function (a) {
26 | this.push(a);
27 | }, this);
28 | return this;
29 | };
30 |
31 | beforeEach(function () {
32 | actual = [];
33 | testSubject.a = [];
34 | });
35 |
36 | it('binds properly without a context', function () {
37 | var context;
38 | testSubject.func = function () {
39 | context = this;
40 | }.bind();
41 | testSubject.func();
42 | expect(context).toBe(function () { return this; }.call());
43 | });
44 | it('binds properly without a context, and still supplies bound arguments', function () {
45 | var a, context;
46 | testSubject.func = function () {
47 | a = Array.prototype.slice.call(arguments);
48 | context = this;
49 | }.bind(undefined, 1, 2, 3);
50 | testSubject.func(1, 2, 3);
51 | expect(a).toEqual([1, 2, 3, 1, 2, 3]);
52 | expect(context).toBe(function () { return this; }.call());
53 | });
54 | it('binds a context properly', function () {
55 | testSubject.func = func.bind(actual);
56 | testSubject.func(1, 2, 3);
57 | expect(actual).toEqual([1, 2, 3]);
58 | expect(testSubject.a).toEqual([]);
59 | });
60 | it('binds a context and supplies bound arguments', function () {
61 | testSubject.func = func.bind(actual, 1, 2, 3);
62 | testSubject.func(4, 5, 6);
63 | expect(actual).toEqual([1, 2, 3, 4, 5, 6]);
64 | expect(testSubject.a).toEqual([]);
65 | });
66 |
67 | it('returns properly without binding a context', function () {
68 | testSubject.func = function () {
69 | return this;
70 | }.bind();
71 | var context = testSubject.func();
72 | expect(context).toBe(function () { return this; }.call());
73 | });
74 | it('returns properly without binding a context, and still supplies bound arguments', function () {
75 | var context;
76 | testSubject.func = function () {
77 | context = this;
78 | return Array.prototype.slice.call(arguments);
79 | }.bind(undefined, 1, 2, 3);
80 | actual = testSubject.func(1, 2, 3);
81 | expect(context).toBe(function () { return this; }.call());
82 | expect(actual).toEqual([1, 2, 3, 1, 2, 3]);
83 | });
84 | it('returns properly while binding a context properly', function () {
85 | var ret;
86 | testSubject.func = func.bind(actual);
87 | ret = testSubject.func(1, 2, 3);
88 | expect(ret).toBe(actual);
89 | expect(ret).not.toBe(testSubject);
90 | });
91 | it('returns properly while binding a context and supplies bound arguments', function () {
92 | var ret;
93 | testSubject.func = func.bind(actual, 1, 2, 3);
94 | ret = testSubject.func(4, 5, 6);
95 | expect(ret).toBe(actual);
96 | expect(ret).not.toBe(testSubject);
97 | });
98 | it('has the new instance\'s context as a constructor', function () {
99 | var actualContext;
100 | var expectedContext = { foo: 'bar' };
101 | testSubject.Func = function () {
102 | actualContext = this;
103 | }.bind(expectedContext);
104 | var result = new testSubject.Func();
105 | expect(result).toBeTruthy();
106 | expect(actualContext).not.toBe(expectedContext);
107 | });
108 | it('passes the correct arguments as a constructor', function () {
109 | var expected = { name: 'Correct' };
110 | testSubject.Func = function (arg) {
111 | expect(Object.prototype.hasOwnProperty.call(this, 'name')).toBe(false);
112 | return arg;
113 | }.bind({ name: 'Incorrect' });
114 | var ret = new testSubject.Func(expected);
115 | expect(ret).toBe(expected);
116 | });
117 | it('returns the return value of the bound function when called as a constructor', function () {
118 | var oracle = [1, 2, 3];
119 | var Subject = function () {
120 | expect(this).not.toBe(oracle);
121 | return oracle;
122 | }.bind(null);
123 | var result = new Subject();
124 | expect(result).toBe(oracle);
125 | });
126 |
127 | it('returns the correct value if constructor returns primitive', function () {
128 | var Subject = function (oracle) {
129 | expect(this).not.toBe(oracle);
130 | return oracle;
131 | }.bind(null);
132 |
133 | var primitives = ['asdf', null, true, 1];
134 | for (var i = 0; i < primitives.length; ++i) {
135 | expect(new Subject(primitives[i])).not.toBe(primitives[i]);
136 | }
137 |
138 | var objects = [[1, 2, 3], {}, function () {}];
139 | for (var j = 0; j < objects.length; ++j) {
140 | expect(new Subject(objects[j])).toBe(objects[j]);
141 | }
142 | });
143 | it('returns the value that instance of original "class" when called as a constructor', function () {
144 | var ClassA = function (x) {
145 | this.name = x || 'A';
146 | };
147 | var ClassB = ClassA.bind(null, 'B');
148 |
149 | var result = new ClassB();
150 | expect(result instanceof ClassA).toBe(true);
151 | expect(result instanceof ClassB).toBe(true);
152 | });
153 | it('sets a correct length without thisArg', function () {
154 | var Subject = function (a, b, c) { return a + b + c; }.bind();
155 | expect(Subject.length).toBe(3);
156 | });
157 | it('sets a correct length with thisArg', function () {
158 | var Subject = function (a, b, c) { return a + b + c + this.d; }.bind({ d: 1 });
159 | expect(Subject.length).toBe(3);
160 | });
161 | it('sets a correct length with thisArg and first argument', function () {
162 | var Subject = function (a, b, c) { return a + b + c + this.d; }.bind({ d: 1 }, 1);
163 | expect(Subject.length).toBe(2);
164 | });
165 | it('sets a correct length without thisArg and first argument', function () {
166 | var Subject = function (a, b, c) { return a + b + c; }.bind(undefined, 1);
167 | expect(Subject.length).toBe(2);
168 | });
169 | it('sets a correct length without thisArg and too many argument', function () {
170 | var Subject = function (a, b, c) { return a + b + c; }.bind(undefined, 1, 2, 3, 4);
171 | expect(Subject.length).toBe(0);
172 | });
173 | });
174 | });
175 |
--------------------------------------------------------------------------------
/tests/spec/s-global.js:
--------------------------------------------------------------------------------
1 | describe('global methods', function () {
2 | 'use strict';
3 |
4 | var foo = function foo() {};
5 | var functionsHaveNames = foo.name === 'foo';
6 | var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
7 | var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
8 | var ifSymbolsIt = hasSymbols ? it : xit;
9 |
10 | var is = function (x, y) {
11 | if (x === 0 && y === 0) {
12 | return 1 / x === 1 / y;
13 | }
14 | return x === y;
15 | };
16 |
17 | describe('parseInt', function () {
18 | /* eslint-disable radix */
19 |
20 | ifFunctionsHaveNamesIt('has the right name', function () {
21 | expect(parseInt.name).toBe('parseInt');
22 | });
23 |
24 | it('accepts a radix', function () {
25 | for (var i = 2; i <= 36; ++i) {
26 | expect(parseInt('10', i)).toBe(i);
27 | }
28 | });
29 |
30 | it('defaults the radix to 10 when the number does not start with 0x or 0X', function () {
31 | [
32 | '01',
33 | '08',
34 | '10',
35 | '42'
36 | ].forEach(function (str) {
37 | expect(parseInt(str)).toBe(parseInt(str, 10));
38 | });
39 | });
40 |
41 | it('defaults the radix to 16 when the number starts with 0x or 0X', function () {
42 | expect(parseInt('0x16')).toBe(parseInt('0x16', 16));
43 | expect(parseInt('0X16')).toBe(parseInt('0X16', 16));
44 | });
45 |
46 | it('ignores leading whitespace', function () {
47 | expect(parseInt(' 0x16')).toBe(parseInt('0x16', 16));
48 | expect(parseInt(' 42')).toBe(parseInt('42', 10));
49 | expect(parseInt(' 08')).toBe(parseInt('08', 10));
50 |
51 | var mvsIsWS = (/\s/).test('\u180E');
52 | if (mvsIsWS) {
53 | expect(parseInt('\u180E' + 1)).toBe(1);
54 | } else {
55 | expect(parseInt('\u180E' + 1)).toBeNaN();
56 | }
57 |
58 | var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'
59 | .replace(/\S/g, ''); // remove the mongolian vowel separator (/u180E) on modern engines
60 | expect(parseInt(ws + '08')).toBe(parseInt('08', 10));
61 | expect(parseInt(ws + '0x16')).toBe(parseInt('0x16', 16));
62 | });
63 |
64 | it('defaults the radix properly when not a true number', function () {
65 | var fakeZero = { valueOf: function () { return 0; } };
66 | expect(parseInt('08', fakeZero)).toBe(parseInt('08', 10));
67 | expect(parseInt('0x16', fakeZero)).toBe(parseInt('0x16', 16));
68 | });
69 |
70 | it('allows sign-prefixed hex values', function () {
71 | expect(parseInt('-0xF')).toBe(-15);
72 | expect(parseInt('-0xF', 16)).toBe(-15);
73 | expect(parseInt('+0xF')).toBe(15);
74 | expect(parseInt('+0xF', 16)).toBe(15);
75 | });
76 |
77 | it('NaN parsing', function () {
78 | expect(parseInt()).toBeNaN();
79 | expect(parseInt(undefined)).toBeNaN();
80 | expect(parseInt(null)).toBeNaN();
81 | expect(parseInt(NaN)).toBeNaN();
82 | });
83 |
84 | ifSymbolsIt('throws on symbols', function () {
85 | expect(function () { parseInt(Symbol('')); }).toThrow();
86 | expect(function () { parseInt(Object(Symbol(''))); }).toThrow();
87 | });
88 | /* eslint-enable radix */
89 | });
90 |
91 | describe('parseFloat()', function () {
92 | it('works with zeroes', function () {
93 | expect(is(parseFloat('0'), 0) ? '+0' : '-0').toBe('+0');
94 | expect(is(parseFloat(' 0'), 0) ? '+0' : '-0').toBe('+0');
95 | expect(is(parseFloat('+0'), 0) ? '+0' : '-0').toBe('+0');
96 | expect(is(parseFloat(' +0'), 0) ? '+0' : '-0').toBe('+0');
97 | expect(is(parseFloat('-0'), -0) ? '-0' : '+0').toBe('-0');
98 | expect(is(parseFloat(' -0'), -0) ? '-0' : '+0').toBe('-0');
99 | });
100 |
101 | it('NaN parsing', function () {
102 | expect(parseFloat(undefined)).toBeNaN();
103 | expect(parseFloat(null)).toBeNaN();
104 | expect(parseFloat(NaN)).toBeNaN();
105 | });
106 | });
107 | });
108 |
--------------------------------------------------------------------------------
/tests/spec/s-number.js:
--------------------------------------------------------------------------------
1 | describe('Number', function () {
2 | 'use strict';
3 |
4 | describe('#toExponential()', function () {
5 | // the spec allows for this test to fail.
6 | it('throws a RangeError when < 0 or > 20 (or > 100 in ES2018+)', function () {
7 | expect(function () { return 1.0.toExponential(-1); }).toThrow();
8 | expect(function () { return 1.0.toExponential(-Infinity); }).toThrow();
9 | expect(function () { return 1.0.toExponential(Infinity); }).toThrow();
10 | expect(function () {
11 | return [
12 | (0.9).toExponential(21), // ES2018 increased the limit from 21 to 100
13 | (0.9).toExponential(101)
14 | ];
15 | }).toThrow();
16 | });
17 |
18 | it('works for NaN receiver', function () {
19 | expect(NaN.toExponential(NaN)).toBe('NaN');
20 | expect(NaN.toExponential('abc')).toBe('NaN');
21 | });
22 |
23 | it('works for non-finite receivers', function () {
24 | expect(Infinity.toExponential()).toBe('Infinity');
25 | expect((-Infinity).toExponential()).toBe('-Infinity');
26 | });
27 |
28 | it('should round properly', function () {
29 | expect(1.0.toExponential()).toBe('1e+0');
30 | expect(1.0.toExponential(0)).toBe('1e+0');
31 | expect(1.0.toExponential(1)).toBe('1.0e+0');
32 | expect(1.0.toExponential(2)).toBe('1.00e+0');
33 |
34 | expect(1.2345.toExponential()).toBe('1.2345e+0');
35 | expect(1.2345.toExponential(0)).toBe('1e+0');
36 | expect(1.2345.toExponential(1)).toBe('1.2e+0');
37 | expect(1.2345.toExponential(2)).toBe('1.23e+0');
38 | expect(1.2345.toExponential(3)).toMatch(/^1.23[45]e\+0$/);
39 | expect(1.2345.toExponential(4)).toBe('1.2345e+0');
40 | expect(1.2345.toExponential(5)).toBe('1.23450e+0');
41 |
42 | expect((-6.9e-11).toExponential(4)).toBe('-6.9000e-11');
43 | });
44 | });
45 |
46 | describe('#toFixed()', function () {
47 | it('should convert numbers correctly', function () {
48 | expect((0.00008).toFixed(3)).toBe('0.000');
49 | expect((0.9).toFixed(0)).toBe('1');
50 | expect((1.255).toFixed(2)).toBe('1.25');
51 | expect((1843654265.0774949).toFixed(5)).toBe('1843654265.07749');
52 | expect((1000000000000000128).toFixed(0)).toBe('1000000000000000128');
53 | });
54 | });
55 |
56 | describe('#toPrecision()', function () {
57 | // the spec allows for this test to fail.
58 | it('throws a RangeError when < 1 or > 21 (or > 100 in ES2018+)', function () {
59 | expect(function () { return (0.9).toPrecision(0); }).toThrow();
60 | expect(function () {
61 | return [
62 | (0.9).toPrecision(22), // ES2018 increased the limit from 21 to 100
63 | (0.9).toPrecision(101)
64 | ];
65 | }).toThrow();
66 | });
67 |
68 | it('works as expected', function () {
69 | expect((0.00008).toPrecision(3)).toBe('0.0000800');
70 | expect((1.255).toPrecision(2)).toBe('1.3');
71 | expect((1843654265.0774949).toPrecision(13)).toBe('1843654265.077');
72 | expect(NaN.toPrecision(1)).toBe('NaN');
73 | });
74 |
75 | it('works with an undefined precision', function () {
76 | var num = 123.456;
77 | expect(num.toPrecision()).toBe(String(num));
78 | expect(num.toPrecision(undefined)).toBe(String(num));
79 | });
80 | });
81 |
82 | describe('constants', function () {
83 | it('should have MAX_VALUE', function () {
84 | expect(Number.MAX_VALUE).toBe(1.7976931348623157e308);
85 | });
86 |
87 | it('should have MIN_VALUE', function () {
88 | expect(Number.MIN_VALUE).toBe(5e-324);
89 | });
90 |
91 | it('should have NaN', function () {
92 | expect(Number.NaN).not.toBe(Number.NaN);
93 | });
94 |
95 | it('should have POSITIVE_INFINITY', function () {
96 | expect(Number.POSITIVE_INFINITY).toBe(Infinity);
97 | });
98 |
99 | it('should have NEGATIVE_INFINITY', function () {
100 | expect(Number.NEGATIVE_INFINITY).toBe(-Infinity);
101 | });
102 | });
103 | });
104 |
--------------------------------------------------------------------------------
/tests/spec/s-object.js:
--------------------------------------------------------------------------------
1 | /* global window */
2 |
3 | var has = Object.prototype.hasOwnProperty;
4 | var supportsDescriptors = Object.defineProperty && (function () {
5 | try {
6 | var obj = {};
7 | Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
8 | // eslint-disable-next-line no-unreachable-loop
9 | for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables
10 | return obj.x === obj;
11 | } catch (e) { /* this is ES3 */
12 | return false;
13 | }
14 | }());
15 | var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit;
16 | var ifWindowIt = typeof window === 'undefined' ? xit : it;
17 | var extensionsPreventible = typeof Object.preventExtensions === 'function' && (function () {
18 | var obj = {};
19 | Object.preventExtensions(obj);
20 | obj.a = 3;
21 | return obj.a !== 3;
22 | }());
23 | var ifExtensionsPreventibleIt = extensionsPreventible ? it : xit;
24 | var canSeal = typeof Object.seal === 'function' && (function () {
25 | var obj = { a: 3 };
26 | Object.seal(obj);
27 | delete obj.a;
28 | return obj.a === 3;
29 | }());
30 | var ifCanSealIt = canSeal ? it : xit;
31 | var canFreeze = typeof Object.freeze === 'function' && (function () {
32 | var obj = {};
33 | Object.freeze(obj);
34 | obj.a = 3;
35 | return obj.a !== 3;
36 | }());
37 | var ifCanFreezeIt = canFreeze ? it : xit;
38 |
39 | describe('Object', function () {
40 | 'use strict';
41 |
42 | describe('.keys()', function () {
43 | var obj = {
44 | str: 'boz',
45 | obj: { },
46 | arr: [],
47 | bool: true,
48 | num: 42,
49 | 'null': null,
50 | undefined: undefined
51 | };
52 |
53 | var loopedValues = [];
54 | for (var key in obj) {
55 | loopedValues.push(key);
56 | }
57 |
58 | var keys = Object.keys(obj);
59 | it('should have correct length', function () {
60 | expect(keys.length).toBe(7);
61 | });
62 |
63 | describe('arguments objects', function () {
64 | it('works with an arguments object', function () {
65 | (function () {
66 | expect(arguments.length).toBe(3);
67 | expect(Object.keys(arguments).length).toBe(arguments.length);
68 | expect(Object.keys(arguments)).toEqual(['0', '1', '2']);
69 | }(1, 2, 3));
70 | });
71 |
72 | it('works with a legacy arguments object', function () {
73 | var FakeArguments = function (args) {
74 | args.forEach(function (arg, i) {
75 | this[i] = arg;
76 | }.bind(this));
77 | };
78 | FakeArguments.prototype.length = 3;
79 | FakeArguments.prototype.callee = function () {};
80 |
81 | var fakeOldArguments = new FakeArguments(['a', 'b', 'c']);
82 | expect(Object.keys(fakeOldArguments)).toEqual(['0', '1', '2']);
83 | });
84 | });
85 |
86 | it('should return an Array', function () {
87 | expect(Array.isArray(keys)).toBe(true);
88 | });
89 |
90 | it('should return names which are own properties', function () {
91 | keys.forEach(function (name) {
92 | expect(has.call(obj, name)).toBe(true);
93 | });
94 | });
95 |
96 | it('should return names which are enumerable', function () {
97 | keys.forEach(function (name) {
98 | expect(loopedValues.indexOf(name)).toNotBe(-1);
99 | });
100 | });
101 |
102 | // ES6 Object.keys does not require this throw
103 | xit('should throw error for non object', function () {
104 | var e = {};
105 | expect(function () {
106 | try {
107 | Object.keys(42);
108 | } catch (err) {
109 | throw e;
110 | }
111 | }).toThrow(e);
112 | });
113 |
114 | describe('enumerating over non-enumerable properties', function () {
115 | it('has no enumerable keys on a Function', function () {
116 | var Foo = function () {};
117 | expect(Object.keys(Foo.prototype)).toEqual([]);
118 | });
119 |
120 | it('has no enumerable keys on a boolean', function () {
121 | expect(Object.keys(Boolean.prototype)).toEqual([]);
122 | });
123 |
124 | it('has no enumerable keys on an object', function () {
125 | expect(Object.keys(Object.prototype)).toEqual([]);
126 | });
127 | });
128 |
129 | it('works with boxed primitives', function () {
130 | expect(Object.keys(Object('hello'))).toEqual(['0', '1', '2', '3', '4']);
131 | });
132 |
133 | it('works with boxed primitives with extra properties', function () {
134 | var x = Object('x');
135 | x.y = 1;
136 | var actual = Object.keys(x);
137 | var expected = ['0', 'y'];
138 | actual.sort();
139 | expected.sort();
140 | expect(actual).toEqual(expected);
141 | });
142 |
143 | ifWindowIt('can serialize all objects on the `window`', function () {
144 | var windowItemKeys, exception;
145 | var excludedKeys = ['window', 'console', 'parent', 'self', 'frame', 'frames', 'frameElement', 'external', 'height', 'width', 'top', 'localStorage', 'applicationCache'];
146 | if (supportsDescriptors) {
147 | Object.defineProperty(window, 'thrower', {
148 | configurable: true,
149 | get: function () { throw new RangeError('thrower!'); }
150 | });
151 | }
152 | for (var k in window) {
153 | exception = void 0;
154 | windowItemKeys = exception;
155 | if (excludedKeys.indexOf(k) === -1 && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
156 | try {
157 | windowItemKeys = Object.keys(window[k]);
158 | } catch (e) {
159 | exception = e;
160 | }
161 | expect(Array.isArray(windowItemKeys)).toBe(true);
162 | expect(exception).toBeUndefined();
163 | }
164 | }
165 | if (supportsDescriptors) {
166 | delete window.thrower;
167 | }
168 | });
169 | });
170 |
171 | describe('.isExtensible()', function () {
172 | var obj = { };
173 |
174 | it('should return true if object is extensible', function () {
175 | expect(Object.isExtensible(obj)).toBe(true);
176 | });
177 |
178 | ifExtensionsPreventibleIt('should return false if object is not extensible', function () {
179 | expect(Object.isExtensible(Object.preventExtensions(obj))).toBe(false);
180 | });
181 |
182 | ifCanSealIt('should return false if object is sealed', function () {
183 | expect(Object.isExtensible(Object.seal(obj))).toBe(false);
184 | });
185 |
186 | ifCanFreezeIt('should return false if object is frozen', function () {
187 | expect(Object.isExtensible(Object.freeze(obj))).toBe(false);
188 | });
189 |
190 | it('should throw error for non object', function () {
191 | try {
192 | // note: in ES6, this is expected to return false.
193 | expect(Object.isExtensible(42)).toBe(false);
194 | } catch (err) {
195 | expect(err).toEqual(jasmine.any(TypeError));
196 | }
197 | });
198 | });
199 |
200 | describe('.defineProperty()', function () {
201 | var obj;
202 |
203 | beforeEach(function () {
204 | obj = {};
205 |
206 | Object.defineProperty(obj, 'name', {
207 | value: 'Testing',
208 | configurable: true,
209 | enumerable: true,
210 | writable: true
211 | });
212 | });
213 |
214 | it('should return the initial value', function () {
215 | expect(has.call(obj, 'name')).toBeTruthy();
216 | expect(obj.name).toBe('Testing');
217 | });
218 |
219 | it('should be setable', function () {
220 | obj.name = 'Other';
221 | expect(obj.name).toBe('Other');
222 | });
223 |
224 | it('should return the parent initial value', function () {
225 | var child = Object.create(obj, {});
226 |
227 | expect(child.name).toBe('Testing');
228 | expect(has.call(child, 'name')).toBeFalsy();
229 | });
230 |
231 | it('should not override the parent value', function () {
232 | var child = Object.create(obj, {});
233 |
234 | Object.defineProperty(child, 'name', { value: 'Other' });
235 |
236 | expect(obj.name).toBe('Testing');
237 | expect(child.name).toBe('Other');
238 | });
239 |
240 | it('should throw error for non object', function () {
241 | expect(function () {
242 | Object.defineProperty(42, 'name', {});
243 | }).toThrow();
244 | });
245 |
246 | it('should not throw error for empty descriptor', function () {
247 | expect(function () {
248 | Object.defineProperty({}, 'name', {});
249 | }).not.toThrow();
250 | });
251 |
252 | ifSupportsDescriptorsIt('allows setting a nonwritable prototype', function () {
253 | var F = function () {};
254 | expect(F.prototype).toEqual(Object.getOwnPropertyDescriptor(F, 'prototype').value);
255 | expect((new F()).toString).toEqual(Object.prototype.toString);
256 |
257 | F.prototype = Number.prototype;
258 | expect(F.prototype).toEqual(Object.getOwnPropertyDescriptor(F, 'prototype').value);
259 | expect((new F()).toString).toEqual(Number.prototype.toString);
260 |
261 | var toStringSentinel = {};
262 | var sentinel = { toString: toStringSentinel };
263 | Object.defineProperty(F, 'prototype', { value: sentinel, writable: false });
264 |
265 | expect(F.prototype).toEqual(Object.getOwnPropertyDescriptor(F, 'prototype').value);
266 | expect((new F()).toString).toEqual(toStringSentinel);
267 | });
268 |
269 | ifSupportsDescriptorsIt('properly makes a prototype non-writable', function () {
270 | var O = { prototype: 1 };
271 | expect(O.prototype).toEqual(Object.getOwnPropertyDescriptor(O, 'prototype').value);
272 | expect(O.prototype).toEqual(1);
273 |
274 | expect(function () {
275 | Object.defineProperty(O, 'prototype', { writable: false, configurable: true });
276 | }).not.toThrow();
277 |
278 | var sentinel = {};
279 | expect(function () {
280 | Object.defineProperty(O, 'prototype', { value: sentinel });
281 | }).not.toThrow();
282 |
283 | expect(O.prototype).toEqual(Object.getOwnPropertyDescriptor(O, 'prototype').value);
284 | expect(O.prototype).toEqual(sentinel);
285 | });
286 | });
287 |
288 | describe('.getOwnPropertyDescriptor()', function () {
289 | it('should return undefined because the object does not own the property', function () {
290 | var descr = Object.getOwnPropertyDescriptor({}, 'name');
291 |
292 | expect(descr).toBeUndefined();
293 | });
294 |
295 | it('should return a data descriptor', function () {
296 | var descr = Object.getOwnPropertyDescriptor({ name: 'Testing' }, 'name');
297 | var expected = {
298 | value: 'Testing',
299 | enumerable: true,
300 | writable: true,
301 | configurable: true
302 | };
303 |
304 | expect(descr).toEqual(expected);
305 | });
306 |
307 | it('should return undefined because the object does not own the property', function () {
308 | var descr = Object.getOwnPropertyDescriptor(Object.create({ name: 'Testing' }, {}), 'name');
309 |
310 | expect(descr).toBeUndefined();
311 | });
312 |
313 | it('should return a data descriptor', function () {
314 | var expected = {
315 | value: 'Testing',
316 | configurable: true,
317 | enumerable: true,
318 | writable: true
319 | };
320 | var obj = Object.create({}, { name: expected });
321 |
322 | var descr = Object.getOwnPropertyDescriptor(obj, 'name');
323 |
324 | expect(descr).toEqual(expected);
325 | });
326 |
327 | it('should throw error for non object', function () {
328 | try {
329 | // note: in ES6, we expect this to return undefined.
330 | expect(Object.getOwnPropertyDescriptor(42, 'name')).toBeUndefined();
331 | } catch (err) {
332 | expect(err).toEqual(jasmine.any(TypeError));
333 | }
334 | });
335 | });
336 |
337 | describe('.getPrototypeOf()', function () {
338 | it('should return the [[Prototype]] of an object', function () {
339 | var Foo = function () {};
340 |
341 | var proto = Object.getPrototypeOf(new Foo());
342 |
343 | expect(proto).toBe(Foo.prototype);
344 | });
345 |
346 | it('should shamone to the `Object.prototype` if `object.constructor` is not a function', function () {
347 | var Foo = function () {};
348 | Foo.prototype.constructor = 1;
349 |
350 | var proto = Object.getPrototypeOf(new Foo()),
351 | fnToString = Function.prototype.toString;
352 |
353 | if (fnToString.call(Object.getPrototypeOf).indexOf('[native code]') < 0) {
354 | expect(proto).toBe(Object.prototype);
355 | } else {
356 | expect(proto).toBe(Foo.prototype);
357 | }
358 | });
359 |
360 | it('should throw error for non object', function () {
361 | try {
362 | expect(Object.getPrototypeOf(1)).toBe(Number.prototype); // ES6 behavior
363 | } catch (err) {
364 | expect(err).toEqual(jasmine.any(TypeError));
365 | }
366 | });
367 |
368 | it('should return null on Object.create(null)', function () {
369 | var obj = Object.create(null);
370 |
371 | expect(Object.getPrototypeOf(obj) === null).toBe(true);
372 | });
373 | });
374 |
375 | describe('.defineProperties()', function () {
376 | it('should define the constructor property', function () {
377 | var target = {};
378 | var newProperties = { constructor: { value: 'new constructor' } };
379 | Object.defineProperties(target, newProperties);
380 | expect(target.constructor).toBe('new constructor');
381 | });
382 | });
383 |
384 | describe('.create()', function () {
385 | it('should create objects with no properties when called as `Object.create(null)`', function () {
386 | var obj = Object.create(null);
387 |
388 | expect('hasOwnProperty' in obj).toBe(false);
389 | expect('toString' in obj).toBe(false);
390 | expect('constructor' in obj).toBe(false);
391 |
392 | var protoIsEnumerable = false;
393 | for (var k in obj) {
394 | if (k === '__proto__') {
395 | protoIsEnumerable = true;
396 | }
397 | }
398 | expect(protoIsEnumerable).toBe(false);
399 |
400 | expect(obj instanceof Object).toBe(false);
401 | });
402 | });
403 | });
404 |
--------------------------------------------------------------------------------
/tests/spec/s-regexp.js:
--------------------------------------------------------------------------------
1 | describe('RegExp', function () {
2 | 'use strict';
3 |
4 | describe('#toString()', function () {
5 | describe('literals', function () {
6 | it('should return correct flags and in correct order', function () {
7 | expect(String(/pattern/)).toBe('/pattern/');
8 | expect(String(/pattern/i)).toBe('/pattern/i');
9 | expect(String(/pattern/mi)).toBe('/pattern/im');
10 | expect(String(/pattern/im)).toBe('/pattern/im');
11 | expect(String(/pattern/mgi)).toBe('/pattern/gim');
12 | });
13 | });
14 |
15 | describe('objects', function () {
16 | it('should return correct flags and in correct order', function () {
17 | /* eslint prefer-regex-literals: 0 */
18 | expect(String(new RegExp('pattern'))).toBe('/pattern/');
19 | expect(String(new RegExp('pattern', 'i'))).toBe('/pattern/i');
20 | expect(String(new RegExp('pattern', 'mi'))).toBe('/pattern/im');
21 | expect(String(new RegExp('pattern', 'im'))).toBe('/pattern/im');
22 | expect(String(new RegExp('pattern', 'mgi'))).toBe('/pattern/gim');
23 | });
24 | });
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/tests/spec/s-string.js:
--------------------------------------------------------------------------------
1 | describe('String', function () {
2 | 'use strict';
3 |
4 | describe('#trim()', function () {
5 | var mvs = '\u180E';
6 | var mvsIsWS = (/\s/).test(mvs);
7 | var test = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680' + (mvsIsWS ? mvs : '') + '\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680' + (mvsIsWS ? mvs : '') + '\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
8 |
9 | it('trims all ES5 whitespace', function () {
10 | expect(test.trim()).toBe('Hello, World!');
11 | expect(test.trim().length).toBe(13);
12 | });
13 |
14 | it('does not trim the zero-width space', function () {
15 | var zws = '\u200b';
16 | expect(zws.trim()).toBe(zws);
17 | });
18 |
19 | it('properly handles the mongolian vowel separator', function () {
20 | if (mvsIsWS) {
21 | expect(mvs.trim()).toBe('');
22 | } else {
23 | expect(mvs.trim()).toBe(mvs);
24 | }
25 | });
26 | });
27 |
28 | describe('#replace()', function () {
29 | it('returns undefined for non-capturing groups', function () {
30 | var groups = [];
31 | 'x'.replace(/x(.)?/g, function (m, group) {
32 | groups.push(group); /* "" in FF, `undefined` in CH/WK/IE */
33 | });
34 | expect(groups.length).toBe(1);
35 | expect(groups[0]).toBeUndefined();
36 | });
37 |
38 | it('should not fail in Firefox', function () {
39 | expect(function () {
40 | return '* alef\n* beth \n* gimel~0\n'.replace(
41 | /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
42 | function (match, m1, m2, m3, m4) { return '' + m4 + '\n'; }
43 | );
44 | }).not.toThrow();
45 | });
46 | });
47 |
48 | describe('#split()', function () {
49 | var test = 'ab';
50 |
51 | it('If "separator" is undefined must return Array with one String - "this" string', function () {
52 | expect(test.split()).toEqual([test]);
53 | expect(test.split(void 0)).toEqual([test]);
54 | });
55 |
56 | it('If "separator" is undefined and "limit" set to 0 must return Array[]', function () {
57 | expect(test.split(void 0, 0)).toEqual([]);
58 | });
59 |
60 | describe('Tests from Steven Levithan', function () {
61 | it("''.split() results in ['']", function () {
62 | expect(''.split()).toEqual(['']);
63 | });
64 | it("''.split(/./) results in ['']", function () {
65 | expect(''.split(/./)).toEqual(['']);
66 | });
67 | it("''.split(/.?/) results in []", function () {
68 | expect(''.split(/.?/)).toEqual([]);
69 | });
70 | it("''.split(/.??/) results in []", function () {
71 | expect(''.split(/.??/)).toEqual([]);
72 | });
73 | it("'ab'.split(/a*/) results in ['', 'b']", function () {
74 | expect('ab'.split(/a*/)).toEqual(['', 'b']);
75 | });
76 | it("'ab'.split(/a*?/) results in ['a', 'b']", function () {
77 | expect('ab'.split(/a*?/)).toEqual(['a', 'b']);
78 | });
79 | it("'ab'.split(/(?:ab)/) results in ['', '']", function () {
80 | expect('ab'.split(/(?:ab)/)).toEqual(['', '']);
81 | });
82 | it("'ab'.split(/(?:ab)*/) results in ['', '']", function () {
83 | expect('ab'.split(/(?:ab)*/)).toEqual(['', '']);
84 | });
85 | it("'ab'.split(/(?:ab)*?/) results in ['a', 'b']", function () {
86 | expect('ab'.split(/(?:ab)*?/)).toEqual(['a', 'b']);
87 | });
88 | it("'test'.split('') results in ['t', 'e', 's', 't']", function () {
89 | expect('test'.split('')).toEqual(['t', 'e', 's', 't']);
90 | });
91 | it("'test'.split() results in ['test']", function () {
92 | expect('test'.split()).toEqual(['test']);
93 | });
94 | it("'111'.split(1) results in ['', '', '', '']", function () {
95 | expect('111'.split(1)).toEqual(['', '', '', '']);
96 | });
97 | it("'test'.split(/(?:)/, 2) results in ['t', 'e']", function () {
98 | expect('test'.split(/(?:)/, 2)).toEqual(['t', 'e']);
99 | });
100 | it("'test'.split(/(?:)/, -1) results in ['t', 'e', 's', 't']", function () {
101 | expect('test'.split(/(?:)/, -1)).toEqual(['t', 'e', 's', 't']);
102 | });
103 | it("'test'.split(/(?:)/, undefined) results in ['t', 'e', 's', 't']", function () {
104 | expect('test'.split(/(?:)/, undefined)).toEqual(['t', 'e', 's', 't']);
105 | });
106 | it("'test'.split(/(?:)/, null) results in []", function () {
107 | expect('test'.split(/(?:)/, null)).toEqual([]);
108 | });
109 | it("'test'.split(/(?:)/, NaN) results in []", function () {
110 | expect('test'.split(/(?:)/, NaN)).toEqual([]);
111 | });
112 | it("'test'.split(/(?:)/, true) results in ['t']", function () {
113 | expect('test'.split(/(?:)/, true)).toEqual(['t']);
114 | });
115 | it("'test'.split(/(?:)/, '2') results in ['t', 'e']", function () {
116 | expect('test'.split(/(?:)/, '2')).toEqual(['t', 'e']);
117 | });
118 | it("'test'.split(/(?:)/, 'two') results in []", function () {
119 | expect('test'.split(/(?:)/, 'two')).toEqual([]);
120 | });
121 | it("'a'.split(/-/) results in ['a']", function () {
122 | expect('a'.split(/-/)).toEqual(['a']);
123 | });
124 | it("'a'.split(/-?/) results in ['a']", function () {
125 | expect('a'.split(/-?/)).toEqual(['a']);
126 | });
127 | it("'a'.split(/-??/) results in ['a']", function () {
128 | expect('a'.split(/-??/)).toEqual(['a']);
129 | });
130 | it("'a'.split(/a/) results in ['', '']", function () {
131 | expect('a'.split(/a/)).toEqual(['', '']);
132 | });
133 | it("'a'.split(/a?/) results in ['', '']", function () {
134 | expect('a'.split(/a?/)).toEqual(['', '']);
135 | });
136 | it("'a'.split(/a??/) results in ['a']", function () {
137 | expect('a'.split(/a??/)).toEqual(['a']);
138 | });
139 | it("'ab'.split(/-/) results in ['ab']", function () {
140 | expect('ab'.split(/-/)).toEqual(['ab']);
141 | });
142 | it("'ab'.split(/-?/) results in ['a', 'b']", function () {
143 | expect('ab'.split(/-?/)).toEqual(['a', 'b']);
144 | });
145 | it("'ab'.split(/-??/) results in ['a', 'b']", function () {
146 | expect('ab'.split(/-??/)).toEqual(['a', 'b']);
147 | });
148 | it("'a-b'.split(/-/) results in ['a', 'b']", function () {
149 | expect('a-b'.split(/-/)).toEqual(['a', 'b']);
150 | });
151 | it("'a-b'.split(/-?/) results in ['a', 'b']", function () {
152 | expect('a-b'.split(/-?/)).toEqual(['a', 'b']);
153 | });
154 | it("'a-b'.split(/-??/) results in ['a', '-', 'b']", function () {
155 | expect('a-b'.split(/-??/)).toEqual(['a', '-', 'b']);
156 | });
157 | it("'a--b'.split(/-/) results in ['a', '', 'b']", function () {
158 | expect('a--b'.split(/-/)).toEqual(['a', '', 'b']);
159 | });
160 | it("'a--b'.split(/-?/) results in ['a', '', 'b']", function () {
161 | expect('a--b'.split(/-?/)).toEqual(['a', '', 'b']);
162 | });
163 | it("'a--b'.split(/-??/) results in ['a', '-', '-', 'b']", function () {
164 | expect('a--b'.split(/-??/)).toEqual(['a', '-', '-', 'b']);
165 | });
166 | it("''.split(/()()/) results in []", function () {
167 | expect(''.split(/()()/)).toEqual([]);
168 | });
169 | it("'.'.split(/()()/) results in ['.']", function () {
170 | expect('.'.split(/()()/)).toEqual(['.']);
171 | });
172 | it("'.'.split(/(.?)(.?)/) results in ['', '.', '', '']", function () {
173 | expect('.'.split(/(.?)(.?)/)).toEqual(['', '.', '', '']);
174 | });
175 | it("'.'.split(/(.??)(.??)/) results in ['.']", function () {
176 | expect('.'.split(/(.??)(.??)/)).toEqual(['.']);
177 | });
178 | it("'.'.split(/(.)?(.)?/) results in ['', '.', undefined, '']", function () {
179 | expect('.'.split(/(.)?(.)?/)).toEqual(['', '.', undefined, '']);
180 | });
181 | it("'Aboldandcoded
'.split(/<(\\/)?([^<>]+)>/) results in ['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']", function () {
182 | expect('Aboldandcoded
'.split(/<(\/)?([^<>]+)>/)).toEqual(['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']);
183 | });
184 | it("'tesst'.split(/(s)*/) results in ['t', undefined, 'e', 's', 't']", function () {
185 | expect('tesst'.split(/(s)*/)).toEqual(['t', undefined, 'e', 's', 't']);
186 | });
187 | it("'tesst'.split(/(s)*?/) results in ['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']", function () {
188 | expect('tesst'.split(/(s)*?/)).toEqual(['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']);
189 | });
190 | it("'tesst'.split(/(s*)/) results in ['t', '', 'e', 'ss', 't']", function () {
191 | expect('tesst'.split(/(s*)/)).toEqual(['t', '', 'e', 'ss', 't']);
192 | });
193 | it("'tesst'.split(/(s*?)/) results in ['t', '', 'e', '', 's', '', 's', '', 't']", function () {
194 | expect('tesst'.split(/(s*?)/)).toEqual(['t', '', 'e', '', 's', '', 's', '', 't']);
195 | });
196 | it("'tesst'.split(/(?:s)*/) results in ['t', 'e', 't']", function () {
197 | expect('tesst'.split(/(?:s)*/)).toEqual(['t', 'e', 't']);
198 | });
199 | it("'tesst'.split(/(?=s+)/) results in ['te', 's', 'st']", function () {
200 | expect('tesst'.split(/(?=s+)/)).toEqual(['te', 's', 'st']);
201 | });
202 | it("'test'.split('t') results in ['', 'es', '']", function () {
203 | expect('test'.split('t')).toEqual(['', 'es', '']);
204 | });
205 | it("'test'.split('es') results in ['t', 't']", function () {
206 | expect('test'.split('es')).toEqual(['t', 't']);
207 | });
208 | it("'test'.split(/t/) results in ['', 'es', '']", function () {
209 | expect('test'.split(/t/)).toEqual(['', 'es', '']);
210 | });
211 | it("'test'.split(/es/) results in ['t', 't']", function () {
212 | expect('test'.split(/es/)).toEqual(['t', 't']);
213 | });
214 | it("'test'.split(/(t)/) results in ['', 't', 'es', 't', '']", function () {
215 | expect('test'.split(/(t)/)).toEqual(['', 't', 'es', 't', '']);
216 | });
217 | it("'test'.split(/(es)/) results in ['t', 'es', 't']", function () {
218 | expect('test'.split(/(es)/)).toEqual(['t', 'es', 't']);
219 | });
220 | it("'test'.split(/(t)(e)(s)(t)/) results in ['', 't', 'e', 's', 't', '']", function () {
221 | expect('test'.split(/(t)(e)(s)(t)/)).toEqual(['', 't', 'e', 's', 't', '']);
222 | });
223 | it("'.'.split(/(((.((.??)))))/) results in ['', '.', '.', '.', '', '', '']", function () {
224 | expect('.'.split(/(((.((.??)))))/)).toEqual(['', '.', '.', '.', '', '', '']);
225 | });
226 | it("'.'.split(/(((((.??)))))/) results in ['.']", function () {
227 | expect('.'.split(/(((((.??)))))/)).toEqual(['.']);
228 | });
229 | it("'a b c d'.split(/ /, -(Math.pow(2, 32) - 1)) results in ['a']", function () {
230 | expect('a b c d'.split(/ /, -(Math.pow(2, 32) - 1))).toEqual(['a']);
231 | });
232 | it("'a b c d'.split(/ /, Math.pow(2, 32) + 1) results in ['a']", function () {
233 | expect('a b c d'.split(/ /, Math.pow(2, 32) + 1)).toEqual(['a']);
234 | });
235 | it("'a b c d'.split(/ /, Infinity) results in []", function () {
236 | expect('a b c d'.split(/ /, Infinity)).toEqual([]);
237 | });
238 | });
239 |
240 | it('works with the second argument', function () {
241 | expect('a b'.split(/ /, 1)).toEqual(['a']);
242 | });
243 | });
244 |
245 | describe('#indexOf()', function () {
246 | it('has basic support', function () {
247 | expect('abcab'.indexOf('a')).toBe(0);
248 | expect('abcab'.indexOf('a', 1)).toBe(3);
249 | expect('abcab'.indexOf('a', 4)).toBe(-1);
250 | });
251 |
252 | it('works with unicode', function () {
253 | expect('あいabcあいabc'.indexOf('あい')).toBe(0);
254 | expect('あいabcあいabc'.indexOf('あい', 0)).toBe(0);
255 | expect('あいabcあいabc'.indexOf('あい', 1)).toBe(5);
256 | expect('あいabcあいabc'.indexOf('あい', 6)).toBe(-1);
257 | });
258 | });
259 |
260 | describe('#lastIndexOf()', function () {
261 | it('has the right length', function () {
262 | expect(String.prototype.lastIndexOf.length).toBe(1);
263 | });
264 |
265 | it('has basic support', function () {
266 | expect('abcd'.lastIndexOf('d')).toBe(3);
267 | expect('abcd'.lastIndexOf('d', 3)).toBe(3);
268 | expect('abcd'.lastIndexOf('d', 2)).toBe(-1);
269 | });
270 |
271 | it('works with unicode', function () {
272 | expect('abcあい'.lastIndexOf('あい')).toBe(3);
273 | expect('abcあい'.lastIndexOf('あい', 3)).toBe(3);
274 | expect('abcあい'.lastIndexOf('あい', 2)).toBe(-1);
275 | });
276 | });
277 | });
278 |
--------------------------------------------------------------------------------