diff --git a/helloworld.js b/helloworld.js new file mode 100644 index 0000000..ddfd115 --- /dev/null +++ b/helloworld.js @@ -0,0 +1,5 @@ +return { + main: function() { + console.log("Hello world"); + } +}; diff --git a/lib/std.js b/lib/std.js index a52a18d..ccc3a52 100644 --- a/lib/std.js +++ b/lib/std.js @@ -33,12 +33,12 @@ if (!Function.prototype.GetResource) { } // ECMAScript 5 compatibility shims for legacy (and modern) JavaScript engines -require("app/assets/js/es5-shim-4.5.14.min"); -require("app/assets/js/es5-sham-4.5.14.min"); +require("node_modules/es5-shim/es5-shim"); +require("node_modules/es5-shim/es5-sham"); // ECMAScript 6 compatibility shims for legacy JS engines -require("app/assets/js/es6-shim-0.35.5.min"); -require("app/assets/js/es6-shim-0.35.5.min"); +require("node_modules/es6-shim/es6-shim"); +require("node_modules/es6-shim/es6-sham"); ///////////////////////////////////////////////////////////////////////////////// // Global APIs diff --git a/node_modules/es5-shim/.eslintignore b/node_modules/es5-shim/.eslintignore new file mode 100644 index 0000000..3ad2567 --- /dev/null +++ b/node_modules/es5-shim/.eslintignore @@ -0,0 +1,2 @@ +*.min.js +tests/lib/* diff --git a/node_modules/es5-shim/.eslintrc b/node_modules/es5-shim/.eslintrc new file mode 100644 index 0000000..59f4eaf --- /dev/null +++ b/node_modules/es5-shim/.eslintrc @@ -0,0 +1,68 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "array-bracket-newline": 0, + "object-curly-newline": 0, + "camelcase": [0], + "complexity": [0], + "eqeqeq": [2, "allow-null"], + "func-name-matching": 0, + "id-length": [2, { "min": 1, "max": 40 }], + "indent": [2, 4], + "max-len": [2, 120, 4, { + "ignoreUrls": true, + "ignoreComments": true, + "ignoreRegExpLiterals": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true + }], + "max-lines": 0, + "max-lines-per-function": 0, + "max-nested-callbacks": [2, 5], + "max-params": [2, 7], + "max-statements": [1, 30], + "new-cap": [2, { "capIsNewExceptions": ["ToInteger", "ToObject", "ToPrimitive", "ToUint32"] }], + "no-constant-condition": [1], + "no-extend-native": [2, {"exceptions": ["Date", "Error", "RegExp"]}], + "no-extra-parens": [0], + "no-extra-semi": [1], + "no-func-assign": [1], + "no-implicit-coercion": [2, { + "boolean": false, + "number": false, + "string": true + }], + "no-invalid-this": [0], + "no-magic-numbers": [0], + "no-native-reassign": [2, {"exceptions": ["Date", "parseInt"]}], + "no-new-func": [1], + "no-plusplus": [1], + "no-restricted-syntax": [2, "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"], + "no-shadow": [1], + "no-unused-vars": [1, { "vars": "all", "args": "after-used" }], + "operator-linebreak": [2, "before"], + "quote-props": [1, "as-needed", { "keywords": true }], + "sort-keys": [0], + "spaced-comment": [0], + "strict": [0], + + "multiline-comment-style": 1, + }, + + "overrides": [ + { + "files": "tests/**", + "rules": { + "max-len": 0, + "max-lines": 0, + "max-statements-per-line": [2, { "max": 2 }], + }, + "env": { + "jasmine": true + }, + }, + ], +} diff --git a/node_modules/es5-shim/.github/workflows/rebase.yml b/node_modules/es5-shim/.github/workflows/rebase.yml new file mode 100644 index 0000000..436cb79 --- /dev/null +++ b/node_modules/es5-shim/.github/workflows/rebase.yml @@ -0,0 +1,15 @@ +name: Automatic Rebase + +on: [pull_request] + +jobs: + _: + name: "Automatic Rebase" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: ljharb/rebase@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/node_modules/es5-shim/.travis.yml b/node_modules/es5-shim/.travis.yml new file mode 100644 index 0000000..7a78e0e --- /dev/null +++ b/node_modules/es5-shim/.travis.yml @@ -0,0 +1,7 @@ +version: ~> 1.0 +language: node_js +os: + - linux +import: + - ljharb/travis-ci:node/all.yml + - ljharb/travis-ci:node/pretest.yml diff --git a/node_modules/es5-shim/CHANGELOG.md b/node_modules/es5-shim/CHANGELOG.md new file mode 100644 index 0000000..1086985 --- /dev/null +++ b/node_modules/es5-shim/CHANGELOG.md @@ -0,0 +1,442 @@ +4.5.14 + - [Fix] handle no `deleteCount` to `splice()` in Opera (#465) + - [Refactor] remove unnecessary comparison + - [meta] remove unused Makefile and associated utilities + - [meta] add `funding` field + - [meta] Rename CHANGES to CHANGELOG.md + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `replace`, `semver`; add `safe-publish-latest` + - [Tests] fix negative Date tests to handle TZData + - [Tests] use shared travis-ci configs + - [Tests] remove `jscs` + - [Tests] clarify toPrecision's range increased in ES2018 + - [actions] add automatic rebasing / merge commit blocking + +4.5.13 + - [Fix] exclude deprecated Firefox keys (#460) + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jasmine-node`, `replace`, `semver` + +4.5.12 + - [meta] republish broken 4.5.11 + +4.5.11 + - [Fix] sync Object.keys excluded list from object-keys (#456) + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jasmine-node`, `replace`, `semver` + - [Tests] pin jasmine-node to ~1.13 + +4.5.10 + - [Fix] Safari 11 throws on `.sort({})`, but not on `.sort(null)` + - [Fix] ensure the shimmed parseInt throws with Symbols (#450) + - [Fix] skip over `localStorage`, which can’t be accessed on file:// + - [Fix] Accessing window.top.{constructor|prototype} throws error in iOS (#445) + - [Fix] avoid `width` and `height` on `window`, to prevent reflow (https://github.com/ljharb/object-keys/issues/31) + - [Fix] ensure minified literal of `1000000000000000128` stays as that literal (#441) + - [Robustness] always prefer `String(x)` over `x.toString()` + - [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 + - [Tests] `parseInt`: add another test for NaN parsing (#433) + - [Dev Deps] `uglify-js`: add `--support-ie8` and peg to v2.7.x since it doesn’t follow semver + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `semver`; remove `concurrently` (#421) + +4.5.9 + - [Fix] parseInt and parseFloat should both accept null/undefined (#402) + - [Tests] up to `node` `v6.2` + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `concurrently` + +4.5.8 + - [Fix] Check if property descriptor is configurable before re-defining it (#394, #373) + - [Dev Deps] update `eslint`, `jscs`, `@ljharb/eslint-config` + - [Tests] up to `node` `v5.10`, `v4.4` + - [Tests] Use `concurrently` instead of `parallelshell` + - [Tests] use `pretest` to run the linter + +4.5.7 + - [Fix] `bind` in IE 8: Update `is-callable` implementation to v1.1.3 (#390) + +4.5.6 + - [Fix] `new Date(new Date())` should work in IE 8 (#389) + - [Tests] on `node` `v5.7` + - [Dev Deps] update `uglify-js` + +4.5.5 + - [Fix] Adobe Photoshop’s JS engine bizarrely can have `+date !== date.getTime()` (#365) + - [Dev Deps] update `eslint` + - [Refactor] Update `is-callable` implementation to match latest + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs` + +4.5.4 + - [Fix] careless error from 5cf99aca49e59bae03b5d542381424bb1b13ec42 + +4.5.3 + - [Fix] Saturday is a day in the week (#386) + - [Robustness] improve Function#bind (#381) + - [Tests] on `node` `v5.6`, `v4.3` + - [Tests] use json3 (#382) + - [Dev Deps] update `eslint`, `@ljharb/eslint-config` + - [Docs] add note about script order (#379) + +4.5.2 + - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380) + +4.5.1 + - [Fix] Make sure preexisting + broken `Array#` methods that throw don’t break the runtime (#377) + - [Dev Deps] update `jscs` + +4.5.0 + - [New] `parseFloat('-0')` should return -0 in Opera 12 (#371) + - [New] Provide and replace Date UTC methods (#360) + - [Robustness] cache `Date` getUTC* methods so that `Date#toISOString` doesn’t observably look them up on the receiver + - [Robustness] use a cached and shimmed `String#trim` + - [Tests] up to `node` `v5.5` + - [Tests] add `parallelshell` and use it in a few tasks + - [Refactor] rename cached methods to avoid linter warnings + - [Dev Deps] update `eslint`, `jscs`, '@ljharb/eslint-config' + - [Docs] Update license year to 2016 (#374) + +4.4.2 + - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380) + +4.4.1 + - [Fix] ensure that IE 11 in compatibility mode doesn't throw (#370) + - [Docs] add missing shimmed things + +4.4.0 + - [New] Detect and patch `RegExp#toString` in IE 8, which returns flags in the wrong order (#364) + - [Fix] Patch `Array#sort` on {Chrome, Safari, IE < 9, FF 4} that throws improperly, per ES5 (#354) + - [Fix] In IE 6, `window.external` makes `Object.keys` throw + - [Fix] `Array#slice`: boxed string access on IE <= 8 (#349) + - [Fix] `Array#join`: fix IE 6-8 join called on string literal (#352) + - [Fix] Ensure that `Error#message` and `Error#name` are non-enumerable (#358) + - [Fix: sham] `Object.getOwnPropertyDescriptor`: In Opera 11.6, `propertyIsEnumerable` is a nonshadowable global, like `toString` + - [Robustness] Use a bound form of `Array#slice.call` + - [Tests] Properly check for descriptor support in IE <= 8 + - [Tests] on `node` `v5.1` + - [Tests] Add `Array#slice` tests (#346) + - [Dev Deps] update `uglify-js`, `eslint`, `jscs`, `uglify-js`, `semver` + - [Docs] Fix broken UMD links (#344) + +4.3.2 + - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380) + +4.3.1 + - [Fix] `String#split`: revert part of dcce96ae21185a69d2d40e67416e7496b73e8e47 which broke in older browsers (#342) + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs` + - [Tests] Firefox allows `Number#toPrecision` values of [1,100], which the spec permits + +4.3.0 + - [New] `Array#push`: in IE <= 7, `Array#push` was not generic (#336) + - [New] `Array#push` in Opera `10.6` has a super weird bug when pushing `undefined` + - [New] `Array#join`: In IE <= 7, passing `undefined` didn't use the default separator (#333) + - [New] `Error#toString`: prints out the proper message in IE 7 and below (#334) + - [New] `Number#toPrecision`: IE 7 and below incorrectly throw when an explicit `undefined` precision is passed (#340) + - [Fix] `String#lastIndexOf`: ensure the correct length in IE 8 + - [Fix] ensure `parseInt` accepts negative and plus-prefixed hex values (#332) + - [Robustness] Use a bound `Array#push` instead of relying on `Function#call` + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs` + - [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) + - [Tests] Fix false negatives in IE 6-8 with jasmine comparing arrays to arraylikes (#114) + - [Tests] add additional `Array#shift` tests (#337) + - [Tests] Add additional `Array#splice` tests (#339) + - [Tests] Add `Array#pop` tests, just in case (#338) + - [Tests] include `global` tests in HTML test files + - [Tests] Make sure the HTML tests run with the right charset + - [Tests] ensure `node` `v0.8` tests stay passing. + - [Tests] Prevent nondeterminism in the tests - this sometime produced values that are one ms off + - [Tests] on `node` `v5.0` + - [Tests] fix npm upgrades for older nodes + +4.2.1 + - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380) + +4.2.0 + - [shim: new] Overwrite `String#lastIndexOf` in IE 9, 10, 11, and Edge, so it has proper unicode support. + - [Dev Deps] update `eslint`, `jscs` + +4.1.16 + - [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380) + +4.1.15 + - [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) + - [shim: fix] add 'frame' to blacklisted keys (#330) + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js` + - [Tests] on `node` `v4.2` + - [Tests] Date: prevent nondeterminism in the tests - this sometime produced values that are one ms off + +4.1.14 + - [shim: fix] Wrap more things in a try/catch, because IE sucks and sometimes throws on [[Get]] of window.localStorage (#327) + - [Refactor] Use `ES.ToUint32` instead of inline `>>>` + - [Tests] up to `node` `v4.1` + - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver`, `jscs` + +4.1.13 + - [shim: fix] Fix a bug where `Date(x)` threw instead of equalling `String(Date(x))` (#326) + +4.1.12 + - [fix] Make sure uglify doesn't remove function names + - [shim: fix] Use `is-arguments` implementation; don't call down legacy code path in modern engines (#325) + - [Tests] up to `io.js` `v3.3` + - [Dev Deps] update `eslint`, `@ljharb/eslint-config` + +4.1.11 + - [shim: fix] Object.keys in Safari 9 has some bugs. (Already fixed in Webkit Nightly) + - [shim: fix] Omit !Date.parse check in the if statement (#323) + - [sham: fix] Fix Object.create sham to not set __proto__ (#301) + - [sham: fix] Add a typeof check to Object.getPrototypeOf (#319, #320) + - [Tests] up to `io.js` `v3.1` + - [Tests] Make sure `Object.getPrototypeOf` tests don't fail when engines implement ES6 semantics + - [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG (#318) + - [Dev Deps] Update `eslint`, `uglify-js`, `jscs`; use my personal shared `eslint` config + +4.1.10 + - [Fix] Fix IE 8 issue with `window.frameElement` access in a child iframe (#322) + - [Tests] Consolidating `Date.parse` extended year tests + - [Tests] Account for a `Date.parse` precision variance in Safari 8 + - [Tests] DRY up some Date.parse tests + - [Tests] Don't create globals in Date tests + - [Tests] Better failure output when an invalid date's toJSON throws + - [Tests] Also compare lengths of array-likes + - [Tests] Extra check on Object.keys(arguments) + - [Tests] Skip appropriate tests when objects aren't extensible/freezeable/sealable + +4.1.9 + - [Fix] Remove "extended", add "unicode" in `String#split` shim, to match ES6 + - [Fix] Object.keys: Preserve the IE 8 dontEnum bugfix, and the automation equality bugfix. + - [Fix] Object.keys: Prevent a deprecation message from showing up in Chrome. + - [Performance] Speed up blacklisted key check for Object.keys automation equality bug. + - [Tests] Test on `io.js` `v2.4` + - [Dev Deps] Update `eslint`, `semver` + +4.1.8 + - [Fix] Fix an `Object.keys` IE 8 bug where `localStorage.prototype.constructor === localStorage` would throw (#275) + - [Fix] Shimmed `Object.defineProperty` should not throw for an empty descriptor (#315) + - [Fix] Fix `Date#toISOString` in Safari 5.1 (#243) + - [Fix] Use `Object#propertyIsEnumerable` to default the initial "enumerable" value in `Object.getOwnPropertyDescriptor` sham (#289) + - [Fix] Fix `Array#splice` with large sparse arrays in Safari 7/8, and Opera 12.15 (#295) + - [Robustness] Safely use and reference many builtins internally (also see #313) + - [Tests] Add `Date#{getUTCDate,getUTCMonth}` tests to expose Opera 10.6/11.61/12 `Date` bugs + - [Dev Deps] Update `eslint` + +4.1.7 + - Make sure `Date.parse` is not enumerable (#310) + +4.1.6 + - Support IE 8 when `document.domain` is set (#306, #150) + - Remove version from `bower.json` (#307) + +4.1.5 + - Add a failing runtime check for Safari 8 `Date.parse` + - Update `eslint`, `semver` + - Test on `io.js` `v2.2` + +4.1.4 + - Make sure copied `Date` properties remain non-enumerable. + - Using a more reliable check for supported property descriptors in non-IE ES3 + - Fix 'constructor' in Object.defineProperties sham in ES3 (#252, #305) + - Use a reference to `Array#concat` rather than relying on the runtime environment's `concat`. + - Test on `io.js` `v2.1` + - Clean up `Array.prototype` iteration methods + +4.1.3 + - Update `license` in `package.json` per https://docs.npmjs.com/files/package.json#license + - Update `uglify-js`, `eslint` + +4.1.2 + - In IE 6-8, `Date` inside the function expression does not reference `DateShim` (#303) + - Date: Ensure all code paths have the correct `constructor` property + - Date: Don't copy non-own properties from original `Date` + - Test up to `io.js` `v2.0.0` + - Simplify `isPrimitive` check. + - Adding sanity check tests for ES5 `Number` constants. + - Update `uglify-js`, `eslint`, `semver` + +4.1.1 + - Fix name of `parseInt` replacement. + - Update copyright year + - Update `eslint`, `jscs` + - Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change. + - All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. + - Run `travis-ci` tests on latest `node` and `iojs`; speed up builds; allow 0.8 failures. + - Ensure some Object tests don't fail in ES6 + - Make sure `Date` instances don't have an enumerable `constructor` property, when possible. + +4.1.0 + - Update `eslint` + - Improve type checks: `Array.isArray`, `isRegex` + - Replace `isRegex`/`isString`/`isCallable` checks with inlined versions from npm modules + - Note which ES abstract methods are replaceable via `es-abstract` + - Run `travis-ci` tests on `iojs`! + +4.0.6 + - Update `jscs`, `uglify-js`, add `eslint` + - es5-sham: fix Object.defineProperty to not check for own properties (#211) + - Fix Array#splice bug in Safari 5 (#284) + - Fix `Object.keys` issue with boxed primitives with extra properties in older browsers. (#242, #285) + +4.0.5 + - Update `jscs` so tests pass + +4.0.4 + - Style/indentation/whitespace cleanups. + - README tweaks + +4.0.3 + - Fix keywords (#268) + - add some Date tests + - Note in README that the es5-sham requires the es5-shim (https://github.com/es-shims/es5-shim/issues/256#issuecomment-52875710) + +4.0.2 + - Start including version numbers in minified files (#267) + +4.0.1 + - Fix legacy arguments object detection in Object.keys (#260) + +4.0.0 + - No longer shim the ES5-spec behavior of splice when `deleteCount` is omitted - since no engines implement it, and ES6 changes it. (#255) + - Use Object.defineProperty where available, so that polyfills are non-enumerable when possible (#250) + - lots of internal refactoring + - Fixed a bug referencing String#indexOf and String#lastIndexOf before polyfilling it (#253, #254) + +3.4.0 + - Removed nonstandard SpiderMonkey extension to Array#splice - when `deleteCount` is omitted, it's now treated as 0. (#192, #239) + - Fix Object.keys with Arguments objects in Safari 5.0 + - Now shimming String#split in Opera 10.6 + - Avoid using "toString" as a variable name, since that breaks Opera + - Internal implementation and test cleanups + +3.3.2 + - Remove an internal "bind" call, which should make the shim a bit faster + - Fix a bug with object boxing in Array#reduceRight that was failing a test in IE 6 + +3.3.1 + - Fixing an Array#splice bug in IE 6/7 + - cleaning up Array#splice tests + +3.3.0 + - Fix Array#reduceRight in node 0.6 and older browsers (#238) + +3.2.0 + - Fix es5-sham UMD definition to work properly with AMD (#237) + - Ensure that Array methods do not autobox context in strict mode (#233) + +3.1.1 + - Update minified files (#231) + +3.1.0 + - Fix String#replace in Firefox up through 29 (#228) + +3.0.2 + - Fix `Function#bind` in IE 7 and 8 (#224, #225, #226) + +3.0.1 + - Version bump to ensure npm has newest minified assets + +3.0.0 + - es5-sham: fix `Object.getPrototypeOf` and `Object.getOwnPropertyDescriptor` for Opera Mini + - Better override noncompliant native ES5 methods: `Array#forEach`, `Array#map`, `Array#filter`, `Array#every`, `Array#some`, `Array#reduce`, `Date.parse`, `String#trim` + - Added spec-compliant shim for `parseInt` + - Ensure `Object.keys` handles more edge cases with `arguments` objects and boxed primitives + - Improve minification of builds + +2.3.0 + - parseInt is now properly shimmed in ES3 browsers to default the radix + - update URLs to point to the new organization + +2.2.0 + - Function.prototype.bind shim now reports correct length on a bound function + - fix node 0.6.x v8 bug in Array#forEach + - test improvements + +2.1.0 + - Object.create fixes + - tweaks to the Object.defineProperties shim + +2.0.0 + - Separate reliable shims from dubious shims (shams). + +1.2.10 + - Group-effort Style Cleanup + - Took a stab at fixing Object.defineProperty on IE8 without + bad side-effects. (@hax) + - Object.isExtensible no longer fakes it. (@xavierm) + - Date.prototype.toISOString no longer deals with partial + ISO dates, per spec (@kitcambridge) + - More (mostly from @bryanforbes) + +1.2.9 + - Corrections to toISOString by @kitcambridge + - Fixed three bugs in array methods revealed by Jasmine tests. + - Cleaned up Function.prototype.bind with more fixes and tests from + @bryanforbes. + +1.2.8 + - Actually fixed problems with Function.prototype.bind, and regressions + from 1.2.7 (@bryanforbes, @jdalton #36) + +1.2.7 - REGRESSED + - Fixed problems with Function.prototype.bind when called as a constructor. + (@jdalton #36) + +1.2.6 + - Revised Date.parse to match ES 5.1 (kitcambridge) + +1.2.5 + - Fixed a bug for padding it Date..toISOString (tadfisher issue #33) + +1.2.4 + - Fixed a descriptor bug in Object.defineProperty (raynos) + +1.2.3 + - Cleaned up RequireJS and + + + + + +``` +[npm-url]: https://npmjs.org/package/es5-shim +[npm-version-svg]: http://versionbadg.es/es-shims/es5-shim.svg +[travis-svg]: https://travis-ci.org/es-shims/es5-shim.svg +[travis-url]: https://travis-ci.org/es-shims/es5-shim +[deps-svg]: https://david-dm.org/es-shims/es5-shim.svg +[deps-url]: https://david-dm.org/es-shims/es5-shim +[dev-deps-svg]: https://david-dm.org/es-shims/es5-shim/dev-status.svg +[dev-deps-url]: https://david-dm.org/es-shims/es5-shim#info=devDependencies +[npm-badge-png]: https://nodei.co/npm/es5-shim.png?downloads=true&stars=true diff --git a/node_modules/es5-shim/bower.json b/node_modules/es5-shim/bower.json new file mode 100644 index 0000000..dcc0b29 --- /dev/null +++ b/node_modules/es5-shim/bower.json @@ -0,0 +1,33 @@ +{ + "name": "es5-shim", + "main": "es5-shim.js", + "repository": { + "type": "git", + "url": "git://github.com/es-shims/es5-shim" + }, + "homepage": "https://github.com/es-shims/es5-shim", + "authors": [ + "Kris Kowal (http://github.com/kriskowal/)", + "Sami Samhuri (http://samhuri.net/)", + "Florian Schäfer (http://github.com/fschaefer)", + "Irakli Gozalishvili (http://jeditoolkit.com)", + "Kit Cambridge (http://kitcambridge.github.com)", + "Jordan Harband (https://github.com/ljharb/)" + ], + "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines", + "keywords": [ + "shim", + "es5", + "es5 shim", + "javascript", + "ecmascript", + "polyfill" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "tests" + ] +} diff --git a/node_modules/es5-shim/component.json b/node_modules/es5-shim/component.json new file mode 100644 index 0000000..7096633 --- /dev/null +++ b/node_modules/es5-shim/component.json @@ -0,0 +1,19 @@ +{ + "name": "es5-shim", + "repo": "es-shims/es5-shim", + "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines", + "version": "v4.5.1", + "keywords": [ + "shim", + "es5", + "es5 shim", + "javascript", + "ecmascript", + "polyfill" + ], + "license": "MIT", + "main": "es5-shim.js", + "scripts": [ + "es5-shim.js" + ] +} diff --git a/node_modules/es5-shim/es5-sham.js b/node_modules/es5-shim/es5-sham.js new file mode 100644 index 0000000..97328d5 --- /dev/null +++ b/node_modules/es5-shim/es5-sham.js @@ -0,0 +1,558 @@ +/*! + * https://github.com/es-shims/es5-shim + * @license es5-shim Copyright 2009-2020 by contributors, MIT License + * see https://github.com/es-shims/es5-shim/blob/master/LICENSE + */ + +// vim: ts=4 sts=4 sw=4 expandtab + +// Add semicolon to prevent IIFE from being passed as argument to concatenated code. +; + +// UMD (Universal Module Definition) +// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js +(function (root, factory) { + 'use strict'; + + /* global define */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like enviroments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); // eslint-disable-line no-param-reassign + } +}(this, function () { + + var call = Function.call; + var prototypeOfObject = Object.prototype; + var owns = call.bind(prototypeOfObject.hasOwnProperty); + var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable); + var toStr = call.bind(prototypeOfObject.toString); + + // If JS engine supports accessors creating shortcuts. + var defineGetter; + var defineSetter; + var lookupGetter; + var lookupSetter; + var supportsAccessors = owns(prototypeOfObject, '__defineGetter__'); + if (supportsAccessors) { + /* eslint-disable no-underscore-dangle, no-restricted-properties */ + defineGetter = call.bind(prototypeOfObject.__defineGetter__); + defineSetter = call.bind(prototypeOfObject.__defineSetter__); + lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); + lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); + /* eslint-enable no-underscore-dangle, no-restricted-properties */ + } + + var isPrimitive = function isPrimitive(o) { + return o == null || (typeof o !== 'object' && typeof o !== 'function'); + }; + + // ES5 15.2.3.2 + // http://es5.github.com/#x15.2.3.2 + if (!Object.getPrototypeOf) { + // https://github.com/es-shims/es5-shim/issues#issue/2 + // http://ejohn.org/blog/objectgetprototypeof/ + // recommended by fschaefer on github + // + // sure, and webreflection says ^_^ + // ... this will nerever possibly return null + // ... Opera Mini breaks here with infinite loops + Object.getPrototypeOf = function getPrototypeOf(object) { + // eslint-disable-next-line no-proto + var proto = object.__proto__; + if (proto || proto === null) { + return proto; + } else if (toStr(object.constructor) === '[object Function]') { + return object.constructor.prototype; + } else if (object instanceof Object) { + return prototypeOfObject; + } else { + // Correctly return null for Objects created with `Object.create(null)` + // (shammed or native) or `{ __proto__: null}`. Also returns null for + // cross-realm objects on browsers that lack `__proto__` support (like + // IE <11), but that's the best we can do. + return null; + } + }; + } + + // ES5 15.2.3.3 + // http://es5.github.com/#x15.2.3.3 + + // check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially. + if (Object.defineProperty) { + var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) { + try { + object.sentinel = 0; // eslint-disable-line no-param-reassign + return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0; + } catch (exception) { + return false; + } + }; + var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({}); + var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' + || doesGetOwnPropertyDescriptorWork(document.createElement('div')); + if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) { + var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor; + } + } + + if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) { + var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: '; + + /* eslint-disable no-proto */ + Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { + if (isPrimitive(object)) { + throw new TypeError(ERR_NON_OBJECT + object); + } + + // make a valiant attempt to use the real getOwnPropertyDescriptor + // for I8's DOM elements. + if (getOwnPropertyDescriptorFallback) { + try { + return getOwnPropertyDescriptorFallback.call(Object, object, property); + } catch (exception) { + // try the shim if the real one doesn't work + } + } + + var descriptor; + + // If object does not owns property return undefined immediately. + if (!owns(object, property)) { + return descriptor; + } + + // If object has a property then it's for sure `configurable`, and + // probably `enumerable`. Detect enumerability though. + descriptor = { + enumerable: isEnumerable(object, property), + configurable: true + }; + + // If JS engine supports accessor properties then property may be a + // getter or setter. + if (supportsAccessors) { + // Unfortunately `__lookupGetter__` will return a getter even + // if object has own non getter property along with a same named + // inherited getter. To avoid misbehavior we temporary remove + // `__proto__` so that `__lookupGetter__` will return getter only + // if it's owned by an object. + var prototype = object.__proto__; + var notPrototypeOfObject = object !== prototypeOfObject; + // avoid recursion problem, breaking in Opera Mini when + // Object.getOwnPropertyDescriptor(Object.prototype, 'toString') + // or any other Object.prototype accessor + if (notPrototypeOfObject) { + object.__proto__ = prototypeOfObject; // eslint-disable-line no-param-reassign + } + + var getter = lookupGetter(object, property); + var setter = lookupSetter(object, property); + + if (notPrototypeOfObject) { + // Once we have getter and setter we can put values back. + object.__proto__ = prototype; // eslint-disable-line no-param-reassign + } + + if (getter || setter) { + if (getter) { + descriptor.get = getter; + } + if (setter) { + descriptor.set = setter; + } + // If it was accessor property we're done and return here + // in order to avoid adding `value` to the descriptor. + return descriptor; + } + } + + // If we got this far we know that object has an own property that is + // not an accessor so we set it as a value and return descriptor. + descriptor.value = object[property]; + descriptor.writable = true; + return descriptor; + }; + /* eslint-enable no-proto */ + } + + // ES5 15.2.3.4 + // http://es5.github.com/#x15.2.3.4 + if (!Object.getOwnPropertyNames) { + Object.getOwnPropertyNames = function getOwnPropertyNames(object) { + return Object.keys(object); + }; + } + + // ES5 15.2.3.5 + // http://es5.github.com/#x15.2.3.5 + if (!Object.create) { + + // Contributed by Brandon Benvie, October, 2012 + var createEmpty; + var supportsProto = !({ __proto__: null } instanceof Object); + // the following produces false positives + // in Opera Mini => not a reliable check + // Object.prototype.__proto__ === null + + // Check for document.domain and active x support + // No need to use active x approach when document.domain is not set + // see https://github.com/es-shims/es5-shim/issues/150 + // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 + /* global ActiveXObject */ + var shouldUseActiveX = function shouldUseActiveX() { + // return early if document.domain not set + if (!document.domain) { + return false; + } + + try { + return !!new ActiveXObject('htmlfile'); + } catch (exception) { + return false; + } + }; + + // This supports IE8 when document.domain is used + // see https://github.com/es-shims/es5-shim/issues/150 + // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 + var getEmptyViaActiveX = function getEmptyViaActiveX() { + var empty; + var xDoc; + + xDoc = new ActiveXObject('htmlfile'); + + var script = 'script'; + xDoc.write('<' + script + '>'); + xDoc.close(); + + empty = xDoc.parentWindow.Object.prototype; + xDoc = null; + + return empty; + }; + + // The original implementation using an iframe + // before the activex approach was added + // see https://github.com/es-shims/es5-shim/issues/150 + var getEmptyViaIFrame = function getEmptyViaIFrame() { + var iframe = document.createElement('iframe'); + var parent = document.body || document.documentElement; + var empty; + + iframe.style.display = 'none'; + parent.appendChild(iframe); + // eslint-disable-next-line no-script-url + iframe.src = 'javascript:'; + + empty = iframe.contentWindow.Object.prototype; + parent.removeChild(iframe); + iframe = null; + + return empty; + }; + + /* global document */ + if (supportsProto || typeof document === 'undefined') { + createEmpty = function () { + return { __proto__: null }; + }; + } else { + // In old IE __proto__ can't be used to manually set `null`, nor does + // any other method exist to make an object that inherits from nothing, + // aside from Object.prototype itself. Instead, create a new global + // object and *steal* its Object.prototype and strip it bare. This is + // used as the prototype to create nullary objects. + createEmpty = function () { + // Determine which approach to use + // see https://github.com/es-shims/es5-shim/issues/150 + var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame(); + + delete empty.constructor; + delete empty.hasOwnProperty; + delete empty.propertyIsEnumerable; + delete empty.isPrototypeOf; + delete empty.toLocaleString; + delete empty.toString; + delete empty.valueOf; + + var Empty = function Empty() {}; + Empty.prototype = empty; + // short-circuit future calls + createEmpty = function () { + return new Empty(); + }; + return new Empty(); + }; + } + + Object.create = function create(prototype, properties) { + + var object; + var Type = function Type() {}; // An empty constructor. + + if (prototype === null) { + object = createEmpty(); + } else if (isPrimitive(prototype)) { + // In the native implementation `parent` can be `null` + // OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc) + // Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object` + // like they are in modern browsers. Using `Object.create` on DOM elements + // is...err...probably inappropriate, but the native version allows for it. + throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome + } else { + Type.prototype = prototype; + object = new Type(); + // IE has no built-in implementation of `Object.getPrototypeOf` + // neither `__proto__`, but this manually setting `__proto__` will + // guarantee that `Object.getPrototypeOf` will work as expected with + // objects created using `Object.create` + // eslint-disable-next-line no-proto + object.__proto__ = prototype; + } + + if (properties !== void 0) { + Object.defineProperties(object, properties); + } + + return object; + }; + } + + // ES5 15.2.3.6 + // http://es5.github.com/#x15.2.3.6 + + // Patch for WebKit and IE8 standard mode + // Designed by hax + // related issue: https://github.com/es-shims/es5-shim/issues#issue/5 + // IE8 Reference: + // http://msdn.microsoft.com/en-us/library/dd282900.aspx + // http://msdn.microsoft.com/en-us/library/dd229916.aspx + // WebKit Bugs: + // https://bugs.webkit.org/show_bug.cgi?id=36423 + + var doesDefinePropertyWork = function doesDefinePropertyWork(object) { + try { + Object.defineProperty(object, 'sentinel', {}); + return 'sentinel' in object; + } catch (exception) { + return false; + } + }; + + // check whether defineProperty works if it's given. Otherwise, + // shim partially. + if (Object.defineProperty) { + var definePropertyWorksOnObject = doesDefinePropertyWork({}); + var definePropertyWorksOnDom = typeof document === 'undefined' + || doesDefinePropertyWork(document.createElement('div')); + if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { + var definePropertyFallback = Object.defineProperty, + definePropertiesFallback = Object.defineProperties; + } + } + + if (!Object.defineProperty || definePropertyFallback) { + var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: '; + var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: '; + var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine'; + + Object.defineProperty = function defineProperty(object, property, descriptor) { + if (isPrimitive(object)) { + throw new TypeError(ERR_NON_OBJECT_TARGET + object); + } + if (isPrimitive(descriptor)) { + throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); + } + // make a valiant attempt to use the real defineProperty + // for I8's DOM elements. + if (definePropertyFallback) { + try { + return definePropertyFallback.call(Object, object, property, descriptor); + } catch (exception) { + // try the shim if the real one doesn't work + } + } + + // If it's a data property. + if ('value' in descriptor) { + // fail silently if 'writable', 'enumerable', or 'configurable' + // are requested but not supported + /* + // alternate approach: + if ( // can't implement these features; allow false but not true + ('writable' in descriptor && !descriptor.writable) || + ('enumerable' in descriptor && !descriptor.enumerable) || + ('configurable' in descriptor && !descriptor.configurable) + )) + throw new RangeError( + 'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.' + ); + */ + + if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) { + // As accessors are supported only on engines implementing + // `__proto__` we can safely override `__proto__` while defining + // a property to make sure that we don't hit an inherited + // accessor. + /* eslint-disable no-proto, no-param-reassign */ + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + // Deleting a property anyway since getter / setter may be + // defined on object itself. + delete object[property]; + object[property] = descriptor.value; + // Setting original `__proto__` back now. + object.__proto__ = prototype; + /* eslint-enable no-proto, no-param-reassign */ + } else { + object[property] = descriptor.value; // eslint-disable-line no-param-reassign + } + } else { + var hasGetter = 'get' in descriptor; + var hasSetter = 'set' in descriptor; + if (!supportsAccessors && (hasGetter || hasSetter)) { + throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); + } + // If we got that far then getters and setters can be defined !! + if (hasGetter) { + defineGetter(object, property, descriptor.get); + } + if (hasSetter) { + defineSetter(object, property, descriptor.set); + } + } + return object; + }; + } + + // ES5 15.2.3.7 + // http://es5.github.com/#x15.2.3.7 + if (!Object.defineProperties || definePropertiesFallback) { + Object.defineProperties = function defineProperties(object, properties) { + // make a valiant attempt to use the real defineProperties + if (definePropertiesFallback) { + try { + return definePropertiesFallback.call(Object, object, properties); + } catch (exception) { + // try the shim if the real one doesn't work + } + } + + Object.keys(properties).forEach(function (property) { + if (property !== '__proto__') { + Object.defineProperty(object, property, properties[property]); + } + }); + return object; + }; + } + + // ES5 15.2.3.8 + // http://es5.github.com/#x15.2.3.8 + if (!Object.seal) { + Object.seal = function seal(object) { + if (Object(object) !== object) { + throw new TypeError('Object.seal can only be called on Objects.'); + } + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; + } + + // ES5 15.2.3.9 + // http://es5.github.com/#x15.2.3.9 + if (!Object.freeze) { + Object.freeze = function freeze(object) { + if (Object(object) !== object) { + throw new TypeError('Object.freeze can only be called on Objects.'); + } + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; + } + + // detect a Rhino bug and patch it + try { + Object.freeze(function () {}); + } catch (exception) { + Object.freeze = (function (freezeObject) { + return function freeze(object) { + if (typeof object === 'function') { + return object; + } else { + return freezeObject(object); + } + }; + }(Object.freeze)); + } + + // ES5 15.2.3.10 + // http://es5.github.com/#x15.2.3.10 + if (!Object.preventExtensions) { + Object.preventExtensions = function preventExtensions(object) { + if (Object(object) !== object) { + throw new TypeError('Object.preventExtensions can only be called on Objects.'); + } + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; + } + + // ES5 15.2.3.11 + // http://es5.github.com/#x15.2.3.11 + if (!Object.isSealed) { + Object.isSealed = function isSealed(object) { + if (Object(object) !== object) { + throw new TypeError('Object.isSealed can only be called on Objects.'); + } + return false; + }; + } + + // ES5 15.2.3.12 + // http://es5.github.com/#x15.2.3.12 + if (!Object.isFrozen) { + Object.isFrozen = function isFrozen(object) { + if (Object(object) !== object) { + throw new TypeError('Object.isFrozen can only be called on Objects.'); + } + return false; + }; + } + + // ES5 15.2.3.13 + // http://es5.github.com/#x15.2.3.13 + if (!Object.isExtensible) { + Object.isExtensible = function isExtensible(object) { + // 1. If Type(O) is not Object throw a TypeError exception. + if (Object(object) !== object) { + throw new TypeError('Object.isExtensible can only be called on Objects.'); + } + // 2. Return the Boolean value of the [[Extensible]] internal property of O. + var name = ''; + while (owns(object, name)) { + name += '?'; + } + object[name] = true; // eslint-disable-line no-param-reassign + var returnValue = owns(object, name); + delete object[name]; // eslint-disable-line no-param-reassign + return returnValue; + }; + } + +})); diff --git a/node_modules/es5-shim/es5-sham.map b/node_modules/es5-shim/es5-sham.map new file mode 100644 index 0000000..c2ad67c --- /dev/null +++ b/node_modules/es5-shim/es5-sham.map @@ -0,0 +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,EAC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AU,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,OACJ,CACH,MAAOyE,GAAazE,MAG9BrB,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"} \ No newline at end of file diff --git a/node_modules/es5-shim/es5-sham.min.js b/node_modules/es5-shim/es5-sham.min.js new file mode 100644 index 0000000..ed57289 --- /dev/null +++ b/node_modules/es5-shim/es5-sham.min.js @@ -0,0 +1,7 @@ +/*! + * https://github.com/es-shims/es5-shim + * @license es5-shim Copyright 2009-2020 by contributors, MIT License + * see https://github.com/es-shims/es5-shim/blob/master/LICENSE + */ +(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}else{return null}}}if(Object.defineProperty){var s=function doesGetOwnPropertyDescriptorWork(e){try{e.sentinel=0;return Object.getOwnPropertyDescriptor(e,"sentinel").value===0}catch(t){return false}};var p=s({});var b=typeof document==="undefined"||s(document.createElement("div"));if(!b||!p){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 s=e.__proto__;var p=e!==t;if(p){e.__proto__=t}var b=f(e,o);var y=a(e,o);if(p){e.__proto__=s}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+">");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 s=e.__proto__;e.__proto__=t;delete e[r];e[r]=n.value;e.__proto__=s}else{e[r]=n.value}}else{var p="get"in n;var b="set"in n;if(!l&&(p||b)){throw new TypeError(x)}if(p){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}else{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}}}); +//# sourceMappingURL=es5-sham.map diff --git a/node_modules/es5-shim/es5-shim.js b/node_modules/es5-shim/es5-shim.js new file mode 100644 index 0000000..940e136 --- /dev/null +++ b/node_modules/es5-shim/es5-shim.js @@ -0,0 +1,2113 @@ +/*! + * https://github.com/es-shims/es5-shim + * @license es5-shim Copyright 2009-2020 by contributors, MIT License + * see https://github.com/es-shims/es5-shim/blob/master/LICENSE + */ + +// vim: ts=4 sts=4 sw=4 expandtab + +// Add semicolon to prevent IIFE from being passed as argument to concatenated code. +; + +// UMD (Universal Module Definition) +// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js +(function (root, factory) { + 'use strict'; + + /* global define */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like enviroments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); // eslint-disable-line no-param-reassign + } +}(this, function () { + /** + * Brings an environment as close to ECMAScript 5 compliance + * as is possible with the facilities of erstwhile engines. + * + * Annotated ES5: http://es5.github.com/ (specific links below) + * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf + * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/ + */ + + // Shortcut to an often accessed properties, in order to avoid multiple + // dereference that costs universally. This also holds a reference to known-good + // functions. + var $Array = Array; + var ArrayPrototype = $Array.prototype; + var $Object = Object; + var ObjectPrototype = $Object.prototype; + var $Function = Function; + var FunctionPrototype = $Function.prototype; + var $String = String; + var StringPrototype = $String.prototype; + var $Number = Number; + var NumberPrototype = $Number.prototype; + var array_slice = ArrayPrototype.slice; + var array_splice = ArrayPrototype.splice; + var array_push = ArrayPrototype.push; + var array_unshift = ArrayPrototype.unshift; + var array_concat = ArrayPrototype.concat; + var array_join = ArrayPrototype.join; + var call = FunctionPrototype.call; + var apply = FunctionPrototype.apply; + var max = Math.max; + var min = Math.min; + + // Having a toString local variable name breaks in Opera so use to_string. + var to_string = ObjectPrototype.toString; + + /* eslint-disable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ + var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, constructorRegex = /^\s*class /, isES6ClassFn = function isES6ClassFn(value) { try { var fnStr = fnToStr.call(value); var singleStripped = fnStr.replace(/\/\/.*\n/g, ''); var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, ''); var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' '); return constructorRegex.test(spaceStripped); } catch (e) { return false; /* not a function */ } }, tryFunctionObject = function tryFunctionObject(value) { try { if (isES6ClassFn(value)) { return false; } fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]', isCallable = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } if (isES6ClassFn(value)) { return false; } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; }; + + var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; }; + var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; }; + /* eslint-enable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ + + /* inlined from http://npmjs.com/define-properties */ + var supportsDescriptors = $Object.defineProperty && (function () { + try { + var obj = {}; + $Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); + for (var _ in obj) { // jscs:ignore disallowUnusedVariables + return false; + } + return obj.x === obj; + } catch (e) { /* this is ES3 */ + return false; + } + }()); + var defineProperties = (function (has) { + // Define configurable, writable, and non-enumerable props + // if they don't exist. + var defineProperty; + if (supportsDescriptors) { + defineProperty = function (object, name, method, forceAssign) { + if (!forceAssign && (name in object)) { + return; + } + $Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: method + }); + }; + } else { + defineProperty = function (object, name, method, forceAssign) { + if (!forceAssign && (name in object)) { + return; + } + object[name] = method; // eslint-disable-line no-param-reassign + }; + } + return function defineProperties(object, map, forceAssign) { + for (var name in map) { + if (has.call(map, name)) { + defineProperty(object, name, map[name], forceAssign); + } + } + }; + }(ObjectPrototype.hasOwnProperty)); + + // + // Util + // ====== + // + + /* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */ + var isPrimitive = function isPrimitive(input) { + var type = typeof input; + return input === null || (type !== 'object' && type !== 'function'); + }; + + var isActualNaN = $Number.isNaN || function isActualNaN(x) { + return x !== x; + }; + + var ES = { + // ES5 9.4 + // http://es5.github.com/#x9.4 + // http://jsperf.com/to-integer + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */ + ToInteger: function ToInteger(num) { + var n = +num; + if (isActualNaN(n)) { + n = 0; + } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + return n; + }, + + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */ + ToPrimitive: function ToPrimitive(input) { + var val, valueOf, toStr; + if (isPrimitive(input)) { + return input; + } + valueOf = input.valueOf; + if (isCallable(valueOf)) { + val = valueOf.call(input); + if (isPrimitive(val)) { + return val; + } + } + toStr = input.toString; + if (isCallable(toStr)) { + val = toStr.call(input); + if (isPrimitive(val)) { + return val; + } + } + throw new TypeError(); + }, + + // ES5 9.9 + // http://es5.github.com/#x9.9 + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */ + ToObject: function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError("can't convert " + o + ' to object'); + } + return $Object(o); + }, + + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */ + ToUint32: function ToUint32(x) { + return x >>> 0; + } + }; + + // + // Function + // ======== + // + + // ES-5 15.3.4.5 + // http://es5.github.com/#x15.3.4.5 + + var Empty = function Empty() {}; + + defineProperties(FunctionPrototype, { + bind: function bind(that) { // .length is 1 + // 1. Let Target be the this value. + var target = this; + // 2. If IsCallable(Target) is false, throw a TypeError exception. + if (!isCallable(target)) { + throw new TypeError('Function.prototype.bind called on incompatible ' + target); + } + // 3. Let A be a new (possibly empty) internal list of all of the + // argument values provided after thisArg (arg1, arg2 etc), in order. + // XXX slicedArgs will stand in for "A" if used + var args = array_slice.call(arguments, 1); // for normal call + // 4. Let F be a new native ECMAScript object. + // 11. Set the [[Prototype]] internal property of F to the standard + // built-in Function prototype object as specified in 15.3.3.1. + // 12. Set the [[Call]] internal property of F as described in + // 15.3.4.5.1. + // 13. Set the [[Construct]] internal property of F as described in + // 15.3.4.5.2. + // 14. Set the [[HasInstance]] internal property of F as described in + // 15.3.4.5.3. + var bound; + var binder = function () { + + if (this instanceof bound) { + // 15.3.4.5.2 [[Construct]] + // When the [[Construct]] internal method of a function object, + // F that was created using the bind function is called with a + // list of arguments ExtraArgs, the following steps are taken: + // 1. Let target be the value of F's [[TargetFunction]] + // internal property. + // 2. If target has no [[Construct]] internal method, a + // TypeError exception is thrown. + // 3. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Construct]] internal + // method of target providing args as the arguments. + + var result = apply.call( + target, + this, + array_concat.call(args, array_slice.call(arguments)) + ); + if ($Object(result) === result) { + return result; + } + return this; + + } else { + // 15.3.4.5.1 [[Call]] + // When the [[Call]] internal method of a function object, F, + // which was created using the bind function is called with a + // this value and a list of arguments ExtraArgs, the following + // steps are taken: + // 1. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 2. Let boundThis be the value of F's [[BoundThis]] internal + // property. + // 3. Let target be the value of F's [[TargetFunction]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Call]] internal method + // of target providing boundThis as the this value and + // providing args as the arguments. + + // equiv: target.call(this, ...boundArgs, ...args) + return apply.call( + target, + that, + array_concat.call(args, array_slice.call(arguments)) + ); + + } + + }; + + // 15. If the [[Class]] internal property of Target is "Function", then + // a. Let L be the length property of Target minus the length of A. + // b. Set the length own property of F to either 0 or L, whichever is + // larger. + // 16. Else set the length own property of F to 0. + + var boundLength = max(0, target.length - args.length); + + // 17. Set the attributes of the length own property of F to the values + // specified in 15.3.5.1. + var boundArgs = []; + for (var i = 0; i < boundLength; i++) { + array_push.call(boundArgs, '$' + i); + } + + // XXX Build a dynamic function with desired amount of arguments is the only + // way to set the length property of a function. + // In environments where Content Security Policies enabled (Chrome extensions, + // for ex.) all use of eval or Function costructor throws an exception. + // However in all of these environments Function.prototype.bind exists + // and so this code will never be executed. + bound = $Function('binder', 'return function (' + array_join.call(boundArgs, ',') + '){ return binder.apply(this, arguments); }')(binder); + + if (target.prototype) { + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + // Clean up dangling references. + Empty.prototype = null; + } + + // TODO + // 18. Set the [[Extensible]] internal property of F to true. + + // TODO + // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). + // 20. Call the [[DefineOwnProperty]] internal method of F with + // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: + // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and + // false. + // 21. Call the [[DefineOwnProperty]] internal method of F with + // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, + // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, + // and false. + + // TODO + // NOTE Function objects created using Function.prototype.bind do not + // have a prototype property or the [[Code]], [[FormalParameters]], and + // [[Scope]] internal properties. + // XXX can't delete prototype in pure-js. + + // 22. Return F. + return bound; + } + }); + + // _Please note: Shortcuts are defined after `Function.prototype.bind` as we + // use it in defining shortcuts. + var owns = call.bind(ObjectPrototype.hasOwnProperty); + var toStr = call.bind(ObjectPrototype.toString); + var arraySlice = call.bind(array_slice); + var arraySliceApply = apply.bind(array_slice); + /* globals document */ + if (typeof document === 'object' && document && document.documentElement) { + try { + arraySlice(document.documentElement.childNodes); + } catch (e) { + var origArraySlice = arraySlice; + var origArraySliceApply = arraySliceApply; + arraySlice = function arraySliceIE(arr) { + var r = []; + var i = arr.length; + while (i-- > 0) { + r[i] = arr[i]; + } + return origArraySliceApply(r, origArraySlice(arguments, 1)); + }; + arraySliceApply = function arraySliceApplyIE(arr, args) { + return origArraySliceApply(arraySlice(arr), args); + }; + } + } + var strSlice = call.bind(StringPrototype.slice); + var strSplit = call.bind(StringPrototype.split); + var strIndexOf = call.bind(StringPrototype.indexOf); + var pushCall = call.bind(array_push); + var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable); + var arraySort = call.bind(ArrayPrototype.sort); + + // + // Array + // ===== + // + + var isArray = $Array.isArray || function isArray(obj) { + return toStr(obj) === '[object Array]'; + }; + + // ES5 15.4.4.12 + // http://es5.github.com/#x15.4.4.13 + // Return len+argCount. + // [bugfix, ielt8] + // IE < 8 bug: [].unshift(0) === undefined but should be "1" + var hasUnshiftReturnValueBug = [].unshift(0) !== 1; + defineProperties(ArrayPrototype, { + unshift: function () { + array_unshift.apply(this, arguments); + return this.length; + } + }, hasUnshiftReturnValueBug); + + // ES5 15.4.3.2 + // http://es5.github.com/#x15.4.3.2 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray + defineProperties($Array, { isArray: isArray }); + + // The IsCallable() check in the Array functions + // has been replaced with a strict check on the + // internal class of the object to trap cases where + // the provided function was actually a regular + // expression literal, which in V8 and + // JavaScriptCore is a typeof "function". Only in + // V8 are regular expression literals permitted as + // reduce parameters, so it is desirable in the + // general case for the shim to match the more + // strict and common behavior of rejecting regular + // expressions. + + // ES5 15.4.4.18 + // http://es5.github.com/#x15.4.4.18 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach + + // Check failure of by-index access of string characters (IE < 9) + // and failure of `0 in boxedString` (Rhino) + var boxedString = $Object('a'); + var splitString = boxedString[0] !== 'a' || !(0 in boxedString); + + var properlyBoxesContext = function properlyBoxed(method) { + // Check node 0.6.21 bug where third parameter is not boxed + var properlyBoxesNonStrict = true; + var properlyBoxesStrict = true; + var threwException = false; + if (method) { + try { + method.call('foo', function (_, __, context) { + if (typeof context !== 'object') { + properlyBoxesNonStrict = false; + } + }); + + method.call([1], function () { + 'use strict'; + + properlyBoxesStrict = typeof this === 'string'; + }, 'x'); + } catch (e) { + threwException = true; + } + } + return !!method && !threwException && properlyBoxesNonStrict && properlyBoxesStrict; + }; + + defineProperties(ArrayPrototype, { + forEach: function forEach(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var i = -1; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.forEach callback must be a function'); + } + + while (++i < length) { + if (i in self) { + // Invoke the callback function with call, passing arguments: + // context, property value, property key, thisArg object + if (typeof T === 'undefined') { + callbackfn(self[i], i, object); + } else { + callbackfn.call(T, self[i], i, object); + } + } + } + } + }, !properlyBoxesContext(ArrayPrototype.forEach)); + + // ES5 15.4.4.19 + // http://es5.github.com/#x15.4.4.19 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map + defineProperties(ArrayPrototype, { + map: function map(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var result = $Array(length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.map callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self) { + if (typeof T === 'undefined') { + result[i] = callbackfn(self[i], i, object); + } else { + result[i] = callbackfn.call(T, self[i], i, object); + } + } + } + return result; + } + }, !properlyBoxesContext(ArrayPrototype.map)); + + // ES5 15.4.4.20 + // http://es5.github.com/#x15.4.4.20 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter + defineProperties(ArrayPrototype, { + filter: function filter(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var result = []; + var value; + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.filter callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self) { + value = self[i]; + if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) { + pushCall(result, value); + } + } + } + return result; + } + }, !properlyBoxesContext(ArrayPrototype.filter)); + + // ES5 15.4.4.16 + // http://es5.github.com/#x15.4.4.16 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every + defineProperties(ArrayPrototype, { + every: function every(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.every callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { + return false; + } + } + return true; + } + }, !properlyBoxesContext(ArrayPrototype.every)); + + // ES5 15.4.4.17 + // http://es5.github.com/#x15.4.4.17 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some + defineProperties(ArrayPrototype, { + some: function some(callbackfn/*, thisArg */) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.some callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { + return true; + } + } + return false; + } + }, !properlyBoxesContext(ArrayPrototype.some)); + + // ES5 15.4.4.21 + // http://es5.github.com/#x15.4.4.21 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce + var reduceCoercesToObject = false; + if (ArrayPrototype.reduce) { + reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { + return list; + }) === 'object'; + } + defineProperties(ArrayPrototype, { + reduce: function reduce(callbackfn/*, initialValue*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.reduce callback must be a function'); + } + + // no value to return if no initial value and an empty array + if (length === 0 && arguments.length === 1) { + throw new TypeError('reduce of empty array with no initial value'); + } + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + + // if array contains no values, no initial value to return + if (++i >= length) { + throw new TypeError('reduce of empty array with no initial value'); + } + } while (true); + } + + for (; i < length; i++) { + if (i in self) { + result = callbackfn(result, self[i], i, object); + } + } + + return result; + } + }, !reduceCoercesToObject); + + // ES5 15.4.4.22 + // http://es5.github.com/#x15.4.4.22 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight + var reduceRightCoercesToObject = false; + if (ArrayPrototype.reduceRight) { + reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { + return list; + }) === 'object'; + } + defineProperties(ArrayPrototype, { + reduceRight: function reduceRight(callbackfn/*, initial*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.reduceRight callback must be a function'); + } + + // no value to return if no initial value, empty array + if (length === 0 && arguments.length === 1) { + throw new TypeError('reduceRight of empty array with no initial value'); + } + + var result; + var i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + + // if array contains no values, no initial value to return + if (--i < 0) { + throw new TypeError('reduceRight of empty array with no initial value'); + } + } while (true); + } + + if (i < 0) { + return result; + } + + do { + if (i in self) { + result = callbackfn(result, self[i], i, object); + } + } while (i--); + + return result; + } + }, !reduceRightCoercesToObject); + + // ES5 15.4.4.14 + // http://es5.github.com/#x15.4.4.14 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf + var hasFirefox2IndexOfBug = ArrayPrototype.indexOf && [0, 1].indexOf(1, 2) !== -1; + defineProperties(ArrayPrototype, { + indexOf: function indexOf(searchElement/*, fromIndex */) { + var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this); + var length = ES.ToUint32(self.length); + + if (length === 0) { + return -1; + } + + var i = 0; + if (arguments.length > 1) { + i = ES.ToInteger(arguments[1]); + } + + // handle negative indices + i = i >= 0 ? i : max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === searchElement) { + return i; + } + } + return -1; + } + }, hasFirefox2IndexOfBug); + + // ES5 15.4.4.15 + // http://es5.github.com/#x15.4.4.15 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf + var hasFirefox2LastIndexOfBug = ArrayPrototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1; + defineProperties(ArrayPrototype, { + lastIndexOf: function lastIndexOf(searchElement/*, fromIndex */) { + var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this); + var length = ES.ToUint32(self.length); + + if (length === 0) { + return -1; + } + var i = length - 1; + if (arguments.length > 1) { + i = min(i, ES.ToInteger(arguments[1])); + } + // handle negative indices + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && searchElement === self[i]) { + return i; + } + } + return -1; + } + }, hasFirefox2LastIndexOfBug); + + // ES5 15.4.4.12 + // http://es5.github.com/#x15.4.4.12 + var spliceNoopReturnsEmptyArray = (function () { + var a = [1, 2]; + var result = a.splice(); + return a.length === 2 && isArray(result) && result.length === 0; + }()); + defineProperties(ArrayPrototype, { + // Safari 5.0 bug where .splice() returns undefined + splice: function splice(start, deleteCount) { + if (arguments.length === 0) { + return []; + } else { + return array_splice.apply(this, arguments); + } + } + }, !spliceNoopReturnsEmptyArray); + + var spliceWorksWithEmptyObject = (function () { + var obj = {}; + ArrayPrototype.splice.call(obj, 0, 0, 1); + return obj.length === 1; + }()); + defineProperties(ArrayPrototype, { + splice: function splice(start, deleteCount) { + if (arguments.length === 0) { + return []; + } + var args = arguments; + this.length = max(ES.ToInteger(this.length), 0); + if (arguments.length > 0 && typeof deleteCount !== 'number') { + args = arraySlice(arguments); + if (args.length < 2) { + pushCall(args, this.length - start); + } else { + args[1] = ES.ToInteger(deleteCount); + } + } + return array_splice.apply(this, args); + } + }, !spliceWorksWithEmptyObject); + var spliceWorksWithLargeSparseArrays = (function () { + // Per https://github.com/es-shims/es5-shim/issues/295 + // Safari 7/8 breaks with sparse arrays of size 1e5 or greater + var arr = new $Array(1e5); + // note: the index MUST be 8 or larger or the test will false pass + arr[8] = 'x'; + arr.splice(1, 1); + // note: this test must be defined *after* the indexOf shim + // per https://github.com/es-shims/es5-shim/issues/313 + return arr.indexOf('x') === 7; + }()); + var spliceWorksWithSmallSparseArrays = (function () { + // Per https://github.com/es-shims/es5-shim/issues/295 + // Opera 12.15 breaks on this, no idea why. + var n = 256; + var arr = []; + arr[n] = 'a'; + arr.splice(n + 1, 0, 'b'); + return arr[n] === 'a'; + }()); + defineProperties(ArrayPrototype, { + splice: function splice(start, deleteCount) { + var O = ES.ToObject(this); + var A = []; + var len = ES.ToUint32(O.length); + var relativeStart = ES.ToInteger(start); + var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len); + var actualDeleteCount = arguments.length === 0 + ? 0 + : arguments.length === 1 + ? len - actualStart + : min(max(ES.ToInteger(deleteCount), 0), len - actualStart); + + var k = 0; + var from; + while (k < actualDeleteCount) { + from = $String(actualStart + k); + if (owns(O, from)) { + A[k] = O[from]; + } + k += 1; + } + + var items = arraySlice(arguments, 2); + var itemCount = items.length; + var to; + if (itemCount < actualDeleteCount) { + k = actualStart; + var maxK = len - actualDeleteCount; + while (k < maxK) { + from = $String(k + actualDeleteCount); + to = $String(k + itemCount); + if (owns(O, from)) { + O[to] = O[from]; + } else { + delete O[to]; + } + k += 1; + } + k = len; + var minK = len - actualDeleteCount + itemCount; + while (k > minK) { + delete O[k - 1]; + k -= 1; + } + } else if (itemCount > actualDeleteCount) { + k = len - actualDeleteCount; + while (k > actualStart) { + from = $String(k + actualDeleteCount - 1); + to = $String(k + itemCount - 1); + if (owns(O, from)) { + O[to] = O[from]; + } else { + delete O[to]; + } + k -= 1; + } + } + k = actualStart; + for (var i = 0; i < items.length; ++i) { + O[k] = items[i]; + k += 1; + } + O.length = len - actualDeleteCount + itemCount; + + return A; + } + }, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays); + + var originalJoin = ArrayPrototype.join; + var hasStringJoinBug; + try { + hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3'; + } catch (e) { + hasStringJoinBug = true; + } + if (hasStringJoinBug) { + defineProperties(ArrayPrototype, { + join: function join(separator) { + var sep = typeof separator === 'undefined' ? ',' : separator; + return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep); + } + }, hasStringJoinBug); + } + + var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2'; + if (hasJoinUndefinedBug) { + defineProperties(ArrayPrototype, { + join: function join(separator) { + var sep = typeof separator === 'undefined' ? ',' : separator; + return originalJoin.call(this, sep); + } + }, hasJoinUndefinedBug); + } + + var pushShim = function push(item) { + var O = ES.ToObject(this); + var n = ES.ToUint32(O.length); + var i = 0; + while (i < arguments.length) { + O[n + i] = arguments[i]; + i += 1; + } + O.length = n + i; + return n + i; + }; + + var pushIsNotGeneric = (function () { + var obj = {}; + var result = Array.prototype.push.call(obj, undefined); + return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0); + }()); + defineProperties(ArrayPrototype, { + push: function push(item) { + if (isArray(this)) { + return array_push.apply(this, arguments); + } + return pushShim.apply(this, arguments); + } + }, pushIsNotGeneric); + + // This fixes a very weird bug in Opera 10.6 when pushing `undefined + var pushUndefinedIsWeird = (function () { + var arr = []; + var result = arr.push(undefined); + return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0); + }()); + defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird); + + // ES5 15.2.3.14 + // http://es5.github.io/#x15.4.4.10 + // Fix boxed string bug + defineProperties(ArrayPrototype, { + slice: function (start, end) { + var arr = isString(this) ? strSplit(this, '') : this; + return arraySliceApply(arr, arguments); + } + }, splitString); + + var sortIgnoresNonFunctions = (function () { + try { + [1, 2].sort(null); + } catch (e) { + try { + [1, 2].sort({}); + } catch (e2) { + return false; + } + } + return true; + }()); + var sortThrowsOnRegex = (function () { + // this is a problem in Firefox 4, in which `typeof /a/ === 'function'` + try { + [1, 2].sort(/a/); + return false; + } catch (e) {} + return true; + }()); + var sortIgnoresUndefined = (function () { + // applies in IE 8, for one. + try { + [1, 2].sort(undefined); + return true; + } catch (e) {} + return false; + }()); + defineProperties(ArrayPrototype, { + sort: function sort(compareFn) { + if (typeof compareFn === 'undefined') { + return arraySort(this); + } + if (!isCallable(compareFn)) { + throw new TypeError('Array.prototype.sort callback must be a function'); + } + return arraySort(this, compareFn); + } + }, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex); + + // + // Object + // ====== + // + + // ES5 15.2.3.14 + // http://es5.github.com/#x15.2.3.14 + + // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation + var hasDontEnumBug = !isEnum({ 'toString': null }, 'toString'); // jscs:ignore disallowQuotedKeysInObjects + var hasProtoEnumBug = isEnum(function () {}, 'prototype'); + var hasStringEnumBug = !owns('x', '0'); + var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; + }; + var excludedKeys = { + $applicationCache: true, + $console: true, + $external: true, + $frame: true, + $frameElement: true, + $frames: true, + $innerHeight: true, + $innerWidth: true, + $onmozfullscreenchange: true, + $onmozfullscreenerror: true, + $outerHeight: true, + $outerWidth: true, + $pageXOffset: true, + $pageYOffset: true, + $parent: true, + $scrollLeft: true, + $scrollTop: true, + $scrollX: true, + $scrollY: true, + $self: true, + $webkitIndexedDB: true, + $webkitStorageInfo: true, + $window: true, + + $width: true, + $height: true, + $top: true, + $localStorage: true + }; + var hasAutomationEqualityBug = (function () { + /* globals window */ + if (typeof window === 'undefined') { + return false; + } + for (var k in window) { + try { + if (!excludedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') { + equalsConstructorPrototype(window[k]); + } + } catch (e) { + return true; + } + } + return false; + }()); + var equalsConstructorPrototypeIfNotBuggy = function (object) { + if (typeof window === 'undefined' || !hasAutomationEqualityBug) { + return equalsConstructorPrototype(object); + } + try { + return equalsConstructorPrototype(object); + } catch (e) { + return false; + } + }; + var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ]; + var dontEnumsLength = dontEnums.length; + + // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js + // can be replaced with require('is-arguments') if we ever use a build process instead + var isStandardArguments = function isArguments(value) { + return toStr(value) === '[object Arguments]'; + }; + var isLegacyArguments = function isArguments(value) { + return value !== null + && typeof value === 'object' + && typeof value.length === 'number' + && value.length >= 0 + && !isArray(value) + && isCallable(value.callee); + }; + var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; + + defineProperties($Object, { + keys: function keys(object) { + var isFn = isCallable(object); + var isArgs = isArguments(object); + var isObject = object !== null && typeof object === 'object'; + var isStr = isObject && isString(object); + + if (!isObject && !isFn && !isArgs) { + throw new TypeError('Object.keys called on a non-object'); + } + + var theKeys = []; + var skipProto = hasProtoEnumBug && isFn; + if ((isStr && hasStringEnumBug) || isArgs) { + for (var i = 0; i < object.length; ++i) { + pushCall(theKeys, $String(i)); + } + } + + if (!isArgs) { + for (var name in object) { + if (!(skipProto && name === 'prototype') && owns(object, name)) { + pushCall(theKeys, $String(name)); + } + } + } + + if (hasDontEnumBug) { + var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); + for (var j = 0; j < dontEnumsLength; j++) { + var dontEnum = dontEnums[j]; + if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) { + pushCall(theKeys, dontEnum); + } + } + } + return theKeys; + } + }); + + var keysWorksWithArguments = $Object.keys && (function () { + // Safari 5.0 bug + return $Object.keys(arguments).length === 2; + }(1, 2)); + var keysHasArgumentsLengthBug = $Object.keys && (function () { + var argKeys = $Object.keys(arguments); + return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1; + }(1)); + var originalKeys = $Object.keys; + defineProperties($Object, { + keys: function keys(object) { + if (isArguments(object)) { + return originalKeys(arraySlice(object)); + } else { + return originalKeys(object); + } + } + }, !keysWorksWithArguments || keysHasArgumentsLengthBug); + + // + // Date + // ==== + // + + var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0; + var aNegativeTestDate = new Date(-1509842289600292); + var aPositiveTestDate = new Date(1449662400000); + var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT'; + var hasToDateStringFormatBug; + var hasToStringFormatBug; + var timeZoneOffset = aNegativeTestDate.getTimezoneOffset(); + if (timeZoneOffset < -720) { + hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875'; + hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate)); + } else { + hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875'; + hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate)); + } + + var originalGetFullYear = call.bind(Date.prototype.getFullYear); + var originalGetMonth = call.bind(Date.prototype.getMonth); + var originalGetDate = call.bind(Date.prototype.getDate); + var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear); + var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth); + var originalGetUTCDate = call.bind(Date.prototype.getUTCDate); + var originalGetUTCDay = call.bind(Date.prototype.getUTCDay); + var originalGetUTCHours = call.bind(Date.prototype.getUTCHours); + var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes); + var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds); + var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds); + var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + var daysInMonth = function daysInMonth(month, year) { + return originalGetDate(new Date(year, month, 0)); + }; + + defineProperties(Date.prototype, { + getFullYear: function getFullYear() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + if (year < 0 && originalGetMonth(this) > 11) { + return year + 1; + } + return year; + }, + getMonth: function getMonth() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + var month = originalGetMonth(this); + if (year < 0 && month > 11) { + return 0; + } + return month; + }, + getDate: function getDate() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + var month = originalGetMonth(this); + var date = originalGetDate(this); + if (year < 0 && month > 11) { + if (month === 12) { + return date; + } + var days = daysInMonth(0, year + 1); + return (days - date) + 1; + } + return date; + }, + getUTCFullYear: function getUTCFullYear() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + if (year < 0 && originalGetUTCMonth(this) > 11) { + return year + 1; + } + return year; + }, + getUTCMonth: function getUTCMonth() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + var month = originalGetUTCMonth(this); + if (year < 0 && month > 11) { + return 0; + } + return month; + }, + getUTCDate: function getUTCDate() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + var month = originalGetUTCMonth(this); + var date = originalGetUTCDate(this); + if (year < 0 && month > 11) { + if (month === 12) { + return date; + } + var days = daysInMonth(0, year + 1); + return (days - date) + 1; + } + return date; + } + }, hasNegativeMonthYearBug); + + defineProperties(Date.prototype, { + toUTCString: function toUTCString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = originalGetUTCDay(this); + var date = originalGetUTCDate(this); + var month = originalGetUTCMonth(this); + var year = originalGetUTCFullYear(this); + var hour = originalGetUTCHours(this); + var minute = originalGetUTCMinutes(this); + var second = originalGetUTCSeconds(this); + return dayName[day] + ', ' + + (date < 10 ? '0' + date : date) + ' ' + + monthName[month] + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT'; + } + }, hasNegativeMonthYearBug || hasToUTCStringFormatBug); + + // Opera 12 has `,` + defineProperties(Date.prototype, { + toDateString: function toDateString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = this.getDay(); + var date = this.getDate(); + var month = this.getMonth(); + var year = this.getFullYear(); + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year; + } + }, hasNegativeMonthYearBug || hasToDateStringFormatBug); + + // can't use defineProperties here because of toString enumeration issue in IE <= 8 + if (hasNegativeMonthYearBug || hasToStringFormatBug) { + Date.prototype.toString = function toString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = this.getDay(); + var date = this.getDate(); + var month = this.getMonth(); + var year = this.getFullYear(); + var hour = this.getHours(); + var minute = this.getMinutes(); + var second = this.getSeconds(); + var timezoneOffset = this.getTimezoneOffset(); + var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60); + var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60); + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT' + + (timezoneOffset > 0 ? '-' : '+') + + (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) + + (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset); + }; + if (supportsDescriptors) { + $Object.defineProperty(Date.prototype, 'toString', { + configurable: true, + enumerable: false, + writable: true + }); + } + } + + // ES5 15.9.5.43 + // http://es5.github.com/#x15.9.5.43 + // This function returns a String value represent the instance in time + // represented by this Date object. The format of the String is the Date Time + // string format defined in 15.9.1.15. All fields are present in the String. + // The time zone is always UTC, denoted by the suffix Z. If the time value of + // this object is not a finite Number a RangeError exception is thrown. + var negativeDate = -62198755200000; + var negativeYearString = '-000001'; + var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1; // eslint-disable-line max-len + var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z'; + + var getTime = call.bind(Date.prototype.getTime); + + defineProperties(Date.prototype, { + toISOString: function toISOString() { + if (!isFinite(this) || !isFinite(getTime(this))) { + // Adope Photoshop requires the second check. + throw new RangeError('Date.prototype.toISOString called on non-finite value.'); + } + + var year = originalGetUTCFullYear(this); + + var month = originalGetUTCMonth(this); + // see https://github.com/es-shims/es5-shim/issues/111 + year += Math.floor(month / 12); + month = ((month % 12) + 12) % 12; + + // the date time string format is specified in 15.9.1.15. + var result = [ + month + 1, + originalGetUTCDate(this), + originalGetUTCHours(this), + originalGetUTCMinutes(this), + originalGetUTCSeconds(this) + ]; + year = ( + (year < 0 ? '-' : (year > 9999 ? '+' : '')) + + strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6) + ); + + for (var i = 0; i < result.length; ++i) { + // pad months, days, hours, minutes, and seconds to have two digits. + result[i] = strSlice('00' + result[i], -2); + } + // pad milliseconds to have three digits. + return ( + year + '-' + arraySlice(result, 0, 2).join('-') + + 'T' + arraySlice(result, 2).join(':') + '.' + + strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z' + ); + } + }, hasNegativeDateBug || hasSafari51DateBug); + + // ES5 15.9.5.44 + // http://es5.github.com/#x15.9.5.44 + // This function provides a String representation of a Date object for use by + // JSON.stringify (15.12.3). + var dateToJSONIsSupported = (function () { + try { + return Date.prototype.toJSON + && new Date(NaN).toJSON() === null + && new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 + && Date.prototype.toJSON.call({ // generic + toISOString: function () { return true; } + }); + } catch (e) { + return false; + } + }()); + if (!dateToJSONIsSupported) { + Date.prototype.toJSON = function toJSON(key) { + // When the toJSON method is called with argument key, the following + // steps are taken: + + // 1. Let O be the result of calling ToObject, giving it the this + // value as its argument. + // 2. Let tv be ES.ToPrimitive(O, hint Number). + var O = $Object(this); + var tv = ES.ToPrimitive(O); + // 3. If tv is a Number and is not finite, return null. + if (typeof tv === 'number' && !isFinite(tv)) { + return null; + } + // 4. Let toISO be the result of calling the [[Get]] internal method of + // O with argument "toISOString". + var toISO = O.toISOString; + // 5. If IsCallable(toISO) is false, throw a TypeError exception. + if (!isCallable(toISO)) { + throw new TypeError('toISOString property is not callable'); + } + // 6. Return the result of calling the [[Call]] internal method of + // toISO with O as the this value and an empty argument list. + return toISO.call(O); + + // NOTE 1 The argument is ignored. + + // NOTE 2 The toJSON function is intentionally generic; it does not + // require that its this value be a Date object. Therefore, it can be + // transferred to other kinds of objects for use as a method. However, + // it does require that any such object have a toISOString method. An + // object is free to use the argument key to filter its + // stringification. + }; + } + + // ES5 15.9.4.2 + // http://es5.github.com/#x15.9.4.2 + // based on work shared by Daniel Friesen (dantman) + // http://gist.github.com/303249 + var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15; + var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z')); + var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z')); + if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) { + // XXX global assignment won't work in embeddings that use + // an alternate object for the context. + var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1; + var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime()); + // eslint-disable-next-line no-implicit-globals, no-global-assign + Date = (function (NativeDate) { + // Date.length === 7 + var DateShim = function Date(Y, M, D, h, m, s, ms) { + var length = arguments.length; + var date; + if (this instanceof NativeDate) { + var seconds = s; + var millis = ms; + if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) { + // work around a Safari 8/9 bug where it treats the seconds as signed + var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; + var sToShift = Math.floor(msToShift / 1e3); + seconds += sToShift; + millis -= sToShift * 1e3; + } + date = length === 1 && $String(Y) === Y // isString(Y) + // We explicitly pass it through parse: + ? new NativeDate(DateShim.parse(Y)) + // We have to manually make calls depending on argument + // length here + : length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) + : length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) + : length >= 5 ? new NativeDate(Y, M, D, h, m) + : length >= 4 ? new NativeDate(Y, M, D, h) + : length >= 3 ? new NativeDate(Y, M, D) + : length >= 2 ? new NativeDate(Y, M) + : length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) + : new NativeDate(); + } else { + date = NativeDate.apply(this, arguments); + } + if (!isPrimitive(date)) { + // Prevent mixups with unfixed Date object + defineProperties(date, { constructor: DateShim }, true); + } + return date; + }; + + // 15.9.1.15 Date Time String Format. + var isoDateExpression = new RegExp('^' + + '(\\d{4}|[+-]\\d{6})' // four-digit year capture or sign + 6-digit extended year + + '(?:-(\\d{2})' // optional month capture + + '(?:-(\\d{2})' // optional day capture + + '(?:' // capture hours:minutes:seconds.milliseconds + + 'T(\\d{2})' // hours capture + + ':(\\d{2})' // minutes capture + + '(?:' // optional :seconds.milliseconds + + ':(\\d{2})' // seconds capture + + '(?:(\\.\\d{1,}))?' // milliseconds capture + + ')?' + + '(' // capture UTC offset component + + 'Z|' // UTC capture + + '(?:' // offset specifier +/-hours:minutes + + '([-+])' // sign capture + + '(\\d{2})' // hours offset capture + + ':(\\d{2})' // minutes offset capture + + ')' + + ')?)?)?)?' + + '$'); + + var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]; + + var dayFromMonth = function dayFromMonth(year, month) { + var t = month > 1 ? 1 : 0; + return ( + months[month] + + Math.floor((year - 1969 + t) / 4) + - Math.floor((year - 1901 + t) / 100) + + Math.floor((year - 1601 + t) / 400) + + (365 * (year - 1970)) + ); + }; + + var toUTC = function toUTC(t) { + var s = 0; + var ms = t; + if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) { + // work around a Safari 8/9 bug where it treats the seconds as signed + var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; + var sToShift = Math.floor(msToShift / 1e3); + s += sToShift; + ms -= sToShift * 1e3; + } + return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms)); + }; + + // Copy any custom methods a 3rd party library may have added + for (var key in NativeDate) { + if (owns(NativeDate, key)) { + DateShim[key] = NativeDate[key]; + } + } + + // Copy "native" methods explicitly; they may be non-enumerable + defineProperties(DateShim, { + now: NativeDate.now, + UTC: NativeDate.UTC + }, true); + DateShim.prototype = NativeDate.prototype; + defineProperties(DateShim.prototype, { constructor: DateShim }, true); + + // Upgrade Date.parse to handle simplified ISO 8601 strings + var parseShim = function parse(string) { + var match = isoDateExpression.exec(string); + if (match) { + // parse months, days, hours, minutes, seconds, and milliseconds + // provide default values if necessary + // parse the UTC offset component + var year = $Number(match[1]), + month = $Number(match[2] || 1) - 1, + day = $Number(match[3] || 1) - 1, + hour = $Number(match[4] || 0), + minute = $Number(match[5] || 0), + second = $Number(match[6] || 0), + millisecond = Math.floor($Number(match[7] || 0) * 1000), + // When time zone is missed, local offset should be used + // (ES 5.1 bug) + // see https://bugs.ecmascript.org/show_bug.cgi?id=112 + isLocalTime = Boolean(match[4] && !match[8]), + signOffset = match[9] === '-' ? 1 : -1, + hourOffset = $Number(match[10] || 0), + minuteOffset = $Number(match[11] || 0), + result; + var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0; + if ( + hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) + && minute < 60 && second < 60 && millisecond < 1000 + && month > -1 && month < 12 && hourOffset < 24 + && minuteOffset < 60 // detect invalid offsets + && day > -1 + && day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month)) + ) { + result = ( + ((dayFromMonth(year, month) + day) * 24) + + hour + + (hourOffset * signOffset) + ) * 60; + result = (( + ((result + minute + (minuteOffset * signOffset)) * 60) + + second + ) * 1000) + millisecond; + if (isLocalTime) { + result = toUTC(result); + } + if (-8.64e15 <= result && result <= 8.64e15) { + return result; + } + } + return NaN; + } + return NativeDate.parse.apply(this, arguments); + }; + defineProperties(DateShim, { parse: parseShim }); + + return DateShim; + }(Date)); + } + + // ES5 15.9.4.4 + // http://es5.github.com/#x15.9.4.4 + if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; + } + + // + // Number + // ====== + // + + // ES5.1 15.7.4.5 + // http://es5.github.com/#x15.7.4.5 + var hasToFixedBugs = NumberPrototype.toFixed && ( + (0.00008).toFixed(3) !== '0.000' + || (0.9).toFixed(0) !== '1' + || (1.255).toFixed(2) !== '1.25' + || (1000000000000000128).toFixed(0) !== '1000000000000000128' + ); + + var toFixedHelpers = { + base: 1e7, + size: 6, + data: [0, 0, 0, 0, 0, 0], + multiply: function multiply(n, c) { + var i = -1; + var c2 = c; + while (++i < toFixedHelpers.size) { + c2 += n * toFixedHelpers.data[i]; + toFixedHelpers.data[i] = c2 % toFixedHelpers.base; + c2 = Math.floor(c2 / toFixedHelpers.base); + } + }, + divide: function divide(n) { + var i = toFixedHelpers.size; + var c = 0; + while (--i >= 0) { + c += toFixedHelpers.data[i]; + toFixedHelpers.data[i] = Math.floor(c / n); + c = (c % n) * toFixedHelpers.base; + } + }, + numToString: function numToString() { + var i = toFixedHelpers.size; + var s = ''; + while (--i >= 0) { + if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) { + var t = $String(toFixedHelpers.data[i]); + if (s === '') { + s = t; + } else { + s += strSlice('0000000', 0, 7 - t.length) + t; + } + } + } + return s; + }, + pow: function pow(x, n, acc) { + return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc))); + }, + log: function log(x) { + var n = 0; + var x2 = x; + while (x2 >= 4096) { + n += 12; + x2 /= 4096; + } + while (x2 >= 2) { + n += 1; + x2 /= 2; + } + return n; + } + }; + + var toFixedShim = function toFixed(fractionDigits) { + var f, x, s, m, e, z, j, k; + + // Test for NaN and round fractionDigits down + f = $Number(fractionDigits); + f = isActualNaN(f) ? 0 : Math.floor(f); + + if (f < 0 || f > 20) { + throw new RangeError('Number.toFixed called with invalid number of decimals'); + } + + x = $Number(this); + + if (isActualNaN(x)) { + return 'NaN'; + } + + // If it is too big or small, return the string value of the number + if (x <= -1e21 || x >= 1e21) { + return $String(x); + } + + s = ''; + + if (x < 0) { + s = '-'; + x = -x; + } + + m = '0'; + + if (x > 1e-21) { + // 1e-21 < x < 1e21 + // -70 < log2(x) < 70 + e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69; + z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1)); + z *= 0x10000000000000; // Math.pow(2, 52); + e = 52 - e; + + // -18 < e < 122 + // x = z / 2 ^ e + if (e > 0) { + toFixedHelpers.multiply(0, z); + j = f; + + while (j >= 7) { + toFixedHelpers.multiply(1e7, 0); + j -= 7; + } + + toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0); + j = e - 1; + + while (j >= 23) { + toFixedHelpers.divide(1 << 23); + j -= 23; + } + + toFixedHelpers.divide(1 << j); + toFixedHelpers.multiply(1, 1); + toFixedHelpers.divide(2); + m = toFixedHelpers.numToString(); + } else { + toFixedHelpers.multiply(0, z); + toFixedHelpers.multiply(1 << (-e), 0); + m = toFixedHelpers.numToString() + strSlice('0.00000000000000000000', 2, 2 + f); + } + } + + if (f > 0) { + k = m.length; + + if (k <= f) { + m = s + strSlice('0.0000000000000000000', 0, f - k + 2) + m; + } else { + m = s + strSlice(m, 0, k - f) + '.' + strSlice(m, k - f); + } + } else { + m = s + m; + } + + return m; + }; + defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs); + + var hasToPrecisionUndefinedBug = (function () { + try { + return 1.0.toPrecision(undefined) === '1'; + } catch (e) { + return true; + } + }()); + var originalToPrecision = NumberPrototype.toPrecision; + defineProperties(NumberPrototype, { + toPrecision: function toPrecision(precision) { + return typeof precision === 'undefined' ? originalToPrecision.call(this) : originalToPrecision.call(this, precision); + } + }, hasToPrecisionUndefinedBug); + + // + // String + // ====== + // + + // ES5 15.5.4.14 + // http://es5.github.com/#x15.5.4.14 + + // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers] + // Many browsers do not split properly with regular expressions or they + // do not perform the split correctly under obscure conditions. + // See http://blog.stevenlevithan.com/archives/cross-browser-split + // I've tested in many browsers and this seems to cover the deviant ones: + // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""] + // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""] + // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not + // [undefined, "t", undefined, "e", ...] + // ''.split(/.?/) should be [], not [""] + // '.'.split(/()()/) should be ["."], not ["", "", "."] + + 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 compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group + var maxSafe32BitInt = Math.pow(2, 32) - 1; + + StringPrototype.split = function (separator, limit) { + var string = String(this); + if (typeof separator === 'undefined' && limit === 0) { + return []; + } + + // If `separator` is not a regex, use native split + if (!isRegex(separator)) { + return strSplit(this, separator, limit); + } + + var output = []; + var flags = (separator.ignoreCase ? 'i' : '') + + (separator.multiline ? 'm' : '') + + (separator.unicode ? 'u' : '') // in ES6 + + (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6 + lastLastIndex = 0, + // Make `global` and avoid `lastIndex` issues by working with a copy + separator2, match, lastIndex, lastLength; + var separatorCopy = new RegExp(separator.source, flags + 'g'); + if (!compliantExecNpcg) { + // Doesn't need flags gy, but they don't hurt + separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); + } + /* Values for `limit`, per the spec: + * If undefined: 4294967295 // maxSafe32BitInt + * If 0, Infinity, or NaN: 0 + * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296; + * If negative number: 4294967296 - Math.floor(Math.abs(limit)) + * If other: Type-convert, then use the above rules + */ + var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit); + match = separatorCopy.exec(string); + while (match) { + // `separatorCopy.lastIndex` is not reliable cross-browser + lastIndex = match.index + match[0].length; + if (lastIndex > lastLastIndex) { + pushCall(output, strSlice(string, lastLastIndex, match.index)); + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1) { + /* eslint-disable no-loop-func */ + match[0].replace(separator2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (typeof arguments[i] === 'undefined') { + match[i] = void 0; + } + } + }); + /* eslint-enable no-loop-func */ + } + if (match.length > 1 && match.index < string.length) { + array_push.apply(output, arraySlice(match, 1)); + } + lastLength = match[0].length; + lastLastIndex = lastIndex; + if (output.length >= splitLimit) { + break; + } + } + if (separatorCopy.lastIndex === match.index) { + separatorCopy.lastIndex++; // Avoid an infinite loop + } + match = separatorCopy.exec(string); + } + if (lastLastIndex === string.length) { + if (lastLength || !separatorCopy.test('')) { + pushCall(output, ''); + } + } else { + pushCall(output, strSlice(string, lastLastIndex)); + } + return output.length > splitLimit ? arraySlice(output, 0, splitLimit) : output; + }; + }()); + + // [bugfix, chrome] + // If separator is undefined, then the result array contains just one String, + // which is the this value (converted to a String). If limit is not undefined, + // then the output array is truncated so that it contains no more than limit + // elements. + // "0".split(undefined, 0) -> [] + } else if ('0'.split(void 0, 0).length) { + StringPrototype.split = function split(separator, limit) { + if (typeof separator === 'undefined' && limit === 0) { + return []; + } + return strSplit(this, separator, limit); + }; + } + + var str_replace = StringPrototype.replace; + var replaceReportsGroupsCorrectly = (function () { + var groups = []; + 'x'.replace(/x(.)?/g, function (match, group) { + pushCall(groups, group); + }); + return groups.length === 1 && typeof groups[0] === 'undefined'; + }()); + + if (!replaceReportsGroupsCorrectly) { + StringPrototype.replace = function replace(searchValue, replaceValue) { + var isFn = isCallable(replaceValue); + var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source); + if (!isFn || !hasCapturingGroups) { + return str_replace.call(this, searchValue, replaceValue); + } else { + var wrappedReplaceValue = function (match) { + var length = arguments.length; + var originalLastIndex = searchValue.lastIndex; + searchValue.lastIndex = 0; // eslint-disable-line no-param-reassign + var args = searchValue.exec(match) || []; + searchValue.lastIndex = originalLastIndex; // eslint-disable-line no-param-reassign + pushCall(args, arguments[length - 2], arguments[length - 1]); + return replaceValue.apply(this, args); + }; + return str_replace.call(this, searchValue, wrappedReplaceValue); + } + }; + } + + // ECMA-262, 3rd B.2.3 + // Not an ECMAScript standard, although ECMAScript 3rd Edition has a + // non-normative section suggesting uniform semantics and it should be + // normalized across all browsers + // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE + var string_substr = StringPrototype.substr; + var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b'; + defineProperties(StringPrototype, { + substr: function substr(start, length) { + var normalizedStart = start; + if (start < 0) { + normalizedStart = max(this.length + start, 0); + } + return string_substr.call(this, normalizedStart, length); + } + }, hasNegativeSubstrBug); + + // ES5 15.5.4.20 + // whitespace from: http://es5.github.io/#x15.5.4.20 + 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'; + var zeroWidth = '\u200b'; + var wsRegexChars = '[' + ws + ']'; + var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*'); + var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$'); + var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim()); + defineProperties(StringPrototype, { + // http://blog.stevenlevithan.com/archives/faster-trim-javascript + // http://perfectionkills.com/whitespace-deviations/ + trim: function trim() { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, ''); + } + }, hasTrimWhitespaceBug); + var trim = call.bind(String.prototype.trim); + + var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1; + defineProperties(StringPrototype, { + lastIndexOf: function lastIndexOf(searchString) { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + var S = $String(this); + var searchStr = $String(searchString); + var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN; + var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos); + var start = min(max(pos, 0), S.length); + var searchLen = searchStr.length; + var k = start + searchLen; + while (k > 0) { + k = max(0, k - searchLen); + var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr); + if (index !== -1) { + return k + index; + } + } + return -1; + } + }, hasLastIndexBug); + + var originalLastIndexOf = StringPrototype.lastIndexOf; + defineProperties(StringPrototype, { + lastIndexOf: function lastIndexOf(searchString) { + return originalLastIndexOf.apply(this, arguments); + } + }, StringPrototype.lastIndexOf.length !== 1); + + // ES-5 15.1.2.2 + // eslint-disable-next-line radix + if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) { + // eslint-disable-next-line no-global-assign, no-implicit-globals + parseInt = (function (origParseInt) { + var hexRegex = /^[-+]?0[xX]/; + return function parseInt(str, radix) { + if (typeof str === 'symbol') { + // handle Symbols in node 8.3/8.4 + // eslint-disable-next-line no-implicit-coercion, no-unused-expressions + '' + str; // jscs:ignore disallowImplicitTypeConversion + } + + var string = trim(String(str)); + var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); + return origParseInt(string, defaultedRadix); + }; + }(parseInt)); + } + + // https://es5.github.io/#x15.1.2.3 + if (1 / parseFloat('-0') !== -Infinity) { + // eslint-disable-next-line no-global-assign, no-implicit-globals, no-native-reassign + parseFloat = (function (origParseFloat) { + return function parseFloat(string) { + var inputString = trim(String(string)); + var result = origParseFloat(inputString); + return result === 0 && strSlice(inputString, 0, 1) === '-' ? -0 : result; + }; + }(parseFloat)); + } + + if (String(new RangeError('test')) !== 'RangeError: test') { + var errorToStringShim = function toString() { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + var name = this.name; + if (typeof name === 'undefined') { + name = 'Error'; + } else if (typeof name !== 'string') { + name = $String(name); + } + var msg = this.message; + if (typeof msg === 'undefined') { + msg = ''; + } else if (typeof msg !== 'string') { + msg = $String(msg); + } + if (!name) { + return msg; + } + if (!msg) { + return name; + } + return name + ': ' + msg; + }; + // can't use defineProperties here because of toString enumeration issue in IE <= 8 + Error.prototype.toString = errorToStringShim; + } + + if (supportsDescriptors) { + var ensureNonEnumerable = function (obj, prop) { + if (isEnum(obj, prop)) { + var desc = Object.getOwnPropertyDescriptor(obj, prop); + if (desc.configurable) { + desc.enumerable = false; + Object.defineProperty(obj, prop, desc); + } + } + }; + ensureNonEnumerable(Error.prototype, 'message'); + if (Error.prototype.message !== '') { + Error.prototype.message = ''; + } + ensureNonEnumerable(Error.prototype, 'name'); + } + + if (String(/a/mig) !== '/a/gim') { + var regexToString = function toString() { + var str = '/' + this.source + '/'; + if (this.global) { + str += 'g'; + } + if (this.ignoreCase) { + str += 'i'; + } + if (this.multiline) { + str += 'm'; + } + return str; + }; + // can't use defineProperties here because of toString enumeration issue in IE <= 8 + RegExp.prototype.toString = regexToString; + } +})); diff --git a/node_modules/es5-shim/es5-shim.map b/node_modules/es5-shim/es5-shim.map new file mode 100644 index 0000000..f88977a --- /dev/null +++ b/node_modules/es5-shim/es5-shim.map @@ -0,0 +1 @@ +{"version":3,"sources":["es5-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","$Array","Array","ArrayPrototype","prototype","$Object","Object","ObjectPrototype","$Function","Function","FunctionPrototype","$String","String","StringPrototype","$Number","Number","NumberPrototype","array_slice","slice","array_splice","splice","array_push","push","array_unshift","unshift","array_concat","concat","array_join","join","call","apply","max","Math","min","to_string","toString","hasToStringTag","Symbol","toStringTag","isCallable","fnToStr","constructorRegex","isES6ClassFn","value","fnStr","singleStripped","replace","multiStripped","spaceStripped","test","e","tryFunctionObject","fnClass","genClass","strClass","isRegex","regexExec","RegExp","exec","tryRegexExec","regexClass","isString","strValue","valueOf","tryStringObject","stringClass","supportsDescriptors","defineProperty","obj","enumerable","_","x","defineProperties","has","object","name","method","forceAssign","configurable","writable","map","hasOwnProperty","isPrimitive","input","type","isActualNaN","isNaN","ES","ToInteger","num","n","floor","abs","ToPrimitive","val","toStr","TypeError","ToObject","o","ToUint32","Empty","bind","that","target","args","arguments","bound","binder","result","boundLength","length","boundArgs","i","owns","arraySlice","arraySliceApply","document","documentElement","childNodes","origArraySlice","origArraySliceApply","arraySliceIE","arr","r","arraySliceApplyIE","strSlice","strSplit","split","strIndexOf","indexOf","pushCall","isEnum","propertyIsEnumerable","arraySort","sort","isArray","hasUnshiftReturnValueBug","boxedString","splitString","properlyBoxesContext","properlyBoxed","properlyBoxesNonStrict","properlyBoxesStrict","threwException","__","context","forEach","callbackfn","self","T","filter","every","some","reduceCoercesToObject","reduce","___","list","reduceRightCoercesToObject","reduceRight","hasFirefox2IndexOfBug","searchElement","hasFirefox2LastIndexOfBug","lastIndexOf","spliceNoopReturnsEmptyArray","a","start","deleteCount","spliceWorksWithEmptyObject","spliceWorksWithLargeSparseArrays","spliceWorksWithSmallSparseArrays","O","A","len","relativeStart","actualStart","actualDeleteCount","k","from","items","itemCount","to","maxK","minK","originalJoin","hasStringJoinBug","separator","sep","hasJoinUndefinedBug","undefined","pushShim","item","pushIsNotGeneric","pushUndefinedIsWeird","end","sortIgnoresNonFunctions","e2","sortThrowsOnRegex","sortIgnoresUndefined","compareFn","hasDontEnumBug","hasProtoEnumBug","hasStringEnumBug","equalsConstructorPrototype","ctor","constructor","excludedKeys","$applicationCache","$console","$external","$frame","$frameElement","$frames","$innerHeight","$innerWidth","$onmozfullscreenchange","$onmozfullscreenerror","$outerHeight","$outerWidth","$pageXOffset","$pageYOffset","$parent","$scrollLeft","$scrollTop","$scrollX","$scrollY","$self","$webkitIndexedDB","$webkitStorageInfo","$window","$width","$height","$top","$localStorage","hasAutomationEqualityBug","window","equalsConstructorPrototypeIfNotBuggy","dontEnums","dontEnumsLength","isStandardArguments","isArguments","isLegacyArguments","callee","keys","isFn","isArgs","isObject","isStr","theKeys","skipProto","skipConstructor","j","dontEnum","keysWorksWithArguments","keysHasArgumentsLengthBug","argKeys","originalKeys","hasNegativeMonthYearBug","Date","getUTCMonth","aNegativeTestDate","aPositiveTestDate","hasToUTCStringFormatBug","toUTCString","hasToDateStringFormatBug","hasToStringFormatBug","timeZoneOffset","getTimezoneOffset","toDateString","originalGetFullYear","getFullYear","originalGetMonth","getMonth","originalGetDate","getDate","originalGetUTCFullYear","getUTCFullYear","originalGetUTCMonth","originalGetUTCDate","getUTCDate","originalGetUTCDay","getUTCDay","originalGetUTCHours","getUTCHours","originalGetUTCMinutes","getUTCMinutes","originalGetUTCSeconds","getUTCSeconds","originalGetUTCMilliseconds","getUTCMilliseconds","dayName","monthName","daysInMonth","month","year","date","days","day","hour","minute","second","getDay","getHours","getMinutes","getSeconds","timezoneOffset","hoursOffset","minutesOffset","negativeDate","negativeYearString","hasNegativeDateBug","toISOString","hasSafari51DateBug","getTime","isFinite","RangeError","dateToJSONIsSupported","toJSON","NaN","key","tv","toISO","supportsExtendedYears","parse","acceptsInvalidDates","doesNotParseY2KNewYear","maxSafeUnsigned32Bit","pow","hasSafariSignedIntBug","NativeDate","DateShim","Y","M","D","h","m","s","ms","seconds","millis","msToShift","sToShift","isoDateExpression","months","dayFromMonth","t","toUTC","now","UTC","parseShim","string","match","millisecond","isLocalTime","Boolean","signOffset","hourOffset","minuteOffset","hasMinutesOrSecondsOrMilliseconds","hasToFixedBugs","toFixed","toFixedHelpers","base","size","data","multiply","c","c2","divide","numToString","acc","log","x2","toFixedShim","fractionDigits","f","z","hasToPrecisionUndefinedBug","toPrecision","originalToPrecision","precision","compliantExecNpcg","maxSafe32BitInt","limit","output","flags","ignoreCase","multiline","unicode","sticky","lastLastIndex","separator2","lastIndex","lastLength","separatorCopy","source","splitLimit","index","str_replace","replaceReportsGroupsCorrectly","groups","group","searchValue","replaceValue","hasCapturingGroups","wrappedReplaceValue","originalLastIndex","string_substr","substr","hasNegativeSubstrBug","normalizedStart","ws","zeroWidth","wsRegexChars","trimBeginRegexp","trimEndRegexp","hasTrimWhitespaceBug","trim","hasLastIndexBug","searchString","S","searchStr","numPos","pos","Infinity","searchLen","originalLastIndexOf","parseInt","origParseInt","hexRegex","str","radix","defaultedRadix","parseFloat","origParseFloat","inputString","errorToStringShim","msg","message","Error","ensureNonEnumerable","prop","desc","getOwnPropertyDescriptor","regexToString","global"],"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,WAaJ,GAAIC,GAASC,KACb,IAAIC,GAAiBF,EAAOG,SAC5B,IAAIC,GAAUC,MACd,IAAIC,GAAkBF,EAAQD,SAC9B,IAAII,GAAYC,QAChB,IAAIC,GAAoBF,EAAUJ,SAClC,IAAIO,GAAUC,MACd,IAAIC,GAAkBF,EAAQP,SAC9B,IAAIU,GAAUC,MACd,IAAIC,GAAkBF,EAAQV,SAC9B,IAAIa,GAAcd,EAAee,KACjC,IAAIC,GAAehB,EAAeiB,MAClC,IAAIC,GAAalB,EAAemB,IAChC,IAAIC,GAAgBpB,EAAeqB,OACnC,IAAIC,GAAetB,EAAeuB,MAClC,IAAIC,GAAaxB,EAAeyB,IAChC,IAAIC,GAAOnB,EAAkBmB,IAC7B,IAAIC,GAAQpB,EAAkBoB,KAC9B,IAAIC,GAAMC,KAAKD,GACf,IAAIE,GAAMD,KAAKC,GAGf,IAAIC,GAAY3B,EAAgB4B,QAGhC,IAAIC,SAAwBC,UAAW,kBAAqBA,QAAOC,cAAgB,QACnF,IAAIC,EAA6D,IAAIC,GAAU/B,SAASL,UAAU+B,SAAUM,EAAmB,aAAcC,EAAe,QAASA,cAAaC,GAAS,IAAM,GAAIC,GAAQJ,EAAQX,KAAKc,EAAQ,IAAIE,GAAiBD,EAAME,QAAQ,YAAa,GAAK,IAAIC,GAAg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AAa,CAC7BA,EAAO,YACJ,UAAWA,KAAS,SAAU,CACjCA,EAAOhE,EAAQgE,GAEnB,GAAIyW,GAAMpb,KAAKqb,OACf,UAAWD,KAAQ,YAAa,CAC5BA,EAAM,OACH,UAAWA,KAAQ,SAAU,CAChCA,EAAMza,EAAQya,GAElB,IAAKzW,EAAM,CACP,MAAOyW,GAEX,IAAKA,EAAK,CACN,MAAOzW,GAEX,MAAOA,GAAO,KAAOyW,EAGzBE,OAAMlb,UAAU+B,SAAWgZ,GAG/B,GAAIjX,EAAqB,CACrB,GAAIqX,IAAsB,SAAUnX,EAAKoX,GACrC,GAAIrT,GAAO/D,EAAKoX,GAAO,CACnB,GAAIC,GAAOnb,OAAOob,yBAAyBtX,EAAKoX,EAChD,IAAIC,EAAK3W,aAAc,CACnB2W,EAAKpX,WAAa,KAClB/D,QAAO6D,eAAeC,EAAKoX,EAAMC,KAI7CF,IAAoBD,MAAMlb,UAAW,UACrC,IAAIkb,MAAMlb,UAAUib,UAAY,GAAI,CAChCC,MAAMlb,UAAUib,QAAU,GAE9BE,GAAoBD,MAAMlb,UAAW,QAGzC,GAAIQ,OAAO,UAAY,SAAU,CAC7B,GAAI+a,IAAgB,QAASxZ,YACzB,GAAI0Y,GAAM,IAAM7a,KAAK0Y,OAAS,GAC9B,IAAI1Y,KAAK4b,OAAQ,CACbf,GAAO,IAEX,GAAI7a,KAAKiY,WAAY,CACjB4C,GAAO,IAEX,GAAI7a,KAAKkY,UAAW,CAChB2C,GAAO,IAEX,MAAOA,GAGXpX,QAAOrD,UAAU+B,SAAWwZ"} \ No newline at end of file diff --git a/node_modules/es5-shim/es5-shim.min.js b/node_modules/es5-shim/es5-shim.min.js new file mode 100644 index 0000000..f301219 --- /dev/null +++ b/node_modules/es5-shim/es5-shim.min.js @@ -0,0 +1,7 @@ +/*! + * https://github.com/es-shims/es5-shim + * @license es5-shim Copyright 2009-2020 by contributors, MIT License + * see https://github.com/es-shims/es5-shim/blob/master/LICENSE + */ +(function(t,r){"use strict";if(typeof define==="function"&&define.amd){define(r)}else if(typeof exports==="object"){module.exports=r()}else{t.returnExports=r()}})(this,function(){var t=Array;var r=t.prototype;var e=Object;var n=e.prototype;var i=Function;var a=i.prototype;var o=String;var f=o.prototype;var u=Number;var l=u.prototype;var s=r.slice;var c=r.splice;var v=r.push;var h=r.unshift;var p=r.concat;var y=r.join;var d=a.call;var g=a.apply;var w=Math.max;var b=Math.min;var T=n.toString;var m=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var D;var S=Function.prototype.toString,x=/^\s*class /,O=function isES6ClassFn(t){try{var r=S.call(t);var e=r.replace(/\/\/.*\n/g,"");var n=e.replace(/\/\*[.\s\S]*\*\//g,"");var i=n.replace(/\n/gm," ").replace(/ {2}/g," ");return x.test(i)}catch(a){return false}},E=function tryFunctionObject(t){try{if(O(t)){return false}S.call(t);return true}catch(r){return false}},j="[object Function]",I="[object GeneratorFunction]",D=function isCallable(t){if(!t){return false}if(typeof t!=="function"&&typeof t!=="object"){return false}if(m){return E(t)}if(O(t)){return false}var r=T.call(t);return r===j||r===I};var M;var U=RegExp.prototype.exec,$=function tryRegexExec(t){try{U.call(t);return true}catch(r){return false}},F="[object RegExp]";M=function isRegex(t){if(typeof t!=="object"){return false}return m?$(t):T.call(t)===F};var N;var C=String.prototype.valueOf,k=function tryStringObject(t){try{C.call(t);return true}catch(r){return false}},A="[object String]";N=function isString(t){if(typeof t==="string"){return true}if(typeof t!=="object"){return false}return m?k(t):T.call(t)===A};var R=e.defineProperty&&function(){try{var t={};e.defineProperty(t,"x",{enumerable:false,value:t});for(var r in t){return false}return t.x===t}catch(n){return false}}();var P=function(t){var r;if(R){r=function(t,r,n,i){if(!i&&r in t){return}e.defineProperty(t,r,{configurable:true,enumerable:false,writable:true,value:n})}}else{r=function(t,r,e,n){if(!n&&r in t){return}t[r]=e}}return function defineProperties(e,n,i){for(var a in n){if(t.call(n,a)){r(e,a,n[a],i)}}}}(n.hasOwnProperty);var J=function isPrimitive(t){var r=typeof t;return t===null||r!=="object"&&r!=="function"};var Y=u.isNaN||function isActualNaN(t){return t!==t};var z={ToInteger:function ToInteger(t){var r=+t;if(Y(r)){r=0}else if(r!==0&&r!==1/0&&r!==-(1/0)){r=(r>0||-1)*Math.floor(Math.abs(r))}return r},ToPrimitive:function ToPrimitive(t){var r,e,n;if(J(t)){return t}e=t.valueOf;if(D(e)){r=e.call(t);if(J(r)){return r}}n=t.toString;if(D(n)){r=n.call(t);if(J(r)){return r}}throw new TypeError},ToObject:function(t){if(t==null){throw new TypeError("can't convert "+t+" to object")}return e(t)},ToUint32:function ToUint32(t){return t>>>0}};var Z=function Empty(){};P(a,{bind:function bind(t){var r=this;if(!D(r)){throw new TypeError("Function.prototype.bind called on incompatible "+r)}var n=s.call(arguments,1);var a;var o=function(){if(this instanceof a){var i=g.call(r,this,p.call(n,s.call(arguments)));if(e(i)===i){return i}return this}else{return g.call(r,t,p.call(n,s.call(arguments)))}};var f=w(0,r.length-n.length);var u=[];for(var l=0;l0){r[e]=t[e]}return q(r,L(arguments,1))};B=function arraySliceApplyIE(t,r){return q(W(t),r)}}}var K=d.bind(f.slice);var Q=d.bind(f.split);var V=d.bind(f.indexOf);var _=d.bind(v);var tt=d.bind(n.propertyIsEnumerable);var rt=d.bind(r.sort);var et=t.isArray||function isArray(t){return H(t)==="[object Array]"};var nt=[].unshift(0)!==1;P(r,{unshift:function(){h.apply(this,arguments);return this.length}},nt);P(t,{isArray:et});var it=e("a");var at=it[0]!=="a"||!(0 in it);var ot=function properlyBoxed(t){var r=true;var e=true;var n=false;if(t){try{t.call("foo",function(t,e,n){if(typeof n!=="object"){r=false}});t.call([1],function(){"use strict";e=typeof this==="string"},"x")}catch(i){n=true}}return!!t&&!n&&r&&e};P(r,{forEach:function forEach(t){var r=z.ToObject(this);var e=at&&N(this)?Q(this,""):r;var n=-1;var i=z.ToUint32(e.length);var a;if(arguments.length>1){a=arguments[1]}if(!D(t)){throw new TypeError("Array.prototype.forEach callback must be a function")}while(++n1){o=arguments[1]}if(!D(r)){throw new TypeError("Array.prototype.map callback must be a function")}for(var f=0;f1){o=arguments[1]}if(!D(t)){throw new TypeError("Array.prototype.filter callback must be a function")}for(var f=0;f1){i=arguments[1]}if(!D(t)){throw new TypeError("Array.prototype.every callback must be a function")}for(var a=0;a1){i=arguments[1]}if(!D(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 e){a=e[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 e){i=e[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 e){i=t(i,e[a],a,r)}}while(a--);return i}},!ut);var lt=r.indexOf&&[0,1].indexOf(1,2)!==-1;P(r,{indexOf:function indexOf(t){var r=at&&N(this)?Q(this,""):z.ToObject(this);var e=z.ToUint32(r.length);if(e===0){return-1}var n=0;if(arguments.length>1){n=z.ToInteger(arguments[1])}n=n>=0?n:w(0,e+n);for(;n1){n=b(n,z.ToInteger(arguments[1]))}n=n>=0?n:e-Math.abs(n);for(;n>=0;n--){if(n in r&&t===r[n]){return n}}return-1}},st);var ct=function(){var t=[1,2];var r=t.splice();return t.length===2&&et(r)&&r.length===0}();P(r,{splice:function splice(t,r){if(arguments.length===0){return[]}else{return c.apply(this,arguments)}}},!ct);var vt=function(){var t={};r.splice.call(t,0,0,1);return t.length===1}();P(r,{splice:function splice(t,r){if(arguments.length===0){return[]}var e=arguments;this.length=w(z.ToInteger(this.length),0);if(arguments.length>0&&typeof r!=="number"){e=W(arguments);if(e.length<2){_(e,this.length-t)}else{e[1]=z.ToInteger(r)}}return c.apply(this,e)}},!vt);var ht=function(){var r=new t(1e5);r[8]="x";r.splice(1,1);return r.indexOf("x")===7}();var pt=function(){var t=256;var r=[];r[t]="a";r.splice(t+1,0,"b");return r[t]==="a"}();P(r,{splice:function splice(t,r){var e=z.ToObject(this);var n=[];var i=z.ToUint32(e.length);var a=z.ToInteger(t);var f=a<0?w(i+a,0):b(a,i);var u=arguments.length===0?0:arguments.length===1?i-f:b(w(z.ToInteger(r),0),i-f);var l=0;var s;while(ly){delete e[l-1];l-=1}}else if(v>u){l=i-u;while(l>f){s=o(l+u-1);h=o(l+v-1);if(G(e,s)){e[h]=e[s]}else{delete e[h]}l-=1}}l=f;for(var d=0;d=0&&!et(t)&&D(t.callee)};var kt=Nt(arguments)?Nt:Ct;P(e,{keys:function keys(t){var r=D(t);var e=kt(t);var n=t!==null&&typeof t==="object";var i=n&&N(t);if(!n&&!r&&!e){throw new TypeError("Object.keys called on a non-object")}var a=[];var f=Ot&&r;if(i&&Et||e){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=Bt(this);var r=Xt(this);if(t<0&&r>11){return 0}return r},getDate:function getDate(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=Bt(this);var r=Xt(this);var e=Lt(this);if(t<0&&r>11){if(r===12){return e}var n=ar(0,t+1);return n-e+1}return e},getUTCFullYear:function getUTCFullYear(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=qt(this);if(t<0&&Kt(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=qt(this);var r=Kt(this);if(t<0&&r>11){return 0}return r},getUTCDate:function getUTCDate(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=qt(this);var r=Kt(this);var e=Qt(this);if(t<0&&r>11){if(r===12){return e}var n=ar(0,t+1);return n-e+1}return e}},Jt);P(Date.prototype,{toUTCString:function toUTCString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=Vt(this);var r=Qt(this);var e=Kt(this);var n=qt(this);var i=_t(this);var a=tr(this);var o=rr(this);return nr[t]+", "+(r<10?"0"+r:r)+" "+ir[e]+" "+n+" "+(i<10?"0"+i:i)+":"+(a<10?"0"+a:a)+":"+(o<10?"0"+o:o)+" GMT"}},Jt||Zt);P(Date.prototype,{toDateString:function toDateString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=this.getDay();var r=this.getDate();var e=this.getMonth();var n=this.getFullYear();return nr[t]+" "+ir[e]+" "+(r<10?"0"+r:r)+" "+n}},Jt||Gt);if(Jt||Ht){Date.prototype.toString=function toString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=this.getDay();var r=this.getDate();var e=this.getMonth();var n=this.getFullYear();var i=this.getHours();var a=this.getMinutes();var o=this.getSeconds();var f=this.getTimezoneOffset();var u=Math.floor(Math.abs(f)/60);var l=Math.floor(Math.abs(f)%60);return nr[t]+" "+ir[e]+" "+(r<10?"0"+r:r)+" "+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(R){e.defineProperty(Date.prototype,"toString",{configurable:true,enumerable:false,writable:true})}}var or=-621987552e5;var fr="-000001";var ur=Date.prototype.toISOString&&new Date(or).toISOString().indexOf(fr)===-1;var lr=Date.prototype.toISOString&&new Date(-1).toISOString()!=="1969-12-31T23:59:59.999Z";var sr=d.bind(Date.prototype.getTime);P(Date.prototype,{toISOString:function toISOString(){if(!isFinite(this)||!isFinite(sr(this))){throw new RangeError("Date.prototype.toISOString called on non-finite value.")}var t=qt(this);var r=Kt(this);t+=Math.floor(r/12);r=(r%12+12)%12;var e=[r+1,Qt(this),_t(this),tr(this),rr(this)];t=(t<0?"-":t>9999?"+":"")+K("00000"+Math.abs(t),0<=t&&t<=9999?-4:-6);for(var n=0;n=7&&l>yr){var p=Math.floor(l/yr)*yr;var y=Math.floor(p/1e3);v+=y;h-=y*1e3}c=s===1&&o(e)===e?new t(r.parse(e)):s>=7?new t(e,n,i,a,f,v,h):s>=6?new t(e,n,i,a,f,v):s>=5?new t(e,n,i,a,f):s>=4?new t(e,n,i,a):s>=3?new t(e,n,i):s>=2?new t(e,n):s>=1?new t(e instanceof t?+e:e):new t}else{c=t.apply(this,arguments)}if(!J(c)){P(c,{constructor:r},true)}return c};var e=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,r){var e=r>1?1:0;return n[r]+Math.floor((t-1969+e)/4)-Math.floor((t-1901+e)/100)+Math.floor((t-1601+e)/400)+365*(t-1970)};var a=function toUTC(r){var e=0;var n=r;if(dr&&n>yr){var i=Math.floor(n/yr)*yr;var a=Math.floor(i/1e3);e+=a;n-=a*1e3}return u(new t(1970,0,1,0,0,e,n))};for(var f in t){if(G(t,f)){r[f]=t[f]}}P(r,{now:t.now,UTC:t.UTC},true);r.prototype=t.prototype;P(r.prototype,{constructor:r},true);var l=function parse(r){var n=e.exec(r);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),h=Math.floor(u(n[7]||0)*1e3),p=Boolean(n[4]&&!n[8]),y=n[9]==="-"?1:-1,d=u(n[10]||0),g=u(n[11]||0),w;var b=c>0||v>0||h>0;if(s<(b?24:25)&&c<60&&v<60&&h<1e3&&f>-1&&f<12&&d<24&&g<60&&l>-1&&l=0){e+=wr.data[r];wr.data[r]=Math.floor(e/t);e=e%t*wr.base}},numToString:function numToString(){var t=wr.size;var r="";while(--t>=0){if(r!==""||t===0||wr.data[t]!==0){var e=o(wr.data[t]);if(r===""){r=e}else{r+=K("0000000",0,7-e.length)+e}}}return r},pow:function pow(t,r,e){return r===0?e:r%2===1?pow(t,r-1,e*t):pow(t*t,r/2,e)},log:function log(t){var r=0;var e=t;while(e>=4096){r+=12;e/=4096}while(e>=2){r+=1;e/=2}return r}};var br=function toFixed(t){var r,e,n,i,a,f,l,s;r=u(t);r=Y(r)?0:Math.floor(r);if(r<0||r>20){throw new RangeError("Number.toFixed called with invalid number of decimals")}e=u(this);if(Y(e)){return"NaN"}if(e<=-1e21||e>=1e21){return o(e)}n="";if(e<0){n="-";e=-e}i="0";if(e>1e-21){a=wr.log(e*wr.pow(2,69,1))-69;f=a<0?e*wr.pow(2,-a,1):e/wr.pow(2,a,1);f*=4503599627370496;a=52-a;if(a>0){wr.multiply(0,f);l=r;while(l>=7){wr.multiply(1e7,0);l-=7}wr.multiply(wr.pow(10,l,1),0);l=a-1;while(l>=23){wr.divide(1<<23);l-=23}wr.divide(1<0){s=i.length;if(s<=r){i=n+K("0.0000000000000000000",0,r-s+2)+i}else{i=n+K(i,0,s-r)+"."+K(i,s-r)}}else{i=n+i}return i};P(l,{toFixed:br},gr);var Tr=function(){try{return 1..toPrecision(undefined)==="1"}catch(t){return true}}();var mr=l.toPrecision;P(l,{toPrecision:function toPrecision(t){return typeof t==="undefined"?mr.call(this):mr.call(this,t)}},Tr);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 r=Math.pow(2,32)-1;f.split=function(e,n){var i=String(this);if(typeof e==="undefined"&&n===0){return[]}if(!M(e)){return Q(this,e,n)}var a=[];var o=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),f=0,u,l,s,c;var h=new RegExp(e.source,o+"g");if(!t){u=new RegExp("^"+h.source+"$(?!\\s)",o)}var p=typeof n==="undefined"?r:z.ToUint32(n);l=h.exec(i);while(l){s=l.index+l[0].length;if(s>f){_(a,K(i,f,l.index));if(!t&&l.length>1){l[0].replace(u,function(){for(var t=1;t1&&l.index=p){break}}if(h.lastIndex===l.index){h.lastIndex++}l=h.exec(i)}if(f===i.length){if(c||!h.test("")){_(a,"")}}else{_(a,K(i,f))}return a.length>p?W(a,0,p):a}})()}else if("0".split(void 0,0).length){f.split=function split(t,r){if(typeof t==="undefined"&&r===0){return[]}return Q(this,t,r)}}var Dr=f.replace;var Sr=function(){var t=[];"x".replace(/x(.)?/g,function(r,e){_(t,e)});return t.length===1&&typeof t[0]==="undefined"}();if(!Sr){f.replace=function replace(t,r){var e=D(r);var n=M(t)&&/\)[*?]/.test(t.source);if(!e||!n){return Dr.call(this,t,r)}else{var i=function(e){var n=arguments.length;var i=t.lastIndex;t.lastIndex=0;var a=t.exec(e)||[];t.lastIndex=i;_(a,arguments[n-2],arguments[n-1]);return r.apply(this,a)};return Dr.call(this,t,i)}}}var xr=f.substr;var Or="".substr&&"0b".substr(-1)!=="b";P(f,{substr:function substr(t,r){var e=t;if(t<0){e=w(this.length+t,0)}return xr.call(this,e,r)}},Or);var Er="\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";var jr="\u200b";var Ir="["+Er+"]";var Mr=new RegExp("^"+Ir+Ir+"*");var Ur=new RegExp(Ir+Ir+"*$");var $r=f.trim&&(Er.trim()||!jr.trim());P(f,{trim:function trim(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}return o(this).replace(Mr,"").replace(Ur,"")}},$r);var Fr=d.bind(String.prototype.trim);var Nr=f.lastIndexOf&&"abc\u3042\u3044".lastIndexOf("\u3042\u3044",2)!==-1;P(f,{lastIndexOf:function lastIndexOf(t){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}var r=o(this);var e=o(t);var n=arguments.length>1?u(arguments[1]):NaN;var i=Y(n)?Infinity:z.ToInteger(n);var a=b(w(i,0),r.length);var f=e.length;var l=a+f;while(l>0){l=w(0,l-f);var s=V(K(r,l,a+f),e);if(s!==-1){return l+s}}return-1}},Nr);var Cr=f.lastIndexOf;P(f,{lastIndexOf:function lastIndexOf(t){return Cr.apply(this,arguments)}},f.lastIndexOf.length!==1);if(parseInt(Er+"08")!==8||parseInt(Er+"0x16")!==22){parseInt=function(t){var r=/^[-+]?0[xX]/;return function parseInt(e,n){if(typeof e==="symbol"){""+e}var i=Fr(String(e));var a=u(n)||(r.test(i)?16:10);return t(i,a)}}(parseInt)}if(1/parseFloat("-0")!==-Infinity){parseFloat=function(t){return function parseFloat(r){var e=Fr(String(r));var n=t(e);return n===0&&K(e,0,1)==="-"?-0:n}}(parseFloat)}if(String(new RangeError("test"))!=="RangeError: test"){var kr=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 r=this.message;if(typeof r==="undefined"){r=""}else if(typeof r!=="string"){r=o(r)}if(!t){return r}if(!r){return t}return t+": "+r};Error.prototype.toString=kr}if(R){var Ar=function(t,r){if(tt(t,r)){var e=Object.getOwnPropertyDescriptor(t,r);if(e.configurable){e.enumerable=false;Object.defineProperty(t,r,e)}}};Ar(Error.prototype,"message");if(Error.prototype.message!==""){Error.prototype.message=""}Ar(Error.prototype,"name")}if(String(/a/gim)!=="/a/gim"){var Rr=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=Rr}}); +//# sourceMappingURL=es5-shim.map diff --git a/node_modules/es5-shim/package.json b/node_modules/es5-shim/package.json new file mode 100644 index 0000000..977142f --- /dev/null +++ b/node_modules/es5-shim/package.json @@ -0,0 +1,124 @@ +{ + "_from": "es5-shim", + "_id": "es5-shim@4.5.14", + "_inBundle": false, + "_integrity": "sha512-7SwlpL+2JpymWTt8sNLuC2zdhhc+wrfe5cMPI2j0o6WsPdfAiPwmFy2f0AocPB4RQVBOZ9kNTgi5YF7TdhkvEg==", + "_location": "/es5-shim", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "es5-shim", + "name": "es5-shim", + "escapedName": "es5-shim", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.14.tgz", + "_shasum": "90009e1019d0ea327447cb523deaff8fe45697ef", + "_spec": "es5-shim", + "_where": "C:\\Users\\knh94\\Documents\\GitHub\\welsonjs", + "bugs": { + "url": "http://github.com/es-shims/es5-shim/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Kris Kowal", + "email": "kris@cixar.com", + "url": "http://github.com/kriskowal/" + }, + { + "name": "Sami Samhuri", + "email": "sami.samhuri@gmail.com", + "url": "http://samhuri.net/" + }, + { + "name": "Florian Schäfer", + "email": "florian.schaefer@gmail.com", + "url": "http://github.com/fschaefer" + }, + { + "name": "Irakli Gozalishvili", + "email": "rfobic@gmail.com", + "url": "http://jeditoolkit.com" + }, + { + "name": "Kit Cambridge", + "email": "kitcambridge@gmail.com", + "url": "http://kitcambridge.github.com" + }, + { + "name": "Jordan Harband", + "email": "ljharb@gmail.com", + "url": "https://github.com/ljharb/" + } + ], + "deprecated": false, + "description": "ECMAScript 5 compatibility shims for legacy JavaScript engines", + "devDependencies": { + "@ljharb/eslint-config": "^16.0.0", + "eslint": "^6.8.0", + "jasmine-node": "^1.16.2", + "safe-publish-latest": "^1.1.4", + "uglify-js": "2.7.3" + }, + "engines": { + "node": ">=0.4.0" + }, + "greenkeeper": { + "ignore": [ + "uglify-js" + ] + }, + "homepage": "http://github.com/es-shims/es5-shim/", + "keywords": [ + "shim", + "es5", + "es5 shim", + "javascript", + "ecmascript", + "polyfill" + ], + "license": "MIT", + "main": "es5-shim.js", + "name": "es5-shim", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/es-shims/es5-shim.git" + }, + "scripts": { + "lint": "eslint .", + "minify": "npm run --silent minify-shim && npm run --silent minify-sham", + "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", + "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", + "prepublish": "safe-publish-latest && npm run minify", + "pretest": "npm run --silent lint", + "test": "npm run --silent tests-only", + "test-native": "jasmine-node --matchall tests/spec/", + "tests-only": "jasmine-node --matchall ./ tests/spec/" + }, + "testling": { + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/18.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/25.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2" + ] + }, + "version": "4.5.14" +} diff --git a/node_modules/es5-shim/shims.json b/node_modules/es5-shim/shims.json new file mode 100644 index 0000000..0c5430a --- /dev/null +++ b/node_modules/es5-shim/shims.json @@ -0,0 +1,7 @@ +{ + "Object": { + "prototype": {}, + "keys": "object-keys" + } +} + diff --git a/node_modules/es5-shim/tests/helpers/h-matchers.js b/node_modules/es5-shim/tests/helpers/h-matchers.js new file mode 100644 index 0000000..35c755e --- /dev/null +++ b/node_modules/es5-shim/tests/helpers/h-matchers.js @@ -0,0 +1,39 @@ +var has = Object.prototype.hasOwnProperty; +var getKeys = function (o) { + 'use strict'; + + var key; + var a = []; + for (key in o) { + if (has.call(o, key)) { + a.push(key); + } + } + return a; +}; + +beforeEach(function () { + 'use strict'; + + this.addMatchers({ + toExactlyMatch: function (expected) { + var a1, a2, l, i, key; + var actual = this.actual; + + a1 = getKeys(actual); + a2 = getKeys(expected); + + l = a1.length; + if (l !== a2.length) { + return false; + } + for (i = 0; i < l; i++) { + key = a1[i]; + expect(key).toEqual(a2[i]); + expect(actual[key]).toEqual(expected[key]); + } + + return true; + } + }); +}); diff --git a/node_modules/es5-shim/tests/index.html b/node_modules/es5-shim/tests/index.html new file mode 100644 index 0000000..3c5c81f --- /dev/null +++ b/node_modules/es5-shim/tests/index.html @@ -0,0 +1,66 @@ + + + + + Jasmine Spec Runner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/node_modules/es5-shim/tests/index.min.html b/node_modules/es5-shim/tests/index.min.html new file mode 100644 index 0000000..622a456 --- /dev/null +++ b/node_modules/es5-shim/tests/index.min.html @@ -0,0 +1,64 @@ + + + + Jasmine Spec Runner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/node_modules/es5-shim/tests/lib/jasmine-html.js b/node_modules/es5-shim/tests/lib/jasmine-html.js new file mode 100644 index 0000000..7383401 --- /dev/null +++ b/node_modules/es5-shim/tests/lib/jasmine-html.js @@ -0,0 +1,190 @@ +jasmine.TrivialReporter = function(doc) { + this.document = doc || document; + this.suiteDivs = {}; + this.logRunningSpecs = false; +}; + +jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) { + var el = document.createElement(type); + + for (var i = 2; i < arguments.length; i++) { + var child = arguments[i]; + + if (typeof child === 'string') { + el.appendChild(document.createTextNode(child)); + } else { + if (child) { el.appendChild(child); } + } + } + + for (var attr in attrs) { + if (attr == "className") { + el[attr] = attrs[attr]; + } else { + el.setAttribute(attr, attrs[attr]); + } + } + + return el; +}; + +jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { + var showPassed, showSkipped; + + this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' }, + this.createDom('div', { className: 'banner' }, + this.createDom('div', { className: 'logo' }, + this.createDom('span', { className: 'title' }, "Jasmine"), + this.createDom('span', { className: 'version' }, runner.env.versionString())), + this.createDom('div', { className: 'options' }, + "Show ", + showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }), + this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "), + showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }), + this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped") + ) + ), + + this.runnerDiv = this.createDom('div', { className: 'runner running' }, + this.createDom('a', { className: 'run_spec', href: '?' }, "run all"), + this.runnerMessageSpan = this.createDom('span', {}, "Running..."), + this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, "")) + ); + + this.document.body.appendChild(this.outerDiv); + + var suites = runner.suites(); + for (var i = 0; i < suites.length; i++) { + var suite = suites[i]; + var suiteDiv = this.createDom('div', { className: 'suite' }, + this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"), + this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description)); + this.suiteDivs[suite.id] = suiteDiv; + var parentDiv = this.outerDiv; + if (suite.parentSuite) { + parentDiv = this.suiteDivs[suite.parentSuite.id]; + } + parentDiv.appendChild(suiteDiv); + } + + this.startedAt = new Date(); + + var self = this; + showPassed.onclick = function(evt) { + if (showPassed.checked) { + self.outerDiv.className += ' show-passed'; + } else { + self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, ''); + } + }; + + showSkipped.onclick = function(evt) { + if (showSkipped.checked) { + self.outerDiv.className += ' show-skipped'; + } else { + self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, ''); + } + }; +}; + +jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { + var results = runner.results(); + var className = (results.failedCount > 0) ? "runner failed" : "runner passed"; + this.runnerDiv.setAttribute("class", className); + //do it twice for IE + this.runnerDiv.setAttribute("className", className); + var specs = runner.specs(); + var specCount = 0; + for (var i = 0; i < specs.length; i++) { + if (this.specFilter(specs[i])) { + specCount++; + } + } + var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); + message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; + this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild); + + this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString())); +}; + +jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { + var results = suite.results(); + var status = results.passed() ? 'passed' : 'failed'; + if (results.totalCount === 0) { // todo: change this to check results.skipped + status = 'skipped'; + } + this.suiteDivs[suite.id].className += " " + status; +}; + +jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) { + if (this.logRunningSpecs) { + this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...'); + } +}; + +jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { + var results = spec.results(); + var status = results.passed() ? 'passed' : 'failed'; + if (results.skipped) { + status = 'skipped'; + } + var specDiv = this.createDom('div', { className: 'spec ' + status }, + this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"), + this.createDom('a', { + className: 'description', + href: '?spec=' + encodeURIComponent(spec.getFullName()), + title: spec.getFullName() + }, spec.description)); + + + var resultItems = results.getItems(); + var messagesDiv = this.createDom('div', { className: 'messages' }); + for (var i = 0; i < resultItems.length; i++) { + var result = resultItems[i]; + + if (result.type == 'log') { + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString())); + } else if (result.type == 'expect' && result.passed && !result.passed()) { + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); + + if (result.trace.stack) { + messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); + } + } + } + + if (messagesDiv.childNodes.length > 0) { + specDiv.appendChild(messagesDiv); + } + + this.suiteDivs[spec.suite.id].appendChild(specDiv); +}; + +jasmine.TrivialReporter.prototype.log = function() { + var console = jasmine.getGlobal().console; + if (console && console.log) { + if (console.log.apply) { + console.log.apply(console, arguments); + } else { + console.log(arguments); // ie fix: console.log.apply doesn't exist on ie + } + } +}; + +jasmine.TrivialReporter.prototype.getLocation = function() { + return this.document.location; +}; + +jasmine.TrivialReporter.prototype.specFilter = function(spec) { + var paramMap = {}; + var params = this.getLocation().search.substring(1).split('&'); + for (var i = 0; i < params.length; i++) { + var p = params[i].split('='); + paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); + } + + if (!paramMap.spec) { + return true; + } + return spec.getFullName().indexOf(paramMap.spec) === 0; +}; diff --git a/node_modules/es5-shim/tests/lib/jasmine.css b/node_modules/es5-shim/tests/lib/jasmine.css new file mode 100644 index 0000000..6583fe7 --- /dev/null +++ b/node_modules/es5-shim/tests/lib/jasmine.css @@ -0,0 +1,166 @@ +body { + font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; +} + + +.jasmine_reporter a:visited, .jasmine_reporter a { + color: #303; +} + +.jasmine_reporter a:hover, .jasmine_reporter a:active { + color: blue; +} + +.run_spec { + float:right; + padding-right: 5px; + font-size: .8em; + text-decoration: none; +} + +.jasmine_reporter { + margin: 0 5px; +} + +.banner { + color: #303; + background-color: #fef; + padding: 5px; +} + +.logo { + float: left; + font-size: 1.1em; + padding-left: 5px; +} + +.logo .version { + font-size: .6em; + padding-left: 1em; +} + +.runner.running { + background-color: yellow; +} + + +.options { + text-align: right; + font-size: .8em; +} + + + + +.suite { + border: 1px outset gray; + margin: 5px 0; + padding-left: 1em; +} + +.suite .suite { + margin: 5px; +} + +.suite.passed { + background-color: #dfd; +} + +.suite.failed { + background-color: #fdd; +} + +.spec { + margin: 5px; + padding-left: 1em; + clear: both; +} + +.spec.failed, .spec.passed, .spec.skipped { + padding-bottom: 5px; + border: 1px solid gray; +} + +.spec.failed { + background-color: #fbb; + border-color: red; +} + +.spec.passed { + background-color: #bfb; + border-color: green; +} + +.spec.skipped { + background-color: #bbb; +} + +.messages { + border-left: 1px dashed gray; + padding-left: 1em; + padding-right: 1em; +} + +.passed { + background-color: #cfc; + display: none; +} + +.failed { + background-color: #fbb; +} + +.skipped { + color: #777; + background-color: #eee; + display: none; +} + + +/*.resultMessage {*/ + /*white-space: pre;*/ +/*}*/ + +.resultMessage span.result { + display: block; + line-height: 2em; + color: black; +} + +.resultMessage .mismatch { + color: black; +} + +.stackTrace { + white-space: pre; + font-size: .8em; + margin-left: 10px; + max-height: 5em; + overflow: auto; + border: 1px inset red; + padding: 1em; + background: #eef; +} + +.finished-at { + padding-left: 1em; + font-size: .6em; +} + +.show-passed .passed, +.show-skipped .skipped { + display: block; +} + + +#jasmine_content { + position:fixed; + right: 100%; +} + +.runner { + border: 1px solid gray; + display: block; + margin: 5px 0; + padding: 2px 0 2px 10px; +} diff --git a/node_modules/es5-shim/tests/lib/jasmine.js b/node_modules/es5-shim/tests/lib/jasmine.js new file mode 100644 index 0000000..fd91ed9 --- /dev/null +++ b/node_modules/es5-shim/tests/lib/jasmine.js @@ -0,0 +1,2601 @@ +var isCommonJS = typeof window == "undefined" && typeof exports == "object"; + +/** + * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. + * + * @namespace + */ +var jasmine = {}; +if (isCommonJS) exports.jasmine = jasmine; +/** + * @private + */ +jasmine.unimplementedMethod_ = function() { + throw new Error("unimplemented method"); +}; + +/** + * Use jasmine.undefined instead of undefined, since undefined is just + * a plain old variable and may be redefined by somebody else. + * + * @private + */ +jasmine.undefined = jasmine.___undefined___; + +/** + * Show diagnostic messages in the console if set to true + * + */ +jasmine.VERBOSE = false; + +/** + * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed. + * + */ +jasmine.DEFAULT_UPDATE_INTERVAL = 250; + +/** + * Maximum levels of nesting that will be included when an object is pretty-printed + */ +jasmine.MAX_PRETTY_PRINT_DEPTH = 40; + +/** + * Default timeout interval in milliseconds for waitsFor() blocks. + */ +jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; + +/** + * By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite. + * Set to false to let the exception bubble up in the browser. + * + */ +jasmine.CATCH_EXCEPTIONS = true; + +jasmine.getGlobal = function() { + function getGlobal() { + return this; + } + + return getGlobal(); +}; + +/** + * Allows for bound functions to be compared. Internal use only. + * + * @ignore + * @private + * @param base {Object} bound 'this' for the function + * @param name {Function} function to find + */ +jasmine.bindOriginal_ = function(base, name) { + var original = base[name]; + if (original.apply) { + return function() { + return original.apply(base, arguments); + }; + } else { + // IE support + return jasmine.getGlobal()[name]; + } +}; + +jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout'); +jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout'); +jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval'); +jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval'); + +jasmine.MessageResult = function(values) { + this.type = 'log'; + this.values = values; + this.trace = new Error(); // todo: test better +}; + +jasmine.MessageResult.prototype.toString = function() { + var text = ""; + for (var i = 0; i < this.values.length; i++) { + if (i > 0) text += " "; + if (jasmine.isString_(this.values[i])) { + text += this.values[i]; + } else { + text += jasmine.pp(this.values[i]); + } + } + return text; +}; + +jasmine.ExpectationResult = function(params) { + this.type = 'expect'; + this.matcherName = params.matcherName; + this.passed_ = params.passed; + this.expected = params.expected; + this.actual = params.actual; + this.message = this.passed_ ? 'Passed.' : params.message; + + var trace = (params.trace || new Error(this.message)); + this.trace = this.passed_ ? '' : trace; +}; + +jasmine.ExpectationResult.prototype.toString = function () { + return this.message; +}; + +jasmine.ExpectationResult.prototype.passed = function () { + return this.passed_; +}; + +/** + * Getter for the Jasmine environment. Ensures one gets created + */ +jasmine.getEnv = function() { + var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); + return env; +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isArray_ = function(value) { + return jasmine.isA_("Array", value); +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isString_ = function(value) { + return jasmine.isA_("String", value); +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isNumber_ = function(value) { + return jasmine.isA_("Number", value); +}; + +/** + * @ignore + * @private + * @param {String} typeName + * @param value + * @returns {Boolean} + */ +jasmine.isA_ = function(typeName, value) { + return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; +}; + +/** + * Pretty printer for expecations. Takes any object and turns it into a human-readable string. + * + * @param value {Object} an object to be outputted + * @returns {String} + */ +jasmine.pp = function(value) { + var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); + stringPrettyPrinter.format(value); + return stringPrettyPrinter.string; +}; + +/** + * Returns true if the object is a DOM Node. + * + * @param {Object} obj object to check + * @returns {Boolean} + */ +jasmine.isDomNode = function(obj) { + return obj.nodeType > 0; +}; + +/** + * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. + * + * @example + * // don't care about which function is passed in, as long as it's a function + * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function)); + * + * @param {Class} clazz + * @returns matchable object of the type clazz + */ +jasmine.any = function(clazz) { + return new jasmine.Matchers.Any(clazz); +}; + +/** + * Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the + * attributes on the object. + * + * @example + * // don't care about any other attributes than foo. + * expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"}); + * + * @param sample {Object} sample + * @returns matchable object for the sample + */ +jasmine.objectContaining = function (sample) { + return new jasmine.Matchers.ObjectContaining(sample); +}; + +/** + * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. + * + * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine + * expectation syntax. Spies can be checked if they were called or not and what the calling params were. + * + * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs). + * + * Spies are torn down at the end of every spec. + * + * Note: Do not call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. + * + * @example + * // a stub + * var myStub = jasmine.createSpy('myStub'); // can be used anywhere + * + * // spy example + * var foo = { + * not: function(bool) { return !bool; } + * } + * + * // actual foo.not will not be called, execution stops + * spyOn(foo, 'not'); + + // foo.not spied upon, execution will continue to implementation + * spyOn(foo, 'not').andCallThrough(); + * + * // fake example + * var foo = { + * not: function(bool) { return !bool; } + * } + * + * // foo.not(val) will return val + * spyOn(foo, 'not').andCallFake(function(value) {return value;}); + * + * // mock example + * foo.not(7 == 7); + * expect(foo.not).toHaveBeenCalled(); + * expect(foo.not).toHaveBeenCalledWith(true); + * + * @constructor + * @see spyOn, jasmine.createSpy, jasmine.createSpyObj + * @param {String} name + */ +jasmine.Spy = function(name) { + /** + * The name of the spy, if provided. + */ + this.identity = name || 'unknown'; + /** + * Is this Object a spy? + */ + this.isSpy = true; + /** + * The actual function this spy stubs. + */ + this.plan = function() { + }; + /** + * Tracking of the most recent call to the spy. + * @example + * var mySpy = jasmine.createSpy('foo'); + * mySpy(1, 2); + * mySpy.mostRecentCall.args = [1, 2]; + */ + this.mostRecentCall = {}; + + /** + * Holds arguments for each call to the spy, indexed by call count + * @example + * var mySpy = jasmine.createSpy('foo'); + * mySpy(1, 2); + * mySpy(7, 8); + * mySpy.mostRecentCall.args = [7, 8]; + * mySpy.argsForCall[0] = [1, 2]; + * mySpy.argsForCall[1] = [7, 8]; + */ + this.argsForCall = []; + this.calls = []; +}; + +/** + * Tells a spy to call through to the actual implemenatation. + * + * @example + * var foo = { + * bar: function() { // do some stuff } + * } + * + * // defining a spy on an existing property: foo.bar + * spyOn(foo, 'bar').andCallThrough(); + */ +jasmine.Spy.prototype.andCallThrough = function() { + this.plan = this.originalValue; + return this; +}; + +/** + * For setting the return value of a spy. + * + * @example + * // defining a spy from scratch: foo() returns 'baz' + * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); + * + * // defining a spy on an existing property: foo.bar() returns 'baz' + * spyOn(foo, 'bar').andReturn('baz'); + * + * @param {Object} value + */ +jasmine.Spy.prototype.andReturn = function(value) { + this.plan = function() { + return value; + }; + return this; +}; + +/** + * For throwing an exception when a spy is called. + * + * @example + * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' + * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); + * + * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' + * spyOn(foo, 'bar').andThrow('baz'); + * + * @param {String} exceptionMsg + */ +jasmine.Spy.prototype.andThrow = function(exceptionMsg) { + this.plan = function() { + throw exceptionMsg; + }; + return this; +}; + +/** + * Calls an alternate implementation when a spy is called. + * + * @example + * var baz = function() { + * // do some stuff, return something + * } + * // defining a spy from scratch: foo() calls the function baz + * var foo = jasmine.createSpy('spy on foo').andCall(baz); + * + * // defining a spy on an existing property: foo.bar() calls an anonymnous function + * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); + * + * @param {Function} fakeFunc + */ +jasmine.Spy.prototype.andCallFake = function(fakeFunc) { + this.plan = fakeFunc; + return this; +}; + +/** + * Resets all of a spy's the tracking variables so that it can be used again. + * + * @example + * spyOn(foo, 'bar'); + * + * foo.bar(); + * + * expect(foo.bar.callCount).toEqual(1); + * + * foo.bar.reset(); + * + * expect(foo.bar.callCount).toEqual(0); + */ +jasmine.Spy.prototype.reset = function() { + this.wasCalled = false; + this.callCount = 0; + this.argsForCall = []; + this.calls = []; + this.mostRecentCall = {}; +}; + +jasmine.createSpy = function(name) { + + var spyObj = function() { + spyObj.wasCalled = true; + spyObj.callCount++; + var args = jasmine.util.argsToArray(arguments); + spyObj.mostRecentCall.object = this; + spyObj.mostRecentCall.args = args; + spyObj.argsForCall.push(args); + spyObj.calls.push({object: this, args: args}); + return spyObj.plan.apply(this, arguments); + }; + + var spy = new jasmine.Spy(name); + + for (var prop in spy) { + spyObj[prop] = spy[prop]; + } + + spyObj.reset(); + + return spyObj; +}; + +/** + * Determines whether an object is a spy. + * + * @param {jasmine.Spy|Object} putativeSpy + * @returns {Boolean} + */ +jasmine.isSpy = function(putativeSpy) { + return putativeSpy && putativeSpy.isSpy; +}; + +/** + * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something + * large in one call. + * + * @param {String} baseName name of spy class + * @param {Array} methodNames array of names of methods to make spies + */ +jasmine.createSpyObj = function(baseName, methodNames) { + if (!jasmine.isArray_(methodNames) || methodNames.length === 0) { + throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); + } + var obj = {}; + for (var i = 0; i < methodNames.length; i++) { + obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); + } + return obj; +}; + +/** + * All parameters are pretty-printed and concatenated together, then written to the current spec's output. + * + * Be careful not to leave calls to jasmine.log in production code. + */ +jasmine.log = function() { + var spec = jasmine.getEnv().currentSpec; + spec.log.apply(spec, arguments); +}; + +/** + * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. + * + * @example + * // spy example + * var foo = { + * not: function(bool) { return !bool; } + * } + * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops + * + * @see jasmine.createSpy + * @param obj + * @param methodName + * @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods + */ +var spyOn = function(obj, methodName) { + return jasmine.getEnv().currentSpec.spyOn(obj, methodName); +}; +if (isCommonJS) exports.spyOn = spyOn; + +/** + * Creates a Jasmine spec that will be added to the current suite. + * + * // TODO: pending tests + * + * @example + * it('should be true', function() { + * expect(true).toEqual(true); + * }); + * + * @param {String} desc description of this specification + * @param {Function} func defines the preconditions and expectations of the spec + */ +var it = function(desc, func) { + return jasmine.getEnv().it(desc, func); +}; +if (isCommonJS) exports.it = it; + +/** + * Creates a disabled Jasmine spec. + * + * A convenience method that allows existing specs to be disabled temporarily during development. + * + * @param {String} desc description of this specification + * @param {Function} func defines the preconditions and expectations of the spec + */ +var xit = function(desc, func) { + return jasmine.getEnv().xit(desc, func); +}; +if (isCommonJS) exports.xit = xit; + +/** + * Starts a chain for a Jasmine expectation. + * + * It is passed an Object that is the actual value and should chain to one of the many + * jasmine.Matchers functions. + * + * @param {Object} actual Actual value to test against and expected value + * @return {jasmine.Matchers} + */ +var expect = function(actual) { + return jasmine.getEnv().currentSpec.expect(actual); +}; +if (isCommonJS) exports.expect = expect; + +/** + * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. + * + * @param {Function} func Function that defines part of a jasmine spec. + */ +var runs = function(func) { + jasmine.getEnv().currentSpec.runs(func); +}; +if (isCommonJS) exports.runs = runs; + +/** + * Waits a fixed time period before moving to the next block. + * + * @deprecated Use waitsFor() instead + * @param {Number} timeout milliseconds to wait + */ +var waits = function(timeout) { + jasmine.getEnv().currentSpec.waits(timeout); +}; +if (isCommonJS) exports.waits = waits; + +/** + * Waits for the latchFunction to return true before proceeding to the next block. + * + * @param {Function} latchFunction + * @param {String} optional_timeoutMessage + * @param {Number} optional_timeout + */ +var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { + jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments); +}; +if (isCommonJS) exports.waitsFor = waitsFor; + +/** + * A function that is called before each spec in a suite. + * + * Used for spec setup, including validating assumptions. + * + * @param {Function} beforeEachFunction + */ +var beforeEach = function(beforeEachFunction) { + jasmine.getEnv().beforeEach(beforeEachFunction); +}; +if (isCommonJS) exports.beforeEach = beforeEach; + +/** + * A function that is called after each spec in a suite. + * + * Used for restoring any state that is hijacked during spec execution. + * + * @param {Function} afterEachFunction + */ +var afterEach = function(afterEachFunction) { + jasmine.getEnv().afterEach(afterEachFunction); +}; +if (isCommonJS) exports.afterEach = afterEach; + +/** + * Defines a suite of specifications. + * + * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared + * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization + * of setup in some tests. + * + * @example + * // TODO: a simple suite + * + * // TODO: a simple suite with a nested describe block + * + * @param {String} description A string, usually the class under test. + * @param {Function} specDefinitions function that defines several specs. + */ +var describe = function(description, specDefinitions) { + return jasmine.getEnv().describe(description, specDefinitions); +}; +if (isCommonJS) exports.describe = describe; + +/** + * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. + * + * @param {String} description A string, usually the class under test. + * @param {Function} specDefinitions function that defines several specs. + */ +var xdescribe = function(description, specDefinitions) { + return jasmine.getEnv().xdescribe(description, specDefinitions); +}; +if (isCommonJS) exports.xdescribe = xdescribe; + + +// Provide the XMLHttpRequest class for IE 5.x-6.x: +jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { + function tryIt(f) { + try { + return f(); + } catch(e) { + } + return null; + } + + var xhr = tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP.6.0"); + }) || + tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP.3.0"); + }) || + tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP"); + }) || + tryIt(function() { + return new ActiveXObject("Microsoft.XMLHTTP"); + }); + + if (!xhr) throw new Error("This browser does not support XMLHttpRequest."); + + return xhr; +} : XMLHttpRequest; +/** + * @namespace + */ +jasmine.util = {}; + +/** + * Declare that a child class inherit it's prototype from the parent class. + * + * @private + * @param {Function} childClass + * @param {Function} parentClass + */ +jasmine.util.inherit = function(childClass, parentClass) { + /** + * @private + */ + var subclass = function() { + }; + subclass.prototype = parentClass.prototype; + childClass.prototype = new subclass(); +}; + +jasmine.util.formatException = function(e) { + var lineNumber; + if (e.line) { + lineNumber = e.line; + } + else if (e.lineNumber) { + lineNumber = e.lineNumber; + } + + var file; + + if (e.sourceURL) { + file = e.sourceURL; + } + else if (e.fileName) { + file = e.fileName; + } + + var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString(); + + if (file && lineNumber) { + message += ' in ' + file + ' (line ' + lineNumber + ')'; + } + + return message; +}; + +jasmine.util.htmlEscape = function(str) { + if (!str) return str; + return str.replace(/&/g, '&') + .replace(//g, '>'); +}; + +jasmine.util.argsToArray = function(args) { + var arrayOfArgs = []; + for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]); + return arrayOfArgs; +}; + +jasmine.util.extend = function(destination, source) { + for (var property in source) destination[property] = source[property]; + return destination; +}; + +/** + * Environment for Jasmine + * + * @constructor + */ +jasmine.Env = function() { + this.currentSpec = null; + this.currentSuite = null; + this.currentRunner_ = new jasmine.Runner(this); + + this.reporter = new jasmine.MultiReporter(); + + this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL; + this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL; + this.lastUpdate = 0; + this.specFilter = function() { + return true; + }; + + this.nextSpecId_ = 0; + this.nextSuiteId_ = 0; + this.equalityTesters_ = []; + + // wrap matchers + this.matchersClass = function() { + jasmine.Matchers.apply(this, arguments); + }; + jasmine.util.inherit(this.matchersClass, jasmine.Matchers); + + jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass); +}; + + +jasmine.Env.prototype.setTimeout = jasmine.setTimeout; +jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; +jasmine.Env.prototype.setInterval = jasmine.setInterval; +jasmine.Env.prototype.clearInterval = jasmine.clearInterval; + +/** + * @returns an object containing jasmine version build info, if set. + */ +jasmine.Env.prototype.version = function () { + if (jasmine.version_) { + return jasmine.version_; + } else { + throw new Error('Version not set'); + } +}; + +/** + * @returns string containing jasmine version build info, if set. + */ +jasmine.Env.prototype.versionString = function() { + if (!jasmine.version_) { + return "version unknown"; + } + + var version = this.version(); + var versionString = version.major + "." + version.minor + "." + version.build; + if (version.release_candidate) { + versionString += ".rc" + version.release_candidate; + } + versionString += " revision " + version.revision; + return versionString; +}; + +/** + * @returns a sequential integer starting at 0 + */ +jasmine.Env.prototype.nextSpecId = function () { + return this.nextSpecId_++; +}; + +/** + * @returns a sequential integer starting at 0 + */ +jasmine.Env.prototype.nextSuiteId = function () { + return this.nextSuiteId_++; +}; + +/** + * Register a reporter to receive status updates from Jasmine. + * @param {jasmine.Reporter} reporter An object which will receive status updates. + */ +jasmine.Env.prototype.addReporter = function(reporter) { + this.reporter.addReporter(reporter); +}; + +jasmine.Env.prototype.execute = function() { + this.currentRunner_.execute(); +}; + +jasmine.Env.prototype.describe = function(description, specDefinitions) { + var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); + + var parentSuite = this.currentSuite; + if (parentSuite) { + parentSuite.add(suite); + } else { + this.currentRunner_.add(suite); + } + + this.currentSuite = suite; + + var declarationError = null; + try { + specDefinitions.call(suite); + } catch(e) { + declarationError = e; + } + + if (declarationError) { + this.it("encountered a declaration exception", function() { + throw declarationError; + }); + } + + this.currentSuite = parentSuite; + + return suite; +}; + +jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { + if (this.currentSuite) { + this.currentSuite.beforeEach(beforeEachFunction); + } else { + this.currentRunner_.beforeEach(beforeEachFunction); + } +}; + +jasmine.Env.prototype.currentRunner = function () { + return this.currentRunner_; +}; + +jasmine.Env.prototype.afterEach = function(afterEachFunction) { + if (this.currentSuite) { + this.currentSuite.afterEach(afterEachFunction); + } else { + this.currentRunner_.afterEach(afterEachFunction); + } + +}; + +jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { + return { + execute: function() { + } + }; +}; + +jasmine.Env.prototype.it = function(description, func) { + var spec = new jasmine.Spec(this, this.currentSuite, description); + this.currentSuite.add(spec); + this.currentSpec = spec; + + if (func) { + spec.runs(func); + } + + return spec; +}; + +jasmine.Env.prototype.xit = function(desc, func) { + return { + id: this.nextSpecId(), + runs: function() { + } + }; +}; + +jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) { + if (a.source != b.source) + mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/"); + + if (a.ignoreCase != b.ignoreCase) + mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier"); + + if (a.global != b.global) + mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier"); + + if (a.multiline != b.multiline) + mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier"); + + if (a.sticky != b.sticky) + mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier"); + + return (mismatchValues.length === 0); +}; + +jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { + if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { + return true; + } + + a.__Jasmine_been_here_before__ = b; + b.__Jasmine_been_here_before__ = a; + + var hasKey = function(obj, keyName) { + return obj !== null && obj[keyName] !== jasmine.undefined; + }; + + for (var property in b) { + if (!hasKey(a, property) && hasKey(b, property)) { + mismatchKeys.push("expected has key '" + property + "', but missing from actual."); + } + } + for (property in a) { + if (!hasKey(b, property) && hasKey(a, property)) { + mismatchKeys.push("expected missing key '" + property + "', but present in actual."); + } + } + for (property in b) { + if (property == '__Jasmine_been_here_before__') continue; + if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { + mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual."); + } + } + + if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { + mismatchValues.push("arrays were not the same length"); + } + + delete a.__Jasmine_been_here_before__; + delete b.__Jasmine_been_here_before__; + return (mismatchKeys.length === 0 && mismatchValues.length === 0); +}; + +jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { + mismatchKeys = mismatchKeys || []; + mismatchValues = mismatchValues || []; + + for (var i = 0; i < this.equalityTesters_.length; i++) { + var equalityTester = this.equalityTesters_[i]; + var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); + if (result !== jasmine.undefined) return result; + } + + if (a === b) return true; + + if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { + return (a == jasmine.undefined && b == jasmine.undefined); + } + + if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { + return a === b; + } + + if (a instanceof Date && b instanceof Date) { + return a.getTime() == b.getTime(); + } + + if (a.jasmineMatches) { + return a.jasmineMatches(b); + } + + if (b.jasmineMatches) { + return b.jasmineMatches(a); + } + + if (a instanceof jasmine.Matchers.ObjectContaining) { + return a.matches(b); + } + + if (b instanceof jasmine.Matchers.ObjectContaining) { + return b.matches(a); + } + + if (jasmine.isString_(a) && jasmine.isString_(b)) { + return (a == b); + } + + if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { + return (a == b); + } + + if (a instanceof RegExp && b instanceof RegExp) { + return this.compareRegExps_(a, b, mismatchKeys, mismatchValues); + } + + if (typeof a === "object" && typeof b === "object") { + return this.compareObjects_(a, b, mismatchKeys, mismatchValues); + } + + //Straight check + return (a === b); +}; + +jasmine.Env.prototype.contains_ = function(haystack, needle) { + if (jasmine.isArray_(haystack)) { + for (var i = 0; i < haystack.length; i++) { + if (this.equals_(haystack[i], needle)) return true; + } + return false; + } + return haystack.indexOf(needle) >= 0; +}; + +jasmine.Env.prototype.addEqualityTester = function(equalityTester) { + this.equalityTesters_.push(equalityTester); +}; +/** No-op base class for Jasmine reporters. + * + * @constructor + */ +jasmine.Reporter = function() { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportRunnerStarting = function(runner) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportRunnerResults = function(runner) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportSuiteResults = function(suite) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportSpecStarting = function(spec) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportSpecResults = function(spec) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.log = function(str) { +}; + +/** + * Blocks are functions with executable code that make up a spec. + * + * @constructor + * @param {jasmine.Env} env + * @param {Function} func + * @param {jasmine.Spec} spec + */ +jasmine.Block = function(env, func, spec) { + this.env = env; + this.func = func; + this.spec = spec; +}; + +jasmine.Block.prototype.execute = function(onComplete) { + if (!jasmine.CATCH_EXCEPTIONS) { + this.func.apply(this.spec); + } + else { + try { + this.func.apply(this.spec); + } catch (e) { + this.spec.fail(e); + } + } + onComplete(); +}; +/** JavaScript API reporter. + * + * @constructor + */ +jasmine.JsApiReporter = function() { + this.started = false; + this.finished = false; + this.suites_ = []; + this.results_ = {}; +}; + +jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { + this.started = true; + var suites = runner.topLevelSuites(); + for (var i = 0; i < suites.length; i++) { + var suite = suites[i]; + this.suites_.push(this.summarize_(suite)); + } +}; + +jasmine.JsApiReporter.prototype.suites = function() { + return this.suites_; +}; + +jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { + var isSuite = suiteOrSpec instanceof jasmine.Suite; + var summary = { + id: suiteOrSpec.id, + name: suiteOrSpec.description, + type: isSuite ? 'suite' : 'spec', + children: [] + }; + + if (isSuite) { + var children = suiteOrSpec.children(); + for (var i = 0; i < children.length; i++) { + summary.children.push(this.summarize_(children[i])); + } + } + return summary; +}; + +jasmine.JsApiReporter.prototype.results = function() { + return this.results_; +}; + +jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) { + return this.results_[specId]; +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { + this.finished = true; +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { + this.results_[spec.id] = { + messages: spec.results().getItems(), + result: spec.results().failedCount > 0 ? "failed" : "passed" + }; +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.log = function(str) { +}; + +jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){ + var results = {}; + for (var i = 0; i < specIds.length; i++) { + var specId = specIds[i]; + results[specId] = this.summarizeResult_(this.results_[specId]); + } + return results; +}; + +jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ + var summaryMessages = []; + var messagesLength = result.messages.length; + for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { + var resultMessage = result.messages[messageIndex]; + summaryMessages.push({ + text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined, + passed: resultMessage.passed ? resultMessage.passed() : true, + type: resultMessage.type, + message: resultMessage.message, + trace: { + stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined + } + }); + } + + return { + result : result.result, + messages : summaryMessages + }; +}; + +/** + * @constructor + * @param {jasmine.Env} env + * @param actual + * @param {jasmine.Spec} spec + */ +jasmine.Matchers = function(env, actual, spec, opt_isNot) { + this.env = env; + this.actual = actual; + this.spec = spec; + this.isNot = opt_isNot || false; + this.reportWasCalled_ = false; +}; + +// todo: @deprecated as of Jasmine 0.11, remove soon [xw] +jasmine.Matchers.pp = function(str) { + throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!"); +}; + +// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw] +jasmine.Matchers.prototype.report = function(result, failing_message, details) { + throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); +}; + +jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { + for (var methodName in prototype) { + if (methodName == 'report') continue; + var orig = prototype[methodName]; + matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); + } +}; + +jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { + return function() { + var matcherArgs = jasmine.util.argsToArray(arguments); + var result = matcherFunction.apply(this, arguments); + + if (this.isNot) { + result = !result; + } + + if (this.reportWasCalled_) return result; + + var message; + if (!result) { + if (this.message) { + message = this.message.apply(this, arguments); + if (jasmine.isArray_(message)) { + message = message[this.isNot ? 1 : 0]; + } + } else { + var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); + message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; + if (matcherArgs.length > 0) { + for (var i = 0; i < matcherArgs.length; i++) { + if (i > 0) message += ","; + message += " " + jasmine.pp(matcherArgs[i]); + } + } + message += "."; + } + } + var expectationResult = new jasmine.ExpectationResult({ + matcherName: matcherName, + passed: result, + expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], + actual: this.actual, + message: message + }); + this.spec.addMatcherResult(expectationResult); + return jasmine.undefined; + }; +}; + + + + +/** + * toBe: compares the actual to the expected using === + * @param expected + */ +jasmine.Matchers.prototype.toBe = function(expected) { + return this.actual === expected; +}; + +/** + * toNotBe: compares the actual to the expected using !== + * @param expected + * @deprecated as of 1.0. Use not.toBe() instead. + */ +jasmine.Matchers.prototype.toNotBe = function(expected) { + return this.actual !== expected; +}; + +/** + * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. + * + * @param expected + */ +jasmine.Matchers.prototype.toEqual = function(expected) { + return this.env.equals_(this.actual, expected); +}; + +/** + * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual + * @param expected + * @deprecated as of 1.0. Use not.toEqual() instead. + */ +jasmine.Matchers.prototype.toNotEqual = function(expected) { + return !this.env.equals_(this.actual, expected); +}; + +/** + * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes + * a pattern or a String. + * + * @param expected + */ +jasmine.Matchers.prototype.toMatch = function(expected) { + return new RegExp(expected).test(this.actual); +}; + +/** + * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch + * @param expected + * @deprecated as of 1.0. Use not.toMatch() instead. + */ +jasmine.Matchers.prototype.toNotMatch = function(expected) { + return !(new RegExp(expected).test(this.actual)); +}; + +/** + * Matcher that compares the actual to jasmine.undefined. + */ +jasmine.Matchers.prototype.toBeDefined = function() { + return (this.actual !== jasmine.undefined); +}; + +/** + * Matcher that compares the actual to jasmine.undefined. + */ +jasmine.Matchers.prototype.toBeUndefined = function() { + return (this.actual === jasmine.undefined); +}; + +/** + * Matcher that compares the actual to null. + */ +jasmine.Matchers.prototype.toBeNull = function() { + return (this.actual === null); +}; + +/** + * Matcher that compares the actual to NaN. + */ +jasmine.Matchers.prototype.toBeNaN = function() { + this.message = function() { + return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ]; + }; + + return (this.actual !== this.actual); +}; + +/** + * Matcher that boolean not-nots the actual. + */ +jasmine.Matchers.prototype.toBeTruthy = function() { + return !!this.actual; +}; + + +/** + * Matcher that boolean nots the actual. + */ +jasmine.Matchers.prototype.toBeFalsy = function() { + return !this.actual; +}; + + +/** + * Matcher that checks to see if the actual, a Jasmine spy, was called. + */ +jasmine.Matchers.prototype.toHaveBeenCalled = function() { + if (arguments.length > 0) { + throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); + } + + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + + this.message = function() { + return [ + "Expected spy " + this.actual.identity + " to have been called.", + "Expected spy " + this.actual.identity + " not to have been called." + ]; + }; + + return this.actual.wasCalled; +}; + +/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */ +jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled; + +/** + * Matcher that checks to see if the actual, a Jasmine spy, was not called. + * + * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead + */ +jasmine.Matchers.prototype.wasNotCalled = function() { + if (arguments.length > 0) { + throw new Error('wasNotCalled does not take arguments'); + } + + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + + this.message = function() { + return [ + "Expected spy " + this.actual.identity + " to not have been called.", + "Expected spy " + this.actual.identity + " to have been called." + ]; + }; + + return !this.actual.wasCalled; +}; + +/** + * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. + * + * @example + * + */ +jasmine.Matchers.prototype.toHaveBeenCalledWith = function() { + var expectedArgs = jasmine.util.argsToArray(arguments); + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + this.message = function() { + var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."; + var positiveMessage = ""; + if (this.actual.callCount === 0) { + positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called."; + } else { + positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '') + } + return [positiveMessage, invertedMessage]; + }; + + return this.env.contains_(this.actual.argsForCall, expectedArgs); +}; + +/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */ +jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith; + +/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */ +jasmine.Matchers.prototype.wasNotCalledWith = function() { + var expectedArgs = jasmine.util.argsToArray(arguments); + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + + this.message = function() { + return [ + "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was", + "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was" + ]; + }; + + return !this.env.contains_(this.actual.argsForCall, expectedArgs); +}; + +/** + * Matcher that checks that the expected item is an element in the actual Array. + * + * @param {Object} expected + */ +jasmine.Matchers.prototype.toContain = function(expected) { + return this.env.contains_(this.actual, expected); +}; + +/** + * Matcher that checks that the expected item is NOT an element in the actual Array. + * + * @param {Object} expected + * @deprecated as of 1.0. Use not.toContain() instead. + */ +jasmine.Matchers.prototype.toNotContain = function(expected) { + return !this.env.contains_(this.actual, expected); +}; + +jasmine.Matchers.prototype.toBeLessThan = function(expected) { + return this.actual < expected; +}; + +jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { + return this.actual > expected; +}; + +/** + * Matcher that checks that the expected item is equal to the actual item + * up to a given level of decimal precision (default 2). + * + * @param {Number} expected + * @param {Number} precision, as number of decimal places + */ +jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) { + if (!(precision === 0)) { + precision = precision || 2; + } + return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2); +}; + +/** + * Matcher that checks that the expected exception was thrown by the actual. + * + * @param {String} [expected] + */ +jasmine.Matchers.prototype.toThrow = function(expected) { + var result = false; + var exception; + if (typeof this.actual != 'function') { + throw new Error('Actual is not a function'); + } + try { + this.actual(); + } catch (e) { + exception = e; + } + if (exception) { + result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); + } + + var not = this.isNot ? "not " : ""; + + this.message = function() { + if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { + return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' '); + } else { + return "Expected function to throw an exception."; + } + }; + + return result; +}; + +jasmine.Matchers.Any = function(expectedClass) { + this.expectedClass = expectedClass; +}; + +jasmine.Matchers.Any.prototype.jasmineMatches = function(other) { + if (this.expectedClass == String) { + return typeof other == 'string' || other instanceof String; + } + + if (this.expectedClass == Number) { + return typeof other == 'number' || other instanceof Number; + } + + if (this.expectedClass == Function) { + return typeof other == 'function' || other instanceof Function; + } + + if (this.expectedClass == Object) { + return typeof other == 'object'; + } + + return other instanceof this.expectedClass; +}; + +jasmine.Matchers.Any.prototype.jasmineToString = function() { + return ''; +}; + +jasmine.Matchers.ObjectContaining = function (sample) { + this.sample = sample; +}; + +jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) { + mismatchKeys = mismatchKeys || []; + mismatchValues = mismatchValues || []; + + var env = jasmine.getEnv(); + + var hasKey = function(obj, keyName) { + return obj != null && obj[keyName] !== jasmine.undefined; + }; + + for (var property in this.sample) { + if (!hasKey(other, property) && hasKey(this.sample, property)) { + mismatchKeys.push("expected has key '" + property + "', but missing from actual."); + } + else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) { + mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual."); + } + } + + return (mismatchKeys.length === 0 && mismatchValues.length === 0); +}; + +jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () { + return ""; +}; +// Mock setTimeout, clearTimeout +// Contributed by Pivotal Computer Systems, www.pivotalsf.com + +jasmine.FakeTimer = function() { + this.reset(); + + var self = this; + self.setTimeout = function(funcToCall, millis) { + self.timeoutsMade++; + self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); + return self.timeoutsMade; + }; + + self.setInterval = function(funcToCall, millis) { + self.timeoutsMade++; + self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); + return self.timeoutsMade; + }; + + self.clearTimeout = function(timeoutKey) { + self.scheduledFunctions[timeoutKey] = jasmine.undefined; + }; + + self.clearInterval = function(timeoutKey) { + self.scheduledFunctions[timeoutKey] = jasmine.undefined; + }; + +}; + +jasmine.FakeTimer.prototype.reset = function() { + this.timeoutsMade = 0; + this.scheduledFunctions = {}; + this.nowMillis = 0; +}; + +jasmine.FakeTimer.prototype.tick = function(millis) { + var oldMillis = this.nowMillis; + var newMillis = oldMillis + millis; + this.runFunctionsWithinRange(oldMillis, newMillis); + this.nowMillis = newMillis; +}; + +jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { + var scheduledFunc; + var funcsToRun = []; + for (var timeoutKey in this.scheduledFunctions) { + scheduledFunc = this.scheduledFunctions[timeoutKey]; + if (scheduledFunc != jasmine.undefined && + scheduledFunc.runAtMillis >= oldMillis && + scheduledFunc.runAtMillis <= nowMillis) { + funcsToRun.push(scheduledFunc); + this.scheduledFunctions[timeoutKey] = jasmine.undefined; + } + } + + if (funcsToRun.length > 0) { + funcsToRun.sort(function(a, b) { + return a.runAtMillis - b.runAtMillis; + }); + for (var i = 0; i < funcsToRun.length; ++i) { + try { + var funcToRun = funcsToRun[i]; + this.nowMillis = funcToRun.runAtMillis; + funcToRun.funcToCall(); + if (funcToRun.recurring) { + this.scheduleFunction(funcToRun.timeoutKey, + funcToRun.funcToCall, + funcToRun.millis, + true); + } + } catch(e) { + } + } + this.runFunctionsWithinRange(oldMillis, nowMillis); + } +}; + +jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { + this.scheduledFunctions[timeoutKey] = { + runAtMillis: this.nowMillis + millis, + funcToCall: funcToCall, + recurring: recurring, + timeoutKey: timeoutKey, + millis: millis + }; +}; + +/** + * @namespace + */ +jasmine.Clock = { + defaultFakeTimer: new jasmine.FakeTimer(), + + reset: function() { + jasmine.Clock.assertInstalled(); + jasmine.Clock.defaultFakeTimer.reset(); + }, + + tick: function(millis) { + jasmine.Clock.assertInstalled(); + jasmine.Clock.defaultFakeTimer.tick(millis); + }, + + runFunctionsWithinRange: function(oldMillis, nowMillis) { + jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); + }, + + scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { + jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); + }, + + useMock: function() { + if (!jasmine.Clock.isInstalled()) { + var spec = jasmine.getEnv().currentSpec; + spec.after(jasmine.Clock.uninstallMock); + + jasmine.Clock.installMock(); + } + }, + + installMock: function() { + jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; + }, + + uninstallMock: function() { + jasmine.Clock.assertInstalled(); + jasmine.Clock.installed = jasmine.Clock.real; + }, + + real: { + setTimeout: jasmine.getGlobal().setTimeout, + clearTimeout: jasmine.getGlobal().clearTimeout, + setInterval: jasmine.getGlobal().setInterval, + clearInterval: jasmine.getGlobal().clearInterval + }, + + assertInstalled: function() { + if (!jasmine.Clock.isInstalled()) { + throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); + } + }, + + isInstalled: function() { + return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer; + }, + + installed: null +}; +jasmine.Clock.installed = jasmine.Clock.real; + +//else for IE support +jasmine.getGlobal().setTimeout = function(funcToCall, millis) { + if (jasmine.Clock.installed.setTimeout.apply) { + return jasmine.Clock.installed.setTimeout.apply(this, arguments); + } else { + return jasmine.Clock.installed.setTimeout(funcToCall, millis); + } +}; + +jasmine.getGlobal().setInterval = function(funcToCall, millis) { + if (jasmine.Clock.installed.setInterval.apply) { + return jasmine.Clock.installed.setInterval.apply(this, arguments); + } else { + return jasmine.Clock.installed.setInterval(funcToCall, millis); + } +}; + +jasmine.getGlobal().clearTimeout = function(timeoutKey) { + if (jasmine.Clock.installed.clearTimeout.apply) { + return jasmine.Clock.installed.clearTimeout.apply(this, arguments); + } else { + return jasmine.Clock.installed.clearTimeout(timeoutKey); + } +}; + +jasmine.getGlobal().clearInterval = function(timeoutKey) { + if (jasmine.Clock.installed.clearTimeout.apply) { + return jasmine.Clock.installed.clearInterval.apply(this, arguments); + } else { + return jasmine.Clock.installed.clearInterval(timeoutKey); + } +}; + +/** + * @constructor + */ +jasmine.MultiReporter = function() { + this.subReporters_ = []; +}; +jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter); + +jasmine.MultiReporter.prototype.addReporter = function(reporter) { + this.subReporters_.push(reporter); +}; + +(function() { + var functionNames = [ + "reportRunnerStarting", + "reportRunnerResults", + "reportSuiteResults", + "reportSpecStarting", + "reportSpecResults", + "log" + ]; + for (var i = 0; i < functionNames.length; i++) { + var functionName = functionNames[i]; + jasmine.MultiReporter.prototype[functionName] = (function(functionName) { + return function() { + for (var j = 0; j < this.subReporters_.length; j++) { + var subReporter = this.subReporters_[j]; + if (subReporter[functionName]) { + subReporter[functionName].apply(subReporter, arguments); + } + } + }; + })(functionName); + } +})(); +/** + * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults + * + * @constructor + */ +jasmine.NestedResults = function() { + /** + * The total count of results + */ + this.totalCount = 0; + /** + * Number of passed results + */ + this.passedCount = 0; + /** + * Number of failed results + */ + this.failedCount = 0; + /** + * Was this suite/spec skipped? + */ + this.skipped = false; + /** + * @ignore + */ + this.items_ = []; +}; + +/** + * Roll up the result counts. + * + * @param result + */ +jasmine.NestedResults.prototype.rollupCounts = function(result) { + this.totalCount += result.totalCount; + this.passedCount += result.passedCount; + this.failedCount += result.failedCount; +}; + +/** + * Adds a log message. + * @param values Array of message parts which will be concatenated later. + */ +jasmine.NestedResults.prototype.log = function(values) { + this.items_.push(new jasmine.MessageResult(values)); +}; + +/** + * Getter for the results: message & results. + */ +jasmine.NestedResults.prototype.getItems = function() { + return this.items_; +}; + +/** + * Adds a result, tracking counts (total, passed, & failed) + * @param {jasmine.ExpectationResult|jasmine.NestedResults} result + */ +jasmine.NestedResults.prototype.addResult = function(result) { + if (result.type != 'log') { + if (result.items_) { + this.rollupCounts(result); + } else { + this.totalCount++; + if (result.passed()) { + this.passedCount++; + } else { + this.failedCount++; + } + } + } + this.items_.push(result); +}; + +/** + * @returns {Boolean} True if everything below passed + */ +jasmine.NestedResults.prototype.passed = function() { + return this.passedCount === this.totalCount; +}; +/** + * Base class for pretty printing for expectation results. + */ +jasmine.PrettyPrinter = function() { + this.ppNestLevel_ = 0; +}; + +/** + * Formats a value in a nice, human-readable string. + * + * @param value + */ +jasmine.PrettyPrinter.prototype.format = function(value) { + this.ppNestLevel_++; + try { + if (value === jasmine.undefined) { + this.emitScalar('undefined'); + } else if (value === null) { + this.emitScalar('null'); + } else if (value === jasmine.getGlobal()) { + this.emitScalar(''); + } else if (value.jasmineToString) { + this.emitScalar(value.jasmineToString()); + } else if (typeof value === 'string') { + this.emitString(value); + } else if (jasmine.isSpy(value)) { + this.emitScalar("spy on " + value.identity); + } else if (value instanceof RegExp) { + this.emitScalar(value.toString()); + } else if (typeof value === 'function') { + this.emitScalar('Function'); + } else if (typeof value.nodeType === 'number') { + this.emitScalar('HTMLNode'); + } else if (value instanceof Date) { + this.emitScalar('Date(' + value + ')'); + } else if (value.__Jasmine_been_here_before__) { + this.emitScalar(''); + } else if (jasmine.isArray_(value) || typeof value == 'object') { + value.__Jasmine_been_here_before__ = true; + if (jasmine.isArray_(value)) { + this.emitArray(value); + } else { + this.emitObject(value); + } + delete value.__Jasmine_been_here_before__; + } else { + this.emitScalar(value.toString()); + } + } finally { + this.ppNestLevel_--; + } +}; + +jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { + for (var property in obj) { + if (!obj.hasOwnProperty(property)) continue; + if (property == '__Jasmine_been_here_before__') continue; + fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && + obj.__lookupGetter__(property) !== null) : false); + } +}; + +jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; +jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; +jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; +jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; + +jasmine.StringPrettyPrinter = function() { + jasmine.PrettyPrinter.call(this); + + this.string = ''; +}; +jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); + +jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { + this.append(value); +}; + +jasmine.StringPrettyPrinter.prototype.emitString = function(value) { + this.append("'" + value + "'"); +}; + +jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { + if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) { + this.append("Array"); + return; + } + + this.append('[ '); + for (var i = 0; i < array.length; i++) { + if (i > 0) { + this.append(', '); + } + this.format(array[i]); + } + this.append(' ]'); +}; + +jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { + if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) { + this.append("Object"); + return; + } + + var self = this; + this.append('{ '); + var first = true; + + this.iterateObject(obj, function(property, isGetter) { + if (first) { + first = false; + } else { + self.append(', '); + } + + self.append(property); + self.append(' : '); + if (isGetter) { + self.append(''); + } else { + self.format(obj[property]); + } + }); + + this.append(' }'); +}; + +jasmine.StringPrettyPrinter.prototype.append = function(value) { + this.string += value; +}; +jasmine.Queue = function(env) { + this.env = env; + + // parallel to blocks. each true value in this array means the block will + // get executed even if we abort + this.ensured = []; + this.blocks = []; + this.running = false; + this.index = 0; + this.offset = 0; + this.abort = false; +}; + +jasmine.Queue.prototype.addBefore = function(block, ensure) { + if (ensure === jasmine.undefined) { + ensure = false; + } + + this.blocks.unshift(block); + this.ensured.unshift(ensure); +}; + +jasmine.Queue.prototype.add = function(block, ensure) { + if (ensure === jasmine.undefined) { + ensure = false; + } + + this.blocks.push(block); + this.ensured.push(ensure); +}; + +jasmine.Queue.prototype.insertNext = function(block, ensure) { + if (ensure === jasmine.undefined) { + ensure = false; + } + + this.ensured.splice((this.index + this.offset + 1), 0, ensure); + this.blocks.splice((this.index + this.offset + 1), 0, block); + this.offset++; +}; + +jasmine.Queue.prototype.start = function(onComplete) { + this.running = true; + this.onComplete = onComplete; + this.next_(); +}; + +jasmine.Queue.prototype.isRunning = function() { + return this.running; +}; + +jasmine.Queue.LOOP_DONT_RECURSE = true; + +jasmine.Queue.prototype.next_ = function() { + var self = this; + var goAgain = true; + + while (goAgain) { + goAgain = false; + + if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) { + var calledSynchronously = true; + var completedSynchronously = false; + + var onComplete = function () { + if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) { + completedSynchronously = true; + return; + } + + if (self.blocks[self.index].abort) { + self.abort = true; + } + + self.offset = 0; + self.index++; + + var now = new Date().getTime(); + if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) { + self.env.lastUpdate = now; + self.env.setTimeout(function() { + self.next_(); + }, 0); + } else { + if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) { + goAgain = true; + } else { + self.next_(); + } + } + }; + self.blocks[self.index].execute(onComplete); + + calledSynchronously = false; + if (completedSynchronously) { + onComplete(); + } + + } else { + self.running = false; + if (self.onComplete) { + self.onComplete(); + } + } + } +}; + +jasmine.Queue.prototype.results = function() { + var results = new jasmine.NestedResults(); + for (var i = 0; i < this.blocks.length; i++) { + if (this.blocks[i].results) { + results.addResult(this.blocks[i].results()); + } + } + return results; +}; + + +/** + * Runner + * + * @constructor + * @param {jasmine.Env} env + */ +jasmine.Runner = function(env) { + var self = this; + self.env = env; + self.queue = new jasmine.Queue(env); + self.before_ = []; + self.after_ = []; + self.suites_ = []; +}; + +jasmine.Runner.prototype.execute = function() { + var self = this; + if (self.env.reporter.reportRunnerStarting) { + self.env.reporter.reportRunnerStarting(this); + } + self.queue.start(function () { + self.finishCallback(); + }); +}; + +jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) { + beforeEachFunction.typeName = 'beforeEach'; + this.before_.splice(0,0,beforeEachFunction); +}; + +jasmine.Runner.prototype.afterEach = function(afterEachFunction) { + afterEachFunction.typeName = 'afterEach'; + this.after_.splice(0,0,afterEachFunction); +}; + + +jasmine.Runner.prototype.finishCallback = function() { + this.env.reporter.reportRunnerResults(this); +}; + +jasmine.Runner.prototype.addSuite = function(suite) { + this.suites_.push(suite); +}; + +jasmine.Runner.prototype.add = function(block) { + if (block instanceof jasmine.Suite) { + this.addSuite(block); + } + this.queue.add(block); +}; + +jasmine.Runner.prototype.specs = function () { + var suites = this.suites(); + var specs = []; + for (var i = 0; i < suites.length; i++) { + specs = specs.concat(suites[i].specs()); + } + return specs; +}; + +jasmine.Runner.prototype.suites = function() { + return this.suites_; +}; + +jasmine.Runner.prototype.topLevelSuites = function() { + var topLevelSuites = []; + for (var i = 0; i < this.suites_.length; i++) { + if (!this.suites_[i].parentSuite) { + topLevelSuites.push(this.suites_[i]); + } + } + return topLevelSuites; +}; + +jasmine.Runner.prototype.results = function() { + return this.queue.results(); +}; +/** + * Internal representation of a Jasmine specification, or test. + * + * @constructor + * @param {jasmine.Env} env + * @param {jasmine.Suite} suite + * @param {String} description + */ +jasmine.Spec = function(env, suite, description) { + if (!env) { + throw new Error('jasmine.Env() required'); + } + if (!suite) { + throw new Error('jasmine.Suite() required'); + } + var spec = this; + spec.id = env.nextSpecId ? env.nextSpecId() : null; + spec.env = env; + spec.suite = suite; + spec.description = description; + spec.queue = new jasmine.Queue(env); + + spec.afterCallbacks = []; + spec.spies_ = []; + + spec.results_ = new jasmine.NestedResults(); + spec.results_.description = description; + spec.matchersClass = null; +}; + +jasmine.Spec.prototype.getFullName = function() { + return this.suite.getFullName() + ' ' + this.description + '.'; +}; + + +jasmine.Spec.prototype.results = function() { + return this.results_; +}; + +/** + * All parameters are pretty-printed and concatenated together, then written to the spec's output. + * + * Be careful not to leave calls to jasmine.log in production code. + */ +jasmine.Spec.prototype.log = function() { + return this.results_.log(arguments); +}; + +jasmine.Spec.prototype.runs = function (func) { + var block = new jasmine.Block(this.env, func, this); + this.addToQueue(block); + return this; +}; + +jasmine.Spec.prototype.addToQueue = function (block) { + if (this.queue.isRunning()) { + this.queue.insertNext(block); + } else { + this.queue.add(block); + } +}; + +/** + * @param {jasmine.ExpectationResult} result + */ +jasmine.Spec.prototype.addMatcherResult = function(result) { + this.results_.addResult(result); +}; + +jasmine.Spec.prototype.expect = function(actual) { + var positive = new (this.getMatchersClass_())(this.env, actual, this); + positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); + return positive; +}; + +/** + * Waits a fixed time period before moving to the next block. + * + * @deprecated Use waitsFor() instead + * @param {Number} timeout milliseconds to wait + */ +jasmine.Spec.prototype.waits = function(timeout) { + var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); + this.addToQueue(waitsFunc); + return this; +}; + +/** + * Waits for the latchFunction to return true before proceeding to the next block. + * + * @param {Function} latchFunction + * @param {String} optional_timeoutMessage + * @param {Number} optional_timeout + */ +jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { + var latchFunction_ = null; + var optional_timeoutMessage_ = null; + var optional_timeout_ = null; + + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + switch (typeof arg) { + case 'function': + latchFunction_ = arg; + break; + case 'string': + optional_timeoutMessage_ = arg; + break; + case 'number': + optional_timeout_ = arg; + break; + } + } + + var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this); + this.addToQueue(waitsForFunc); + return this; +}; + +jasmine.Spec.prototype.fail = function (e) { + var expectationResult = new jasmine.ExpectationResult({ + passed: false, + message: e ? jasmine.util.formatException(e) : 'Exception', + trace: { stack: e.stack } + }); + this.results_.addResult(expectationResult); +}; + +jasmine.Spec.prototype.getMatchersClass_ = function() { + return this.matchersClass || this.env.matchersClass; +}; + +jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { + var parent = this.getMatchersClass_(); + var newMatchersClass = function() { + parent.apply(this, arguments); + }; + jasmine.util.inherit(newMatchersClass, parent); + jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); + this.matchersClass = newMatchersClass; +}; + +jasmine.Spec.prototype.finishCallback = function() { + this.env.reporter.reportSpecResults(this); +}; + +jasmine.Spec.prototype.finish = function(onComplete) { + this.removeAllSpies(); + this.finishCallback(); + if (onComplete) { + onComplete(); + } +}; + +jasmine.Spec.prototype.after = function(doAfter) { + if (this.queue.isRunning()) { + this.queue.add(new jasmine.Block(this.env, doAfter, this), true); + } else { + this.afterCallbacks.unshift(doAfter); + } +}; + +jasmine.Spec.prototype.execute = function(onComplete) { + var spec = this; + if (!spec.env.specFilter(spec)) { + spec.results_.skipped = true; + spec.finish(onComplete); + return; + } + + this.env.reporter.reportSpecStarting(this); + + spec.env.currentSpec = spec; + + spec.addBeforesAndAftersToQueue(); + + spec.queue.start(function () { + spec.finish(onComplete); + }); +}; + +jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { + var runner = this.env.currentRunner(); + var i; + + for (var suite = this.suite; suite; suite = suite.parentSuite) { + for (i = 0; i < suite.before_.length; i++) { + this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); + } + } + for (i = 0; i < runner.before_.length; i++) { + this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); + } + for (i = 0; i < this.afterCallbacks.length; i++) { + this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true); + } + for (suite = this.suite; suite; suite = suite.parentSuite) { + for (i = 0; i < suite.after_.length; i++) { + this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true); + } + } + for (i = 0; i < runner.after_.length; i++) { + this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true); + } +}; + +jasmine.Spec.prototype.explodes = function() { + throw 'explodes function should not have been called'; +}; + +jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { + if (obj == jasmine.undefined) { + throw "spyOn could not find an object to spy upon for " + methodName + "()"; + } + + if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { + throw methodName + '() method does not exist'; + } + + if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { + throw new Error(methodName + ' has already been spied upon'); + } + + var spyObj = jasmine.createSpy(methodName); + + this.spies_.push(spyObj); + spyObj.baseObj = obj; + spyObj.methodName = methodName; + spyObj.originalValue = obj[methodName]; + + obj[methodName] = spyObj; + + return spyObj; +}; + +jasmine.Spec.prototype.removeAllSpies = function() { + for (var i = 0; i < this.spies_.length; i++) { + var spy = this.spies_[i]; + spy.baseObj[spy.methodName] = spy.originalValue; + } + this.spies_ = []; +}; + +/** + * Internal representation of a Jasmine suite. + * + * @constructor + * @param {jasmine.Env} env + * @param {String} description + * @param {Function} specDefinitions + * @param {jasmine.Suite} parentSuite + */ +jasmine.Suite = function(env, description, specDefinitions, parentSuite) { + var self = this; + self.id = env.nextSuiteId ? env.nextSuiteId() : null; + self.description = description; + self.queue = new jasmine.Queue(env); + self.parentSuite = parentSuite; + self.env = env; + self.before_ = []; + self.after_ = []; + self.children_ = []; + self.suites_ = []; + self.specs_ = []; +}; + +jasmine.Suite.prototype.getFullName = function() { + var fullName = this.description; + for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { + fullName = parentSuite.description + ' ' + fullName; + } + return fullName; +}; + +jasmine.Suite.prototype.finish = function(onComplete) { + this.env.reporter.reportSuiteResults(this); + this.finished = true; + if (typeof(onComplete) == 'function') { + onComplete(); + } +}; + +jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { + beforeEachFunction.typeName = 'beforeEach'; + this.before_.unshift(beforeEachFunction); +}; + +jasmine.Suite.prototype.afterEach = function(afterEachFunction) { + afterEachFunction.typeName = 'afterEach'; + this.after_.unshift(afterEachFunction); +}; + +jasmine.Suite.prototype.results = function() { + return this.queue.results(); +}; + +jasmine.Suite.prototype.add = function(suiteOrSpec) { + this.children_.push(suiteOrSpec); + if (suiteOrSpec instanceof jasmine.Suite) { + this.suites_.push(suiteOrSpec); + this.env.currentRunner().addSuite(suiteOrSpec); + } else { + this.specs_.push(suiteOrSpec); + } + this.queue.add(suiteOrSpec); +}; + +jasmine.Suite.prototype.specs = function() { + return this.specs_; +}; + +jasmine.Suite.prototype.suites = function() { + return this.suites_; +}; + +jasmine.Suite.prototype.children = function() { + return this.children_; +}; + +jasmine.Suite.prototype.execute = function(onComplete) { + var self = this; + this.queue.start(function () { + self.finish(onComplete); + }); +}; +jasmine.WaitsBlock = function(env, timeout, spec) { + this.timeout = timeout; + jasmine.Block.call(this, env, null, spec); +}; + +jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); + +jasmine.WaitsBlock.prototype.execute = function (onComplete) { + if (jasmine.VERBOSE) { + this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); + } + this.env.setTimeout(function () { + onComplete(); + }, this.timeout); +}; +/** + * A block which waits for some condition to become true, with timeout. + * + * @constructor + * @extends jasmine.Block + * @param {jasmine.Env} env The Jasmine environment. + * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true. + * @param {Function} latchFunction A function which returns true when the desired condition has been met. + * @param {String} message The message to display if the desired condition hasn't been met within the given time period. + * @param {jasmine.Spec} spec The Jasmine spec. + */ +jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { + this.timeout = timeout || env.defaultTimeoutInterval; + this.latchFunction = latchFunction; + this.message = message; + this.totalTimeSpentWaitingForLatch = 0; + jasmine.Block.call(this, env, null, spec); +}; +jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); + +jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10; + +jasmine.WaitsForBlock.prototype.execute = function(onComplete) { + if (jasmine.VERBOSE) { + this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen')); + } + var latchFunctionResult; + try { + latchFunctionResult = this.latchFunction.apply(this.spec); + } catch (e) { + this.spec.fail(e); + onComplete(); + return; + } + + if (latchFunctionResult) { + onComplete(); + } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) { + var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen'); + this.spec.fail({ + name: 'timeout', + message: message + }); + + this.abort = true; + onComplete(); + } else { + this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; + var self = this; + this.env.setTimeout(function() { + self.execute(onComplete); + }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); + } +}; + +jasmine.version_= { + "major": 1, + "minor": 3, + "build": 1, + "revision": 1354556913 +}; + diff --git a/node_modules/es5-shim/tests/native.html b/node_modules/es5-shim/tests/native.html new file mode 100644 index 0000000..c6d2324 --- /dev/null +++ b/node_modules/es5-shim/tests/native.html @@ -0,0 +1,62 @@ + + + + + Jasmine Spec Runner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/node_modules/es5-shim/tests/spec/s-array.js b/node_modules/es5-shim/tests/spec/s-array.js new file mode 100644 index 0000000..88cce66 --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-array.js @@ -0,0 +1,1978 @@ +/* globals document */ + +var toStr = Object.prototype.toString; +var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false. +var ifHasDenseUndefinedsIt = canDistinguishSparseFromUndefined ? it : xit; +var undefinedIfNoSparseBug = canDistinguishSparseFromUndefined ? undefined : { valueOf: function () { return 0; } }; +var hasStrictMode = (function () { + 'use strict'; + + return !this; +}()); +var ifHasStrictIt = hasStrictMode ? it : xit; + +describe('Array', function () { + var testSubject; + + beforeEach(function () { + testSubject = [2, 3, undefinedIfNoSparseBug, true, 'hej', null, false, 0]; + delete testSubject[1]; + }); + + var createArrayLikeFromArray = function createArrayLikeFromArray(arr) { + var o = {}; + Array.prototype.forEach.call(arr, function (e, i) { + o[i] = e; + }); + o.length = arr.length; + return o; + }; + + describe('#forEach()', function () { + var expected, actual; + + beforeEach(function () { + expected = { 0: 2, 2: undefinedIfNoSparseBug, 3: true, 4: 'hej', 5: null, 6: false, 7: 0 }; + actual = {}; + }); + + it('should pass the right parameters', function () { + var callback = jasmine.createSpy('callback'); + var array = ['1']; + array.forEach(callback); + expect(callback).toHaveBeenCalledWith('1', 0, array); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = [1, 2, 3]; + var i = 0; + arr.forEach(function (a) { + i += 1; + arr.push(a + 3); + }); + expect(arr).toEqual([1, 2, 3, 4, 5, 6]); + expect(i).toBe(3); + }); + + it('should set the right context when given none', function () { + var context; + [1].forEach(function () { context = this; }); + expect(context).toBe(function () { return this; }.call()); + }); + + it('should iterate all', function () { + testSubject.forEach(function (obj, index) { + actual[index] = obj; + }); + expect(actual).toExactlyMatch(expected); + }); + + it('should iterate all using a context', function () { + var o = { a: actual }; + + testSubject.forEach(function (obj, index) { + this.a[index] = obj; + }, o); + expect(actual).toExactlyMatch(expected); + }); + + it('should iterate all in an array-like object', function () { + var ts = createArrayLikeFromArray(testSubject); + Array.prototype.forEach.call(ts, function (obj, index) { + actual[index] = obj; + }); + expect(actual).toExactlyMatch(expected); + }); + + it('should iterate all in an array-like object using a context', function () { + var ts = createArrayLikeFromArray(testSubject); + var o = { a: actual }; + + Array.prototype.forEach.call(ts, function (obj, index) { + this.a[index] = obj; + }, o); + expect(actual).toExactlyMatch(expected); + }); + + describe('strings', function () { + var str = 'Hello, World!'; + + it('should iterate all in a string', function () { + actual = []; + Array.prototype.forEach.call(str, function (item, index) { + actual[index] = item; + }); + expect(actual).toExactlyMatch(str.split('')); + }); + + it('should iterate all in a string using a context', function () { + actual = []; + var o = { a: actual }; + Array.prototype.forEach.call(str, function (item, index) { + this.a[index] = item; + }, o); + expect(actual).toExactlyMatch(str.split('')); + }); + }); + + it('should have a boxed object as list argument of callback', function () { + var listArg; + Array.prototype.forEach.call('foo', function (item, index, list) { + listArg = list; + }); + expect(typeof listArg).toBe('object'); + expect(toStr.call(listArg)).toBe('[object String]'); + }); + + ifHasStrictIt('does not autobox the content in strict mode', function () { + var context; + [1].forEach(function () { + 'use strict'; + + context = this; + }, 'x'); + expect(typeof context).toBe('string'); + }); + }); + describe('#some()', function () { + var actual, expected, numberOfRuns; + + beforeEach(function () { + expected = { 0: 2, 2: undefinedIfNoSparseBug, 3: true }; + actual = {}; + numberOfRuns = 0; + }); + + it('should pass the correct values along to the callback', function () { + var callback = jasmine.createSpy('callback'); + var array = ['1']; + array.some(callback); + expect(callback).toHaveBeenCalledWith('1', 0, array); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = [1, 2, 3]; + var i = 0; + arr.some(function (a) { + i += 1; + arr.push(a + 3); + return i > 3; + }); + expect(arr).toEqual([1, 2, 3, 4, 5, 6]); + expect(i).toBe(3); + }); + + it('should set the right context when given none', function () { + /* eslint-disable array-callback-return */ + var context; + [1].some(function () { context = this; }); + expect(context).toBe(function () { return this; }.call()); + }); + + it('should return false if it runs to the end', function () { + /* eslint-disable array-callback-return */ + actual = testSubject.some(function () {}); + expect(actual).toBeFalsy(); + }); + + it('should return true if it is stopped somewhere', function () { + actual = testSubject.some(function () { return true; }); + expect(actual).toBeTruthy(); + }); + + it('should return false if there are no elements', function () { + actual = [].some(function () { return true; }); + expect(actual).toBeFalsy(); + }); + + it('should stop after 3 elements', function () { + testSubject.some(function (obj, index) { + actual[index] = obj; + numberOfRuns += 1; + return numberOfRuns === 3; + }); + expect(actual).toExactlyMatch(expected); + }); + + it('should stop after 3 elements using a context', function () { + var o = { a: actual }; + testSubject.some(function (obj, index) { + this.a[index] = obj; + numberOfRuns += 1; + return numberOfRuns === 3; + }, o); + expect(actual).toExactlyMatch(expected); + }); + + it('should stop after 3 elements in an array-like object', function () { + var ts = createArrayLikeFromArray(testSubject); + Array.prototype.some.call(ts, function (obj, index) { + actual[index] = obj; + numberOfRuns += 1; + return numberOfRuns === 3; + }); + expect(actual).toExactlyMatch(expected); + }); + + it('should stop after 3 elements in an array-like object using a context', function () { + var ts = createArrayLikeFromArray(testSubject); + var o = { a: actual }; + Array.prototype.some.call(ts, function (obj, index) { + this.a[index] = obj; + numberOfRuns += 1; + return numberOfRuns === 3; + }, o); + expect(actual).toExactlyMatch(expected); + }); + + it('should have a boxed object as list argument of callback', function () { + var listArg; + Array.prototype.some.call('foo', function (item, index, list) { + listArg = list; + }); + expect(typeof listArg).toBe('object'); + expect(toStr.call(listArg)).toBe('[object String]'); + }); + }); + describe('#every()', function () { + var actual, expected, numberOfRuns; + + beforeEach(function () { + expected = { 0: 2, 2: undefinedIfNoSparseBug, 3: true }; + actual = {}; + numberOfRuns = 0; + }); + + it('should pass the correct values along to the callback', function () { + var callback = jasmine.createSpy('callback'); + var array = ['1']; + array.every(callback); + expect(callback).toHaveBeenCalledWith('1', 0, array); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = [1, 2, 3]; + var i = 0; + arr.every(function (a) { + i += 1; + arr.push(a + 3); + return i <= 3; + }); + expect(arr).toEqual([1, 2, 3, 4, 5, 6]); + expect(i).toBe(3); + }); + + it('should set the right context when given none', function () { + /* eslint-disable array-callback-return */ + var context; + [1].every(function () { context = this; }); + expect(context).toBe(function () { return this; }.call()); + }); + + it('should return true if the array is empty', function () { + actual = [].every(function () { return true; }); + expect(actual).toBeTruthy(); + + actual = [].every(function () { return false; }); + expect(actual).toBeTruthy(); + }); + + it('should return true if it runs to the end', function () { + actual = [1, 2, 3].every(function () { return true; }); + expect(actual).toBeTruthy(); + }); + + it('should return false if it is stopped before the end', function () { + actual = [1, 2, 3].every(function () { return false; }); + expect(actual).toBeFalsy(); + }); + + it('should return after 3 elements', function () { + testSubject.every(function (obj, index) { + actual[index] = obj; + numberOfRuns += 1; + return numberOfRuns !== 3; + }); + expect(actual).toExactlyMatch(expected); + }); + + it('should stop after 3 elements using a context', function () { + var o = { a: actual }; + testSubject.every(function (obj, index) { + this.a[index] = obj; + numberOfRuns += 1; + return numberOfRuns !== 3; + }, o); + expect(actual).toExactlyMatch(expected); + }); + + it('should stop after 3 elements in an array-like object', function () { + var ts = createArrayLikeFromArray(testSubject); + Array.prototype.every.call(ts, function (obj, index) { + actual[index] = obj; + numberOfRuns += 1; + return numberOfRuns !== 3; + }); + expect(actual).toExactlyMatch(expected); + }); + + it('should stop after 3 elements in an array-like object using a context', function () { + var ts = createArrayLikeFromArray(testSubject); + var o = { a: actual }; + Array.prototype.every.call(ts, function (obj, index) { + this.a[index] = obj; + numberOfRuns += 1; + return numberOfRuns !== 3; + }, o); + expect(actual).toExactlyMatch(expected); + }); + + it('should have a boxed object as list argument of callback', function () { + var listArg; + Array.prototype.every.call('foo', function (item, index, list) { + listArg = list; + }); + expect(typeof listArg).toBe('object'); + expect(toStr.call(listArg)).toBe('[object String]'); + }); + }); + + describe('#indexOf()', function () { + 'use strict'; + + var actual, expected; + + beforeEach(function () { + testSubject = [2, 3, undefinedIfNoSparseBug, true, 'hej', null, 2, false, 0]; + delete testSubject[1]; + }); + + it('should find the element', function () { + expected = 4; + actual = testSubject.indexOf('hej'); + expect(actual).toBe(expected); + }); + + it('should not find the element', function () { + expected = -1; + actual = testSubject.indexOf('mus'); + expect(actual).toBe(expected); + }); + + ifHasDenseUndefinedsIt('should find undefined as well', function () { + expected = -1; + actual = testSubject.indexOf(undefined); + expect(actual).not.toBe(expected); + }); + + ifHasDenseUndefinedsIt('should skip unset indexes', function () { + expected = 2; + actual = testSubject.indexOf(undefined); + expect(actual).toBe(expected); + }); + + it('should use a strict test', function () { + actual = testSubject.indexOf(null); + expect(actual).toBe(5); + + actual = testSubject.indexOf('2'); + expect(actual).toBe(-1); + }); + + it('should skip the first if fromIndex is set', function () { + expect(testSubject.indexOf(2, 2)).toBe(6); + expect(testSubject.indexOf(2, 0)).toBe(0); + expect(testSubject.indexOf(2, 6)).toBe(6); + }); + + it('should work with negative fromIndex', function () { + expect(testSubject.indexOf(2, -3)).toBe(6); + expect(testSubject.indexOf(2, -9)).toBe(0); + }); + + it('should work with fromIndex being greater than the length', function () { + expect(testSubject.indexOf(0, 20)).toBe(-1); + }); + + it('should work with fromIndex being negative and greater than the length', function () { + expect(testSubject.indexOf('hej', -20)).toBe(4); + }); + + describe('Array-like', function ArrayLike() { + var indexOf = Array.prototype.indexOf; + var testAL; + + beforeEach(function beforeEach() { + testAL = {}; + testSubject = [2, 3, undefinedIfNoSparseBug, true, 'hej', null, 2, false, 0]; + testSubject.forEach(function (o, i) { + testAL[i] = o; + }); + testAL.length = testSubject.length; + }); + + it('should find the element (array-like)', function () { + expected = 4; + actual = indexOf.call(testAL, 'hej'); + expect(actual).toBe(expected); + }); + + it('should not find the element (array-like)', function () { + expected = -1; + actual = indexOf.call(testAL, 'mus'); + expect(actual).toBe(expected); + }); + + ifHasDenseUndefinedsIt('should find undefined as well (array-like)', function () { + expected = -1; + actual = indexOf.call(testAL, undefined); + expect(actual).not.toBe(expected); + }); + + ifHasDenseUndefinedsIt('should skip unset indexes (array-like)', function () { + expected = 2; + actual = indexOf.call(testAL, undefined); + expect(actual).toBe(expected); + }); + + it('should use a strict test (array-like)', function () { + actual = Array.prototype.indexOf.call(testAL, null); + expect(actual).toBe(5); + + actual = Array.prototype.indexOf.call(testAL, '2'); + expect(actual).toBe(-1); + }); + + it('should skip the first if fromIndex is set (array-like)', function () { + expect(indexOf.call(testAL, 2, 2)).toBe(6); + expect(indexOf.call(testAL, 2, 0)).toBe(0); + expect(indexOf.call(testAL, 2, 6)).toBe(6); + }); + + it('should work with negative fromIndex (array-like)', function () { + expect(indexOf.call(testAL, 2, -3)).toBe(6); + expect(indexOf.call(testAL, 2, -9)).toBe(0); + }); + + it('should work with fromIndex being greater than the length (array-like)', function () { + expect(indexOf.call(testAL, 0, 20)).toBe(-1); + }); + + it('should work with fromIndex being negative and greater than the length (array-like)', function () { + expect(indexOf.call(testAL, 'hej', -20)).toBe(4); + }); + }); + }); + describe('#lastIndexOf()', function () { + 'use strict'; + + var actual, expected; + + beforeEach(function () { + testSubject = [2, 3, undefinedIfNoSparseBug, true, 'hej', null, 2, 3, false, 0]; + delete testSubject[1]; + delete testSubject[7]; + }); + + describe('Array', function () { + it('should find the element', function () { + expected = 4; + actual = testSubject.lastIndexOf('hej'); + expect(actual).toBe(expected); + }); + + it('should not find the element', function () { + expected = -1; + actual = testSubject.lastIndexOf('mus'); + expect(actual).toBe(expected); + }); + + ifHasDenseUndefinedsIt('should find undefined as well', function () { + expected = -1; + actual = testSubject.lastIndexOf(undefined); + expect(actual).not.toBe(expected); + }); + + ifHasDenseUndefinedsIt('should skip unset indexes', function () { + expected = 2; + actual = testSubject.lastIndexOf(undefined); + expect(actual).toBe(expected); + }); + + it('should use a strict test', function () { + actual = testSubject.lastIndexOf(null); + expect(actual).toBe(5); + + actual = testSubject.lastIndexOf('2'); + expect(actual).toBe(-1); + }); + + it('should skip the first if fromIndex is set', function () { + expect(testSubject.lastIndexOf(2, 2)).toBe(0); + expect(testSubject.lastIndexOf(2, 0)).toBe(0); + expect(testSubject.lastIndexOf(2, 6)).toBe(6); + }); + + it('should work with negative fromIndex', function () { + expect(testSubject.lastIndexOf(2, -3)).toBe(6); + expect(testSubject.lastIndexOf(2, -9)).toBe(0); + }); + + it('should work with fromIndex being greater than the length', function () { + expect(testSubject.lastIndexOf(2, 20)).toBe(6); + }); + + it('should work with fromIndex being negative and greater than the length', function () { + expect(testSubject.lastIndexOf(2, -20)).toBe(-1); + }); + }); + + describe('Array like', function () { + var lastIndexOf = Array.prototype.lastIndexOf; + var testAL; + + beforeEach(function () { + testAL = {}; + testSubject.forEach(function (o, i) { + testAL[i] = o; + }); + testAL.length = testSubject.length; + }); + + it('should find the element (array-like)', function () { + expected = 4; + actual = lastIndexOf.call(testAL, 'hej'); + expect(actual).toBe(expected); + }); + + it('should not find the element (array-like)', function () { + expected = -1; + actual = lastIndexOf.call(testAL, 'mus'); + expect(actual).toBe(expected); + }); + + ifHasDenseUndefinedsIt('should find undefined as well (array-like)', function () { + expected = -1; + actual = lastIndexOf.call(testAL, undefined); + expect(actual).not.toBe(expected); + }); + + ifHasDenseUndefinedsIt('should skip unset indexes (array-like)', function () { + expected = 2; + actual = lastIndexOf.call(testAL, undefined); + expect(actual).toBe(expected); + }); + + it('should use a strict test (array-like)', function () { + actual = lastIndexOf.call(testAL, null); + expect(actual).toBe(5); + + actual = lastIndexOf.call(testAL, '2'); + expect(actual).toBe(-1); + }); + + it('should skip the first if fromIndex is set', function () { + expect(lastIndexOf.call(testAL, 2, 2)).toBe(0); + expect(lastIndexOf.call(testAL, 2, 0)).toBe(0); + expect(lastIndexOf.call(testAL, 2, 6)).toBe(6); + }); + + it('should work with negative fromIndex', function () { + expect(lastIndexOf.call(testAL, 2, -3)).toBe(6); + expect(lastIndexOf.call(testAL, 2, -9)).toBe(0); + }); + + it('should work with fromIndex being greater than the length', function () { + expect(lastIndexOf.call(testAL, 2, 20)).toBe(6); + }); + + it('should work with fromIndex being negative and greater than the length', function () { + expect(lastIndexOf.call(testAL, 2, -20)).toBe(-1); + }); + }); + }); + + describe('#filter()', function () { + var filteredArray; + var callback = function callback(o, i) { + return i !== 3 && i !== 5; + }; + + beforeEach(function () { + testSubject = [2, 3, undefinedIfNoSparseBug, true, 'hej', 3, null, false, 0]; + delete testSubject[1]; + filteredArray = [2, undefinedIfNoSparseBug, 'hej', null, false, 0]; + }); + describe('Array object', function () { + it('should call the callback with the proper arguments', function () { + var predicate = jasmine.createSpy('predicate'); + var arr = ['1']; + arr.filter(predicate); + expect(predicate).toHaveBeenCalledWith('1', 0, arr); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = [1, 2, 3]; + var i = 0; + arr.filter(function (a) { + i += 1; + if (i <= 4) { + arr.push(a + 3); + } + return true; + }); + expect(arr).toEqual([1, 2, 3, 4, 5, 6]); + expect(i).toBe(3); + }); + + ifHasDenseUndefinedsIt('should skip unset values', function () { + var passedValues = {}; + testSubject = [1, 2, 3, 4]; + delete testSubject[1]; + testSubject.filter(function (o, i) { + passedValues[i] = o; + return true; + }); + expect(passedValues).toExactlyMatch(testSubject); + }); + + it('should pass the right context to the filter', function () { + var passedValues = {}; + testSubject = [1, 2, 3, 4]; + delete testSubject[1]; + testSubject.filter(function (o, i) { + this[i] = o; + return true; + }, passedValues); + expect(passedValues).toExactlyMatch(testSubject); + }); + + it('should set the right context when given none', function () { + /* eslint-disable array-callback-return */ + var context; + [1].filter(function () { context = this; }); + expect(context).toBe(function () { return this; }.call()); + }); + + it('should remove only the values for which the callback returns false', function () { + var result = testSubject.filter(callback); + expect(result).toExactlyMatch(filteredArray); + }); + + it('should leave the original array untouched', function () { + var copy = testSubject.slice(); + testSubject.filter(callback); + expect(testSubject).toExactlyMatch(copy); + }); + + it('should not be affected by same-index mutation', function () { + var results = [1, 2, 3].filter(function (value, index, array) { + array[index] = 'a'; // eslint-disable-line no-param-reassign + return true; + }); + expect(results).toEqual([1, 2, 3]); + }); + }); + + describe('Array like', function () { + beforeEach(function () { + testSubject = createArrayLikeFromArray(testSubject); + }); + + it('should call the predicate with the proper arguments', function () { + var predicate = jasmine.createSpy('predicate'); + var arr = createArrayLikeFromArray(['1']); + Array.prototype.filter.call(arr, predicate); + expect(predicate).toHaveBeenCalledWith('1', 0, arr); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = createArrayLikeFromArray([1, 2, 3]); + var i = 0; + Array.prototype.filter.call(arr, function (a) { + i += 1; + if (i <= 4) { + arr[i + 2] = a + 3; + arr.length += 1; + } + return true; + }); + expect(Array.prototype.slice.call(arr)).toEqual([1, 2, 3, 4, 5, 6]); + expect(i).toBe(3); + }); + + it('should skip non-set values', function () { + var passedValues = createArrayLikeFromArray([]); + testSubject = createArrayLikeFromArray([1, 2, 3, 4]); + delete testSubject[1]; + Array.prototype.filter.call(testSubject, function (o, i) { + passedValues[i] = o; + passedValues.length = i + 1; + return true; + }); + expect(passedValues).toEqual(testSubject); + }); + + it('should set the right context when given none', function () { + var context; + Array.prototype.filter.call(createArrayLikeFromArray([1]), function () { context = this; }, undefined); + expect(context).toBe(function () { return this; }.call()); + }); + + it('should pass the right context to the filter', function () { + var passedValues = {}; + testSubject = createArrayLikeFromArray([1, 2, 3, 4]); + delete testSubject[1]; + Array.prototype.filter.call(testSubject, function (o, i) { + this[i] = o; + this.length = i + 1; + return true; + }, passedValues); + expect(passedValues).toEqual(testSubject); + }); + + it('should remove only the values for which the callback returns false', function () { + var result = Array.prototype.filter.call(testSubject, callback); + expect(result).toExactlyMatch(filteredArray); + }); + + it('should leave the original array untouched', function () { + var copy = createArrayLikeFromArray(testSubject); + Array.prototype.filter.call(testSubject, callback); + expect(testSubject).toExactlyMatch(copy); + }); + }); + + it('should have a boxed object as list argument of callback', function () { + var actual; + Array.prototype.filter.call('foo', function (item, index, list) { + actual = list; + }); + expect(typeof actual).toBe('object'); + expect(toStr.call(actual)).toBe('[object String]'); + }); + }); + describe('#map()', function () { + var callback; + beforeEach(function () { + var i = 0; + callback = function () { + return i++; + }; + }); + describe('Array object', function () { + it('should call mapper with the right parameters', function () { + var mapper = jasmine.createSpy('mapper'); + var array = [1]; + array.map(mapper); + expect(mapper).toHaveBeenCalledWith(1, 0, array); + }); + + it('should set the context correctly', function () { + var context = {}; + testSubject.map(function (o, i) { + this[i] = o; + }, context); + expect(context).toExactlyMatch(testSubject); + }); + + it('should set the right context when given none', function () { + var context; + [1].map(function () { context = this; }); + expect(context).toBe(function () { return this; }.call()); + }); + + it('should not change the array it is called on', function () { + var copy = testSubject.slice(); + testSubject.map(callback); + expect(testSubject).toExactlyMatch(copy); + }); + + it('should only run for the number of objects in the array when it started', function () { + var arr = [1, 2, 3]; + var i = 0; + arr.map(function (o) { + arr.push(o + 3); + i += 1; + return o; + }); + expect(arr).toExactlyMatch([1, 2, 3, 4, 5, 6]); + expect(i).toBe(3); + }); + + it('should properly translate the values as according to the callback', function () { + var result = testSubject.map(callback); + var expected = [0, 0, 1, 2, 3, 4, 5, 6]; + delete expected[1]; + expect(result).toExactlyMatch(expected); + }); + + it('should skip non-existing values', function () { + var array = [1, 2, 3, 4]; + var i = 0; + delete array[2]; + array.map(function () { + i += 1; + }); + expect(i).toBe(3); + }); + }); + describe('Array-like', function () { + beforeEach(function () { + testSubject = createArrayLikeFromArray(testSubject); + }); + + it('should call mapper with the right parameters', function () { + var mapper = jasmine.createSpy('mapper'); + var array = createArrayLikeFromArray([1]); + Array.prototype.map.call(array, mapper); + expect(mapper).toHaveBeenCalledWith(1, 0, array); + }); + + it('should set the context correctly', function () { + var context = {}; + Array.prototype.map.call(testSubject, function (o, i) { + this[i] = o; + this.length = i + 1; + }, context); + expect(context).toEqual(testSubject); + }); + + it('should set the right context when given none', function () { + var context; + Array.prototype.map.call(createArrayLikeFromArray([1]), function () { context = this; }); + expect(context).toBe(function () { return this; }.call()); + }); + + it('should not change the array it is called on', function () { + var copy = createArrayLikeFromArray(testSubject); + Array.prototype.map.call(testSubject, callback); + expect(testSubject).toExactlyMatch(copy); + }); + + it('should only run for the number of objects in the array when it started', function () { + var arr = createArrayLikeFromArray([1, 2, 3]); + var i = 0; + Array.prototype.map.call(arr, function (o) { + Array.prototype.push.call(arr, o + 3); + i += 1; + return o; + }); + expect(Array.prototype.slice.call(arr)).toEqual([1, 2, 3, 4, 5, 6]); + expect(i).toBe(3); + }); + + it('should properly translate the values as according to the callback', function () { + var result = Array.prototype.map.call(testSubject, callback); + var expected = [0, 0, 1, 2, 3, 4, 5, 6]; + delete expected[1]; + expect(result).toExactlyMatch(expected); + }); + + it('should skip non-existing values', function () { + var array = createArrayLikeFromArray([1, 2, 3, 4]); + var i = 0; + delete array[2]; + Array.prototype.map.call(array, function () { + i += 1; + }); + expect(i).toBe(3); + }); + }); + + it('should have a boxed object as list argument of callback', function () { + var actual; + Array.prototype.map.call('foo', function (item, index, list) { + actual = list; + }); + expect(typeof actual).toBe('object'); + expect(toStr.call(actual)).toBe('[object String]'); + }); + }); + + describe('#reduce()', function () { + beforeEach(function () { + testSubject = [1, 2, 3]; + }); + + describe('Array', function () { + it('should pass the correct arguments to the callback', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduce(spy); + expect(spy.calls[0].args).toExactlyMatch([1, 2, 1, testSubject]); + }); + + it('should start with the right initialValue', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduce(spy, 0); + expect(spy.calls[0].args).toExactlyMatch([0, 1, 0, testSubject]); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = [1, 2, 3]; + var i = 0; + arr.reduce(function (a, b) { + i += 1; + if (i <= 4) { + arr.push(a + 3); + } + return b; + }); + expect(arr).toEqual([1, 2, 3, 4, 5]); + expect(i).toBe(2); + }); + + it('should work as expected for empty arrays', function () { + var spy = jasmine.createSpy(); + expect(function () { + [].reduce(spy); + }).toThrow(); + expect(spy).not.toHaveBeenCalled(); + }); + + it('should throw correctly if no callback is given', function () { + expect(function () { + testSubject.reduce(); + }).toThrow(); + }); + + it('should return the expected result', function () { + expect(testSubject.reduce(function (a, b) { + return String(a || '') + String(b || ''); + })).toBe(testSubject.join('')); + }); + + it('should not directly affect the passed array', function () { + var copy = testSubject.slice(); + testSubject.reduce(function (a, b) { + return a + b; + }); + expect(testSubject).toEqual(copy); + }); + + it('should skip non-set values', function () { + delete testSubject[1]; + var visited = {}; + testSubject.reduce(function (a, b) { + if (a) { visited[a] = true; } + if (b) { visited[b] = true; } + return 0; + }); + + expect(visited).toEqual({ 1: true, 3: true }); + }); + + it('should have the right length', function () { + expect(testSubject.reduce.length).toBe(1); + }); + }); + describe('Array-like objects', function () { + beforeEach(function () { + testSubject = createArrayLikeFromArray(testSubject); + testSubject.reduce = Array.prototype.reduce; + }); + + it('should pass the correct arguments to the callback', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduce(spy); + expect(spy.calls[0].args).toExactlyMatch([1, 2, 1, testSubject]); + }); + + it('should start with the right initialValue', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduce(spy, 0); + expect(spy.calls[0].args).toExactlyMatch([0, 1, 0, testSubject]); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = createArrayLikeFromArray([1, 2, 3]); + var i = 0; + Array.prototype.reduce.call(arr, function (a, b) { + i += 1; + if (i <= 4) { + arr[i + 2] = a + 3; + } + return b; + }); + expect(arr).toEqual({ + 0: 1, + 1: 2, + 2: 3, + 3: 4, + 4: 5, + length: 3 + }); + expect(i).toBe(2); + }); + + it('should work as expected for empty arrays', function () { + var spy = jasmine.createSpy(); + expect(function () { + Array.prototype.reduce.call({ length: 0 }, spy); + }).toThrow(); + expect(spy).not.toHaveBeenCalled(); + }); + + it('should throw correctly if no callback is given', function () { + expect(function () { + testSubject.reduce(); + }).toThrow(); + }); + + it('should return the expected result', function () { + expect(testSubject.reduce(function (a, b) { + return String(a || '') + String(b || ''); + })).toBe('123'); + }); + + it('should not directly affect the passed array', function () { + var copy = createArrayLikeFromArray(testSubject); + testSubject.reduce(function (a, b) { + return a + b; + }); + delete testSubject.reduce; + expect(testSubject).toEqual(copy); + }); + + it('should skip non-set values', function () { + delete testSubject[1]; + var visited = {}; + testSubject.reduce(function (a, b) { + if (a) { visited[a] = true; } + if (b) { visited[b] = true; } + return 0; + }); + + expect(visited).toEqual({ 1: true, 3: true }); + }); + + it('should have the right length', function () { + expect(testSubject.reduce.length).toBe(1); + }); + }); + + it('should have a boxed object as list argument of callback', function () { + var actual; + Array.prototype.reduce.call('foo', function (accumulator, item, index, list) { + actual = list; + }); + expect(typeof actual).toBe('object'); + expect(toStr.call(actual)).toBe('[object String]'); + }); + }); + describe('#reduceRight()', function () { + beforeEach(function () { + testSubject = [1, 2, 3]; + }); + + describe('Array', function () { + it('should pass the correct arguments to the callback', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduceRight(spy); + expect(spy.calls[0].args).toExactlyMatch([3, 2, 1, testSubject]); + }); + + it('should start with the right initialValue', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduceRight(spy, 0); + expect(spy.calls[0].args).toExactlyMatch([0, 3, 2, testSubject]); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = [1, 2, 3]; + var i = 0; + arr.reduceRight(function (a, b) { + i += 1; + if (i <= 4) { + arr.push(a + 3); + } + return b; + }); + expect(arr).toEqual([1, 2, 3, 6, 5]); + expect(i).toBe(2); + }); + + it('should work as expected for empty arrays', function () { + var spy = jasmine.createSpy(); + expect(function () { + [].reduceRight(spy); + }).toThrow(); + expect(spy).not.toHaveBeenCalled(); + }); + + it('should work as expected for empty arrays with an initial value', function () { + var spy = jasmine.createSpy(); + var result; + + result = [].reduceRight(spy, ''); + expect(spy).not.toHaveBeenCalled(); + expect(result).toBe(''); + }); + + it('should throw correctly if no callback is given', function () { + expect(function () { + testSubject.reduceRight(); + }).toThrow(); + }); + + it('should return the expected result', function () { + expect(testSubject.reduceRight(function (a, b) { + return String(a || '') + String(b || ''); + })).toBe('321'); + }); + + it('should not directly affect the passed array', function () { + var copy = testSubject.slice(); + testSubject.reduceRight(function (a, b) { + return a + b; + }); + expect(testSubject).toEqual(copy); + }); + + it('should skip non-set values', function () { + delete testSubject[1]; + var visited = {}; + testSubject.reduceRight(function (a, b) { + if (a) { visited[a] = true; } + if (b) { visited[b] = true; } + return 0; + }); + + expect(visited).toEqual({ 1: true, 3: true }); + }); + + it('should have the right length', function () { + expect(testSubject.reduceRight.length).toBe(1); + }); + }); + describe('Array-like objects', function () { + beforeEach(function () { + testSubject = createArrayLikeFromArray(testSubject); + testSubject.reduceRight = Array.prototype.reduceRight; + }); + + it('should pass the correct arguments to the callback', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduceRight(spy); + expect(spy.calls[0].args).toExactlyMatch([3, 2, 1, testSubject]); + }); + + it('should start with the right initialValue', function () { + var spy = jasmine.createSpy().andReturn(0); + testSubject.reduceRight(spy, 0); + expect(spy.calls[0].args).toExactlyMatch([0, 3, 2, testSubject]); + }); + + it('should not affect elements added to the array after it has begun', function () { + var arr = createArrayLikeFromArray([1, 2, 3]); + var i = 0; + Array.prototype.reduceRight.call(arr, function (a, b) { + i += 1; + if (i <= 4) { + arr[i + 2] = a + 3; + } + return b; + }); + expect(arr).toEqual({ + 0: 1, + 1: 2, + 2: 3, + 3: 6, + 4: 5, + length: 3 // does not get updated on property assignment + }); + expect(i).toBe(2); + }); + + it('should work as expected for empty arrays', function () { + var spy = jasmine.createSpy(); + expect(function () { + Array.prototype.reduceRight.call({ length: 0 }, spy); + }).toThrow(); + expect(spy).not.toHaveBeenCalled(); + }); + + it('should throw correctly if no callback is given', function () { + expect(function () { + testSubject.reduceRight(); + }).toThrow(); + }); + + it('should return the expected result', function () { + expect(testSubject.reduceRight(function (a, b) { + return String(a || '') + String(b || ''); + })).toBe('321'); + }); + + it('should not directly affect the passed array', function () { + var copy = createArrayLikeFromArray(testSubject); + testSubject.reduceRight(function (a, b) { + return a + b; + }); + delete testSubject.reduceRight; + expect(testSubject).toEqual(copy); + }); + + it('should skip non-set values', function () { + delete testSubject[1]; + var visited = {}; + testSubject.reduceRight(function (a, b) { + if (a) { visited[a] = true; } + if (b) { visited[b] = true; } + return 0; + }); + + expect(visited).toEqual({ 1: true, 3: true }); + }); + + it('should have the right length', function () { + expect(testSubject.reduceRight.length).toBe(1); + }); + }); + + it('should have a boxed object as list argument of callback', function () { + var actual; + Array.prototype.reduceRight.call('foo', function (accumulator, item, index, list) { + actual = list; + }); + expect(typeof actual).toBe('object'); + expect(toStr.call(actual)).toBe('[object String]'); + }); + }); + + describe('.isArray()', function () { + it('should be true for Array', function () { + expect(Array.isArray([])).toBe(true); + }); + + it('should be false for primitives', function () { + var primitives = [ + 'foo', + true, + false, + 42, + 0, + -0, + NaN, + Infinity, + -Infinity + ]; + primitives.forEach(function (v) { + expect(Array.isArray(v)).toBe(false); + }); + }); + + it('should fail for other objects', function () { + var objects = [ + {}, + /foo/, + arguments + ]; + if (Object.create) { + objects.push(Object.create(null)); + } + + objects.forEach(function (v) { + expect(Array.isArray(v)).toBe(false); + }); + }); + + if (typeof document !== 'undefined') { + it('should be false for an HTML element', function () { + var el = document.getElementsByTagName('div'); + expect(Array.isArray(el)).toBe(false); + }); + } + }); + + describe('#shift()', function () { + it('works on arrays', function () { + var arr = [1, 2]; + var result = arr.shift(); + expect(result).toBe(1); + expect(arr.length).toBe(1); + expect(Object.prototype.hasOwnProperty.call(arr, 0)).toBe(true); + expect(Object.prototype.hasOwnProperty.call(arr, 1)).toBe(false); + expect(arr[0]).toBe(2); + expect(arr[1]).toBeUndefined(); + }); + + it('is generic', function () { + var obj = { 0: 1, 1: 2, length: 2 }; + var result = Array.prototype.shift.call(obj); + expect(result).toBe(1); + expect(obj.length).toBe(1); + expect(Object.prototype.hasOwnProperty.call(obj, 0)).toBe(true); + expect(Object.prototype.hasOwnProperty.call(obj, 1)).toBe(false); + expect(obj[0]).toBe(2); + expect(obj[1]).toBeUndefined(); + }); + }); + + describe('#unshift()', function () { + it('should return length', function () { + expect([].unshift(0)).toBe(1); + }); + + it('works on arrays', function () { + var arr = [1]; + var result = arr.unshift(undefined); + expect(result).toBe(2); + expect(arr.length).toBe(2); + expect(Object.prototype.hasOwnProperty.call(arr, 0)).toBe(true); + expect(Object.prototype.hasOwnProperty.call(arr, 1)).toBe(true); + expect(arr[0]).toBeUndefined(); + expect(arr[1]).toBe(1); + }); + + it('is generic', function () { + var obj = { 0: 1, length: 1 }; + var result = Array.prototype.unshift.call(obj, undefined); + expect(result).toBe(2); + expect(obj.length).toBe(2); + expect(Object.prototype.hasOwnProperty.call(obj, 0)).toBe(true); + expect(Object.prototype.hasOwnProperty.call(obj, 1)).toBe(true); + expect(obj[0]).toBeUndefined(); + expect(obj[1]).toBe(1); + }); + }); + + describe('#splice()', function () { + var b = ['b']; + var a = [1, 'a', b]; + var test; + + var makeArray = function (l, givenPrefix) { + var prefix = givenPrefix || ''; + var length = l; + var arr = []; + while (length--) { + arr.unshift(prefix + Array(length + 1).join(' ') + length); + } + return arr; + }; + + beforeEach(function () { + test = a.slice(0); + }); + + it('has the right length', function () { + expect(Array.prototype.splice.length).toBe(2); + }); + + /* This test is disabled, because ES6 normalizes actual + * browser behavior, contradicting ES5. + */ + xit('treats undefined deleteCount as 0', function () { + expect(test.splice(0).length).toBe(0); + expect(test.splice(0)).toEqual(test.splice(0, 0)); + }); + + // ES6 introduced a proper default value + it('defaults deleteCount to length - start if there is only 1 argument', function () { + expect([0, 1, 2].splice(0).length).toBe(3); + expect([0, 1, 2].splice(1).length).toBe(2); + }); + + it('basic implementation test 1', function () { + expect(test.splice(0, 0)).toEqual([]); + }); + + it('basic implementation test 2', function () { + test.splice(0, 2); + expect(test).toEqual([b]); + }); + + it('should return right result 1', function () { + var array = []; + + array.splice(0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); + array.splice(1, 0, 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26'); + array.splice(5, 0, 'XXX'); + + expect(array).toEqual([1, 'F1', 'F2', 'F3', 'F4', 'XXX', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26', 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]); + }); + + it('should return right result 2', function () { + var array = makeArray(6); + + array.splice(array.length - 1, 1, ''); + array.splice(0, 1, 1, 2, 3, 4); + array.splice(0, 0, 1, 2, 3, 4, 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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45); + + array.splice(4, 0, '99999999999999'); + + expect(array).toEqual([1, 2, 3, 4, '99999999999999', 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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 1, 2, 3, 4, ' 1', ' 2', ' 3', ' 4', '']); + }); + + it('should return right result 3', function () { + var array = [1, 2, 3]; + + array.splice(0, array.length); + array.splice(0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + array.splice(1, 1, 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26'); + array.splice(5, 1, 'YYY', 'XXX'); + array.splice(0, 1); + array.splice(0, 2); + array.pop(); + array.push.apply(array, makeArray(10, '-')); + array.splice(array.length - 2, 10); + array.splice(); + array.splice(1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9); + array.splice(1, 1, 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26', 1, 23, 4, 5, 6, 7, 8); + array.splice(30, 10); + array.splice(30, 1); + array.splice(30, 0); + array.splice(2, 5, 1, 2, 3, 'P', 'LLL', 'CCC', 'YYY', 'XXX'); + array.push(1, 2, 3, 4, 5, 6); + array.splice(1, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9); + array.splice(3, 7); + array.unshift(7, 8, 9, 10, 11); + array.pop(); + array.splice(5, 2); + array.pop(); + array.unshift.apply(array, makeArray(8, '~')); + array.pop(); + array.splice(3, 1, 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26', 1, 23, 4, 5, 6, 7, 8); + array.splice(4, 5, 'P', 'LLL', 'CCC', 'YYY', 'XXX'); + + expect(array).toEqual(['~0', '~ 1', '~ 2', 'F1', 'P', 'LLL', 'CCC', 'YYY', 'XXX', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26', 1, 23, 4, 5, 6, 7, 8, '~ 4', '~ 5', '~ 6', '~ 7', 7, 8, 9, 10, 11, 2, 4, 5, 6, 7, 8, 9, 'CCC', 'YYY', 'XXX', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26', 1, 23, 4, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'YYY', 'XXX', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26', 3, 4, 5, 6, 7, 8, 9, '-0', '- 1', '- 2', '- 3', '- 4', '- 5', '- 6', '- 7', 1, 2, 3]); + }); + + it('should do nothing if method called with no arguments', function () { + expect(test.splice()).toEqual([]); + expect(test).toEqual(a); + }); + + it('should set first argument to 0 if first argument is set but undefined', function () { + var test2 = test.slice(0); + expect(test.splice(void 0, 2)).toEqual(test2.splice(0, 2)); + expect(test).toEqual(test2); + }); + + it('should work with objects - adding 1', function () { + var obj = {}; + Array.prototype.splice.call(obj, 0, 0, 1, 2, 3); + expect(obj.length).toBe(3); + }); + + it('should work with objects - adding 2', function () { + var obj = { 0: 1, length: 1 }; + Array.prototype.splice.call(obj, 1, 0, 2, 3); + expect(obj.length).toBe(3); + }); + + it('should work with objects - removing', function () { + var obj = { 0: 1, 1: 2, 2: 3, length: 3 }; + Array.prototype.splice.call(obj, 0, 3); + expect(obj.length).toBe(0); + }); + + it('should work with objects - replacing', function () { + var obj = { 0: 99, length: 1 }; + Array.prototype.splice.call(obj, 0, 1, 1, 2, 3); + expect(obj.length).toBe(3); + expect(obj[0]).toBe(1); + }); + + ifHasDenseUndefinedsIt('should not break on sparse arrays in Opera', function () { + // test from https://github.com/wikimedia/VisualEditor/blob/d468b00311e69c2095b9da360c5745153342a5c3/src/ve.utils.js#L182-L196 + var n = 256; + var arr = []; + arr[n] = 'a'; + arr.splice(n + 1, 0, 'b'); + expect(arr[n]).toBe('a'); + }); + + ifHasDenseUndefinedsIt('should not break on sparse arrays in Safari 7/8', function () { + // test from https://github.com/wikimedia/VisualEditor/blob/d468b00311e69c2095b9da360c5745153342a5c3/src/ve.utils.js#L182-L196 + var justFine = new Array(1e5 - 1); + justFine[10] = 'x'; + var tooBig = new Array(1e5); + tooBig[8] = 'x'; + + justFine.splice(1, 1); + expect(8 in justFine).toBe(false); + expect(justFine.indexOf('x')).toBe(9); + tooBig.splice(1, 1); + expect(6 in tooBig).toBe(false); + expect(tooBig.indexOf('x')).toBe(7); + }); + }); + + describe('#join()', function () { + it('defaults to a comma separator when none is provided', function () { + expect([1, 2].join()).toBe('1,2'); + }); + + it('defaults to a comma separator when undefined is provided', function () { + expect([1, 2].join(undefined)).toBe('1,2'); + }); + + it('works, extended', function () { + expect([].join()).toBe(''); + expect([undefined].join()).toBe(''); + expect([undefined, undefined].join()).toBe(','); + expect([null, null].join()).toBe(','); + expect([undefined, undefined].join('|')).toBe('|'); + expect([null, null].join('|')).toBe('|'); + expect([1, 2, 3].join('|')).toBe('1|2|3'); + expect([1, 2, 3].join(null)).toBe('1null2null3'); + expect([1, 2, 3].join({})).toBe('1[object Object]2[object Object]3'); + expect([1, 2, 3].join('')).toBe('123'); + }); + + it('is generic', function () { + var obj = { 0: 1, 1: 2, 2: 3, 3: 4, length: 3 }; + expect(Array.prototype.join.call(obj, ',')).toBe('1,2,3'); + }); + + it('works with a string literal', function () { + var str = '123'; + expect(Array.prototype.join.call(str, ',')).toBe('1,2,3'); + }); + + it('works with `arguments`', function () { + var args = (function () { return arguments; }(1, 2, 3)); + expect(Array.prototype.join.call(args, ',')).toBe('1,2,3'); + }); + }); + + describe('#push()', function () { + it('works on arrays', function () { + var arr = []; + var result = arr.push(undefined); + expect(result).toBe(1); + expect(arr.length).toBe(1); + expect(Object.prototype.hasOwnProperty.call(arr, 0)).toBe(true); + expect(arr[0]).toBeUndefined(); + }); + + it('is generic', function () { + var obj = {}; + var result = Array.prototype.push.call(obj, undefined); + expect(result).toBe(1); + expect(obj.length).toBe(1); + expect(Object.prototype.hasOwnProperty.call(obj, 0)).toBe(true); + expect(obj[0]).toBeUndefined(); + }); + }); + + describe('#pop()', function () { + it('works on arrays', function () { + var arr = [1, 2, 3]; + var result = arr.pop(); + expect(result).toBe(3); + expect(arr.length).toBe(2); + expect(Object.prototype.hasOwnProperty.call(arr, 2)).toBe(false); + expect(arr[2]).toBeUndefined(); + }); + + it('is generic', function () { + var obj = { 0: 1, 1: 2, 2: 3, length: 3 }; + var result = Array.prototype.pop.call(obj); + expect(result).toBe(3); + expect(obj.length).toBe(2); + expect(Object.prototype.hasOwnProperty.call(obj, 2)).toBe(false); + expect(obj[2]).toBeUndefined(); + }); + }); + + describe('#slice()', function () { + it('works on arrays', function () { + var arr = [1, 2, 3, 4]; + var result = arr.slice(1, 3); + expect(result).toEqual([2, 3]); + }); + + it('is generic', function () { + var obj = { 0: 1, 1: 2, 2: 3, 3: 4, length: 4 }; + var result = Array.prototype.slice.call(obj, 1, 3); + expect(result).toEqual([2, 3]); + }); + + it('works with `arguments`', function () { + var obj = (function () { + return arguments; + }(1, 2, 3, 4)); + var result = Array.prototype.slice.call(obj, 1, 3); + expect(result).toEqual([2, 3]); + }); + + it('boxed string access', function () { + var obj = '1234'; + var result = Array.prototype.slice.call(obj, 1, 3); + expect(result).toEqual(['2', '3']); + }); + + if (typeof document !== 'undefined') { + it('should be able to slice a NodeList', function () { + var nodes = document.getElementsByTagName('div'); + expect(Array.isArray(Array.prototype.slice.call(nodes))).toBe(true); + }); + } + }); + + describe('#sort()', function () { + describe('usage', function () { + it('requires a function or undefined as first argument', function () { + var actual = [1, 2]; + expect(actual.sort()).toBe(actual); + expect(actual.sort(undefined)).toBe(actual); + expect(actual.sort(function () { return 0; })).toBe(actual); + }); + + it('requires a non-function or non-undefined to throw a `TypeError`', function () { + expect(function () { [1, 2].sort(null); }).toThrow(); + expect(function () { [1, 2].sort(1); }).toThrow(); + expect(function () { [1, 2].sort(''); }).toThrow(); + expect(function () { [1, 2].sort(true); }).toThrow(); + expect(function () { [1, 2].sort({}); }).toThrow(); + expect(function () { [1, 2].sort([]); }).toThrow(); + expect(function () { [1, 2].sort(new Date()); }).toThrow(); + expect(function () { [1, 2].sort(/pattern/); }).toThrow(); + }); + }); + + describe('ascending', function () { + it('[5,2,4,6,1,3] should result in [1,2,3,4,5,6]', function () { + var actual = [5, 2, 4, 6, 1, 3]; + var expected = [1, 2, 3, 4, 5, 6]; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[5,2,2,6,1,3] should result in [1,2,2,3,5,6]', function () { + var actual = [5, 2, 2, 6, 1, 3]; + var expected = [1, 2, 2, 3, 5, 6]; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[0,0,0,0,0,1] should result in [0,0,0,0,0,1]', function () { + var actual = [0, 0, 0, 0, 0, 1]; + var expected = [0, 0, 0, 0, 0, 1]; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[0,0,0,0,0,-1] should result in [-1,0,0,0,0,0]', function () { + var actual = [0, 0, 0, 0, 0, -1]; + var expected = [-1, 0, 0, 0, 0, 0]; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,a,c,b] should result in [a,b,c,d,e,f]', function () { + var actual = ['f', 'e', 'd', 'a', 'c', 'b']; + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,,,,a,c,b] should result in [a,b,c,d,e,f,,,]', function () { + var actual = ['f', 'e', 'd', 1, 2, 'a', 'c', 'b']; + delete actual[3]; + delete actual[4]; + var expected = ['a', 'b', 'c', 'd', 'e', 'f']; + expected.length = 8; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,,null,,a,c,b] should result in [a,b,c,d,e,f,null,,,]', function () { + var actual = ['f', 'e', 'd', 1, null, 2, 'a', 'c', 'b']; + delete actual[3]; + delete actual[5]; + var expected = ['a', 'b', 'c', 'd', 'e', 'f', null]; + expected.length = 9; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,,null,undefined,a,c,b] should result in [a,b,c,d,e,f,null,undefined,,]', function () { + var actual = ['f', 'e', 'd', 1, null, undefined, 'a', 'c', 'b']; + delete actual[3]; + var expected = ['a', 'b', 'c', 'd', 'e', 'f', null, undefined]; + expected.length = 9; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[] should result in []', function () { + var actual = []; + var expected = []; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('[1] should result in [1]', function () { + var actual = [1]; + var expected = [1]; + actual.sort(); + expect(actual).toEqual(expected); + }); + + it('result should find only greater or equal values', function () { + var actual = []; + var i; + for (i = 0; i < 100; i += 1) { + actual.push(('00' + (Math.random() * 100).toFixed(0)).slice(-3)); + } + actual.sort(); + for (i = 0; i < actual.length - 1; i += 1) { + expect(actual[i] <= actual[i + 1]).toBe(true); + } + }); + }); + + describe('descending', function () { + var descending = function (left, right) { + var leftS = String(left); + var rightS = String(right); + if (leftS === rightS) { + return +0; + } + if (leftS < rightS) { + return 1; + } + return -1; + }; + + it('[5,2,4,6,1,3] should result in [6,5,4,3,2,1]', function () { + var actual = [5, 2, 4, 6, 1, 3]; + var expected = [6, 5, 4, 3, 2, 1]; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[5,2,2,6,1,3] should result in [6,5,4,2,2,1]', function () { + var actual = [5, 2, 2, 6, 1, 3]; + var expected = [6, 5, 3, 2, 2, 1]; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[0,0,0,0,0,1] should result in [1,0,0,0,0,0]', function () { + var actual = [0, 0, 0, 0, 0, 1]; + var expected = [1, 0, 0, 0, 0, 0]; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[0,0,0,0,0,-1] should result in [0,0,0,0,0,-1]', function () { + var actual = [0, 0, 0, 0, 0, -1]; + var expected = [0, 0, 0, 0, 0, -1]; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,a,c,b] should result in [f,e,d,c,b,a]', function () { + var actual = ['f', 'e', 'd', 'a', 'c', 'b']; + var expected = ['f', 'e', 'd', 'c', 'b', 'a']; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,,,a,c,b] should result in [f,e,d,c,b,a,,,]', function () { + var actual = ['f', 'e', 'd', 1, 2, 'a', 'c', 'b']; + delete actual[3]; + delete actual[4]; + var expected = ['f', 'e', 'd', 'c', 'b', 'a']; + expected.length = 8; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,,null,,a,c,b] should result in [null,f,e,d,c,b,a,,,]', function () { + var actual = ['f', 'e', 'd', 1, null, 2, 'a', 'c', 'b']; + delete actual[3]; + delete actual[5]; + var expected = [null, 'f', 'e', 'd', 'c', 'b', 'a']; + expected.length = 9; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[f,e,d,undefined,null,,a,c,b] should result in [null,f,e,d,c,b,a,undefined,,]', function () { + var actual = ['f', 'e', 'd', undefined, null, 2, 'a', 'c', 'b']; + delete actual[5]; + var expected = [null, 'f', 'e', 'd', 'c', 'b', 'a', undefined]; + expected.length = 9; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[] should result in []', function () { + var actual = []; + var expected = []; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('[1] should result in [1]', function () { + var actual = [1]; + var expected = [1]; + actual.sort(descending); + expect(actual).toEqual(expected); + }); + + it('result should find only lesser or equal values', function () { + var actual = []; + var i; + for (i = 0; i < 100; i += 1) { + actual.push(('00' + (Math.random() * 100).toFixed(0)).slice(-3)); + } + actual.sort(descending); + for (i = 0; i < actual.length - 1; i += 1) { + expect(actual[i] >= actual[i + 1]).toBe(true); + } + }); + }); + + describe('returned value', function () { + it('should be the source object', function () { + var actual = [1, 3, 2]; + expect(actual.sort()).toBe(actual); + }); + }); + + describe('when used generically', function () { + var descending = function (left, right) { + var leftS = String(left); + var rightS = String(right); + if (leftS === rightS) { + return +0; + } + if (leftS < rightS) { + return 1; + } + return -1; + }; + + var args = function () { + return arguments; + }; + + it('should not sort objects without length', function () { + var actual = { + 0: 5, + 1: 2, + 2: 4, + 3: 6, + 4: 1, + 5: 3 + }; + var expected = { + 0: 5, + 1: 2, + 2: 4, + 3: 6, + 4: 1, + 5: 3 + }; + Array.prototype.sort.call(actual); + expect(actual).toEqual(expected); + Array.prototype.sort.call(actual, descending); + expect(actual).toEqual(expected); + }); + + it('should sort objects ascending with length', function () { + var actual = { + 0: 5, + 1: 2, + 2: 4, + 3: 6, + 4: 1, + 5: 3, + length: 6 + }; + var expected = { + 0: 1, + 1: 2, + 2: 3, + 3: 4, + 4: 5, + 5: 6, + length: 6 + }; + Array.prototype.sort.call(actual); + expect(actual).toEqual(expected); + }); + + it('should sort objects descending with length', function () { + var actual = { + 0: 5, + 1: 2, + 2: 4, + 3: 6, + 4: 1, + 5: 3, + length: 6 + }; + var expected = { + 0: 6, + 1: 5, + 2: 4, + 3: 3, + 4: 2, + 5: 1, + length: 6 + }; + Array.prototype.sort.call(actual, descending); + expect(actual).toEqual(expected); + }); + + it('should sort objects descending with mixed content types and with length', function () { + var actual = { + 0: 5, + 1: 2, + 2: 4, + 4: null, + 6: 1, + 7: 3, + length: 8 + }; + var expected = { + 0: null, + 1: 5, + 2: 4, + 3: 3, + 4: 2, + 5: 1, + length: 8 + }; + Array.prototype.sort.call(actual, descending); + expect(actual).toEqual(expected); + }); + + it('should sort `arguments` object ascending', function () { + var actual = args(5, 2, 4, 6, 1, 3); + var expected = args(1, 2, 3, 4, 5, 6); + Array.prototype.sort.call(actual); + expect(actual).toEqual(expected); + }); + + it('should sort `arguments` object ascending with mixed content types', function () { + var actual = args(5, 2, 4, null, 1, 3); + var expected = args(1, 2, 3, 4, 5, null); + Array.prototype.sort.call(actual); + expect(actual).toEqual(expected); + }); + + it('should sort `arguments` object descending', function () { + var actual = args(5, 2, 4, 6, 1, 3); + var expected = args(6, 5, 4, 3, 2, 1); + Array.prototype.sort.call(actual, descending); + expect(actual).toEqual(expected); + }); + + it('should sort `arguments` object descending with mixed content types', function () { + var actual = args(5, 2, 4, null, 1, 3); + var expected = args(null, 5, 4, 3, 2, 1); + Array.prototype.sort.call(actual, descending); + expect(actual).toEqual(expected); + }); + }); + }); +}); diff --git a/node_modules/es5-shim/tests/spec/s-date.js b/node_modules/es5-shim/tests/spec/s-date.js new file mode 100644 index 0000000..92ec121 --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-date.js @@ -0,0 +1,558 @@ +describe('Date', function () { + 'use strict'; + + var supportsDescriptors = Object.defineProperty && (function () { + try { + var obj = {}; + Object.defineProperty(obj, 'x', { + enumerable: false, + value: obj + }); + for (var _ in obj) { // jscs:ignore disallowUnusedVariables + return false; + } + return obj.x === obj; + } catch (e) { /* this is ES3 */ + return false; + } + }()); + var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit; + var has = Object.prototype.hasOwnProperty; + + var negativeDate; + beforeEach(function () { + var negativeCanned = [ + { + getTime: -3509827329600292, + getUTCDay: 4, + getDay: 4, + dim: 31 + }, + { + getTime: -3509824651200292, + getUTCDay: 0, + getDay: 0, + dim: 29 + }, + { + getTime: -3509822145600292, + getUTCDay: 1, + getDay: 1, + dim: 31 + }, + { + getTime: -3509819467200292, + getUTCDay: 4, + getDay: 4, + dim: 30 + }, + { + getTime: -3509816875200292, + getUTCDay: 6, + getDay: 6, + dim: 31 + }, + { + getTime: -3509814196800292, + getUTCDay: 2, + getDay: 2, + dim: 30 + }, + { + getTime: -3509811604800292, + getUTCDay: 4, + getDay: 4, + dim: 31 + }, + { + getTime: -3509808926400292, + getUTCDay: 0, + getDay: 0, + dim: 31 + }, + { + getTime: -3509806248000292, + getUTCDay: 3, + getDay: 3, + dim: 30 + }, + { + getTime: -3509803656000292, + getUTCDay: 5, + getDay: 5, + dim: 31 + }, + { + getTime: -3509800977600292, + getUTCDay: 1, + getDay: 1, + dim: 30 + }, + { + getTime: -3509798385600292, + getUTCDay: 3, + getDay: 3, + dim: 31 + } + ]; + negativeDate = negativeCanned.map(function (item) { + var dateFirst = new Date(item.getTime); + var dateLast = new Date(item.getTime + ((item.dim - 1) * 86400000)); + return { + dates: [dateFirst, dateLast], + days: [1, item.dim], + getUTCDay: [item.getUTCDay, (item.getUTCDay + item.dim - 1) % 7], + getDay: [item.getDay, (item.getDay + item.dim - 1) % 7] + }; + }); + }); + + describe('.now()', function () { + it('should be the current time', function () { + var before = (new Date()).getTime(); + var middle = Date.now(); + var after = (new Date()).getTime(); + expect(middle).not.toBeLessThan(before); + expect(middle).not.toBeGreaterThan(after); + }); + }); + + describe('constructor', function () { + it('works with standard formats', function () { + // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1 + expect(+new Date('2012-12-31T23:59:59.000Z')).toBe(1356998399000); // 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000 + expect(+new Date('2012-04-04T05:02:02.170Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 + expect(+new Date('2012-04-04T05:02:02.170999Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 + expect(+new Date('2012-04-04T05:02:02.17Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 + expect(+new Date('2012-04-04T05:02:02.1Z')).toBe(1333515722100); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 + expect(+new Date('2012-04-04T24:00:00.000Z')).toBe(1333584000000); // NaN 1333584000000 1333584000000 1333584000000 1333584000000 + expect(+new Date('2012-02-29T12:00:00.000Z')).toBe(1330516800000); // 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000 + expect(+new Date('2011-03-01T12:00:00.000Z')).toBe(1298980800000); // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000 + + // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day + expect(new Date('2034-03-01T00:00:00.000Z') + - new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1 + + }); + + ifSupportsDescriptorsIt('is not enumerable', function () { + expect(Object.keys(new Date())).not.toContain('constructor'); + }); + + it('works as a function', function () { + var zeroDate = Date(0); + expect(zeroDate).toBe(String(zeroDate)); + var value = Date(1441705534578); + expect(value).toBe(String(value)); + }); + + it('fixes this Safari 8/9 bug', function () { + var offset = new Date(1970).getTimezoneOffset() * 60e3; + + var timestamp = 2147483647; // Math.pow(2, 31) - 1 + var date = new Date(1970, 0, 1, 0, 0, 0, timestamp); + var expectedTimestamp = timestamp + offset; + expect(date.getTime()).toBe(expectedTimestamp); + + var brokenTimestamp = 2147483648; // Math.pow(2, 31) + var brokenDate = new Date(1970, 0, 1, 0, 0, 0, brokenTimestamp); + var expectedBrokenTimestamp = brokenTimestamp + offset; + expect(brokenDate.getTime()).toBe(expectedBrokenTimestamp); // NaN in Safari 8/9 + + var veryBrokenTS = 1435734000000; + var veryBrokenDate = new Date(1970, 0, 1, 0, 0, 0, veryBrokenTS); + var largeDate = new Date('Wed Jul 01 2015 07:00:00 GMT-0700 (PDT)'); + var expectedVeryBrokenTS = veryBrokenTS + (largeDate.getTimezoneOffset() * 60e3); + expect(veryBrokenDate.getTime()).toBe(expectedVeryBrokenTS); // NaN in Safari 8/9 + }); + + it('works with a Date object', function () { + var date = new Date(1456297712984); + var copiedDate = new Date(date); + expect(date).not.toBe(copiedDate); + expect(copiedDate.getTime()).toBe(date.getTime()); + expect(+copiedDate).toBe(+date); + expect(String(copiedDate)).toBe(String(date)); + }); + }); + + describe('.parse()', function () { + // TODO: Write the rest of the test. + + ifSupportsDescriptorsIt('is not enumerable', function () { + expect(Object.getOwnPropertyDescriptor(Date, 'parse').enumerable).toBe(false); + }); + + it('should be an invalid date', function () { + // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1 + expect(Date.parse('2012-11-31T23:59:59.000Z')).toBeFalsy(); // 1354406399000 NaN NaN 1354406399000 NaN + expect(Date.parse('2012-12-31T23:59:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356998400000 + expect(Date.parse('2012-04-04T24:00:00.500Z')).toBeFalsy(); // NaN NaN 1333584000500 1333584000500 NaN + expect(Date.parse('2012-12-31T10:08:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356948540000 + expect(Date.parse('2012-13-01T12:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('2012-12-32T12:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('2012-12-31T25:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('2012-12-31T24:01:00.000Z')).toBeFalsy(); // NaN NaN NaN 1356998460000 NaN + expect(Date.parse('2012-12-31T12:60:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('2012-12-31T12:00:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356955260000 + expect(Date.parse('2012-00-31T23:59:59.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('2012-12-00T23:59:59.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('2011-02-29T12:00:00.000Z')).toBeFalsy(); // 1298980800000 NaN NaN 1298980800000 NaN + }); + + it('should work', function () { + var dates = { + // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1 Safari 8 + '2012-12-31T23:59:59.000Z': 1356998399000, // 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000 + '2012-04-04T05:02:02.170Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 + '2012-04-04T05:02:02.170999Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170.999 + '2012-04-04T05:02:02.17Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 + '2012-04-04T05:02:02.1Z': 1333515722100, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 + '2012-04-04T24:00:00.000Z': 1333584000000, // NaN 1333584000000 1333584000000 1333584000000 1333584000000 1333584000000 + '2012-02-29T12:00:00.000Z': 1330516800000, // 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000 + '2011-03-01T12:00:00.000Z': 1298980800000 // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000 + }; + for (var str in dates) { + if (has.call(dates, str)) { + expect(Math.floor(Date.parse(str))).toBe(dates[str]); + } + } + + // https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day + expect(Date.parse('2034-03-01T00:00:00.000Z') + - Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1 + + }); + + it('fixes a Safari 8/9 bug with parsing in UTC instead of local time', function () { + var offset = new Date('2015-07-01').getTimezoneOffset() * 60e3; + expect(Date.parse('2015-07-01T00:00:00')).toBe(1435708800000 + offset); // Safari 8/9 give NaN + }); + + it('should support extended years', function () { + // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1 + expect(Date.parse('0000-01-01T00:00:00.000Z')).toBe(-621672192e5); // -621672192e5 -621672192e5 -621672192e5 -621672192e5 -621672192e5 + expect(Date.parse('0001-01-01T00:00:00Z')).toBe(-621355968e5); // -621355968e5 -621355968e5 -621355968e5 8.64e15 -621355968e5 + expect(Date.parse('+275760-09-13T00:00:00.000Z')).toBe(8.64e15); // 8.64e15 NaN 8.64e15 8.64e15 8.64e15 + expect(Date.parse('-271821-04-20T00:00:00.000Z')).toBe(-8.64e15); // -8.64e15 NaN -8.64e15 -8.64e15 -8.6400000864e15 + expect(Date.parse('+275760-09-13T00:00:00.001Z')).toBeFalsy(); // NaN NaN NaN 8.64e15 + 1 8.64e15 + 1 + expect(Date.parse('-271821-04-19T23:59:59.999Z')).toBeFalsy(); // NaN NaN NaN -8.64e15 - 1 -8.6400000864e15 - 1 + expect(Date.parse('+033658-09-27T01:46:40.000Z')).toBe(1e15); // 1e15 NaN 1e15 1e15 9999999136e5 + expect(Date.parse('-000001-01-01T00:00:00Z')).toBe(-621987552e5); // -621987552e5 NaN -621987552e5 -621987552e5 -621987552e5 + expect(Date.parse('+002009-12-15T00:00:00Z')).toBe(12608352e5); // 12608352e5 NaN 12608352e5 12608352e5 12608352e5 + }); + + it('works with timezone offsets', function () { + // Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1 + expect(Date.parse('2012-01-29T12:00:00.000+01:00')).toBe(132783480e4); // 132783480e4 132783480e4 132783480e4 132783480e4 132783480e4 + expect(Date.parse('2012-01-29T12:00:00.000-00:00')).toBe(132783840e4); // 132783840e4 132783840e4 132783840e4 132783840e4 132783840e4 + expect(Date.parse('2012-01-29T12:00:00.000+00:00')).toBe(132783840e4); // 132783840e4 132783840e4 132783840e4 132783840e4 132783840e4 + expect(Date.parse('2012-01-29T12:00:00.000+23:59')).toBe(132775206e4); // 132775206e4 132775206e4 132775206e4 132775206e4 132775206e4 + expect(Date.parse('2012-01-29T12:00:00.000-23:59')).toBe(132792474e4); // 132792474e4 132792474e4 132792474e4 132792474e4 132792474e4 + expect(Date.parse('2012-01-29T12:00:00.000+24:00')).toBeFalsy(); // NaN 1327752e6 NaN 1327752000000 1327752000000 + expect(Date.parse('2012-01-29T12:00:00.000+24:01')).toBeFalsy(); // NaN NaN NaN 1327751940000 1327751940000 + expect(Date.parse('2012-01-29T12:00:00.000+24:59')).toBeFalsy(); // NaN NaN NaN 1327748460000 1327748460000 + expect(Date.parse('2012-01-29T12:00:00.000+25:00')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('2012-01-29T12:00:00.000+00:60')).toBeFalsy(); // NaN NaN NaN NaN NaN + expect(Date.parse('-271821-04-20T00:00:00.000+00:01')).toBeFalsy(); // NaN NaN NaN -864000000006e4 -864000008646e4 + expect(Date.parse('-271821-04-20T00:01:00.000+00:01')).toBe(-8.64e15); // -8.64e15 NaN -8.64e15 -8.64e15 -864000008640e4 + + // When time zone is missed, local offset should be used (ES 5.1 bug) + // see https://bugs.ecmascript.org/show_bug.cgi?id=112 + var tzOffset = Number(new Date(1970, 0)); + // same as (new Date().getTimezoneOffset() * 60000) + expect(Date.parse('1970-01-01T00:00:00')).toBe(tzOffset); // tzOffset 0 0 0 NaN + }); + + it('should be able to coerce to a number', function () { + var actual = Number(new Date(1970, 0)); + var expected = parseInt(actual, 10); + expect(actual).toBeDefined(); + expect(actual).toBe(expected); + expect(isNaN(actual)).toBeFalsy(); + }); + + }); + + describe('#toString()', function () { + var actual; + + beforeEach(function () { + actual = (new Date(1970, 0)).toString(); + }); + + it('should show correct date info for ' + actual, function () { + expect(actual).toMatch(/1970/); + expect(actual).toMatch(/jan/i); + expect(actual).toMatch(/thu/i); + expect(actual).toMatch(/00:00:00/); + }); + }); + + describe('#valueOf()', function () { + // Note that new Date(1970, 0).valueOf() is 0 in UTC timezone. + // Check check that it's a number (and an int), not that it's "truthy". + var actual; + + beforeEach(function () { + actual = (new Date(1970, 0)).valueOf(); + }); + it('should give a numeric value', function () { + expect(typeof actual).toBe('number'); + }); + it('should not be NaN', function () { + expect(isNaN(actual)).toBe(false); + }); + it('should give an int value', function () { + expect(actual).toBe(Math.floor(actual)); + }); + }); + + describe('#getUTCDate()', function () { + it('should return the right value for negative dates', function () { + // Opera 10.6/11.61/Opera 12 bug + negativeDate.forEach(function (item) { + item.dates.forEach(function (date, index) { + expect(date.getUTCDate()).toBe(item.days[index], date); + }); + }); + }); + }); + + describe('#getUTCDay()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date, index) { + expect(date.getUTCDay()).toBe(item.getUTCDay[index]); + }); + }); + }); + }); + + describe('#getUTCFullYear()', function () { + it('should return the right value for negative dates', function () { + // Opera 10.6/11.61/Opera 12 bug + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getUTCFullYear()).toBe(-109252); + }); + }); + }); + }); + + describe('#getUTCMonth()', function () { + it('should return the right value for negative dates', function () { + // Opera 10.6/11.61/Opera 12 bug + negativeDate.forEach(function (item, index) { + item.dates.forEach(function (date) { + expect(date.getUTCMonth()).toBe(index); + }); + }); + }); + + it('should return correct values', function () { + expect(new Date(8.64e15).getUTCMonth()).toBe(8); + expect(new Date(0).getUTCMonth()).toBe(0); + }); + }); + + describe('#getUTCHours()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getUTCHours()).toBe(11); + }); + }); + }); + }); + + describe('#getUTCMinutes()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getUTCMinutes()).toBe(59); + }); + }); + }); + }); + + describe('#getUTCSeconds()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getUTCSeconds()).toBe(59); + }); + }); + }); + }); + + describe('#getUTCMilliseconds()', function () { + it('should return the right value for negative dates', function () { + // Opera 10.6/11.61/Opera 12 bug + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getUTCMilliseconds()).toBe(708); + }); + }); + }); + }); + + describe('#getDate()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date, index) { + expect(date.getDate()).toBe(item.days[index]); + }); + }); + }); + }); + + describe('#getDay()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date, index) { + expect(date.getDay()).toBe(item.getDay[index]); + }); + }); + }); + }); + + describe('#getFullYear()', function () { + it('should return the right value for negative dates', function () { + // Opera 10.6/11.61/Opera 12 bug + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getFullYear()).toBe(-109252); + }); + }); + }); + }); + + describe('#getMonth()', function () { + it('should return the right value for negative dates', function () { + // Opera 10.6/11.61/Opera 12 bug + negativeDate.forEach(function (item, index) { + item.dates.forEach(function (date) { + expect(date.getMonth()).toBe(index); + }); + }); + }); + }); + + describe('#getHours()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getHours() + Math.floor(date.getTimezoneOffset() / 60)).toBe(11); + }); + }); + }); + }); + + describe('#getMinutes()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + var off = date.getTimezoneOffset(); + var offHours = Math.floor(off / 60); + var offMins = off - (offHours * 60); + expect(date.getMinutes() + offMins).toBe(59); + }); + }); + }); + }); + + describe('#getSeconds()', function () { + it('should return the right value for negative dates', function () { + negativeDate.forEach(function (item) { + item.dates.forEach(function (date, i) { + // the regex here is because in UTC, it's 59, but with TZData applied, + // which can have fractional hour offsets, it'll be 1. + expect(i + ':' + date.getSeconds()).toMatch(new RegExp(i + ':(?:' + 59 + '|' + 1 + ')')); + }); + }); + }); + }); + + describe('#getMilliseconds()', function () { + it('should return the right value for negative dates', function () { + // Opera 10.6/11.61/Opera 12 bug + negativeDate.forEach(function (item) { + item.dates.forEach(function (date) { + expect(date.getMilliseconds()).toBe(708); + }); + }); + }); + }); + + describe('#toISOString()', function () { + // TODO: write the rest of the test. + + it('should support extended years', function () { + expect(new Date(-62198755200000).toISOString().indexOf('-000001-01-01')).toBe(0); + expect(new Date(8.64e15).toISOString().indexOf('+275760-09-13')).toBe(0); + }); + + it('should return correct dates', function () { + expect(new Date(-1).toISOString()).toBe('1969-12-31T23:59:59.999Z'); // Safari 5.1.5 "1969-12-31T23:59:59.-01Z" + negativeDate.forEach(function (item, index) { + var m = index + 1; + item.dates.forEach(function (date, idx) { + var d = item.days[idx]; + 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 + }); + }); + }); + + }); + + describe('#toUTCString()', function () { + it('should return correct dates', function () { + expect(new Date(-1509842289600292).toUTCString()).toBe('Mon, 01 Jan -45875 11:59:59 GMT'); + }); + }); + + describe('#toDateString()', function () { + it('should return correct dates', function () { + expect(new Date(-1509842289600292).toDateString()).toBe('Mon Jan 01 -45875'); + }); + }); + + describe('#toString()', function () { + it('should return correct dates', function () { + var actual = new Date(1449662400000).toString(); + var re = /^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/; + expect(re.test(actual)).toBe(true, actual); + }); + }); + + describe('#toJSON()', function () { + + // Opera 11.6x/12 bug + it('should call toISOString', function () { + var date = new Date(0); + date.toISOString = function () { + return 1; + }; + expect(date.toJSON()).toBe(1); + }); + + it('should return null for not finite dates', function () { + var date = new Date(NaN), + json; + try { + json = date.toJSON(); + } catch (e) { + /* invalid json */ + expect(e).not.toEqual(jasmine.any(Error)); + } + expect(json).toBe(null); + }); + + it('should return the isoString when stringified', function () { + var date = new Date(); + expect(JSON.stringify(date.toISOString())).toBe(JSON.stringify(date)); + }); + }); + +}); diff --git a/node_modules/es5-shim/tests/spec/s-error.js b/node_modules/es5-shim/tests/spec/s-error.js new file mode 100644 index 0000000..c67c1ee --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-error.js @@ -0,0 +1,48 @@ +describe('Error', function () { + 'use strict'; + + var supportsDescriptors = Object.defineProperty && (function () { + try { + var obj = {}; + Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); + for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables + return obj.x === obj; + } catch (e) { /* this is ES3 */ + return false; + } + }()); + var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit; + + describe('#toString()', function () { + it('stringifies a newed error properly', function () { + var msg = 'test'; + var error = new RangeError(msg); + expect(error.name).toBe('RangeError'); + expect(error.message).toBe(msg); + expect(String(error)).toBe(error.name + ': ' + msg); + }); + + it('stringifies a thrown error properly', function () { + var msg = 'test'; + var error; + try { + throw new RangeError(msg); + } catch (e) { + error = e; + } + expect(error.name).toBe('RangeError'); + expect(error.message).toBe(msg); + expect(String(error)).toBe(error.name + ': ' + msg); + }); + }); + + describe('enumerability of prototype properties', function () { + ifSupportsDescriptorsIt('#message', function () { + expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'message')).toBe(false); + }); + + ifSupportsDescriptorsIt('#name', function () { + expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'name')).toBe(false); + }); + }); +}); diff --git a/node_modules/es5-shim/tests/spec/s-function.js b/node_modules/es5-shim/tests/spec/s-function.js new file mode 100644 index 0000000..98376d2 --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-function.js @@ -0,0 +1,174 @@ +describe('Function', function () { + 'use strict'; + + describe('#apply()', function () { + it('works with arraylike objects', function () { + var arrayLike = { length: 4, 0: 1, 2: 4, 3: true }; + var expectedArray = [1, undefined, 4, true]; + var actualArray = (function () { + return Array.prototype.slice.apply(arguments); + }.apply(null, arrayLike)); + expect(actualArray).toEqual(expectedArray); + }); + }); + + describe('#bind()', function () { + var actual; + + var testSubject = { + push: function (o) { + this.a.push(o); + } + }; + + var func = function func() { + Array.prototype.forEach.call(arguments, function (a) { + this.push(a); + }, this); + return this; + }; + + beforeEach(function () { + actual = []; + testSubject.a = []; + }); + + it('binds properly without a context', function () { + var context; + testSubject.func = function () { + context = this; + }.bind(); + testSubject.func(); + expect(context).toBe(function () { return this; }.call()); + }); + it('binds properly without a context, and still supplies bound arguments', function () { + var a, context; + testSubject.func = function () { + a = Array.prototype.slice.call(arguments); + context = this; + }.bind(undefined, 1, 2, 3); + testSubject.func(1, 2, 3); + expect(a).toEqual([1, 2, 3, 1, 2, 3]); + expect(context).toBe(function () { return this; }.call()); + }); + it('binds a context properly', function () { + testSubject.func = func.bind(actual); + testSubject.func(1, 2, 3); + expect(actual).toEqual([1, 2, 3]); + expect(testSubject.a).toEqual([]); + }); + it('binds a context and supplies bound arguments', function () { + testSubject.func = func.bind(actual, 1, 2, 3); + testSubject.func(4, 5, 6); + expect(actual).toEqual([1, 2, 3, 4, 5, 6]); + expect(testSubject.a).toEqual([]); + }); + + it('returns properly without binding a context', function () { + testSubject.func = function () { + return this; + }.bind(); + var context = testSubject.func(); + expect(context).toBe(function () { return this; }.call()); + }); + it('returns properly without binding a context, and still supplies bound arguments', function () { + var context; + testSubject.func = function () { + context = this; + return Array.prototype.slice.call(arguments); + }.bind(undefined, 1, 2, 3); + actual = testSubject.func(1, 2, 3); + expect(context).toBe(function () { return this; }.call()); + expect(actual).toEqual([1, 2, 3, 1, 2, 3]); + }); + it('returns properly while binding a context properly', function () { + var ret; + testSubject.func = func.bind(actual); + ret = testSubject.func(1, 2, 3); + expect(ret).toBe(actual); + expect(ret).not.toBe(testSubject); + }); + it('returns properly while binding a context and supplies bound arguments', function () { + var ret; + testSubject.func = func.bind(actual, 1, 2, 3); + ret = testSubject.func(4, 5, 6); + expect(ret).toBe(actual); + expect(ret).not.toBe(testSubject); + }); + it('has the new instance\'s context as a constructor', function () { + var actualContext; + var expectedContext = { foo: 'bar' }; + testSubject.Func = function () { + actualContext = this; + }.bind(expectedContext); + var result = new testSubject.Func(); + expect(result).toBeTruthy(); + expect(actualContext).not.toBe(expectedContext); + }); + it('passes the correct arguments as a constructor', function () { + var expected = { name: 'Correct' }; + testSubject.Func = function (arg) { + expect(Object.prototype.hasOwnProperty.call(this, 'name')).toBe(false); + return arg; + }.bind({ name: 'Incorrect' }); + var ret = new testSubject.Func(expected); + expect(ret).toBe(expected); + }); + it('returns the return value of the bound function when called as a constructor', function () { + var oracle = [1, 2, 3]; + var Subject = function () { + expect(this).not.toBe(oracle); + return oracle; + }.bind(null); + var result = new Subject(); + expect(result).toBe(oracle); + }); + + it('returns the correct value if constructor returns primitive', function () { + var Subject = function (oracle) { + expect(this).not.toBe(oracle); + return oracle; + }.bind(null); + + var primitives = ['asdf', null, true, 1]; + for (var i = 0; i < primitives.length; ++i) { + expect(new Subject(primitives[i])).not.toBe(primitives[i]); + } + + var objects = [[1, 2, 3], {}, function () {}]; + for (var j = 0; j < objects.length; ++j) { + expect(new Subject(objects[j])).toBe(objects[j]); + } + }); + it('returns the value that instance of original "class" when called as a constructor', function () { + var ClassA = function (x) { + this.name = x || 'A'; + }; + var ClassB = ClassA.bind(null, 'B'); + + var result = new ClassB(); + expect(result instanceof ClassA).toBe(true); + expect(result instanceof ClassB).toBe(true); + }); + it('sets a correct length without thisArg', function () { + var Subject = function (a, b, c) { return a + b + c; }.bind(); + expect(Subject.length).toBe(3); + }); + it('sets a correct length with thisArg', function () { + var Subject = function (a, b, c) { return a + b + c + this.d; }.bind({ d: 1 }); + expect(Subject.length).toBe(3); + }); + it('sets a correct length with thisArg and first argument', function () { + var Subject = function (a, b, c) { return a + b + c + this.d; }.bind({ d: 1 }, 1); + expect(Subject.length).toBe(2); + }); + it('sets a correct length without thisArg and first argument', function () { + var Subject = function (a, b, c) { return a + b + c; }.bind(undefined, 1); + expect(Subject.length).toBe(2); + }); + it('sets a correct length without thisArg and too many argument', function () { + var Subject = function (a, b, c) { return a + b + c; }.bind(undefined, 1, 2, 3, 4); + expect(Subject.length).toBe(0); + }); + }); +}); diff --git a/node_modules/es5-shim/tests/spec/s-global.js b/node_modules/es5-shim/tests/spec/s-global.js new file mode 100644 index 0000000..fdca15d --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-global.js @@ -0,0 +1,101 @@ +describe('global methods', function () { + 'use strict'; + + var foo = function foo() {}; + var functionsHaveNames = foo.name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; + var ifSymbolsIt = hasSymbols ? it : xit; + + var is = function (x, y) { + if (x === 0 && y === 0) { + return 1 / x === 1 / y; + } + return x === y; + }; + + describe('parseInt', function () { + /* eslint-disable radix */ + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(parseInt.name).toBe('parseInt'); + }); + + it('accepts a radix', function () { + for (var i = 2; i <= 36; ++i) { + expect(parseInt('10', i)).toBe(i); + } + }); + + it('defaults the radix to 10 when the number does not start with 0x or 0X', function () { + [ + '01', + '08', + '10', + '42' + ].forEach(function (str) { + expect(parseInt(str)).toBe(parseInt(str, 10)); + }); + }); + + it('defaults the radix to 16 when the number starts with 0x or 0X', function () { + expect(parseInt('0x16')).toBe(parseInt('0x16', 16)); + expect(parseInt('0X16')).toBe(parseInt('0X16', 16)); + }); + + it('ignores leading whitespace', function () { + expect(parseInt(' 0x16')).toBe(parseInt('0x16', 16)); + expect(parseInt(' 42')).toBe(parseInt('42', 10)); + expect(parseInt(' 08')).toBe(parseInt('08', 10)); + + 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'; + expect(parseInt(ws + '08')).toBe(parseInt('08', 10)); + expect(parseInt(ws + '0x16')).toBe(parseInt('0x16', 16)); + }); + + it('defaults the radix properly when not a true number', function () { + var fakeZero = { valueOf: function () { return 0; } }; + expect(parseInt('08', fakeZero)).toBe(parseInt('08', 10)); + expect(parseInt('0x16', fakeZero)).toBe(parseInt('0x16', 16)); + }); + + it('allows sign-prefixed hex values', function () { + expect(parseInt('-0xF')).toBe(-15); + expect(parseInt('-0xF', 16)).toBe(-15); + expect(parseInt('+0xF')).toBe(15); + expect(parseInt('+0xF', 16)).toBe(15); + }); + + it('NaN parsing', function () { + expect(parseInt()).toBeNaN(); + expect(parseInt(undefined)).toBeNaN(); + expect(parseInt(null)).toBeNaN(); + expect(parseInt(NaN)).toBeNaN(); + }); + + ifSymbolsIt('throws on symbols', function () { + expect(function () { parseInt(Symbol('')); }).toThrow(); + expect(function () { parseInt(Object(Symbol(''))); }).toThrow(); + }); + /* eslint-enable radix */ + }); + + describe('parseFloat()', function () { + it('works with zeroes', function () { + expect(is(parseFloat('0'), 0) ? '+0' : '-0').toBe('+0'); + expect(is(parseFloat(' 0'), 0) ? '+0' : '-0').toBe('+0'); + expect(is(parseFloat('+0'), 0) ? '+0' : '-0').toBe('+0'); + expect(is(parseFloat(' +0'), 0) ? '+0' : '-0').toBe('+0'); + expect(is(parseFloat('-0'), -0) ? '-0' : '+0').toBe('-0'); + expect(is(parseFloat(' -0'), -0) ? '-0' : '+0').toBe('-0'); + }); + + it('NaN parsing', function () { + expect(parseFloat(undefined)).toBeNaN(); + expect(parseFloat(null)).toBeNaN(); + expect(parseFloat(NaN)).toBeNaN(); + }); + }); +}); diff --git a/node_modules/es5-shim/tests/spec/s-number.js b/node_modules/es5-shim/tests/spec/s-number.js new file mode 100644 index 0000000..291ed44 --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-number.js @@ -0,0 +1,61 @@ +describe('Number', function () { + 'use strict'; + + describe('#toFixed()', function () { + it('should convert numbers correctly', function () { + expect((0.00008).toFixed(3)).toBe('0.000'); + expect((0.9).toFixed(0)).toBe('1'); + expect((1.255).toFixed(2)).toBe('1.25'); + expect((1843654265.0774949).toFixed(5)).toBe('1843654265.07749'); + expect((1000000000000000128).toFixed(0)).toBe('1000000000000000128'); + }); + }); + + describe('#toPrecision()', function () { + // the spec allows for this test to fail. + it('throws a RangeError when < 1 or > 21 (or > 100 in ES2018+)', function () { + expect(function () { return (0.9).toPrecision(0); }).toThrow(); + expect(function () { + return [ + (0.9).toPrecision(22), // ES2018 increased the limit from 21 to 100 + (0.9).toPrecision(101) + ]; + }).toThrow(); + }); + + it('works as expected', function () { + expect((0.00008).toPrecision(3)).toBe('0.0000800'); + expect((1.255).toPrecision(2)).toBe('1.3'); + expect((1843654265.0774949).toPrecision(13)).toBe('1843654265.077'); + expect(NaN.toPrecision(1)).toBe('NaN'); + }); + + it('works with an undefined precision', function () { + var num = 123.456; + expect(num.toPrecision()).toBe(String(num)); + expect(num.toPrecision(undefined)).toBe(String(num)); + }); + }); + + describe('constants', function () { + it('should have MAX_VALUE', function () { + expect(Number.MAX_VALUE).toBe(1.7976931348623157e308); + }); + + it('should have MIN_VALUE', function () { + expect(Number.MIN_VALUE).toBe(5e-324); + }); + + it('should have NaN', function () { + expect(Number.NaN).not.toBe(Number.NaN); + }); + + it('should have POSITIVE_INFINITY', function () { + expect(Number.POSITIVE_INFINITY).toBe(Infinity); + }); + + it('should have NEGATIVE_INFINITY', function () { + expect(Number.NEGATIVE_INFINITY).toBe(-Infinity); + }); + }); +}); diff --git a/node_modules/es5-shim/tests/spec/s-object.js b/node_modules/es5-shim/tests/spec/s-object.js new file mode 100644 index 0000000..8de6fcf --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-object.js @@ -0,0 +1,366 @@ +/* global window */ + +var has = Object.prototype.hasOwnProperty; +var supportsDescriptors = Object.defineProperty && (function () { + try { + var obj = {}; + Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); + for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables + return obj.x === obj; + } catch (e) { /* this is ES3 */ + return false; + } +}()); +var ifWindowIt = typeof window === 'undefined' ? xit : it; +var extensionsPreventible = typeof Object.preventExtensions === 'function' && (function () { + var obj = {}; + Object.preventExtensions(obj); + obj.a = 3; + return obj.a !== 3; +}()); +var ifExtensionsPreventibleIt = extensionsPreventible ? it : xit; +var canSeal = typeof Object.seal === 'function' && (function () { + var obj = { a: 3 }; + Object.seal(obj); + delete obj.a; + return obj.a === 3; +}()); +var ifCanSealIt = canSeal ? it : xit; +var canFreeze = typeof Object.freeze === 'function' && (function () { + var obj = {}; + Object.freeze(obj); + obj.a = 3; + return obj.a !== 3; +}()); +var ifCanFreezeIt = canFreeze ? it : xit; + +describe('Object', function () { + 'use strict'; + + describe('.keys()', function () { + var obj = { + str: 'boz', + obj: { }, + arr: [], + bool: true, + num: 42, + 'null': null, + undefined: undefined + }; + + var loopedValues = []; + for (var key in obj) { + loopedValues.push(key); + } + + var keys = Object.keys(obj); + it('should have correct length', function () { + expect(keys.length).toBe(7); + }); + + describe('arguments objects', function () { + it('works with an arguments object', function () { + (function () { + expect(arguments.length).toBe(3); + expect(Object.keys(arguments).length).toBe(arguments.length); + expect(Object.keys(arguments)).toEqual(['0', '1', '2']); + }(1, 2, 3)); + }); + + it('works with a legacy arguments object', function () { + var FakeArguments = function (args) { + args.forEach(function (arg, i) { + this[i] = arg; + }.bind(this)); + }; + FakeArguments.prototype.length = 3; + FakeArguments.prototype.callee = function () {}; + + var fakeOldArguments = new FakeArguments(['a', 'b', 'c']); + expect(Object.keys(fakeOldArguments)).toEqual(['0', '1', '2']); + }); + }); + + it('should return an Array', function () { + expect(Array.isArray(keys)).toBe(true); + }); + + it('should return names which are own properties', function () { + keys.forEach(function (name) { + expect(has.call(obj, name)).toBe(true); + }); + }); + + it('should return names which are enumerable', function () { + keys.forEach(function (name) { + expect(loopedValues.indexOf(name)).toNotBe(-1); + }); + }); + + // ES6 Object.keys does not require this throw + xit('should throw error for non object', function () { + var e = {}; + expect(function () { + try { + Object.keys(42); + } catch (err) { + throw e; + } + }).toThrow(e); + }); + + describe('enumerating over non-enumerable properties', function () { + it('has no enumerable keys on a Function', function () { + var Foo = function () {}; + expect(Object.keys(Foo.prototype)).toEqual([]); + }); + + it('has no enumerable keys on a boolean', function () { + expect(Object.keys(Boolean.prototype)).toEqual([]); + }); + + it('has no enumerable keys on an object', function () { + expect(Object.keys(Object.prototype)).toEqual([]); + }); + }); + + it('works with boxed primitives', function () { + expect(Object.keys(Object('hello'))).toEqual(['0', '1', '2', '3', '4']); + }); + + it('works with boxed primitives with extra properties', function () { + var x = Object('x'); + x.y = 1; + var actual = Object.keys(x); + var expected = ['0', 'y']; + actual.sort(); + expected.sort(); + expect(actual).toEqual(expected); + }); + + ifWindowIt('can serialize all objects on the `window`', function () { + var windowItemKeys, exception; + var excludedKeys = ['window', 'console', 'parent', 'self', 'frame', 'frames', 'frameElement', 'external', 'height', 'width', 'top', 'localStorage', 'applicationCache']; + if (supportsDescriptors) { + Object.defineProperty(window, 'thrower', { + configurable: true, + get: function () { throw new RangeError('thrower!'); } + }); + } + for (var k in window) { + exception = void 0; + windowItemKeys = exception; + if (excludedKeys.indexOf(k) === -1 && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { + try { + windowItemKeys = Object.keys(window[k]); + } catch (e) { + exception = e; + } + expect(Array.isArray(windowItemKeys)).toBe(true); + expect(exception).toBeUndefined(); + } + } + if (supportsDescriptors) { + delete window.thrower; + } + }); + }); + + describe('.isExtensible()', function () { + var obj = { }; + + it('should return true if object is extensible', function () { + expect(Object.isExtensible(obj)).toBe(true); + }); + + ifExtensionsPreventibleIt('should return false if object is not extensible', function () { + expect(Object.isExtensible(Object.preventExtensions(obj))).toBe(false); + }); + + ifCanSealIt('should return false if object is sealed', function () { + expect(Object.isExtensible(Object.seal(obj))).toBe(false); + }); + + ifCanFreezeIt('should return false if object is frozen', function () { + expect(Object.isExtensible(Object.freeze(obj))).toBe(false); + }); + + it('should throw error for non object', function () { + try { + // note: in ES6, this is expected to return false. + expect(Object.isExtensible(42)).toBe(false); + } catch (err) { + expect(err).toEqual(jasmine.any(TypeError)); + } + }); + }); + + describe('.defineProperty()', function () { + var obj; + + beforeEach(function () { + obj = {}; + + Object.defineProperty(obj, 'name', { + value: 'Testing', + configurable: true, + enumerable: true, + writable: true + }); + }); + + it('should return the initial value', function () { + expect(has.call(obj, 'name')).toBeTruthy(); + expect(obj.name).toBe('Testing'); + }); + + it('should be setable', function () { + obj.name = 'Other'; + expect(obj.name).toBe('Other'); + }); + + it('should return the parent initial value', function () { + var child = Object.create(obj, {}); + + expect(child.name).toBe('Testing'); + expect(has.call(child, 'name')).toBeFalsy(); + }); + + it('should not override the parent value', function () { + var child = Object.create(obj, {}); + + Object.defineProperty(child, 'name', { value: 'Other' }); + + expect(obj.name).toBe('Testing'); + expect(child.name).toBe('Other'); + }); + + it('should throw error for non object', function () { + expect(function () { + Object.defineProperty(42, 'name', {}); + }).toThrow(); + }); + + it('should not throw error for empty descriptor', function () { + expect(function () { + Object.defineProperty({}, 'name', {}); + }).not.toThrow(); + }); + }); + + describe('.getOwnPropertyDescriptor()', function () { + it('should return undefined because the object does not own the property', function () { + var descr = Object.getOwnPropertyDescriptor({}, 'name'); + + expect(descr).toBeUndefined(); + }); + + it('should return a data descriptor', function () { + var descr = Object.getOwnPropertyDescriptor({ name: 'Testing' }, 'name'); + var expected = { + value: 'Testing', + enumerable: true, + writable: true, + configurable: true + }; + + expect(descr).toEqual(expected); + }); + + it('should return undefined because the object does not own the property', function () { + var descr = Object.getOwnPropertyDescriptor(Object.create({ name: 'Testing' }, {}), 'name'); + + expect(descr).toBeUndefined(); + }); + + it('should return a data descriptor', function () { + var expected = { + value: 'Testing', + configurable: true, + enumerable: true, + writable: true + }; + var obj = Object.create({}, { name: expected }); + + var descr = Object.getOwnPropertyDescriptor(obj, 'name'); + + expect(descr).toEqual(expected); + }); + + it('should throw error for non object', function () { + try { + // note: in ES6, we expect this to return undefined. + expect(Object.getOwnPropertyDescriptor(42, 'name')).toBeUndefined(); + } catch (err) { + expect(err).toEqual(jasmine.any(TypeError)); + } + }); + }); + + describe('.getPrototypeOf()', function () { + it('should return the [[Prototype]] of an object', function () { + var Foo = function () {}; + + var proto = Object.getPrototypeOf(new Foo()); + + expect(proto).toBe(Foo.prototype); + }); + + it('should shamone to the `Object.prototype` if `object.constructor` is not a function', function () { + var Foo = function () {}; + Foo.prototype.constructor = 1; + + var proto = Object.getPrototypeOf(new Foo()), + fnToString = Function.prototype.toString; + + if (fnToString.call(Object.getPrototypeOf).indexOf('[native code]') < 0) { + expect(proto).toBe(Object.prototype); + } else { + expect(proto).toBe(Foo.prototype); + } + }); + + it('should throw error for non object', function () { + try { + expect(Object.getPrototypeOf(1)).toBe(Number.prototype); // ES6 behavior + } catch (err) { + expect(err).toEqual(jasmine.any(TypeError)); + } + }); + + it('should return null on Object.create(null)', function () { + var obj = Object.create(null); + + expect(Object.getPrototypeOf(obj) === null).toBe(true); + }); + }); + + describe('.defineProperties()', function () { + it('should define the constructor property', function () { + var target = {}; + var newProperties = { constructor: { value: 'new constructor' } }; + Object.defineProperties(target, newProperties); + expect(target.constructor).toBe('new constructor'); + }); + }); + + describe('.create()', function () { + it('should create objects with no properties when called as `Object.create(null)`', function () { + var obj = Object.create(null); + + expect('hasOwnProperty' in obj).toBe(false); + expect('toString' in obj).toBe(false); + expect('constructor' in obj).toBe(false); + + var protoIsEnumerable = false; + for (var k in obj) { + if (k === '__proto__') { + protoIsEnumerable = true; + } + } + expect(protoIsEnumerable).toBe(false); + + expect(obj instanceof Object).toBe(false); + }); + }); +}); diff --git a/node_modules/es5-shim/tests/spec/s-regexp.js b/node_modules/es5-shim/tests/spec/s-regexp.js new file mode 100644 index 0000000..ab7313b --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-regexp.js @@ -0,0 +1,26 @@ +describe('RegExp', function () { + 'use strict'; + + describe('#toString()', function () { + describe('literals', function () { + it('should return correct flags and in correct order', function () { + expect(String(/pattern/)).toBe('/pattern/'); + expect(String(/pattern/i)).toBe('/pattern/i'); + expect(String(/pattern/mi)).toBe('/pattern/im'); + expect(String(/pattern/im)).toBe('/pattern/im'); + expect(String(/pattern/mgi)).toBe('/pattern/gim'); + }); + }); + + describe('objects', function () { + it('should return correct flags and in correct order', function () { + /* eslint prefer-regex-literals: 0 */ + expect(String(new RegExp('pattern'))).toBe('/pattern/'); + expect(String(new RegExp('pattern', 'i'))).toBe('/pattern/i'); + expect(String(new RegExp('pattern', 'mi'))).toBe('/pattern/im'); + expect(String(new RegExp('pattern', 'im'))).toBe('/pattern/im'); + expect(String(new RegExp('pattern', 'mgi'))).toBe('/pattern/gim'); + }); + }); + }); +}); diff --git a/node_modules/es5-shim/tests/spec/s-string.js b/node_modules/es5-shim/tests/spec/s-string.js new file mode 100644 index 0000000..07c54a8 --- /dev/null +++ b/node_modules/es5-shim/tests/spec/s-string.js @@ -0,0 +1,267 @@ +describe('String', function () { + 'use strict'; + + describe('#trim()', function () { + var test = '\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\uFEFFHello, World!\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'; + + it('trims all ES5 whitespace', function () { + expect(test.trim()).toBe('Hello, World!'); + expect(test.trim().length).toBe(13); + }); + + it('does not trim the zero-width space', function () { + expect('\u200b'.trim()).toBe('\u200b'); + expect('\u200b'.trim().length).toBe(1); + }); + }); + + describe('#replace()', function () { + it('returns undefined for non-capturing groups', function () { + var groups = []; + 'x'.replace(/x(.)?/g, function (m, group) { + groups.push(group); /* "" in FF, `undefined` in CH/WK/IE */ + }); + expect(groups.length).toBe(1); + expect(groups[0]).toBeUndefined(); + }); + + it('should not fail in Firefox', function () { + expect(function () { + return '* alef\n* beth \n* gimel~0\n'.replace( + /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm, + function (match, m1, m2, m3, m4) { return '
  • ' + m4 + '
  • \n'; } + ); + }).not.toThrow(); + }); + }); + + describe('#split()', function () { + var test = 'ab'; + + it('If "separator" is undefined must return Array with one String - "this" string', function () { + expect(test.split()).toEqual([test]); + expect(test.split(void 0)).toEqual([test]); + }); + + it('If "separator" is undefined and "limit" set to 0 must return Array[]', function () { + expect(test.split(void 0, 0)).toEqual([]); + }); + + describe('Tests from Steven Levithan', function () { + it("''.split() results in ['']", function () { + expect(''.split()).toEqual(['']); + }); + it("''.split(/./) results in ['']", function () { + expect(''.split(/./)).toEqual(['']); + }); + it("''.split(/.?/) results in []", function () { + expect(''.split(/.?/)).toEqual([]); + }); + it("''.split(/.??/) results in []", function () { + expect(''.split(/.??/)).toEqual([]); + }); + it("'ab'.split(/a*/) results in ['', 'b']", function () { + expect('ab'.split(/a*/)).toEqual(['', 'b']); + }); + it("'ab'.split(/a*?/) results in ['a', 'b']", function () { + expect('ab'.split(/a*?/)).toEqual(['a', 'b']); + }); + it("'ab'.split(/(?:ab)/) results in ['', '']", function () { + expect('ab'.split(/(?:ab)/)).toEqual(['', '']); + }); + it("'ab'.split(/(?:ab)*/) results in ['', '']", function () { + expect('ab'.split(/(?:ab)*/)).toEqual(['', '']); + }); + it("'ab'.split(/(?:ab)*?/) results in ['a', 'b']", function () { + expect('ab'.split(/(?:ab)*?/)).toEqual(['a', 'b']); + }); + it("'test'.split('') results in ['t', 'e', 's', 't']", function () { + expect('test'.split('')).toEqual(['t', 'e', 's', 't']); + }); + it("'test'.split() results in ['test']", function () { + expect('test'.split()).toEqual(['test']); + }); + it("'111'.split(1) results in ['', '', '', '']", function () { + expect('111'.split(1)).toEqual(['', '', '', '']); + }); + it("'test'.split(/(?:)/, 2) results in ['t', 'e']", function () { + expect('test'.split(/(?:)/, 2)).toEqual(['t', 'e']); + }); + it("'test'.split(/(?:)/, -1) results in ['t', 'e', 's', 't']", function () { + expect('test'.split(/(?:)/, -1)).toEqual(['t', 'e', 's', 't']); + }); + it("'test'.split(/(?:)/, undefined) results in ['t', 'e', 's', 't']", function () { + expect('test'.split(/(?:)/, undefined)).toEqual(['t', 'e', 's', 't']); + }); + it("'test'.split(/(?:)/, null) results in []", function () { + expect('test'.split(/(?:)/, null)).toEqual([]); + }); + it("'test'.split(/(?:)/, NaN) results in []", function () { + expect('test'.split(/(?:)/, NaN)).toEqual([]); + }); + it("'test'.split(/(?:)/, true) results in ['t']", function () { + expect('test'.split(/(?:)/, true)).toEqual(['t']); + }); + it("'test'.split(/(?:)/, '2') results in ['t', 'e']", function () { + expect('test'.split(/(?:)/, '2')).toEqual(['t', 'e']); + }); + it("'test'.split(/(?:)/, 'two') results in []", function () { + expect('test'.split(/(?:)/, 'two')).toEqual([]); + }); + it("'a'.split(/-/) results in ['a']", function () { + expect('a'.split(/-/)).toEqual(['a']); + }); + it("'a'.split(/-?/) results in ['a']", function () { + expect('a'.split(/-?/)).toEqual(['a']); + }); + it("'a'.split(/-??/) results in ['a']", function () { + expect('a'.split(/-??/)).toEqual(['a']); + }); + it("'a'.split(/a/) results in ['', '']", function () { + expect('a'.split(/a/)).toEqual(['', '']); + }); + it("'a'.split(/a?/) results in ['', '']", function () { + expect('a'.split(/a?/)).toEqual(['', '']); + }); + it("'a'.split(/a??/) results in ['a']", function () { + expect('a'.split(/a??/)).toEqual(['a']); + }); + it("'ab'.split(/-/) results in ['ab']", function () { + expect('ab'.split(/-/)).toEqual(['ab']); + }); + it("'ab'.split(/-?/) results in ['a', 'b']", function () { + expect('ab'.split(/-?/)).toEqual(['a', 'b']); + }); + it("'ab'.split(/-??/) results in ['a', 'b']", function () { + expect('ab'.split(/-??/)).toEqual(['a', 'b']); + }); + it("'a-b'.split(/-/) results in ['a', 'b']", function () { + expect('a-b'.split(/-/)).toEqual(['a', 'b']); + }); + it("'a-b'.split(/-?/) results in ['a', 'b']", function () { + expect('a-b'.split(/-?/)).toEqual(['a', 'b']); + }); + it("'a-b'.split(/-??/) results in ['a', '-', 'b']", function () { + expect('a-b'.split(/-??/)).toEqual(['a', '-', 'b']); + }); + it("'a--b'.split(/-/) results in ['a', '', 'b']", function () { + expect('a--b'.split(/-/)).toEqual(['a', '', 'b']); + }); + it("'a--b'.split(/-?/) results in ['a', '', 'b']", function () { + expect('a--b'.split(/-?/)).toEqual(['a', '', 'b']); + }); + it("'a--b'.split(/-??/) results in ['a', '-', '-', 'b']", function () { + expect('a--b'.split(/-??/)).toEqual(['a', '-', '-', 'b']); + }); + it("''.split(/()()/) results in []", function () { + expect(''.split(/()()/)).toEqual([]); + }); + it("'.'.split(/()()/) results in ['.']", function () { + expect('.'.split(/()()/)).toEqual(['.']); + }); + it("'.'.split(/(.?)(.?)/) results in ['', '.', '', '']", function () { + expect('.'.split(/(.?)(.?)/)).toEqual(['', '.', '', '']); + }); + it("'.'.split(/(.??)(.??)/) results in ['.']", function () { + expect('.'.split(/(.??)(.??)/)).toEqual(['.']); + }); + it("'.'.split(/(.)?(.)?/) results in ['', '.', undefined, '']", function () { + expect('.'.split(/(.)?(.)?/)).toEqual(['', '.', undefined, '']); + }); + it("'Aboldandcoded'.split(/<(\\/)?([^<>]+)>/) results in ['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']", function () { + expect('Aboldandcoded'.split(/<(\/)?([^<>]+)>/)).toEqual(['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']); + }); + it("'tesst'.split(/(s)*/) results in ['t', undefined, 'e', 's', 't']", function () { + expect('tesst'.split(/(s)*/)).toEqual(['t', undefined, 'e', 's', 't']); + }); + it("'tesst'.split(/(s)*?/) results in ['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']", function () { + expect('tesst'.split(/(s)*?/)).toEqual(['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']); + }); + it("'tesst'.split(/(s*)/) results in ['t', '', 'e', 'ss', 't']", function () { + expect('tesst'.split(/(s*)/)).toEqual(['t', '', 'e', 'ss', 't']); + }); + it("'tesst'.split(/(s*?)/) results in ['t', '', 'e', '', 's', '', 's', '', 't']", function () { + expect('tesst'.split(/(s*?)/)).toEqual(['t', '', 'e', '', 's', '', 's', '', 't']); + }); + it("'tesst'.split(/(?:s)*/) results in ['t', 'e', 't']", function () { + expect('tesst'.split(/(?:s)*/)).toEqual(['t', 'e', 't']); + }); + it("'tesst'.split(/(?=s+)/) results in ['te', 's', 'st']", function () { + expect('tesst'.split(/(?=s+)/)).toEqual(['te', 's', 'st']); + }); + it("'test'.split('t') results in ['', 'es', '']", function () { + expect('test'.split('t')).toEqual(['', 'es', '']); + }); + it("'test'.split('es') results in ['t', 't']", function () { + expect('test'.split('es')).toEqual(['t', 't']); + }); + it("'test'.split(/t/) results in ['', 'es', '']", function () { + expect('test'.split(/t/)).toEqual(['', 'es', '']); + }); + it("'test'.split(/es/) results in ['t', 't']", function () { + expect('test'.split(/es/)).toEqual(['t', 't']); + }); + it("'test'.split(/(t)/) results in ['', 't', 'es', 't', '']", function () { + expect('test'.split(/(t)/)).toEqual(['', 't', 'es', 't', '']); + }); + it("'test'.split(/(es)/) results in ['t', 'es', 't']", function () { + expect('test'.split(/(es)/)).toEqual(['t', 'es', 't']); + }); + it("'test'.split(/(t)(e)(s)(t)/) results in ['', 't', 'e', 's', 't', '']", function () { + expect('test'.split(/(t)(e)(s)(t)/)).toEqual(['', 't', 'e', 's', 't', '']); + }); + it("'.'.split(/(((.((.??)))))/) results in ['', '.', '.', '.', '', '', '']", function () { + expect('.'.split(/(((.((.??)))))/)).toEqual(['', '.', '.', '.', '', '', '']); + }); + it("'.'.split(/(((((.??)))))/) results in ['.']", function () { + expect('.'.split(/(((((.??)))))/)).toEqual(['.']); + }); + it("'a b c d'.split(/ /, -(Math.pow(2, 32) - 1)) results in ['a']", function () { + expect('a b c d'.split(/ /, -(Math.pow(2, 32) - 1))).toEqual(['a']); + }); + it("'a b c d'.split(/ /, Math.pow(2, 32) + 1) results in ['a']", function () { + expect('a b c d'.split(/ /, Math.pow(2, 32) + 1)).toEqual(['a']); + }); + it("'a b c d'.split(/ /, Infinity) results in []", function () { + expect('a b c d'.split(/ /, Infinity)).toEqual([]); + }); + }); + + it('works with the second argument', function () { + expect('a b'.split(/ /, 1)).toEqual(['a']); + }); + }); + + describe('#indexOf()', function () { + it('has basic support', function () { + expect('abcab'.indexOf('a')).toBe(0); + expect('abcab'.indexOf('a', 1)).toBe(3); + expect('abcab'.indexOf('a', 4)).toBe(-1); + }); + + it('works with unicode', function () { + expect('あいabcあいabc'.indexOf('あい')).toBe(0); + expect('あいabcあいabc'.indexOf('あい', 0)).toBe(0); + expect('あいabcあいabc'.indexOf('あい', 1)).toBe(5); + expect('あいabcあいabc'.indexOf('あい', 6)).toBe(-1); + }); + }); + + describe('#lastIndexOf()', function () { + it('has the right length', function () { + expect(String.prototype.lastIndexOf.length).toBe(1); + }); + + it('has basic support', function () { + expect('abcd'.lastIndexOf('d')).toBe(3); + expect('abcd'.lastIndexOf('d', 3)).toBe(3); + expect('abcd'.lastIndexOf('d', 2)).toBe(-1); + }); + + it('works with unicode', function () { + expect('abcあい'.lastIndexOf('あい')).toBe(3); + expect('abcあい'.lastIndexOf('あい', 3)).toBe(3); + expect('abcあい'.lastIndexOf('あい', 2)).toBe(-1); + }); + }); +}); diff --git a/node_modules/es6-shim/.editorconfig b/node_modules/es6-shim/.editorconfig new file mode 100644 index 0000000..bc228f8 --- /dev/null +++ b/node_modules/es6-shim/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 150 + +[CHANGELOG.md] +indent_style = space +indent_size = 2 + +[*.json] +max_line_length = off + +[Makefile] +max_line_length = off diff --git a/node_modules/es6-shim/.eslintignore b/node_modules/es6-shim/.eslintignore new file mode 100644 index 0000000..4628158 --- /dev/null +++ b/node_modules/es6-shim/.eslintignore @@ -0,0 +1,2 @@ +Gruntfile.js +*.min.js diff --git a/node_modules/es6-shim/.eslintrc b/node_modules/es6-shim/.eslintrc new file mode 100644 index 0000000..6b9b977 --- /dev/null +++ b/node_modules/es6-shim/.eslintrc @@ -0,0 +1,56 @@ +{ + "root": true, + + "extends": "@ljharb", + + "rules": { + "array-bracket-newline": [0], + "array-element-newline": [0], + "callback-return": [0], + "complexity": [1], + "consistent-return": [1], + "dot-notation": [2, { "allowKeywords": false }], + "eqeqeq": [2, "allow-null"], + "func-name-matching": [0], + "global-require": [0], + "id-length": [2, { "min": 1, "max": 40 }], + "indent": [2, 2], + "max-depth": [2, 5], + "max-len": 0, + "max-lines": [1], + "max-lines-per-function": [0], + "max-params": [2, 4], + "max-nested-callbacks": [2, 5], + "max-statements": [1, 25], + "max-statements-per-line": [2, { "max": 2 }], + "multiline-comment-style": [0], + "new-cap": [2, { "capIsNewExceptions": ["Call", "Construct", "CreateHTML", "GetIterator", "GetMethod", "IsCallable", "IsConstructor", "IsPromise", "IsRegExp", "IteratorClose", "IteratorComplete", "IteratorNext", "IteratorStep", "Map", "OrigNumber", "RequireObjectCoercible", "SameValue", "SameValueZero", "Set", "SpeciesConstructor", "ToInteger", "ToLength", "ToNumber", "ToObject", "ToString", "ToUint32", "TypeIsObject"] }], + "no-constant-condition": [1], + "no-continue": [1], + "no-extend-native": [2, { "exceptions": ["Set"] }], + "no-extra-parens": [1], + "no-func-assign": [1], + "no-implicit-coercion": [2, { + "boolean": false, + "number": false, + "string": true + }], + "no-invalid-this": [0], + "no-invalid-regexp": [2, { "allowConstructorFlags": ["u", "y"] }], + "no-magic-numbers": [0], + "no-native-reassign": [2, { "exceptions": ["Number", "Promise", "RegExp"] }], + "no-negated-condition": [1], + "no-plusplus": [1], + "no-restricted-syntax": [2, "DebuggerStatement", "LabeledStatement", "WithStatement"], + "no-shadow": [1], + "no-underscore-dangle": [0], + "no-unused-vars": [1, { "vars": "all", "args": "after-used" }], + "no-use-before-define": [1], + "no-useless-call": [0], + "object-curly-newline": [1], + "operator-linebreak": [2, "after"], + "sort-keys": [0], + "spaced-comment": [0], + "strict": [0] + } +} diff --git a/node_modules/es6-shim/CHANGELOG.md b/node_modules/es6-shim/CHANGELOG.md new file mode 100644 index 0000000..48e3f09 --- /dev/null +++ b/node_modules/es6-shim/CHANGELOG.md @@ -0,0 +1,612 @@ +# es6-shim 0.35.5 (7 March 2019) +* [Fix] `es6-sham`: `Function.prototype.name`: don’t poison the getter when the receiver is `Function.prototype` (#454) +* [Dev Deps] update `eslint`, `@ljharb/eslint-config` +* [Dev Deps] remove `jscs` and `jshint` + +# es6-shim 0.35.4 (29 October 2018) +* [Fix] protect against evil build processes by ensuring these feature tests don‘t look like no-ops that are safe to remove +* [Fix] broken `hasULPDistance` → working `withinULPDistance` helper +* [Fix] `acosh`: fix precision (#338) +* [Fix] `Math.{asinh,atanh,cosh,sinh}` precision (from #338) +* [Fix] Google Translate adds a broken `Set` to the global scope (#438) +* [Fix] Distinguish Set and Map iterators (#387) +* [Docs] Tweaking documentation specifying inclusion order (#435) + +# es6-shim 0.35.3 (23 January 2017) +* [Fix] avoid needlessly shimming `Array#{find, findIndex}` (#433) +* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `grunt-saucelabs` +* [Tests] up to `node` `v7.4`, `v4.7`; improve test matrix + +# es6-shim 0.35.2 (3 December 2016) +* [Fix] ensure `document.all` is not treated as a non-object-coercible (#428) +* [Performance] Use original map for data backing when possible (#429, #422) +* [Dev Deps] update `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`, `jshint`, `mocha`, `promises-plus-tests`, `uglify-js` +* [Tests] up to `node` `v7.2`, `v5.12`, `v4.6`; improve test matrix +* [Tests] avoid function name inference in node 7+ +* [Tests] add Firefox Nightly error messages to fix false failure + +# es6-shim 0.35.1 (12 May 2016) +* [Fix] Functions are objects (#418) +* [Fix] use `createDataPropertyOrThrow` in `Array.from`, rather than `[[Put]]` (#415) +* [Refactor] Use `iteratorResult` internally for iterator result objects +* [Refactor] Simplify logic for Math.tanh (#412) +* [Robustness] cache `Math` constants +* [Robustness] cache `Math.exp` +* [Robustness] don’t rely on a `Math` lookup inside `Math.asinh` +* [Robustness] use cached `Number.isNaN` +* [Robustness] cache `Math.sign` +* [Dev Deps] update `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `grunt-contrib-connect`, `grunt-contrib-watch`, `evalmd`, `jshint` +* [Tests] up to `node` `v6.1`, `v5.10`, `v4.4` +* [Tests] `npm run --silent`, use “pretest” for linting +* [Tests] `RegExp#toString`: Chrome Canary 51 produces `/undefined/` +* [Docs] update ES6 draft comment URLs to point to the published spec + +# es6-shim 0.35.0 (29 Feb 2016) +* [Breaking] remove `Reflect.enumerate` (#405) +* [New] Add `Array#indexOf` from post-ES6 errata +* [New] Ensure `RegExp#toString` is compliant +* [New] [sham] Add `Function#toString` to `es6-sham` +* [Fix] ensure that a non-object `globals.Reflect` doesn’t break the shim (#392) +* [Fix] In ES3 browsers (like Safari 4) `Reflect.getPrototypeOf` is undefined +* [Fix] `Object.keys`: handle regexes in ES3 browsers (#287) +* [Performance] Early exit from tanh for values outside of +-20 at limits of JS precision (#411) +* [Tests] `Function#name` on `new Function`s is empty string in v8 +* [Tests] `Function#name` is non-configurable pre-ES6 +* [Tests] up to `node` `v5.7`, `v4.3` +* [Docs] correct readme; we sham Function#name, not toString + +# es6-shim 0.34.4 (9 Feb 2016) +* [Fix] 'Uncaught (in promise) TypeError' in Chrome 48 (#408, #407) +* [Fix] handle the obscure case where `startsWith` throws on the second parameter (#399) +* [Tests] silence a promise rejection error in Chrome + +# es6-shim 0.34.3 (8 Feb 2016) +* [Fix] Suppress “uncaught rejection” warnings in Chrome 50 console (#403) +* [Fix] ensure ES3 `Number` constants don’t get lost in ES3 browsers (#402) +* [Dev Deps] update `chai`, `es5-shim`, `jscs`, `mocha` +* [Tests] up to `node` `v5.5` + +# es6-shim 0.34.2 (22 Jan 2016) +* [Fix] `JSON.stringify` should ignore a replacer arg unless it’s an array or function. +* [Fix] `Array#copyWithin`: check for inherited properties as well +* [Fix] `Array#copyWithin`: should delete the target key if the source key is not present +* [Performance] Optimize Map/Set fast key path (#397) +* [Tests] fix `Reflect.enumerate` tests to not call `next` too many times +* [Dev Deps] update `jscs`, `jshint` +* [Docs] update license year to 2016 (#400) + +# es6-shim 0.34.1 (5 Jan 2016) +* [Fix] `RegExp#[Symbol.search]` was broken with a regex argument (#394) +* [Fix] ensure that Set#clear works with both primitive and object values +* [Fix] static Promise methods have the wrong length in Firefox +* [Robustness] Cache `Object.keys` +* [Performance] Avoid accessing arguments array without length check +* [Performance] Optimize ES.TypeIsObject (#388) +* [Performance] Promises: lots of improvements (#383) +* [Performance] Only use slow implementation of IsCallable where necessary (old browsers) +* [Performance] Promises: remove unnecessary `.bind` on `setImmediate` +* [Refactor] extract “decode fast Map key” logic +* [Dev Deps] update `s5-shim`, `@ljharb/eslint-config` +* Don’t npmignore tests +* [Tests] Fix a bug with “deep equal” wrt NaN +* [Tests] split up Map and Set test files +* [Tests] up to `node` `v5.3` + +# es6-shim 0.34.0 (14 Dec 2015) +* [Breaking] Remove `Symbol.species` from `Promise.all` and `Promise.race` (#34) +* [Fix] Firefox has enumerable Promise static methods +* [Fix] prevent crashes in older Firefox when checking if Array methods ToLength correctly +* [Fix] `Reflect.enumerate`: ensure correct property ordering in Firefox 19 (and likely others) +* [Fix] Ensure that `toLengthsCorrectly` returns `true` when it passes, instead of `undefined` +* [Fix] Don't call `Reflect.construct` unless it's actually present +* [Fix] Ensure `Map` and `Set` do not have an own `constructor` property (#368) +* [Fix] Add missing checks to Promise.resolve and Promise.reject (#379) +* [Fix] `Map`: older v8s have a SameValueZero bug when a Map has a size > 4 (#378) +* [Fix] `Map`: when provided with an iterable that yields non-Object values, should throw +* [Fix] `Promise`: Make sure to shim broken implementations in Chrome 49 Canary +* [Fix] `Promise`: Chrome does not retrieve a thenable's .then synchronously (#372) +* [New] Add `RegExp.prototype[Symbol.{match,search,split,replace}]` +* [New] support `Symbol.match` in `RegExp` constructor +* [New] add `Symbol.match` and ensure `String#{match, startsWith, endsWith, includes}` support it +* [New] add `Symbol.split` and ensure `String#split` supports it +* [New] add `Symbol.replace` and ensure `String#replace` supports it +* [New] add `Symbol.search` and ensure `String#search` supports it +* [Robustness] Add and use `ES.ToString` so as not to rely on the global `String` +* [Dev Deps] update `eslint`, `jscs`, `mocha`, `uglify-js`, `es5-shim`, `grunt-saucelabs` +* [Tests] bailing out of some tests when the feature isn't present, to clean up native test failure output +* [Tests] up to `node` `v5.2` +* [Tests] fix `npm run test:native` +* [Tests] Ensure `Promise.{reject,resolve}` throws when the receiver is a primitive (#379) +* [Tests] Further ensure that Promise.resolve/reject work with a non-promise receiver (#379) +* [Docs] update README URLs (#375) +* [Docs] fix some typos (#380) + +# es6-shim 0.33.13 (12 Nov 2015) +* [Fix] `Number`: when no arguments are passed, return `+0`. +* [Fix] `Number`: Make sure string values are trimmed before attempting to parse. +* [Tests] cleaning up `Number` tests) +* [Dev Deps] update `uglify-js` + +# es6-shim 0.33.12 (11 Nov 2015) +* [Fix] IE 8: more NFE madness. +* [Dev Deps] update `es5-shim` +* [Docs] removing now-fixed `Number` caveat +* [Docs] use assertions so `evalmd` will test the readme better. +* [Docs] fix incorrect isFinite note (#373) + +# es6-shim 0.33.11 (9 Nov 2015) +* [Fix] handle future change of RegExp.prototype not being a regex (#370, #371) +* [Fix] disallow invalid hex strings in `Number` (#369) +* [Tests] Tweak "polluted prototype" approach +* [Dev Deps] update `chai`, `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs` + +# es6-shim 0.33.10 (2 Nov 2015) +* [Fix] the `Number` constructor properly trims (or not) whitespace characters (#368) +* [Fix] `Number('0b12')` and `Number('0o18')` should both be `NaN` (#366) +* [Tests] Fix npm upgrades in older nodes +* [Tests] add `npm run tests-only` +* [Tests] on `node` `v5.0` +* [Tests] ensure `JSON.stringify` has the right name +* [Tests] add `npm run eslint` +* [Dev Deps] update `es5-shim`, `jscs` +* [Cleanup] Rearrange things so that they’re defined before they’re used +* [Cleanup] Don't reassign to function or catch parameters +* [Cleanup] Remove unused variables +* [Refactor] String#trim shim should use `defineProperty`, and check more non-whitespace chars + +# es6-shim 0.33.9 (29 Oct 2015) +* [Fix] IE 8: `Number(new Number(1))` was throwing. More NFE madness. (#365) + +# es6-shim 0.33.8 (23 Oct 2015) +* [Fix] IE 8: `Promise.resolve(2)` was throwing. More named function expression madness. +* [Tests] Reflect: Don't attempt to define properties on this test object unless we're in true ES5. + +# es6-shim 0.33.7 (23 Oct 2015) +* [Fix] Ensure `preserveToString` does not throw when the original does not exist (#359) +* [Fix] `Promise`: properly handle named function expressions in IE 8. +* [Fix] `Number`: `wrapConstructor` now works in ES3 (#365) +* [Docs] Document `Number` supporting string binary and octal literals. +* [Tests] add commented-out test for `typeof Number.call(Object(3), 3) === 'number'`, which fails atm. +* [Tests] Fix browser tests sans-`npm install` +* [Dev Deps] update `es5-shim`, `jscs`, `uglify-js`, `chai` + +# es6-shim 0.33.6 (29 Sep 2015) +* [Fix] In IE 6-8, of course, `typeof setTimeout` is "object" +* [Tests] Upgrade jQuery on the test HTML pages + +# es6-shim 0.33.5 (28 Sep 2015) +* [Fix] IE 6-8 have wacky scoping issues with named function expressions. +* [Fix] Apparently in IE 8, RegExp#test is an own property of regexes, not a prototype method +* [Fix] Make sure to treat `es5-sham`'s `Object.defineProperty` as unsupported, in IE 8 + +# es6-shim 0.33.4 (27 Sep 2015) +* [Fix] Add test, and fix, for `JSON.stringify(Object(Symbol()))` throwing on Chrome 45 +* [Fix] Wrap `JSON.stringify` when `Symbol` exists and it fails to serialize them correctly +* [Fix] fix `Reflect.defineProperty` on edge v0.12 +* [Robustness] Cache `Array.isArray` internally +* [Refactor] Use internal `overrideNative` helper for String.prototype HTML methods +* [Refactor] Update `is-arguments` implementation; don't call down legacy code path in modern engines +* [Tests] Add `evalmd` to verify that example code blocks are valid +* [Tests] Adding a test for Safari 7.1 and later (runtime check added in 8a8ddd36186cdc1fcb3fcc259ec9ecef1e141901) +* [Tests] Add additional `JSON.stringify` test for `Symbol` and object `Symbol` values +* [Tests] up to `io.js` `v3.3`, `node` `v4.1` +* [Dev Deps] update `es5-shim`, `mocha`, `chai` + +# es6-shim 0.33.3 (31 Aug 2015) +* [Fix] Handle Firefox Nightly's broken `construct` method +* [Tests] Add `JSON.stringify` tests for handling `Symbol`s + +# es6-shim 0.33.2 (26 Aug 2015) +* [Fix] Make sure that minified code preserves function names. +* [Fix] Skip the `Promise` shim when `setTimeout` is not available ([#301](https://github.com/paulmillr/es6-shim/issues/301#issuecomment-126566703)) +* [Docs] Add note about `setPrototypeOf` on null objects + +# es6-shim 0.33.1 (20 Aug 2015) +* [New] Add support for binary and octal literals in strings to the `Number` constructor (#358) +* [Docs] Update spec link to final spec +* [Fix] `Reflect.enumerate`: does not necessarily wait until the first `next()` to determine keys. +* [Refactors] split up some tests; name some functions; remove unnecessary code +* {Refactors] make ObjectIterator properties non-enumerable +* [Refactors] Refactor `RegExp` wrapping code so most of it can be reused. +* [Tests] up to `io.js` `v3.1` +* [Dev Deps] update `grunt-contrib-connect`, `jscs` + +# es6-shim 0.33.0 (30 Jul 2015) +* [Breaking] Avoid CSP errors in Chrome apps by using global var detection (#301) +* [Performance] Rearranging some of the Map/Set runtime shim clobberings to be more efficient. +* [Refactor] Implement `Array.of` directly, rather than in terms of `Array.from` +* [Dev Deps] Update `chai`, `es5-shim`, `promises-aplus-tests`, `uglify-js` +* [Tests] Add test for `Object.getPrototypeOf` accepting primitives. +* [Tests] Bail out of individual `Reflect` tests when the methods don’t exist +* [Tests] Test on latest `io.js` + +# es6-shim 0.32.3 (21 Jun 2015) +* [Fix] Override or wrap native `Reflect` methods in Microsoft Edge v0.11 as required. +* [Fix] Edge v0.11: `Array.from([], undefined)` should not throw +* [Fix] Fix a bug in `Array.from handles iterables` runtime clobbering, which would always replace the native function +* [Fix] Ensure that `Set#has` has the correct name in Edge v0.11 +* [Tests] Add `Map`/`Set` error messages for Edge v0.11 +* [Tests] Fix `Math.fround` test value for Edge v0.11 +* [Tests] Bail out of `Map`/`Set` test blocks if they don't exist +* [Docs] Update ES5 subclassing instructions in the README. +* [Dev Deps] Update `es5-shim` + +# es6-shim 0.32.2 (17 Jun 2015) +* [Fix] `Object.assign` with no sources should coerce to an object (#348) +* [Fix] `String#includes` should throw when given a `RegExp` (#349) +* [Fix] `RegExp()` should not throw (#350) +* [Fix] Create `Value.defineByDescriptor`, fix `create` when `Object.create` is unavailable. +* [Compliance] Update `Promise.reject` to match official ECMA-262 spec. +* [Dev Deps] Update `es5-shim` + +# es6-shim 0.32.1 (13 Jun 2015) +* [Fix] Make sure that all `Map`/`Set` shim forms properly add an iterable to the collection instance. +* [Tests] Make sure none of the `Array` ToLength tests throw *any* error (#347) + +# es6-shim 0.32.0 (7 Jun 2015) +* [Spec compliance] Update Promises to match finalized ES6 spec (#345, #344, #239) +* [Fix] Ensure `Map`, `Set`, and `Promise` shims all throw when used without "new". +* [Tests] Fix the pending exceptions test for Safari 5.1 +* [Refactor] Since the String HTML shims will be iterated anyways, no need to defineProperties them twice. +* [Deps] Update `chai`, `es5-shim` + +# es6-shim 0.31.3 (2 Jun 2015) +* [Fix] Properly name more shim functions +* [Fix] Fix an IE bug where the layout engine internally calls the userland `Object.getOwnPropertyNames` +* [Fix] Ensure `Map.prototype[Symbol.iterator] === Map.prototype.entries` +* [Fix] Ensure `Set.prototype[Symbol.iterator] === Set.prototype.values` +* [Tests] `Object.assign` pending exceptions: IE 9 `preventExtensions` doesn't throw, even in strict mode +* [Security] Cache more native methods in case they're overwritten later +* [Tests] IE 11 has native `Map`/`Set`, but it takes an optional *function*, not an optional iterable, in the constructor +* [Tests] Add more "exists" early bailouts, to declutter native test results +* [Docs] Alphabetize shim lists in the README +* [Perf] Add more `Map`/`Set` fast paths for more primitives: boolean, null, undefined +* [Tests] Test up to `io.js` `v2.2` +* [Deps] Update `mocha`, `es5-shim`, `uglify-js`, `jshint` +* [Refactor] Style cleanups + +# es6-shim 0.31.2 (9 May 2015) +* Fix ES5 `Array.prototype` method wrappers to return the correct value. (#341) + +# es6-shim 0.31.1 (7 May 2015) +* `RegExp` should work properly as a wrapper (#340) + +# es6-shim 0.31.0 (1 May 2015) +* All Array.prototype methods should use `ToLength`, not `ToUint32`, on `this.length`. +* Preserve and use original Array.prototype functions (for later shimming) +* Make String#{startsWith, endsWith, includes} tests a bit more granular. +* Fix Map/Set invalid receiver error messages for WebKit +* Update `grunt-saucelabs`, `jscs` + +# es6-shim 0.30.0 (26 Apr 2015) +* `Map` and `Set` methods are not generic, and must only be called on valid `Map` and `Set` objects. +* Use the native `Number#clz` (in Safari 8, eg) inside `Math.clz32` + +# es6-shim 0.29.0 (26 Apr 2015) +* Test on `io.js` `v1.7` and `v1.8` +* Ensure that shallowly wrapped Maps’ and Sets’ prototypes aren't one level too far away. +* Update `chai` and use new matchers +* Avoid reassigning argument variables to avoid deoptimizations +* Ensure that ES3 browsers get both `Object.is` and `Object.assign` +* Improve `Object.assign` to avoid leaking arguments in v8 +* Ensuring `Number.parseInt === parseInt` (failed in FF 37) +* a little more accurate Math.cbrt (#335) +* Test cleanups +* Adding `Symbol.unscopables` tests +* Adding tests to ensure that default iterators on builtins === the appropriate prototype function. + +# es6-shim 0.28.2 (13 Apr 2015) +* `Map` and `Set` should have an arity of 0. + +# es6-shim 0.28.1 (12 Apr 2015) +* Ensure `Object.assign` only includes enumerable Symbols. + +# es6-shim 0.28.0 (12 Apr 2015) +* Ensure `Object.assign` also includes Symbols. +* Make sure to clobber Firefox 37's very slow native Object.assign, that has "pending exception" logic. +* Adding much more granular Set/Map acceptance tests and replacements, to preserve as much of the original implementation as possible. (#326, #328) +* Lots of test additions and cleanup + * Fill in (and fix) missing name, arity, and enumerability tests. + * Using `property` matcher for a more helpful failure message. + * Make sure this test doesn't fail if `Array#values` doesn't exist yet. + * Make this `@@iterator` test not depend on `Array#values`, and properly skip tests if the symbol isn't available. +* Update `Math.fround` with a much smaller implementation (#332) +* Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change. +* Update `es5-shim`, `mocha`, `grunt-contrib-connect`, `chai`, `jshint` +* IE 11 TP has a broken `String.raw` implementation +* Overwriting some imprecise Math functions on IE 11 TP. +* Overwrite `Math.imul` in Safari 8 to report the correct length. +* Fix Math.round for very large numbers +* Don't rely on shims in tests, for better native failure checking. +* Shim `Object.is` in ES3 environments, and add tests. +* Test the native `Object.assign` prior to shimming it. +* Tweak the `travis-ci` config to make a separate "lint only" test run. +* Fix Firefox 4 test failures: ensure RegExp global aliases starting with "$" exist. +* more efficient Math.clz32 (#327) +* Fix Webkit nightly bugs with `Array.from` and `Array.of`. +* Make sure shims that depend on `Number.isNaN` and `Number.isFinite` will always work. +* The latest Webkit nightly has a bug with `String#includes` and a position arg of `Infinity`. +* Webkit r181855 has a noncompliant `String#startsWith` and `String#endsWith` +* Clean up README; add more accurate note about `es5-shim`. +* Updating the `String.raw` code to be more in line with the changes in RC2/Rev 35 of the spec. + +# es6-shim 0.27.1 (5 Mar 2015) +* Revert `Array#slice` changes. (#322) +* Test on `io.js` `v1.4` + +# es6-shim 0.27.0 (26 Feb 2015) +* Overwrite `Array#slice` so that it supports Array subclasses. +* Improve `Map`/`Set` `TypeError` messages when called as a function. (#321) + +# es6-shim 0.26.1 (25 Feb 2015) +* Ensure `Array`/`Array.prototype` functions have the correct name. +* Chrome 40 defines the incorrect name for `Array#values` +* Make sure that `Array.of` works when subclassed. + +# es6-shim 0.26.0 (24 Feb 2015) +* Ensure that remaining Object static methods accept primitives. +* Update `chai` +* Document `String.prototype` HTML methods and `Reflect` methods in README + +# es6-shim 0.25.3 (22 Feb 2015) +* Removing nonexistent arguments from some String.prototype HTML methods +* All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`. +* Test on `iojs-v1.3` +* Update `chai` +* Add a LICENSE file + +# es6-shim 0.25.2 (18 Feb 2015) +* If someone (looking at you, chalk) has previously modified String.prototype with a non-function “bold”, don‘t break. (#315) + +# es6-shim 0.25.1 (18 Feb 2015) +* Add Annex B String.prototype HTML methods. +* Overwriting Annex B String.prototype HTML methods in IE 9, which both uppercases the tag names, and fails to escape double quotes. +* Overwriting Annex B String.prototype HTML methods in Safari 4-5, which fails to escape double quotes. +* Ensuring that Date#toString returns “Invalid Date” when the date‘s value is NaN. +* Test on `iojs-v1.2` + +# es6-shim 0.25.0 (16 Feb 2015) +* Ensure Object.getOwnPropertyNames accepts primitives. +* Make sure the replaced `Object.keys` is non-enumerable. +* Clean up lots of tests to make failures easier to read, and false negatives less common + +# es6-shim 0.24.0 (5 Feb 2015) +* Improving accuracy of Math.expm1 values, and ensuring a shim on Linux FF 35, which reports an inaccurate value for Math.expm1(10). +* Fix bug from 7454db144e5aa251d599415cfb296b67aa3cf992 which prevented String#startsWith and String#endsWith from being overwritten in old Firefox. +* Improve tests across a wider list of browsers +* Ensure that individual Reflect methods are added when possible +* Add Reflect (#313) +* Fix node 0.11: it has an imprecise Math.sinh with very small numbers. +* Alter String#repeat RangeError message to align with Firefox’s native implementation. + +# es6-shim 0.23.0 (26 Jan 2015) +* Use Symbol.species when available, else fall back to "@@species" (renamed from "@@create") +* Fix `npm run test-native` +* Correct broken Math implementations: `log1p`, `exmp1`, `tanh`, `acosh`, `cosh`, `sinh`, `round` (#314) +* Update `jscs`, `grunt-saucelabs`, `jshint` + +# es6-shim 0.22.2 (4 Jan 2015) +* Faster travis-ci builds +* Better ES3 support: quoting/avoiding reserved words +* Update `mocha`, `jscs`, `jshint`, `grunt-saucelabs`, `uglify-js` + +# es6-shim 0.22.1 (13 Dec 2014) +* Make RegExp#flags generic, per spec (#310) + +# es6-shim 0.22.0 (12 Dec 2014) +* Add RegExp#flags +* Make `new RegExp` work with both a regex and a flags string +* Remove non-spec `Object.{getPropertyNames,getPropertyDescriptor}` + +# es6-shim 0.21.1 (4 Dec 2014) +* Promise/Promise.prototype methods, and String#{startsWith,endsWith} are now not enumerable +* Array#{keys, values, entries} should all be @@unscopeable in browsers that support that +* Ensure that tampering with Function#{call,apply} won’t break internal methods +* Add Math.clz32, RegExp tests +* Update es6-sham UMD +* Update `chai`, `es5-shim`, `grunt-saucelabs`, `jscs` + +# es6-shim 0.21.0 (21 Nov 2014) +* String#contains → String#includes per 2014-11-19 TC39 meeting +* Use an invalid identifier as the es6-shim iterator key, so it doesn’t show up in the console as easily. + +# es6-shim 0.20.4 (20 Nov 2014) +* Performance improvements: avoid slicing arguments, avoid `Function#call` when possible +* Name `String.{fromCodePoint,raw}` for debugging +* Fix `String.raw` to match spec +* Ensure Chrome’s excess Promise methods are purged +* Ensure `Set#keys === Set#values`, per spec + +# es6-shim 0.20.3 (19 Nov 2014) +* Fix Set#add and Map#set to always return "this" (#302) +* Clarify TypeError messages thrown by Map/Set +* Fix Chrome 38 bug with Array#values + +# es6-shim 0.20.2 (28 Oct 2014) +* Fix AMD (#299) + +# es6-shim 0.20.1 (27 Oct 2014) +* Set#delete and Map#delete should return false unless a deletion occurred. (#298) + +# es6-shim 0.20.0 (26 Oct 2014) +* Use a more reliable UMD +* export the global object rather than undefined + +# es6-shim 0.19.2 (25 Oct 2014) +* Set#delete and Map#delete should return a boolean indicating success. (#298) +* Make style consistent; add jscs + +# es6-shim 0.19.1 (14 Oct 2014) +* Fix Map#set and Set#add to be chainable (#295) +* Update mocha + +# es6-shim 0.19.0 (9 Oct 2014) +* Detect and override noncompliant Map in Firefox 32 (#294) +* Fix Map and Set for engines that don’t preserve numeric key order (#292, #290) +* Detect and override noncompliant Safari 7.1 Promises (#289) +* Fix Array#keys and Array#entries in Safari 7.1 +* General style and whitespace cleanup +* Update dependencies +* Clean up tests for ES3 by removing reserved words + +# es6-shim 0.18.0 (6 Sep 2014) +* Speed up String#trim replacement (#284) +* named Array#find and Array#findIndex for easier debugging +* Replace broken native implementation in Firefox 25-31 for Array#find and Array#findIndex +* Ensure String.fromCodePoint has the correct length in Firefox +* List the license in `package.json` for `npm` +* Array.from: fix spec bug with Array.from([], undefined) throwing +* Array.from: fix Firefox Array.from bug wrt swallowing negative lengths vs throwing + +# es6-shim 0.17.0 (31 Aug 2014) +* Added es6-sham (#281) +* Fixing some flaky tests (#268) +* Tweaking how ArrayIterator is checked in its "next" function +* Cleaning up some of the logic in Array.from + +# es6-shim 0.16.0 (6 Aug 2014) +* Array#find and Array#findIndex: no longer skips holes in sparse arrays, per https://bugs.ecmascript.org/show_bug.cgi?id=3107 + +# es6-shim 0.15.1 (5 Aug 2014) +* Array.from: now correctly throws if provided `undefined` as a mapper function +* Array.from: now correctly works if provided a falsy `thisArg` +* Fix tests so they work properly when Array#(values|keys|entries) are not present +* Add `npm run lint` to run style checks independently +* Add `test/native.html` so browsers can be easily checked for shim-less compliance. + +# es6-shim 0.15.0 (31 Jul 2014) +* Object.assign no longer throws on null or undefined sources, per https://bugs.ecmascript.org/show_bug.cgi?id=3096 + +# es6-shim 0.14.0 (20 Jul 2014) +* Properly recognize Symbol.iterator when it is present (#277) +* Fix Math.clz’s improper handling of values that coerce to NaN (#269) +* Fix incorrect handling of negative end index on Array#fill (#270) +* Removed Object.getOwnPropertyKeys, which shouldn’t be anywhere (#267) +* Fixed arity of Map and Set constructors, per 2014.04.27 draft spec (rev 24) +* Added a full additional suite of ES6 promise tests (thanks to @smikes!) (#265) +* Make Number.isInteger a bit more efficient (#266) +* Added `npm run test-native` to expose how broken implementations are without the shim ;-) +* Added additional tests + +# es6-shim 0.13.0 (11 Jun 2014) +* Adapt to new Array.from changes: mapper function is now called with both value and index (#261, #262) +* More reliably getting the global object in strict mode to fix node-webkit (#258, #259) +* Properly test the global Promise for ignoring non-function callbacks (#258) + +# es6-shim 0.12.0 (4 Jun 2014) +* Fix String#trim implementations that incorrectly trim \u0085 +* Stop relying on ArrayIterator being a public var, fixing Safari 8 + +# es6-shim 0.11.1 (2 Jun 2014) +* Make sure to shim Object.assign in all environments, not just true ES5 +* Now including minified file and source map + +# es6-shim 0.11.0 (11 May 2014) +* Remove `Object.getOwnPropertyDescriptors`, per spec. (#234, #235) +* IE8 fixes. (#163, #236) +* Improve `Promise` scheduling. (#231) +* Add some more standalone shims +* Use an Object.create fallback, for better ES3 compatibility +* Fix Math.expm1 in more browsers (#84) +* Fix es6-shim in Web Workers (#247, #248) +* Correct Object.assign to take multiple sources (#241) + +# es6-shim 0.10.1 (13 Mar 2014) +* Update bower.json, component.json, and .npmignore (#229, #230, #233) +* Minor updates to `Promise` implementation and test suite. +* Workaround lack of "strict mode" in IE9. (#232) + +# es6-shim 0.10.0 (1 March 2014) +* Implement `Promise`, per spec. (#209, #215, #224, #225) +* Make `Map`/`Set` subclassable; support `iterable` argument to + constructor (#218) +* Rename `Number#clz` to `Math.clz32` (#217) +* Bug fixes to `Array#find` and `Array#findIndex` on sparse arrays (#213) +* Re-add `Number.isInteger` (mistakenly removed in 0.9.0) +* Allow use of `arguments` as an iterable +* Minor spec-compliance fixes for `String.raw` +* In ES6, `Object.keys` accepts non-Object types (#220) +* Improved browser compatibility with IE 9/10, Opera 12 (#225) + +# es6-shim 0.9.3 (5 February 2014) +* Per spec, removed `Object.mixin` (#192) +* Per spec, treat -0 and +0 keys as identical in Map/Set (#129, #204) +* Per spec, `ArrayIterator`/`Array#values()` skips sparse indexes now. (#189) +* Added `Array.from`, supporting Map/Set/Array/String iterators (the String iterator iterates over codepoints, not indexes) (#182) +* Bug fixes to Map/Set iteration after concurrent delete. (#183) +* Bug fixes to `Number.clz`: 0 and 0x100000000 are handled correctly now. (#196) +* Added `Math.fround` to truncate to a 32-bit floating point number. (#140) +* Bug fix for `Math.cosh` (#178) +* Work around Firefox bugs in `String#startsWith` and `String#endsWith` (#172) +* Work around Safari bug in `Math.imul` + +# es6-shim 0.9.2 (18 December 2013) +* Negative `String#endsWith` position is now handled properly. +* `TypeError` is now thrown when string methods are called + on `null` / `undefined`. + +# es6-shim 0.9.1 (28 October 2013) +* Added `Array#copyWithin` and `Number.MIN_SAFE_INTEGER` +* Big speed-up of Maps / Sets for string / number keys: + they are O(1) now. +* Changed `Math.hypot` according to spec. +* Other small fixes. + +# es6-shim 0.9.0 (30 August 2013) +* Added Array iteration methods: `Array#keys`, `Array#values`, `Array#entries`, which return an `ArrayIterator` +* Changed `Map` and `Set` constructors to conform to spec when called without `new` +* Added `Math.imul` +* Per spec, removed `Number.toInteger`, `Number.isInteger`, and `Number.MAX_INTEGER`; added `Number.isSafeInteger`, `Number.MAX_SAFE_INTEGER` +* Added extensive additional tests for many methods + +# es6-shim 0.8.0 (8 June 2013) +* Added `Object.setPrototypeOf`, `Set#keys`, `Set#values`, `Map#keys`, `Map#values`, `Map#entries`, `Set#entries`. +* Fixed `String#repeat` according to spec. + +# es6-shim 0.7.0 (2 April 2013) +* Added `Array#find`, `Array#findIndex`, `Object.assign`, `Object.mixin`, + `Math.cbrt`, `String.fromCodePoint`, `String#codePointAt`. +* Removed `Object.isnt`. +* Made Math functions fully conform spec. + +# es6-shim 0.6.0 (15 January 2013) +* Added `Map#keys`, `Map#values`, `Map#size`, `Set#size`, `Set#clear`. + +# es6-shim 0.5.3 (2 September 2012) +* Made `String#startsWith`, `String#endsWith` fully conform spec. + +# es6-shim 0.5.2 (17 June 2012) +* Removed `String#toArray` and `Object.isObject` as per spec updates. + +# es6-shim 0.5.1 (14 June 2012) +* Made Map and Set follow Spidermonkey implementation instead of V8. +`var m = Map(); m.set('key', void 0); m.has('key');` now gives true. + +# es6-shim 0.5.0 (13 June 2012) +* Added Number.MAX_INTEGER, Number.EPSILON, Number.parseInt, +Number.parseFloat, Number.prototype.clz, Object.isObject. + +# es6-shim 0.4.1 (11 May 2012) +* Fixed boundary checking in Number.isInteger. + +# es6-shim 0.4.0 (8 February 2012) +* Added Math.log10, Math.log2, Math.log1p, Math.expm1, Math.cosh, +Math.sinh, Math.tanh, Math.acosh, Math.asinh, Math.atanh, Math.hypot, +Math.trunc. + +# es6-shim 0.3.1 (30 January 2012) +* Added IE8 support. + +# es6-shim 0.3.0 (27 January 2012) +* Added Number.isFinite() and Object.isnt(). + +# es6-shim 0.2.1 (7 January 2012) +* Fixed a bug in String#endsWith(). + +# es6-shim 0.2.0 (25 December 2011) +* Added browser support. +* Added tests. +* Added Math.sign(). + +# es6-shim 0.1.0 (25 December 2011) +* Initial release diff --git a/node_modules/es6-shim/Gruntfile.js b/node_modules/es6-shim/Gruntfile.js new file mode 100644 index 0000000..230934d --- /dev/null +++ b/node_modules/es6-shim/Gruntfile.js @@ -0,0 +1,98 @@ +'use strict'; + +module.exports = function (grunt) { + var browsers = [ + { browserName: 'firefox', version: '19', platform: 'XP' }, + { browserName: 'firefox', platform: 'linux' }, + { browserName: 'firefox', platform: 'OS X 10.10' }, + { browserName: 'chrome', platform: 'linux' }, + { browserName: 'chrome', platform: 'OS X 10.9' }, + { browserName: 'chrome', platform: 'XP' }, + { browserName: 'internet explorer', platform: 'Windows 8.1', version: '11' }, + { browserName: 'internet explorer', platform: 'WIN8', version: '10' }, + { browserName: 'internet explorer', platform: 'VISTA', version: '9' }, + { browserName: 'safari', platform: 'OS X 10.6' }, + { browserName: 'safari', platform: 'OS X 10.8' }, + { browserName: 'safari', platform: 'OS X 10.9' }, + { browserName: 'safari', platform: 'OS X 10.10' }, + { browserName: 'iphone', platform: 'OS X 10.9', version: '7.1' }, + { browserName: 'android', platform: 'Linux', version: '4.4' }, + ]; + var extraBrowsers = [ + { browserName: 'firefox', platform: 'linux', version: '30' }, + { browserName: 'firefox', platform: 'linux', version: '25' }, + { browserName: 'iphone', platform: 'OS X 10.8', version: '6.1' }, + { browserName: 'iphone', platform: 'OS X 10.8', version: '5.1' }, + { browserName: 'android', platform: 'Linux', version: '4.2' }, + // XXX haven't investigated these: + // { browserName: 'opera', platform: 'Windows 7', version: '12' }, + // { browserName: 'opera', platform: 'Windows 2008', version: '12' } + // { browserName: 'iphone', platform: 'OS X 10.6', version: '4.3' }, + // { browserName: 'android', platform: 'Linux', version: '4.0' }, + ]; + if (grunt.option('extra')) { + browsers = browsers.concat(extraBrowsers); + } + grunt.initConfig({ + connect: { + server: { + options: { + base: '', + port: 9999, + useAvailablePort: true + } + } + }, + 'saucelabs-mocha': { + all: { + options: { + urls: (function () { + var urls = ['http://localhost:9999/test/']; + if (grunt.option('extra')) { + urls.push('http://localhost:9999/test-sham/'); + } + return urls; + }()), + // tunnelTimeout: 5, + build: process.env.TRAVIS_BUILD_NUMBER, + tunneled: !process.env.SAUCE_HAS_TUNNEL, + identifier: process.env.TRAVIS_JOB_NUMBER, + sauceConfig: { + 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER + }, + // concurrency: 3, + browsers: browsers, + testname: (function () { + var testname = 'mocha'; + if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') { + testname += ' (PR ' + process.env.TRAVIS_PULL_REQUEST + ')'; + } + if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') { + testname += ' (branch ' + process.env.TRAVIS_BRANCH + ')'; + } + return testname; + }()), + tags: (function () { + var tags = []; + if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') { + tags.push('PR-' + process.env.TRAVIS_PULL_REQUEST); + } + if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') { + tags.push(process.env.TRAVIS_BRANCH); + } + return tags; + }()) + } + } + }, + watch: {} + }); + // Loading dependencies + for (var key in grunt.file.readJSON('package.json').devDependencies) { + if (key !== 'grunt' && key.indexOf('grunt') === 0) { + grunt.loadNpmTasks(key); + } + } + grunt.registerTask('dev', ['connect', 'watch']); + grunt.registerTask('sauce', ['connect', 'saucelabs-mocha']); +}; diff --git a/node_modules/es6-shim/LICENSE b/node_modules/es6-shim/LICENSE new file mode 100644 index 0000000..996ec8d --- /dev/null +++ b/node_modules/es6-shim/LICENSE @@ -0,0 +1,26 @@ +The project was initially based on [es6-shim by Axel Rauschmayer](https://github.com/rauschma/es6-shim). + +Current maintainers are: [Paul Miller](http://paulmillr.com), [Jordan Harband](https://github.com/ljharb), and [C. Scott Ananian](http://cscott.net). + +The MIT License (MIT) + +Copyright (c) 2013-2016 Paul Miller (http://paulmillr.com) and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/node_modules/es6-shim/README.md b/node_modules/es6-shim/README.md new file mode 100644 index 0000000..9c3136e --- /dev/null +++ b/node_modules/es6-shim/README.md @@ -0,0 +1,269 @@ +# ES6 Shim +Provides compatibility shims so that legacy JavaScript engines behave as +closely as possible to ECMAScript 6 (Harmony). + +[![Build Status][1]][2] [![dependency status][3]][4] [![dev dependency status][5]][6] + +[![browser support](https://ci.testling.com/paulmillr/es6-shim.png)](https://ci.testling.com/paulmillr/es6-shim) + +[![Sauce Test Status](https://saucelabs.com/browser-matrix/es6-shim.svg)](https://saucelabs.com/u/es6-shim) + +[HTML version of the final ECMAScript 6 spec][spec-html-url] + +## Installation +If you want to use it in browser: + +* Just include `es6-shim` before your scripts. +* Include [es5-shim][es5-shim-url] especially if your browser doesn't support ECMAScript 5 - but every JS engine requires the `es5-shim` to correct broken implementations, so it's strongly recommended to always include it. Additionally, `es5-shim` should be loaded before `es6-shim`. + +For `node.js`, `io.js`, or any `npm`-managed workflow (this is the recommended method): + + npm install es6-shim + +Alternative methods: +* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/componentjs/component). +* `bower install es6-shim` if you’re using [Bower](http://bower.io/). + +In both browser and node you may also want to include `unorm`; see the [`String.prototype.normalize`](#stringprototypenormalize) section for details. + +## Safe shims + +* `Map`, `Set` (requires ES5 property descriptor support) +* `Promise` +* `String`: + * `fromCodePoint()` ([a standalone shim is also available](http://mths.be/fromcodepoint)) + * `raw()` +* `String.prototype`: + * `codePointAt()` ([a standalone shim is also available](http://mths.be/codepointat)) + * `endsWith()` ([a standalone shim is also available](http://mths.be/endswith)) + * `includes()` ([a standalone shim is also available](http://mths.be/includes)) + * `repeat()` ([a standalone shim is also available](http://mths.be/repeat)) + * `startsWith()` ([a standalone shim is also available](http://mths.be/startswith)) +* `RegExp`: + * `new RegExp`, when given a RegExp as the pattern, will no longer throw when given a "flags" string argument. (requires ES5) +* `RegExp.prototype`: + * `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags)) + * `[Symbol.match]` (requires native `Symbol`s) + * `[Symbol.replace]` (requires native `Symbol`s) + * `[Symbol.search]` (requires native `Symbol`s) + * `[Symbol.split]` (requires native `Symbol`s) + * `toString` +* `Number`: + * binary and octal literals: `Number('0b1')` and `Number('0o7')` + * `EPSILON` + * `MAX_SAFE_INTEGER` + * `MIN_SAFE_INTEGER` + * `isNaN()`([a standalone shim is also available](https://www.npmjs.com/package/is-nan)) + * `isInteger()` + * `isSafeInteger()` + * `isFinite()` + * `parseInt()` + * `parseFloat()` +* `Array`: + * `from()` ([a standalone shim is also available](https://www.npmjs.com/package/array.from)) + * `of()` ([a standalone shim is also available](https://www.npmjs.com/package/array.of)) +* `Array.prototype`: + * `copyWithin()` + * `entries()` + * `fill()` + * `find()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.find)) + * `findIndex()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.findIndex)) + * `keys()` (note: keys/values/entries return an `ArrayIterator` object) + * `values()` + * `indexOf()` (ES6 errata) +* `Object`: + * `assign()` ([a standalone shim is also available](https://github.com/ljharb/object.assign)) + * `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is)) + * `keys()` (in ES5, but no longer throws on non-object non-null/undefined values in ES6) + * `setPrototypeOf()` (IE >= 11) +* `Function.prototype`: + * `name` (es6-sham, covers IE 9-11) +* `Math`: + * `acosh()` + * `asinh()` + * `atanh()` + * `cbrt()` + * `clz32()` + * `cosh()` + * `expm1()` + * `fround()` + * `hypot()` + * `imul()` + * `log10()` + * `log1p()` + * `log2()` + * `sign()` + * `sinh()` + * `tanh()` + * `trunc()` + +Math functions’ accuracy is 1e-11. + +* `Reflect` + * `apply()` + * `construct()` + * `defineProperty()` + * `deleteProperty()` + * `get()` + * `getOwnPropertyDescriptor()` + * `getPrototypeOf()` + * `has()` + * `isExtensible()` + * `ownKeys()` + * `preventExtensions()` + * `set()` + * `setPrototypeOf()` + +* `Symbol` (only if it already exists) + * `match` (and corresponding `String#match`, `String#startsWith`, `String#endsWith`, `String#includes`, `RegExp` support) + * `replace` (and corresponding `String#replace` support) + * `search` (and corresponding `String#search` support) + * `split` (and corresponding `String#split` support) + +Well-known symbols will only be provided if the engine already has `Symbol` support. + +* `String.prototype` Annex B HTML methods + * `anchor()` + * `big()` + * `blink()` + * `bold()` + * `fixed()` + * `fontcolor()` + * `fontsize()` + * `italics()` + * `link()` + * `small()` + * `strike()` + * `sub()` + * `sup()` + +These methods are part of "Annex B", which means that although they are a defacto standard, you shouldn't use them. None the less, the `es6-shim` provides them and normalizes their behavior across browsers. + +## Subclassing +The `Map`, `Set`, and `Promise` implementations are subclassable. +You should use the following pattern to create a subclass in ES5 which will continue to work in ES6: +```javascript +require('es6-shim'); + +function MyPromise(exec) { + var promise = new Promise(exec); + Object.setPrototypeOf(promise, MyPromise.prototype); + // ... + return promise; +} +Object.setPrototypeOf(MyPromise, Promise); +MyPromise.prototype = Object.create(Promise.prototype, { + constructor: { value: MyPromise } +}); +``` + +## String.prototype.normalize +Including a proper shim for `String.prototype.normalize` would increase the size of this library by a factor of more than 4. +So instead we recommend that you install the [`unorm`](https://github.com/walling/unorm) package alongside `es6-shim` if you need `String.prototype.normalize`. +See https://github.com/paulmillr/es6-shim/issues/134 for more discussion. + + +## WeakMap shim +It is not possible to implement WeakMap in pure javascript. +The [es6-collections](https://github.com/WebReflection/es6-collections) implementation doesn't hold values strongly, which is critical for the collection. `es6-shim` decided to not include an incorrect shim. + +`WeakMap` has very unusual use-cases, so you probably won't need it at all (use simple `Map` instead). + +## Getting started + +```javascript +require('es6-shim'); +var assert = require('assert'); + +assert.equal(true, 'abc'.startsWith('a')); +assert.equal(false, 'abc'.endsWith('a')); +assert.equal(true, 'john alice'.includes('john')); +assert.equal('123'.repeat(2), '123123'); + +assert.equal(false, NaN === NaN); +assert.equal(true, Object.is(NaN, NaN)); +assert.equal(true, -0 === 0); +assert.equal(false, Object.is(-0, 0)); + +var result = Object.assign({ a: 1 }, { b: 2 }); +assert.deepEqual(result, { a: 1, b: 2 }); + +assert.equal(true, isNaN('a')); +assert.equal(false, Number.isNaN('a')); +assert.equal(true, Number.isNaN(NaN)); + +assert.equal(true, isFinite('123')); +assert.equal(false, Number.isFinite('123')); +assert.equal(false, Number.isFinite(Infinity)); + +// Tests if value is a number, finite, +// >= -9007199254740992 && <= 9007199254740992 and floor(value) === value +assert.equal(false, Number.isInteger(2.4)); + +assert.equal(1, Math.sign(400)); +assert.equal(0, Math.sign(0)); +assert.equal(-1, Math.sign(-400)); + +var found = [5, 10, 15, 10].find(function (item) { return item / 2 === 5; }); +assert.equal(10, found); + +var foundIndex = [5, 10, 15, 10].findIndex(function (item) { return item / 2 === 5; }); +assert.equal(1, foundIndex); + +// Replacement for `{}` key-value storage. +// Keys can be anything. +var map = new Map([['Bob', 42], ['Foo', 'bar']]); +map.set('John', 25); +map.set('Alice', 400); +map.set(['meh'], 555); +assert.equal(undefined, map.get(['meh'])); // undefined because you need to use exactly the same object. +map.delete('Alice'); +map.keys(); +map.values(); +assert.equal(4, map.size); + +// Useful for storing unique items. +var set = new Set([0, 1]); +set.add(2); +set.add(5); +assert.equal(true, set.has(0)); +assert.equal(true, set.has(1)); +assert.equal(true, set.has(2)); +assert.equal(false, set.has(4)); +assert.equal(true, set.has(5)); +set.delete(5); +assert.equal(false, set.has(5)); + +// Promises, see +// http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript +// https://github.com/petkaantonov/bluebird/#what-are-promises-and-why-should-i-use-them +Promise.resolve(5).then(function (value) { + assert.equal(value, 5); + if (value) throw new Error('whoops!'); + // do some stuff + return anotherPromise(); +}).catch(function (e) { + assert.equal(e.message, 'whoops!'); + assert.equal(true, e instanceof Error); + // any errors thrown asynchronously end up here +}); +``` + +## Caveats + + - `Object.setPrototypeOf` / `Reflect.setPrototypeOf` + - Note that null objects (`Object.create(null)`, eg, an object with `null` as its `[[Prototype]]`) can not have their `[[Prototype]]` changed except via a native `Object.setPrototypeOf`. + - Well-known `Symbol`s + - In order to make them work cross-realm, these are created with the global `Symbol` registry via `Symbol.for`. This does not violate the spec, but it does mean that `Symbol.for('Symbol.search') === Symbol.search` will be `true`, which it would not by default in a fresh compliant realm. + +## [License][license-url] + +[1]: https://travis-ci.org/paulmillr/es6-shim.svg +[2]: https://travis-ci.org/paulmillr/es6-shim +[3]: https://david-dm.org/paulmillr/es6-shim.svg +[4]: https://david-dm.org/paulmillr/es6-shim +[5]: https://david-dm.org/paulmillr/es6-shim/dev-status.svg +[6]: https://david-dm.org/paulmillr/es6-shim#info=devDependencies +[license-url]: https://github.com/paulmillr/es6-shim/blob/master/LICENSE +[spec-html-url]: http://www.ecma-international.org/ecma-262/6.0/ +[es5-shim-url]: https://github.com/es-shims/es5-shim diff --git a/node_modules/es6-shim/bower.json b/node_modules/es6-shim/bower.json new file mode 100644 index 0000000..231768d --- /dev/null +++ b/node_modules/es6-shim/bower.json @@ -0,0 +1,28 @@ +{ + "name": "es6-shim", + "repo": "paulmillr/es6-shim", + "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", + "keywords": [ + "ecmascript", + "harmony", + "es6", + "shim", + "promise", + "promises", + "setPrototypeOf", + "map", + "set", + "__proto__" + ], + "main": "es6-shim.js", + "scripts": ["es6-shim.js"], + "dependencies": {}, + "development": {}, + "ignore": [ + "**/.*", + "node_modules", + "components", + "test" + ] +} + diff --git a/node_modules/es6-shim/component.json b/node_modules/es6-shim/component.json new file mode 100644 index 0000000..49a3541 --- /dev/null +++ b/node_modules/es6-shim/component.json @@ -0,0 +1,23 @@ +{ + "name": "es6-shim", + "version": "0.35.3", + "repo": "paulmillr/es6-shim", + "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", + "keywords": [ + "ecmascript", + "harmony", + "es6", + "shim", + "promise", + "promises", + "setPrototypeOf", + "map", + "set", + "__proto__" + ], + "main": "es6-shim.js", + "scripts": ["es6-shim.js"], + "dependencies": {}, + "development": {} +} + diff --git a/node_modules/es6-shim/es6-sham.js b/node_modules/es6-shim/es6-sham.js new file mode 100644 index 0000000..93f15b2 --- /dev/null +++ b/node_modules/es6-shim/es6-sham.js @@ -0,0 +1,170 @@ +/*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-sham: v0.35.4 + * see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ + +// UMD (Universal Module Definition) +// see https://github.com/umdjs/umd/blob/master/returnExports.js +(function (root, factory) { + /*global define, exports, module */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); + } +}(this, function () { + 'use strict'; + + /* eslint-disable no-new-func */ + var getGlobal = new Function('return this;'); + /* eslint-enable no-new-func */ + + var globals = getGlobal(); + var Object = globals.Object; + var _call = Function.call.bind(Function.call); + var functionToString = Function.toString; + var _strMatch = String.prototype.match; + + var throwsError = function (func) { + try { + func(); + return false; + } catch (e) { + return true; + } + }; + var arePropertyDescriptorsSupported = function () { + // if Object.defineProperty exists but throws, it's IE 8 + return !throwsError(function () { + Object.defineProperty({}, 'x', { get: function () {} }); // eslint-disable-line getter-return + }); + }; + var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); + + // NOTE: This versions needs object ownership + // because every promoted object needs to be reassigned + // otherwise uncompatible browsers cannot work as expected + // + // NOTE: This might need es5-shim or polyfills upfront + // because it's based on ES5 API. + // (probably just an IE <= 8 problem) + // + // NOTE: nodejs is fine in version 0.8, 0.10, and future versions. + (function () { + if (Object.setPrototypeOf) { return; } + + // @author Andrea Giammarchi - @WebReflection + + var getOwnPropertyNames = Object.getOwnPropertyNames; + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var create = Object.create; + var defineProperty = Object.defineProperty; + var getPrototypeOf = Object.getPrototypeOf; + var objProto = Object.prototype; + + var copyDescriptors = function (target, source) { + // define into target descriptors from source + getOwnPropertyNames(source).forEach(function (key) { + defineProperty( + target, + key, + getOwnPropertyDescriptor(source, key) + ); + }); + return target; + }; + // used as fallback when no promotion is possible + var createAndCopy = function (origin, proto) { + return copyDescriptors(create(proto), origin); + }; + var set, setPrototypeOf; + try { + // this might fail for various reasons + // ignore if Chrome cought it at runtime + set = getOwnPropertyDescriptor(objProto, '__proto__').set; + set.call({}, null); + // setter not poisoned, it can promote + // Firefox, Chrome + setPrototypeOf = function (origin, proto) { + set.call(origin, proto); + return origin; + }; + } catch (e) { + // do one or more feature detections + set = { __proto__: null }; + // if proto does not work, needs to fallback + // some Opera, Rhino, ducktape + if (set instanceof Object) { + setPrototypeOf = createAndCopy; + } else { + // verify if null objects are buggy + /* eslint-disable no-proto */ + set.__proto__ = objProto; + /* eslint-enable no-proto */ + // if null objects are buggy + // nodejs 0.8 to 0.10 + if (set instanceof Object) { + setPrototypeOf = function (origin, proto) { + // use such bug to promote + /* eslint-disable no-proto */ + origin.__proto__ = proto; + /* eslint-enable no-proto */ + return origin; + }; + } else { + // try to use proto or fallback + // Safari, old Firefox, many others + setPrototypeOf = function (origin, proto) { + // if proto is not null + if (getPrototypeOf(origin)) { + // use __proto__ to promote + /* eslint-disable no-proto */ + origin.__proto__ = proto; + /* eslint-enable no-proto */ + return origin; + } else { + // otherwise unable to promote: fallback + return createAndCopy(origin, proto); + } + }; + } + } + } + Object.setPrototypeOf = setPrototypeOf; + }()); + + if (supportsDescriptors && function foo() {}.name !== 'foo') { + /* eslint no-extend-native: 1 */ + Object.defineProperty(Function.prototype, 'name', { + configurable: true, + enumerable: false, + get: function () { + if (this === Function.prototype) { + return ''; + } + var str = _call(functionToString, this); + var match = _call(_strMatch, str, /\s*function\s+([^(\s]*)\s*/); + var name = match && match[1]; + Object.defineProperty(this, 'name', { + configurable: true, + enumerable: false, + writable: false, + value: name + }); + return name; + } + }); + } +})); diff --git a/node_modules/es6-shim/es6-sham.map b/node_modules/es6-shim/es6-sham.map new file mode 100644 index 0000000..bbe97fa --- /dev/null +++ b/node_modules/es6-shim/es6-sham.map @@ -0,0 +1 @@ +{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","_call","call","bind","functionToString","toString","_strMatch","String","prototype","match","throwsError","func","e","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","getPrototypeOf","objProto","copyDescriptors","target","source","forEach","key","createAndCopy","origin","proto","set","__proto__","foo","name","configurable","enumerable","str","writable","value"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,MACrB,IAAIC,GAAQH,SAASI,KAAKC,KAAKL,SAASI,KACxC,IAAIE,GAAmBN,SAASO,QAChC,IAAIC,GAAYC,OAAOC,UAAUC,KAEjC,IAAIC,GAAc,SAAUC,GAC1B,IACEA,GACA,OAAO,OACP,MAAOC,GACP,MAAO,OAGX,IAAIC,GAAkC,WAEpC,OAAQH,EAAY,WAClBV,EAAOc,kBAAmB,KAAOC,IAAK,iBAG1C,IAAIC,KAAwBhB,EAAOc,gBAAkBD,KAWpD,WACC,GAAIb,EAAOiB,eAAgB,CAAE,OAI7B,GAAIC,GAAsBlB,EAAOkB,mBACjC,IAAIC,GAA2BnB,EAAOmB,wBACtC,IAAIC,GAASpB,EAAOoB,MACpB,IAAIN,GAAiBd,EAAOc,cAC5B,IAAIO,GAAiBrB,EAAOqB,cAC5B,IAAIC,GAAWtB,EAAOQ,SAEtB,IAAIe,GAAkB,SAAUC,EAAQC,GAEtCP,EAAoBO,GAAQC,QAAQ,SAAUC,GAC5Cb,EACEU,EACAG,EACAR,EAAyBM,EAAQE,KAGrC,OAAOH,GAGT,IAAII,GAAgB,SAAUC,EAAQC,GACpC,MAAOP,GAAgBH,EAAOU,GAAQD,GAExC,IAAIE,GAAKd,CACT,KAGEc,EAAMZ,EAAyBG,EAAU,aAAaS,GACtDA,GAAI7B,QAAS,KAGbe,GAAiB,SAAUY,EAAQC,GACjCC,EAAI7B,KAAK2B,EAAQC,EACjB,OAAOD,IAET,MAAOjB,GAEPmB,GAAQC,UAAW,KAGnB,IAAID,YAAe/B,GAAQ,CACzBiB,EAAiBW,MACZ,CAGLG,EAAIC,UAAYV,CAIhB,IAAIS,YAAe/B,GAAQ,CACzBiB,EAAiB,SAAUY,EAAQC,GAGjCD,EAAOG,UAAYF,CAEnB,OAAOD,QAEJ,CAGLZ,EAAiB,SAAUY,EAAQC,GAEjC,GAAIT,EAAeQ,GAAS,CAG1BA,EAAOG,UAAYF,CAEnB,OAAOD,OACF,CAEL,MAAOD,GAAcC,EAAQC,OAMvC9B,EAAOiB,eAAiBA,KAG1B,IAAID,GAAuB,QAASiB,SAASC,OAAS,MAAO,CAE3DlC,EAAOc,eAAehB,SAASU,UAAW,QACxC2B,aAAc,KACdC,WAAY,MACZrB,IAAK,WACH,GAAInB,OAASE,SAASU,UAAW,CAC/B,MAAO,GAET,GAAI6B,GAAMpC,EAAMG,EAAkBR,KAClC,IAAIa,GAAQR,EAAMK,EAAW+B,EAAK,6BAClC,IAAIH,GAAOzB,GAASA,EAAM,EAC1BT,GAAOc,eAAelB,KAAM,QAC1BuC,aAAc,KACdC,WAAY,MACZE,SAAU,MACVC,MAAOL,GAET,OAAOA"} \ No newline at end of file diff --git a/node_modules/es6-shim/es6-sham.min.js b/node_modules/es6-shim/es6-sham.min.js new file mode 100644 index 0000000..0ac365e --- /dev/null +++ b/node_modules/es6-shim/es6-sham.min.js @@ -0,0 +1,11 @@ +/*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-sham: v0.35.4 + * see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ +(function(t,e){if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){"use strict";var t=new Function("return this;");var e=t();var r=e.Object;var n=Function.call.bind(Function.call);var o=Function.toString;var i=String.prototype.match;var f=function(t){try{t();return false}catch(e){return true}};var u=function(){return!f(function(){r.defineProperty({},"x",{get:function(){}})})};var a=!!r.defineProperty&&u();(function(){if(r.setPrototypeOf){return}var t=r.getOwnPropertyNames;var e=r.getOwnPropertyDescriptor;var n=r.create;var o=r.defineProperty;var i=r.getPrototypeOf;var f=r.prototype;var u=function(r,n){t(n).forEach(function(t){o(r,t,e(n,t))});return r};var a=function(t,e){return u(n(e),t)};var c,s;try{c=e(f,"__proto__").set;c.call({},null);s=function(t,e){c.call(t,e);return t}}catch(p){c={__proto__:null};if(c instanceof r){s=a}else{c.__proto__=f;if(c instanceof r){s=function(t,e){t.__proto__=e;return t}}else{s=function(t,e){if(i(t)){t.__proto__=e;return t}else{return a(t,e)}}}}}r.setPrototypeOf=s})();if(a&&function foo(){}.name!=="foo"){r.defineProperty(Function.prototype,"name",{configurable:true,enumerable:false,get:function(){if(this===Function.prototype){return""}var t=n(o,this);var e=n(i,t,/\s*function\s+([^(\s]*)\s*/);var f=e&&e[1];r.defineProperty(this,"name",{configurable:true,enumerable:false,writable:false,value:f});return f}})}}); +//# sourceMappingURL=es6-sham.map diff --git a/node_modules/es6-shim/es6-shim.js b/node_modules/es6-shim/es6-shim.js new file mode 100644 index 0000000..6e7263b --- /dev/null +++ b/node_modules/es6-shim/es6-shim.js @@ -0,0 +1,3890 @@ +/*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-shim: v0.35.4 + * see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ + +// UMD (Universal Module Definition) +// see https://github.com/umdjs/umd/blob/master/returnExports.js +(function (root, factory) { + /*global define, module, exports */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); + } +}(this, function () { + 'use strict'; + + var _apply = Function.call.bind(Function.apply); + var _call = Function.call.bind(Function.call); + var isArray = Array.isArray; + var keys = Object.keys; + + var not = function notThunker(func) { + return function notThunk() { + return !_apply(func, this, arguments); + }; + }; + var throwsError = function (func) { + try { + func(); + return false; + } catch (e) { + return true; + } + }; + var valueOrFalseIfThrows = function valueOrFalseIfThrows(func) { + try { + return func(); + } catch (e) { + return false; + } + }; + + var isCallableWithoutNew = not(throwsError); + var arePropertyDescriptorsSupported = function () { + // if Object.defineProperty exists but throws, it's IE 8 + return !throwsError(function () { + return Object.defineProperty({}, 'x', { get: function () { } }); // eslint-disable-line getter-return + }); + }; + var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); + var functionsHaveNames = (function foo() {}).name === 'foo'; // eslint-disable-line no-extra-parens + + var _forEach = Function.call.bind(Array.prototype.forEach); + var _reduce = Function.call.bind(Array.prototype.reduce); + var _filter = Function.call.bind(Array.prototype.filter); + var _some = Function.call.bind(Array.prototype.some); + + var defineProperty = function (object, name, value, force) { + if (!force && name in object) { return; } + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + + // Define configurable, writable and non-enumerable props + // if they don’t exist. + var defineProperties = function (object, map, forceOverride) { + _forEach(keys(map), function (name) { + var method = map[name]; + defineProperty(object, name, method, !!forceOverride); + }); + }; + + var _toString = Function.call.bind(Object.prototype.toString); + var isCallable = typeof /abc/ === 'function' ? function IsCallableSlow(x) { + // Some old browsers (IE, FF) say that typeof /abc/ === 'function' + return typeof x === 'function' && _toString(x) === '[object Function]'; + } : function IsCallableFast(x) { return typeof x === 'function'; }; + + var Value = { + getter: function (object, name, getter) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + get: getter + }); + }, + proxy: function (originalObject, key, targetObject) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key); + Object.defineProperty(targetObject, key, { + configurable: originalDescriptor.configurable, + enumerable: originalDescriptor.enumerable, + get: function getKey() { return originalObject[key]; }, + set: function setKey(value) { originalObject[key] = value; } + }); + }, + redefine: function (object, property, newValue) { + if (supportsDescriptors) { + var descriptor = Object.getOwnPropertyDescriptor(object, property); + descriptor.value = newValue; + Object.defineProperty(object, property, descriptor); + } else { + object[property] = newValue; + } + }, + defineByDescriptor: function (object, property, descriptor) { + if (supportsDescriptors) { + Object.defineProperty(object, property, descriptor); + } else if ('value' in descriptor) { + object[property] = descriptor.value; + } + }, + preserveToString: function (target, source) { + if (source && isCallable(source.toString)) { + defineProperty(target, 'toString', source.toString.bind(source), true); + } + } + }; + + // Simple shim for Object.create on ES3 browsers + // (unlike real shim, no attempt to support `prototype === null`) + var create = Object.create || function (prototype, properties) { + var Prototype = function Prototype() {}; + Prototype.prototype = prototype; + var object = new Prototype(); + if (typeof properties !== 'undefined') { + keys(properties).forEach(function (key) { + Value.defineByDescriptor(object, key, properties[key]); + }); + } + return object; + }; + + var supportsSubclassing = function (C, f) { + if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ } + return valueOrFalseIfThrows(function () { + var Sub = function Subclass(arg) { + var o = new C(arg); + Object.setPrototypeOf(o, Subclass.prototype); + return o; + }; + Object.setPrototypeOf(Sub, C); + Sub.prototype = create(C.prototype, { + constructor: { value: Sub } + }); + return f(Sub); + }); + }; + + var getGlobal = function () { + /* global self, window, global */ + // the only reliable means to get the global object is + // `Function('return this')()` + // However, this causes CSP violations in Chrome apps. + if (typeof self !== 'undefined') { return self; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + throw new Error('unable to locate global object'); + }; + + var globals = getGlobal(); + var globalIsFinite = globals.isFinite; + var _indexOf = Function.call.bind(String.prototype.indexOf); + var _arrayIndexOfApply = Function.apply.bind(Array.prototype.indexOf); + var _concat = Function.call.bind(Array.prototype.concat); + // var _sort = Function.call.bind(Array.prototype.sort); + var _strSlice = Function.call.bind(String.prototype.slice); + var _push = Function.call.bind(Array.prototype.push); + var _pushApply = Function.apply.bind(Array.prototype.push); + var _shift = Function.call.bind(Array.prototype.shift); + var _max = Math.max; + var _min = Math.min; + var _floor = Math.floor; + var _abs = Math.abs; + var _exp = Math.exp; + var _log = Math.log; + var _sqrt = Math.sqrt; + var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); + var ArrayIterator; // make our implementation private + var noop = function () {}; + + var OrigMap = globals.Map; + var origMapDelete = OrigMap && OrigMap.prototype['delete']; + var origMapGet = OrigMap && OrigMap.prototype.get; + var origMapHas = OrigMap && OrigMap.prototype.has; + var origMapSet = OrigMap && OrigMap.prototype.set; + + var Symbol = globals.Symbol || {}; + var symbolSpecies = Symbol.species || '@@species'; + + var numberIsNaN = Number.isNaN || function isNaN(value) { + // NaN !== NaN, but they are identical. + // NaNs are the only non-reflexive value, i.e., if x !== x, + // then x is NaN. + // isNaN is broken: it converts its argument to number, so + // isNaN('foo') => true + return value !== value; + }; + var numberIsFinite = Number.isFinite || function isFinite(value) { + return typeof value === 'number' && globalIsFinite(value); + }; + var _sign = isCallable(Math.sign) ? Math.sign : function sign(value) { + var number = Number(value); + if (number === 0) { return number; } + if (numberIsNaN(number)) { return number; } + return number < 0 ? -1 : 1; + }; + var _log1p = function log1p(value) { + var x = Number(value); + if (x < -1 || numberIsNaN(x)) { return NaN; } + if (x === 0 || x === Infinity) { return x; } + if (x === -1) { return -Infinity; } + + return (1 + x) - 1 === 0 ? x : x * (_log(1 + x) / ((1 + x) - 1)); + }; + + // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js + // can be replaced with require('is-arguments') if we ever use a build process instead + var isStandardArguments = function isArguments(value) { + return _toString(value) === '[object Arguments]'; + }; + var isLegacyArguments = function isArguments(value) { + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + _toString(value) !== '[object Array]' && + _toString(value.callee) === '[object Function]'; + }; + var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; + + var Type = { + primitive: function (x) { return x === null || (typeof x !== 'function' && typeof x !== 'object'); }, + string: function (x) { return _toString(x) === '[object String]'; }, + regex: function (x) { return _toString(x) === '[object RegExp]'; }, + symbol: function (x) { + return typeof globals.Symbol === 'function' && typeof x === 'symbol'; + } + }; + + var overrideNative = function overrideNative(object, property, replacement) { + var original = object[property]; + defineProperty(object, property, replacement, true); + Value.preserveToString(object[property], original); + }; + + // eslint-disable-next-line no-restricted-properties + var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && Type.symbol(Symbol()); + + // This is a private name in the es6 spec, equal to '[Symbol.iterator]' + // we're going to use an arbitrary _-prefixed name to make our shims + // work properly with each other, even though we don't have full Iterator + // support. That is, `Array.from(map.keys())` will work, but we don't + // pretend to export a "real" Iterator interface. + var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator : '_es6-shim iterator_'; + // Firefox ships a partial implementation using the name @@iterator. + // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14 + // So use that name if we detect it. + if (globals.Set && typeof new globals.Set()['@@iterator'] === 'function') { + $iterator$ = '@@iterator'; + } + + // Reflect + if (!globals.Reflect) { + defineProperty(globals, 'Reflect', {}, true); + } + var Reflect = globals.Reflect; + + var $String = String; + + /* global document */ + var domAll = (typeof document === 'undefined' || !document) ? null : document.all; + var isNullOrUndefined = domAll == null ? function isNullOrUndefined(x) { + return x == null; + } : function isNullOrUndefinedAndNotDocumentAll(x) { + return x == null && x !== domAll; + }; + + var ES = { + // http://www.ecma-international.org/ecma-262/6.0/#sec-call + Call: function Call(F, V) { + var args = arguments.length > 2 ? arguments[2] : []; + if (!ES.IsCallable(F)) { + throw new TypeError(F + ' is not a function'); + } + return _apply(F, V, args); + }, + + RequireObjectCoercible: function (x, optMessage) { + if (isNullOrUndefined(x)) { + throw new TypeError(optMessage || 'Cannot call method on ' + x); + } + return x; + }, + + // This might miss the "(non-standard exotic and does not implement + // [[Call]])" case from + // http://www.ecma-international.org/ecma-262/6.0/#sec-typeof-operator-runtime-semantics-evaluation + // but we can't find any evidence these objects exist in practice. + // If we find some in the future, you could test `Object(x) === x`, + // which is reliable according to + // http://www.ecma-international.org/ecma-262/6.0/#sec-toobject + // but is not well optimized by runtimes and creates an object + // whenever it returns false, and thus is very slow. + TypeIsObject: function (x) { + if (x === void 0 || x === null || x === true || x === false) { + return false; + } + return typeof x === 'function' || typeof x === 'object' || x === domAll; + }, + + ToObject: function (o, optMessage) { + return Object(ES.RequireObjectCoercible(o, optMessage)); + }, + + IsCallable: isCallable, + + IsConstructor: function (x) { + // We can't tell callables from constructors in ES5 + return ES.IsCallable(x); + }, + + ToInt32: function (x) { + return ES.ToNumber(x) >> 0; + }, + + ToUint32: function (x) { + return ES.ToNumber(x) >>> 0; + }, + + ToNumber: function (value) { + if (_toString(value) === '[object Symbol]') { + throw new TypeError('Cannot convert a Symbol value to a number'); + } + return +value; + }, + + ToInteger: function (value) { + var number = ES.ToNumber(value); + if (numberIsNaN(number)) { return 0; } + if (number === 0 || !numberIsFinite(number)) { return number; } + return (number > 0 ? 1 : -1) * _floor(_abs(number)); + }, + + ToLength: function (value) { + var len = ES.ToInteger(value); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > Number.MAX_SAFE_INTEGER) { return Number.MAX_SAFE_INTEGER; } + return len; + }, + + SameValue: function (a, b) { + if (a === b) { + // 0 === -0, but they are not identical. + if (a === 0) { return 1 / a === 1 / b; } + return true; + } + return numberIsNaN(a) && numberIsNaN(b); + }, + + SameValueZero: function (a, b) { + // same as SameValue except for SameValueZero(+0, -0) == true + return (a === b) || (numberIsNaN(a) && numberIsNaN(b)); + }, + + IsIterable: function (o) { + return ES.TypeIsObject(o) && (typeof o[$iterator$] !== 'undefined' || isArguments(o)); + }, + + GetIterator: function (o) { + if (isArguments(o)) { + // special case support for `arguments` + return new ArrayIterator(o, 'value'); + } + var itFn = ES.GetMethod(o, $iterator$); + if (!ES.IsCallable(itFn)) { + // Better diagnostics if itFn is null or undefined + throw new TypeError('value is not an iterable'); + } + var it = ES.Call(itFn, o); + if (!ES.TypeIsObject(it)) { + throw new TypeError('bad iterator'); + } + return it; + }, + + GetMethod: function (o, p) { + var func = ES.ToObject(o)[p]; + if (isNullOrUndefined(func)) { + return void 0; + } + if (!ES.IsCallable(func)) { + throw new TypeError('Method not callable: ' + p); + } + return func; + }, + + IteratorComplete: function (iterResult) { + return !!iterResult.done; + }, + + IteratorClose: function (iterator, completionIsThrow) { + var returnMethod = ES.GetMethod(iterator, 'return'); + if (returnMethod === void 0) { + return; + } + var innerResult, innerException; + try { + innerResult = ES.Call(returnMethod, iterator); + } catch (e) { + innerException = e; + } + if (completionIsThrow) { + return; + } + if (innerException) { + throw innerException; + } + if (!ES.TypeIsObject(innerResult)) { + throw new TypeError("Iterator's return method returned a non-object."); + } + }, + + IteratorNext: function (it) { + var result = arguments.length > 1 ? it.next(arguments[1]) : it.next(); + if (!ES.TypeIsObject(result)) { + throw new TypeError('bad iterator'); + } + return result; + }, + + IteratorStep: function (it) { + var result = ES.IteratorNext(it); + var done = ES.IteratorComplete(result); + return done ? false : result; + }, + + Construct: function (C, args, newTarget, isES6internal) { + var target = typeof newTarget === 'undefined' ? C : newTarget; + + if (!isES6internal && Reflect.construct) { + // Try to use Reflect.construct if available + return Reflect.construct(C, args, target); + } + // OK, we have to fake it. This will only work if the + // C.[[ConstructorKind]] == "base" -- but that's the only + // kind we can make in ES5 code anyway. + + // OrdinaryCreateFromConstructor(target, "%ObjectPrototype%") + var proto = target.prototype; + if (!ES.TypeIsObject(proto)) { + proto = Object.prototype; + } + var obj = create(proto); + // Call the constructor. + var result = ES.Call(C, obj, args); + return ES.TypeIsObject(result) ? result : obj; + }, + + SpeciesConstructor: function (O, defaultConstructor) { + var C = O.constructor; + if (C === void 0) { + return defaultConstructor; + } + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad constructor'); + } + var S = C[symbolSpecies]; + if (isNullOrUndefined(S)) { + return defaultConstructor; + } + if (!ES.IsConstructor(S)) { + throw new TypeError('Bad @@species'); + } + return S; + }, + + CreateHTML: function (string, tag, attribute, value) { + var S = ES.ToString(string); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ES.ToString(value); + var escapedV = V.replace(/"/g, '"'); + p1 += ' ' + attribute + '="' + escapedV + '"'; + } + var p2 = p1 + '>'; + var p3 = p2 + S; + return p3 + ''; + }, + + IsRegExp: function IsRegExp(argument) { + if (!ES.TypeIsObject(argument)) { + return false; + } + var isRegExp = argument[Symbol.match]; + if (typeof isRegExp !== 'undefined') { + return !!isRegExp; + } + return Type.regex(argument); + }, + + ToString: function ToString(string) { + return $String(string); + } + }; + + // Well-known Symbol shims + if (supportsDescriptors && hasSymbols) { + var defineWellKnownSymbol = function defineWellKnownSymbol(name) { + if (Type.symbol(Symbol[name])) { + return Symbol[name]; + } + // eslint-disable-next-line no-restricted-properties + var sym = Symbol['for']('Symbol.' + name); + Object.defineProperty(Symbol, name, { + configurable: false, + enumerable: false, + writable: false, + value: sym + }); + return sym; + }; + if (!Type.symbol(Symbol.search)) { + var symbolSearch = defineWellKnownSymbol('search'); + var originalSearch = String.prototype.search; + defineProperty(RegExp.prototype, symbolSearch, function search(string) { + return ES.Call(originalSearch, string, [this]); + }); + var searchShim = function search(regexp) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(regexp)) { + var searcher = ES.GetMethod(regexp, symbolSearch); + if (typeof searcher !== 'undefined') { + return ES.Call(searcher, regexp, [O]); + } + } + return ES.Call(originalSearch, O, [ES.ToString(regexp)]); + }; + overrideNative(String.prototype, 'search', searchShim); + } + if (!Type.symbol(Symbol.replace)) { + var symbolReplace = defineWellKnownSymbol('replace'); + var originalReplace = String.prototype.replace; + defineProperty(RegExp.prototype, symbolReplace, function replace(string, replaceValue) { + return ES.Call(originalReplace, string, [this, replaceValue]); + }); + var replaceShim = function replace(searchValue, replaceValue) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(searchValue)) { + var replacer = ES.GetMethod(searchValue, symbolReplace); + if (typeof replacer !== 'undefined') { + return ES.Call(replacer, searchValue, [O, replaceValue]); + } + } + return ES.Call(originalReplace, O, [ES.ToString(searchValue), replaceValue]); + }; + overrideNative(String.prototype, 'replace', replaceShim); + } + if (!Type.symbol(Symbol.split)) { + var symbolSplit = defineWellKnownSymbol('split'); + var originalSplit = String.prototype.split; + defineProperty(RegExp.prototype, symbolSplit, function split(string, limit) { + return ES.Call(originalSplit, string, [this, limit]); + }); + var splitShim = function split(separator, limit) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(separator)) { + var splitter = ES.GetMethod(separator, symbolSplit); + if (typeof splitter !== 'undefined') { + return ES.Call(splitter, separator, [O, limit]); + } + } + return ES.Call(originalSplit, O, [ES.ToString(separator), limit]); + }; + overrideNative(String.prototype, 'split', splitShim); + } + var symbolMatchExists = Type.symbol(Symbol.match); + var stringMatchIgnoresSymbolMatch = symbolMatchExists && (function () { + // Firefox 41, through Nightly 45 has Symbol.match, but String#match ignores it. + // Firefox 40 and below have Symbol.match but String#match works fine. + var o = {}; + o[Symbol.match] = function () { return 42; }; + return 'a'.match(o) !== 42; + }()); + if (!symbolMatchExists || stringMatchIgnoresSymbolMatch) { + var symbolMatch = defineWellKnownSymbol('match'); + + var originalMatch = String.prototype.match; + defineProperty(RegExp.prototype, symbolMatch, function match(string) { + return ES.Call(originalMatch, string, [this]); + }); + + var matchShim = function match(regexp) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(regexp)) { + var matcher = ES.GetMethod(regexp, symbolMatch); + if (typeof matcher !== 'undefined') { + return ES.Call(matcher, regexp, [O]); + } + } + return ES.Call(originalMatch, O, [ES.ToString(regexp)]); + }; + overrideNative(String.prototype, 'match', matchShim); + } + } + + var wrapConstructor = function wrapConstructor(original, replacement, keysToSkip) { + Value.preserveToString(replacement, original); + if (Object.setPrototypeOf) { + // sets up proper prototype chain where possible + Object.setPrototypeOf(original, replacement); + } + if (supportsDescriptors) { + _forEach(Object.getOwnPropertyNames(original), function (key) { + if (key in noop || keysToSkip[key]) { return; } + Value.proxy(original, key, replacement); + }); + } else { + _forEach(Object.keys(original), function (key) { + if (key in noop || keysToSkip[key]) { return; } + replacement[key] = original[key]; + }); + } + replacement.prototype = original.prototype; + Value.redefine(original.prototype, 'constructor', replacement); + }; + + var defaultSpeciesGetter = function () { return this; }; + var addDefaultSpecies = function (C) { + if (supportsDescriptors && !_hasOwnProperty(C, symbolSpecies)) { + Value.getter(C, symbolSpecies, defaultSpeciesGetter); + } + }; + + var addIterator = function (prototype, impl) { + var implementation = impl || function iterator() { return this; }; + defineProperty(prototype, $iterator$, implementation); + if (!prototype[$iterator$] && Type.symbol($iterator$)) { + // implementations are buggy when $iterator$ is a Symbol + prototype[$iterator$] = implementation; + } + }; + + var createDataProperty = function createDataProperty(object, name, value) { + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: true, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + var createDataPropertyOrThrow = function createDataPropertyOrThrow(object, name, value) { + createDataProperty(object, name, value); + if (!ES.SameValue(object[name], value)) { + throw new TypeError('property is nonconfigurable'); + } + }; + + var emulateES6construct = function (o, defaultNewTarget, defaultProto, slots) { + // This is an es5 approximation to es6 construct semantics. in es6, + // 'new Foo' invokes Foo.[[Construct]] which (for almost all objects) + // just sets the internal variable NewTarget (in es6 syntax `new.target`) + // to Foo and then returns Foo(). + + // Many ES6 object then have constructors of the form: + // 1. If NewTarget is undefined, throw a TypeError exception + // 2. Let xxx by OrdinaryCreateFromConstructor(NewTarget, yyy, zzz) + + // So we're going to emulate those first two steps. + if (!ES.TypeIsObject(o)) { + throw new TypeError('Constructor requires `new`: ' + defaultNewTarget.name); + } + var proto = defaultNewTarget.prototype; + if (!ES.TypeIsObject(proto)) { + proto = defaultProto; + } + var obj = create(proto); + for (var name in slots) { + if (_hasOwnProperty(slots, name)) { + var value = slots[name]; + defineProperty(obj, name, value, true); + } + } + return obj; + }; + + // Firefox 31 reports this function's length as 0 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484 + if (String.fromCodePoint && String.fromCodePoint.length !== 1) { + var originalFromCodePoint = String.fromCodePoint; + overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) { + return ES.Call(originalFromCodePoint, this, arguments); + }); + } + + var StringShims = { + fromCodePoint: function fromCodePoint(codePoints) { + var result = []; + var next; + for (var i = 0, length = arguments.length; i < length; i++) { + next = Number(arguments[i]); + if (!ES.SameValue(next, ES.ToInteger(next)) || next < 0 || next > 0x10FFFF) { + throw new RangeError('Invalid code point ' + next); + } + + if (next < 0x10000) { + _push(result, String.fromCharCode(next)); + } else { + next -= 0x10000; + _push(result, String.fromCharCode((next >> 10) + 0xD800)); + _push(result, String.fromCharCode((next % 0x400) + 0xDC00)); + } + } + return result.join(''); + }, + + raw: function raw(callSite) { + var cooked = ES.ToObject(callSite, 'bad callSite'); + var rawString = ES.ToObject(cooked.raw, 'bad raw value'); + var len = rawString.length; + var literalsegments = ES.ToLength(len); + if (literalsegments <= 0) { + return ''; + } + + var stringElements = []; + var nextIndex = 0; + var nextKey, next, nextSeg, nextSub; + while (nextIndex < literalsegments) { + nextKey = ES.ToString(nextIndex); + nextSeg = ES.ToString(rawString[nextKey]); + _push(stringElements, nextSeg); + if (nextIndex + 1 >= literalsegments) { + break; + } + next = nextIndex + 1 < arguments.length ? arguments[nextIndex + 1] : ''; + nextSub = ES.ToString(next); + _push(stringElements, nextSub); + nextIndex += 1; + } + return stringElements.join(''); + } + }; + if (String.raw && String.raw({ raw: { 0: 'x', 1: 'y', length: 2 } }) !== 'xy') { + // IE 11 TP has a broken String.raw implementation + overrideNative(String, 'raw', StringShims.raw); + } + defineProperties(String, StringShims); + + // Fast repeat, uses the `Exponentiation by squaring` algorithm. + // Perf: http://jsperf.com/string-repeat2/2 + var stringRepeat = function repeat(s, times) { + if (times < 1) { return ''; } + if (times % 2) { return repeat(s, times - 1) + s; } + var half = repeat(s, times / 2); + return half + half; + }; + var stringMaxLength = Infinity; + + var StringPrototypeShims = { + repeat: function repeat(times) { + var thisStr = ES.ToString(ES.RequireObjectCoercible(this)); + var numTimes = ES.ToInteger(times); + if (numTimes < 0 || numTimes >= stringMaxLength) { + throw new RangeError('repeat count must be less than infinity and not overflow maximum string size'); + } + return stringRepeat(thisStr, numTimes); + }, + + startsWith: function startsWith(searchString) { + var S = ES.ToString(ES.RequireObjectCoercible(this)); + if (ES.IsRegExp(searchString)) { + throw new TypeError('Cannot call method "startsWith" with a regex'); + } + var searchStr = ES.ToString(searchString); + var position; + if (arguments.length > 1) { + position = arguments[1]; + } + var start = _max(ES.ToInteger(position), 0); + return _strSlice(S, start, start + searchStr.length) === searchStr; + }, + + endsWith: function endsWith(searchString) { + var S = ES.ToString(ES.RequireObjectCoercible(this)); + if (ES.IsRegExp(searchString)) { + throw new TypeError('Cannot call method "endsWith" with a regex'); + } + var searchStr = ES.ToString(searchString); + var len = S.length; + var endPosition; + if (arguments.length > 1) { + endPosition = arguments[1]; + } + var pos = typeof endPosition === 'undefined' ? len : ES.ToInteger(endPosition); + var end = _min(_max(pos, 0), len); + return _strSlice(S, end - searchStr.length, end) === searchStr; + }, + + includes: function includes(searchString) { + if (ES.IsRegExp(searchString)) { + throw new TypeError('"includes" does not accept a RegExp'); + } + var searchStr = ES.ToString(searchString); + var position; + if (arguments.length > 1) { + position = arguments[1]; + } + // Somehow this trick makes method 100% compat with the spec. + return _indexOf(this, searchStr, position) !== -1; + }, + + codePointAt: function codePointAt(pos) { + var thisStr = ES.ToString(ES.RequireObjectCoercible(this)); + var position = ES.ToInteger(pos); + var length = thisStr.length; + if (position >= 0 && position < length) { + var first = thisStr.charCodeAt(position); + var isEnd = position + 1 === length; + if (first < 0xD800 || first > 0xDBFF || isEnd) { return first; } + var second = thisStr.charCodeAt(position + 1); + if (second < 0xDC00 || second > 0xDFFF) { return first; } + return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000; + } + } + }; + if (String.prototype.includes && 'a'.includes('a', Infinity) !== false) { + overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); + } + + if (String.prototype.startsWith && String.prototype.endsWith) { + var startsWithRejectsRegex = throwsError(function () { + /* throws if spec-compliant */ + return '/a/'.startsWith(/a/); + }); + var startsWithHandlesInfinity = valueOrFalseIfThrows(function () { + return 'abc'.startsWith('a', Infinity) === false; + }); + if (!startsWithRejectsRegex || !startsWithHandlesInfinity) { + // Firefox (< 37?) and IE 11 TP have a noncompliant startsWith implementation + overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); + overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); + } + } + if (hasSymbols) { + var startsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () { + var re = /a/; + re[Symbol.match] = false; + return '/a/'.startsWith(re); + }); + if (!startsWithSupportsSymbolMatch) { + overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); + } + var endsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () { + var re = /a/; + re[Symbol.match] = false; + return '/a/'.endsWith(re); + }); + if (!endsWithSupportsSymbolMatch) { + overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); + } + var includesSupportsSymbolMatch = valueOrFalseIfThrows(function () { + var re = /a/; + re[Symbol.match] = false; + return '/a/'.includes(re); + }); + if (!includesSupportsSymbolMatch) { + overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); + } + } + + defineProperties(String.prototype, StringPrototypeShims); + + // whitespace from: http://es5.github.io/#x15.5.4.20 + // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324 + 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' + ].join(''); + var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g'); + var trimShim = function trim() { + return ES.ToString(ES.RequireObjectCoercible(this)).replace(trimRegexp, ''); + }; + var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); + var nonWSregex = new RegExp('[' + nonWS + ']', 'g'); + var isBadHexRegex = /^[-+]0x[0-9a-f]+$/i; + var hasStringTrimBug = nonWS.trim().length !== nonWS.length; + defineProperty(String.prototype, 'trim', trimShim, hasStringTrimBug); + + // Given an argument x, it will return an IteratorResult object, + // with value set to x and done to false. + // Given no arguments, it will return an iterator completion object. + var iteratorResult = function (x) { + return { value: x, done: arguments.length === 0 }; + }; + + // see http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype-@@iterator + var StringIterator = function (s) { + ES.RequireObjectCoercible(s); + this._s = ES.ToString(s); + this._i = 0; + }; + StringIterator.prototype.next = function () { + var s = this._s; + var i = this._i; + if (typeof s === 'undefined' || i >= s.length) { + this._s = void 0; + return iteratorResult(); + } + var first = s.charCodeAt(i); + var second, len; + if (first < 0xD800 || first > 0xDBFF || (i + 1) === s.length) { + len = 1; + } else { + second = s.charCodeAt(i + 1); + len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2; + } + this._i = i + len; + return iteratorResult(s.substr(i, len)); + }; + addIterator(StringIterator.prototype); + addIterator(String.prototype, function () { + return new StringIterator(this); + }); + + var ArrayShims = { + from: function from(items) { + var C = this; + var mapFn; + if (arguments.length > 1) { + mapFn = arguments[1]; + } + var mapping, T; + if (typeof mapFn === 'undefined') { + mapping = false; + } else { + if (!ES.IsCallable(mapFn)) { + throw new TypeError('Array.from: when provided, the second argument must be a function'); + } + if (arguments.length > 2) { + T = arguments[2]; + } + mapping = true; + } + + // Note that that Arrays will use ArrayIterator: + // https://bugs.ecmascript.org/show_bug.cgi?id=2416 + var usingIterator = typeof (isArguments(items) || ES.GetMethod(items, $iterator$)) !== 'undefined'; + + var length, result, i; + if (usingIterator) { + result = ES.IsConstructor(C) ? Object(new C()) : []; + var iterator = ES.GetIterator(items); + var next, nextValue; + + i = 0; + while (true) { + next = ES.IteratorStep(iterator); + if (next === false) { + break; + } + nextValue = next.value; + try { + if (mapping) { + nextValue = typeof T === 'undefined' ? mapFn(nextValue, i) : _call(mapFn, T, nextValue, i); + } + result[i] = nextValue; + } catch (e) { + ES.IteratorClose(iterator, true); + throw e; + } + i += 1; + } + length = i; + } else { + var arrayLike = ES.ToObject(items); + length = ES.ToLength(arrayLike.length); + result = ES.IsConstructor(C) ? Object(new C(length)) : new Array(length); + var value; + for (i = 0; i < length; ++i) { + value = arrayLike[i]; + if (mapping) { + value = typeof T === 'undefined' ? mapFn(value, i) : _call(mapFn, T, value, i); + } + createDataPropertyOrThrow(result, i, value); + } + } + + result.length = length; + return result; + }, + + of: function of() { + var len = arguments.length; + var C = this; + var A = isArray(C) || !ES.IsCallable(C) ? new Array(len) : ES.Construct(C, [len]); + for (var k = 0; k < len; ++k) { + createDataPropertyOrThrow(A, k, arguments[k]); + } + A.length = len; + return A; + } + }; + defineProperties(Array, ArrayShims); + addDefaultSpecies(Array); + + // Our ArrayIterator is private; see + // https://github.com/paulmillr/es6-shim/issues/252 + ArrayIterator = function (array, kind) { + this.i = 0; + this.array = array; + this.kind = kind; + }; + + defineProperties(ArrayIterator.prototype, { + next: function () { + var i = this.i; + var array = this.array; + if (!(this instanceof ArrayIterator)) { + throw new TypeError('Not an ArrayIterator'); + } + if (typeof array !== 'undefined') { + var len = ES.ToLength(array.length); + for (; i < len; i++) { + var kind = this.kind; + var retval; + if (kind === 'key') { + retval = i; + } else if (kind === 'value') { + retval = array[i]; + } else if (kind === 'entry') { + retval = [i, array[i]]; + } + this.i = i + 1; + return iteratorResult(retval); + } + } + this.array = void 0; + return iteratorResult(); + } + }); + addIterator(ArrayIterator.prototype); + + /* + var orderKeys = function orderKeys(a, b) { + var aNumeric = String(ES.ToInteger(a)) === a; + var bNumeric = String(ES.ToInteger(b)) === b; + if (aNumeric && bNumeric) { + return b - a; + } else if (aNumeric && !bNumeric) { + return -1; + } else if (!aNumeric && bNumeric) { + return 1; + } else { + return a.localeCompare(b); + } + }; + + var getAllKeys = function getAllKeys(object) { + var ownKeys = []; + var keys = []; + + for (var key in object) { + _push(_hasOwnProperty(object, key) ? ownKeys : keys, key); + } + _sort(ownKeys, orderKeys); + _sort(keys, orderKeys); + + return _concat(ownKeys, keys); + }; + */ + + // note: this is positioned here because it depends on ArrayIterator + var arrayOfSupportsSubclassing = Array.of === ArrayShims.of || (function () { + // Detects a bug in Webkit nightly r181886 + var Foo = function Foo(len) { this.length = len; }; + Foo.prototype = []; + var fooArr = Array.of.apply(Foo, [1, 2]); + return fooArr instanceof Foo && fooArr.length === 2; + }()); + if (!arrayOfSupportsSubclassing) { + overrideNative(Array, 'of', ArrayShims.of); + } + + var ArrayPrototypeShims = { + copyWithin: function copyWithin(target, start) { + var o = ES.ToObject(this); + var len = ES.ToLength(o.length); + var relativeTarget = ES.ToInteger(target); + var relativeStart = ES.ToInteger(start); + var to = relativeTarget < 0 ? _max(len + relativeTarget, 0) : _min(relativeTarget, len); + var from = relativeStart < 0 ? _max(len + relativeStart, 0) : _min(relativeStart, len); + var end; + if (arguments.length > 2) { + end = arguments[2]; + } + var relativeEnd = typeof end === 'undefined' ? len : ES.ToInteger(end); + var finalItem = relativeEnd < 0 ? _max(len + relativeEnd, 0) : _min(relativeEnd, len); + var count = _min(finalItem - from, len - to); + var direction = 1; + if (from < to && to < (from + count)) { + direction = -1; + from += count - 1; + to += count - 1; + } + while (count > 0) { + if (from in o) { + o[to] = o[from]; + } else { + delete o[to]; + } + from += direction; + to += direction; + count -= 1; + } + return o; + }, + + fill: function fill(value) { + var start; + if (arguments.length > 1) { + start = arguments[1]; + } + var end; + if (arguments.length > 2) { + end = arguments[2]; + } + var O = ES.ToObject(this); + var len = ES.ToLength(O.length); + start = ES.ToInteger(typeof start === 'undefined' ? 0 : start); + end = ES.ToInteger(typeof end === 'undefined' ? len : end); + + var relativeStart = start < 0 ? _max(len + start, 0) : _min(start, len); + var relativeEnd = end < 0 ? len + end : end; + + for (var i = relativeStart; i < len && i < relativeEnd; ++i) { + O[i] = value; + } + return O; + }, + + find: function find(predicate) { + var list = ES.ToObject(this); + var length = ES.ToLength(list.length); + if (!ES.IsCallable(predicate)) { + throw new TypeError('Array#find: predicate must be a function'); + } + var thisArg = arguments.length > 1 ? arguments[1] : null; + for (var i = 0, value; i < length; i++) { + value = list[i]; + if (thisArg) { + if (_call(predicate, thisArg, value, i, list)) { + return value; + } + } else if (predicate(value, i, list)) { + return value; + } + } + }, + + findIndex: function findIndex(predicate) { + var list = ES.ToObject(this); + var length = ES.ToLength(list.length); + if (!ES.IsCallable(predicate)) { + throw new TypeError('Array#findIndex: predicate must be a function'); + } + var thisArg = arguments.length > 1 ? arguments[1] : null; + for (var i = 0; i < length; i++) { + if (thisArg) { + if (_call(predicate, thisArg, list[i], i, list)) { + return i; + } + } else if (predicate(list[i], i, list)) { + return i; + } + } + return -1; + }, + + keys: function keys() { + return new ArrayIterator(this, 'key'); + }, + + values: function values() { + return new ArrayIterator(this, 'value'); + }, + + entries: function entries() { + return new ArrayIterator(this, 'entry'); + } + }; + // Safari 7.1 defines Array#keys and Array#entries natively, + // but the resulting ArrayIterator objects don't have a "next" method. + if (Array.prototype.keys && !ES.IsCallable([1].keys().next)) { + delete Array.prototype.keys; + } + if (Array.prototype.entries && !ES.IsCallable([1].entries().next)) { + delete Array.prototype.entries; + } + + // Chrome 38 defines Array#keys and Array#entries, and Array#@@iterator, but not Array#values + if (Array.prototype.keys && Array.prototype.entries && !Array.prototype.values && Array.prototype[$iterator$]) { + defineProperties(Array.prototype, { + values: Array.prototype[$iterator$] + }); + if (Type.symbol(Symbol.unscopables)) { + Array.prototype[Symbol.unscopables].values = true; + } + } + // Chrome 40 defines Array#values with the incorrect name, although Array#{keys,entries} have the correct name + if (functionsHaveNames && Array.prototype.values && Array.prototype.values.name !== 'values') { + var originalArrayPrototypeValues = Array.prototype.values; + overrideNative(Array.prototype, 'values', function values() { return ES.Call(originalArrayPrototypeValues, this, arguments); }); + defineProperty(Array.prototype, $iterator$, Array.prototype.values, true); + } + defineProperties(Array.prototype, ArrayPrototypeShims); + + if (1 / [true].indexOf(true, -0) < 0) { + // indexOf when given a position arg of -0 should return +0. + // https://github.com/tc39/ecma262/pull/316 + defineProperty(Array.prototype, 'indexOf', function indexOf(searchElement) { + var value = _arrayIndexOfApply(this, arguments); + if (value === 0 && (1 / value) < 0) { + return 0; + } + return value; + }, true); + } + + addIterator(Array.prototype, function () { return this.values(); }); + // Chrome defines keys/values/entries on Array, but doesn't give us + // any way to identify its iterator. So add our own shimmed field. + if (Object.getPrototypeOf) { + addIterator(Object.getPrototypeOf([].values())); + } + + // note: this is positioned here because it relies on Array#entries + var arrayFromSwallowsNegativeLengths = (function () { + // Detects a Firefox bug in v32 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993 + return valueOrFalseIfThrows(function () { + return Array.from({ length: -1 }).length === 0; + }); + }()); + var arrayFromHandlesIterables = (function () { + // Detects a bug in Webkit nightly r181886 + var arr = Array.from([0].entries()); + return arr.length === 1 && isArray(arr[0]) && arr[0][0] === 0 && arr[0][1] === 0; + }()); + if (!arrayFromSwallowsNegativeLengths || !arrayFromHandlesIterables) { + overrideNative(Array, 'from', ArrayShims.from); + } + var arrayFromHandlesUndefinedMapFunction = (function () { + // Microsoft Edge v0.11 throws if the mapFn argument is *provided* but undefined, + // but the spec doesn't care if it's provided or not - undefined doesn't throw. + return valueOrFalseIfThrows(function () { + return Array.from([0], void 0); + }); + }()); + if (!arrayFromHandlesUndefinedMapFunction) { + var origArrayFrom = Array.from; + overrideNative(Array, 'from', function from(items) { + if (arguments.length > 1 && typeof arguments[1] !== 'undefined') { + return ES.Call(origArrayFrom, this, arguments); + } else { + return _call(origArrayFrom, this, items); + } + }); + } + + var int32sAsOne = -(Math.pow(2, 32) - 1); + var toLengthsCorrectly = function (method, reversed) { + var obj = { length: int32sAsOne }; + obj[reversed ? (obj.length >>> 0) - 1 : 0] = true; + return valueOrFalseIfThrows(function () { + _call(method, obj, function () { + // note: in nonconforming browsers, this will be called + // -1 >>> 0 times, which is 4294967295, so the throw matters. + throw new RangeError('should not reach here'); + }, []); + return true; + }); + }; + if (!toLengthsCorrectly(Array.prototype.forEach)) { + var originalForEach = Array.prototype.forEach; + overrideNative(Array.prototype, 'forEach', function forEach(callbackFn) { + return ES.Call(originalForEach, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.map)) { + var originalMap = Array.prototype.map; + overrideNative(Array.prototype, 'map', function map(callbackFn) { + return ES.Call(originalMap, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.filter)) { + var originalFilter = Array.prototype.filter; + overrideNative(Array.prototype, 'filter', function filter(callbackFn) { + return ES.Call(originalFilter, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.some)) { + var originalSome = Array.prototype.some; + overrideNative(Array.prototype, 'some', function some(callbackFn) { + return ES.Call(originalSome, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.every)) { + var originalEvery = Array.prototype.every; + overrideNative(Array.prototype, 'every', function every(callbackFn) { + return ES.Call(originalEvery, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.reduce)) { + var originalReduce = Array.prototype.reduce; + overrideNative(Array.prototype, 'reduce', function reduce(callbackFn) { + return ES.Call(originalReduce, this.length >= 0 ? this : [], arguments); + }, true); + } + if (!toLengthsCorrectly(Array.prototype.reduceRight, true)) { + var originalReduceRight = Array.prototype.reduceRight; + overrideNative(Array.prototype, 'reduceRight', function reduceRight(callbackFn) { + return ES.Call(originalReduceRight, this.length >= 0 ? this : [], arguments); + }, true); + } + + var lacksOctalSupport = Number('0o10') !== 8; + var lacksBinarySupport = Number('0b10') !== 2; + var trimsNonWhitespace = _some(nonWS, function (c) { + return Number(c + 0 + c) === 0; + }); + if (lacksOctalSupport || lacksBinarySupport || trimsNonWhitespace) { + var OrigNumber = Number; + var binaryRegex = /^0b[01]+$/i; + var octalRegex = /^0o[0-7]+$/i; + // Note that in IE 8, RegExp.prototype.test doesn't seem to exist: ie, "test" is an own property of regexes. wtf. + var isBinary = binaryRegex.test.bind(binaryRegex); + var isOctal = octalRegex.test.bind(octalRegex); + var toPrimitive = function (O) { // need to replace this with `es-to-primitive/es6` + var result; + if (typeof O.valueOf === 'function') { + result = O.valueOf(); + if (Type.primitive(result)) { + return result; + } + } + if (typeof O.toString === 'function') { + result = O.toString(); + if (Type.primitive(result)) { + return result; + } + } + throw new TypeError('No default value'); + }; + var hasNonWS = nonWSregex.test.bind(nonWSregex); + var isBadHex = isBadHexRegex.test.bind(isBadHexRegex); + var NumberShim = (function () { + // this is wrapped in an IIFE because of IE 6-8's wacky scoping issues with named function expressions. + var NumberShim = function Number(value) { + var primValue; + if (arguments.length > 0) { + primValue = Type.primitive(value) ? value : toPrimitive(value, 'number'); + } else { + primValue = 0; + } + if (typeof primValue === 'string') { + primValue = ES.Call(trimShim, primValue); + if (isBinary(primValue)) { + primValue = parseInt(_strSlice(primValue, 2), 2); + } else if (isOctal(primValue)) { + primValue = parseInt(_strSlice(primValue, 2), 8); + } else if (hasNonWS(primValue) || isBadHex(primValue)) { + primValue = NaN; + } + } + var receiver = this; + var valueOfSucceeds = valueOrFalseIfThrows(function () { + OrigNumber.prototype.valueOf.call(receiver); + return true; + }); + if (receiver instanceof NumberShim && !valueOfSucceeds) { + return new OrigNumber(primValue); + } + return OrigNumber(primValue); + }; + return NumberShim; + }()); + wrapConstructor(OrigNumber, NumberShim, {}); + // this is necessary for ES3 browsers, where these properties are non-enumerable. + defineProperties(NumberShim, { + NaN: OrigNumber.NaN, + MAX_VALUE: OrigNumber.MAX_VALUE, + MIN_VALUE: OrigNumber.MIN_VALUE, + NEGATIVE_INFINITY: OrigNumber.NEGATIVE_INFINITY, + POSITIVE_INFINITY: OrigNumber.POSITIVE_INFINITY + }); + /* globals Number: true */ + /* eslint-disable no-undef, no-global-assign */ + Number = NumberShim; + Value.redefine(globals, 'Number', NumberShim); + /* eslint-enable no-undef, no-global-assign */ + /* globals Number: false */ + } + + var maxSafeInteger = Math.pow(2, 53) - 1; + defineProperties(Number, { + MAX_SAFE_INTEGER: maxSafeInteger, + MIN_SAFE_INTEGER: -maxSafeInteger, + EPSILON: 2.220446049250313e-16, + + parseInt: globals.parseInt, + parseFloat: globals.parseFloat, + + isFinite: numberIsFinite, + + isInteger: function isInteger(value) { + return numberIsFinite(value) && ES.ToInteger(value) === value; + }, + + isSafeInteger: function isSafeInteger(value) { + return Number.isInteger(value) && _abs(value) <= Number.MAX_SAFE_INTEGER; + }, + + isNaN: numberIsNaN + }); + // Firefox 37 has a conforming Number.parseInt, but it's not === to the global parseInt (fixed in v40) + defineProperty(Number, 'parseInt', globals.parseInt, Number.parseInt !== globals.parseInt); + + // Work around bugs in Array#find and Array#findIndex -- early + // implementations skipped holes in sparse arrays. (Note that the + // implementations of find/findIndex indirectly use shimmed + // methods of Number, so this test has to happen down here.) + /* eslint-disable no-sparse-arrays */ + if ([, 1].find(function () { return true; }) === 1) { + overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find); + } + if ([, 1].findIndex(function () { return true; }) !== 0) { + overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex); + } + /* eslint-enable no-sparse-arrays */ + + var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable); + var ensureEnumerable = function ensureEnumerable(obj, prop) { + if (supportsDescriptors && isEnumerableOn(obj, prop)) { + Object.defineProperty(obj, prop, { enumerable: false }); + } + }; + var sliceArgs = function sliceArgs() { + // per https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments + // and https://gist.github.com/WebReflection/4327762cb87a8c634a29 + var initial = Number(this); + var len = arguments.length; + var desiredArgCount = len - initial; + var args = new Array(desiredArgCount < 0 ? 0 : desiredArgCount); + for (var i = initial; i < len; ++i) { + args[i - initial] = arguments[i]; + } + return args; + }; + var assignTo = function assignTo(source) { + return function assignToSource(target, key) { + target[key] = source[key]; + return target; + }; + }; + var assignReducer = function (target, source) { + var sourceKeys = keys(Object(source)); + var symbols; + if (ES.IsCallable(Object.getOwnPropertySymbols)) { + symbols = _filter(Object.getOwnPropertySymbols(Object(source)), isEnumerableOn(source)); + } + return _reduce(_concat(sourceKeys, symbols || []), assignTo(source), target); + }; + + var ObjectShims = { + // 19.1.3.1 + assign: function (target, source) { + var to = ES.ToObject(target, 'Cannot convert undefined or null to object'); + return _reduce(ES.Call(sliceArgs, 1, arguments), assignReducer, to); + }, + + // Added in WebKit in https://bugs.webkit.org/show_bug.cgi?id=143865 + is: function is(a, b) { + return ES.SameValue(a, b); + } + }; + var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () { + // Firefox 37 still has "pending exception" logic in its Object.assign implementation, + // which is 72% slower than our shim, and Firefox 40's native implementation. + var thrower = Object.preventExtensions({ 1: 2 }); + try { + Object.assign(thrower, 'xy'); + } catch (e) { + return thrower[1] === 'y'; + } + }()); + if (assignHasPendingExceptions) { + overrideNative(Object, 'assign', ObjectShims.assign); + } + defineProperties(Object, ObjectShims); + + if (supportsDescriptors) { + var ES5ObjectShims = { + // 19.1.3.9 + // shim from https://gist.github.com/WebReflection/5593554 + setPrototypeOf: (function (Object, magic) { + var set; + + var checkArgs = function (O, proto) { + if (!ES.TypeIsObject(O)) { + throw new TypeError('cannot set prototype on a non-object'); + } + if (!(proto === null || ES.TypeIsObject(proto))) { + throw new TypeError('can only set prototype to an object or null' + proto); + } + }; + + var setPrototypeOf = function (O, proto) { + checkArgs(O, proto); + _call(set, O, proto); + return O; + }; + + try { + // this works already in Firefox and Safari + set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set; + _call(set, {}, null); + } catch (e) { + if (Object.prototype !== {}[magic]) { + // IE < 11 cannot be shimmed + return; + } + // probably Chrome or some old Mobile stock browser + set = function (proto) { + this[magic] = proto; + }; + // please note that this will **not** work + // in those browsers that do not inherit + // __proto__ by mistake from Object.prototype + // in these cases we should probably throw an error + // or at least be informed about the issue + setPrototypeOf.polyfill = setPrototypeOf( + setPrototypeOf({}, null), + Object.prototype + ) instanceof Object; + // setPrototypeOf.polyfill === true means it works as meant + // setPrototypeOf.polyfill === false means it's not 100% reliable + // setPrototypeOf.polyfill === undefined + // or + // setPrototypeOf.polyfill == null means it's not a polyfill + // which means it works as expected + // we can even delete Object.prototype.__proto__; + } + return setPrototypeOf; + }(Object, '__proto__')) + }; + + defineProperties(Object, ES5ObjectShims); + } + + // Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work, + // but Object.create(null) does. + if (Object.setPrototypeOf && Object.getPrototypeOf && + Object.getPrototypeOf(Object.setPrototypeOf({}, null)) !== null && + Object.getPrototypeOf(Object.create(null)) === null) { + (function () { + var FAKENULL = Object.create(null); + var gpo = Object.getPrototypeOf; + var spo = Object.setPrototypeOf; + Object.getPrototypeOf = function (o) { + var result = gpo(o); + return result === FAKENULL ? null : result; + }; + Object.setPrototypeOf = function (o, p) { + var proto = p === null ? FAKENULL : p; + return spo(o, proto); + }; + Object.setPrototypeOf.polyfill = false; + }()); + } + + var objectKeysAcceptsPrimitives = !throwsError(function () { return Object.keys('foo'); }); + if (!objectKeysAcceptsPrimitives) { + var originalObjectKeys = Object.keys; + overrideNative(Object, 'keys', function keys(value) { + return originalObjectKeys(ES.ToObject(value)); + }); + keys = Object.keys; + } + var objectKeysRejectsRegex = throwsError(function () { return Object.keys(/a/g); }); + if (objectKeysRejectsRegex) { + var regexRejectingObjectKeys = Object.keys; + overrideNative(Object, 'keys', function keys(value) { + if (Type.regex(value)) { + var regexKeys = []; + for (var k in value) { + if (_hasOwnProperty(value, k)) { + _push(regexKeys, k); + } + } + return regexKeys; + } + return regexRejectingObjectKeys(value); + }); + keys = Object.keys; + } + + if (Object.getOwnPropertyNames) { + var objectGOPNAcceptsPrimitives = !throwsError(function () { return Object.getOwnPropertyNames('foo'); }); + if (!objectGOPNAcceptsPrimitives) { + var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : []; + var originalObjectGetOwnPropertyNames = Object.getOwnPropertyNames; + overrideNative(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) { + var val = ES.ToObject(value); + if (_toString(val) === '[object Window]') { + try { + return originalObjectGetOwnPropertyNames(val); + } catch (e) { + // IE bug where layout engine calls userland gOPN for cross-domain `window` objects + return _concat([], cachedWindowNames); + } + } + return originalObjectGetOwnPropertyNames(val); + }); + } + } + if (Object.getOwnPropertyDescriptor) { + var objectGOPDAcceptsPrimitives = !throwsError(function () { return Object.getOwnPropertyDescriptor('foo', 'bar'); }); + if (!objectGOPDAcceptsPrimitives) { + var originalObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + overrideNative(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) { + return originalObjectGetOwnPropertyDescriptor(ES.ToObject(value), property); + }); + } + } + if (Object.seal) { + var objectSealAcceptsPrimitives = !throwsError(function () { return Object.seal('foo'); }); + if (!objectSealAcceptsPrimitives) { + var originalObjectSeal = Object.seal; + overrideNative(Object, 'seal', function seal(value) { + if (!ES.TypeIsObject(value)) { return value; } + return originalObjectSeal(value); + }); + } + } + if (Object.isSealed) { + var objectIsSealedAcceptsPrimitives = !throwsError(function () { return Object.isSealed('foo'); }); + if (!objectIsSealedAcceptsPrimitives) { + var originalObjectIsSealed = Object.isSealed; + overrideNative(Object, 'isSealed', function isSealed(value) { + if (!ES.TypeIsObject(value)) { return true; } + return originalObjectIsSealed(value); + }); + } + } + if (Object.freeze) { + var objectFreezeAcceptsPrimitives = !throwsError(function () { return Object.freeze('foo'); }); + if (!objectFreezeAcceptsPrimitives) { + var originalObjectFreeze = Object.freeze; + overrideNative(Object, 'freeze', function freeze(value) { + if (!ES.TypeIsObject(value)) { return value; } + return originalObjectFreeze(value); + }); + } + } + if (Object.isFrozen) { + var objectIsFrozenAcceptsPrimitives = !throwsError(function () { return Object.isFrozen('foo'); }); + if (!objectIsFrozenAcceptsPrimitives) { + var originalObjectIsFrozen = Object.isFrozen; + overrideNative(Object, 'isFrozen', function isFrozen(value) { + if (!ES.TypeIsObject(value)) { return true; } + return originalObjectIsFrozen(value); + }); + } + } + if (Object.preventExtensions) { + var objectPreventExtensionsAcceptsPrimitives = !throwsError(function () { return Object.preventExtensions('foo'); }); + if (!objectPreventExtensionsAcceptsPrimitives) { + var originalObjectPreventExtensions = Object.preventExtensions; + overrideNative(Object, 'preventExtensions', function preventExtensions(value) { + if (!ES.TypeIsObject(value)) { return value; } + return originalObjectPreventExtensions(value); + }); + } + } + if (Object.isExtensible) { + var objectIsExtensibleAcceptsPrimitives = !throwsError(function () { return Object.isExtensible('foo'); }); + if (!objectIsExtensibleAcceptsPrimitives) { + var originalObjectIsExtensible = Object.isExtensible; + overrideNative(Object, 'isExtensible', function isExtensible(value) { + if (!ES.TypeIsObject(value)) { return false; } + return originalObjectIsExtensible(value); + }); + } + } + if (Object.getPrototypeOf) { + var objectGetProtoAcceptsPrimitives = !throwsError(function () { return Object.getPrototypeOf('foo'); }); + if (!objectGetProtoAcceptsPrimitives) { + var originalGetProto = Object.getPrototypeOf; + overrideNative(Object, 'getPrototypeOf', function getPrototypeOf(value) { + return originalGetProto(ES.ToObject(value)); + }); + } + } + + var hasFlags = supportsDescriptors && (function () { + var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags'); + return desc && ES.IsCallable(desc.get); + }()); + if (supportsDescriptors && !hasFlags) { + var regExpFlagsGetter = function flags() { + if (!ES.TypeIsObject(this)) { + throw new TypeError('Method called on incompatible type: must be an object.'); + } + var result = ''; + if (this.global) { + result += 'g'; + } + if (this.ignoreCase) { + result += 'i'; + } + if (this.multiline) { + result += 'm'; + } + if (this.unicode) { + result += 'u'; + } + if (this.sticky) { + result += 'y'; + } + return result; + }; + + Value.getter(RegExp.prototype, 'flags', regExpFlagsGetter); + } + + var regExpSupportsFlagsWithRegex = supportsDescriptors && valueOrFalseIfThrows(function () { + return String(new RegExp(/a/g, 'i')) === '/a/i'; + }); + var regExpNeedsToSupportSymbolMatch = hasSymbols && supportsDescriptors && (function () { + // Edge 0.12 supports flags fully, but does not support Symbol.match + var regex = /./; + regex[Symbol.match] = false; + return RegExp(regex) === regex; + }()); + + var regexToStringIsGeneric = valueOrFalseIfThrows(function () { + return RegExp.prototype.toString.call({ source: 'abc' }) === '/abc/'; + }); + var regexToStringSupportsGenericFlags = regexToStringIsGeneric && valueOrFalseIfThrows(function () { + return RegExp.prototype.toString.call({ source: 'a', flags: 'b' }) === '/a/b'; + }); + if (!regexToStringIsGeneric || !regexToStringSupportsGenericFlags) { + var origRegExpToString = RegExp.prototype.toString; + defineProperty(RegExp.prototype, 'toString', function toString() { + var R = ES.RequireObjectCoercible(this); + if (Type.regex(R)) { + return _call(origRegExpToString, R); + } + var pattern = $String(R.source); + var flags = $String(R.flags); + return '/' + pattern + '/' + flags; + }, true); + Value.preserveToString(RegExp.prototype.toString, origRegExpToString); + } + + if (supportsDescriptors && (!regExpSupportsFlagsWithRegex || regExpNeedsToSupportSymbolMatch)) { + var flagsGetter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get; + var sourceDesc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source') || {}; + var legacySourceGetter = function () { + // prior to it being a getter, it's own + nonconfigurable + return this.source; + }; + var sourceGetter = ES.IsCallable(sourceDesc.get) ? sourceDesc.get : legacySourceGetter; + + var OrigRegExp = RegExp; + var RegExpShim = (function () { + return function RegExp(pattern, flags) { + var patternIsRegExp = ES.IsRegExp(pattern); + var calledWithNew = this instanceof RegExp; + if (!calledWithNew && patternIsRegExp && typeof flags === 'undefined' && pattern.constructor === RegExp) { + return pattern; + } + + var P = pattern; + var F = flags; + if (Type.regex(pattern)) { + P = ES.Call(sourceGetter, pattern); + F = typeof flags === 'undefined' ? ES.Call(flagsGetter, pattern) : flags; + return new RegExp(P, F); + } else if (patternIsRegExp) { + P = pattern.source; + F = typeof flags === 'undefined' ? pattern.flags : flags; + } + return new OrigRegExp(pattern, flags); + }; + }()); + wrapConstructor(OrigRegExp, RegExpShim, { + $input: true // Chrome < v39 & Opera < 26 have a nonstandard "$input" property + }); + /* globals RegExp: true */ + /* eslint-disable no-undef, no-global-assign */ + RegExp = RegExpShim; + Value.redefine(globals, 'RegExp', RegExpShim); + /* eslint-enable no-undef, no-global-assign */ + /* globals RegExp: false */ + } + + if (supportsDescriptors) { + var regexGlobals = { + input: '$_', + lastMatch: '$&', + lastParen: '$+', + leftContext: '$`', + rightContext: '$\'' + }; + _forEach(keys(regexGlobals), function (prop) { + if (prop in RegExp && !(regexGlobals[prop] in RegExp)) { + Value.getter(RegExp, regexGlobals[prop], function get() { + return RegExp[prop]; + }); + } + }); + } + addDefaultSpecies(RegExp); + + var inverseEpsilon = 1 / Number.EPSILON; + var roundTiesToEven = function roundTiesToEven(n) { + // Even though this reduces down to `return n`, it takes advantage of built-in rounding. + return (n + inverseEpsilon) - inverseEpsilon; + }; + var BINARY_32_EPSILON = Math.pow(2, -23); + var BINARY_32_MAX_VALUE = Math.pow(2, 127) * (2 - BINARY_32_EPSILON); + var BINARY_32_MIN_VALUE = Math.pow(2, -126); + var E = Math.E; + var LOG2E = Math.LOG2E; + var LOG10E = Math.LOG10E; + var numberCLZ = Number.prototype.clz; + delete Number.prototype.clz; // Safari 8 has Number#clz + + var MathShims = { + acosh: function acosh(value) { + var x = Number(value); + if (numberIsNaN(x) || value < 1) { return NaN; } + if (x === 1) { return 0; } + if (x === Infinity) { return x; } + + var xInvSquared = 1 / (x * x); + if (x < 2) { + return _log1p(x - 1 + (_sqrt(1 - xInvSquared) * x)); + } + var halfX = x / 2; + return _log1p(halfX + (_sqrt(1 - xInvSquared) * halfX) - 1) + (1 / LOG2E); + }, + + asinh: function asinh(value) { + var x = Number(value); + if (x === 0 || !globalIsFinite(x)) { + return x; + } + + var a = _abs(x); + var aSquared = a * a; + var s = _sign(x); + if (a < 1) { + return s * _log1p(a + (aSquared / (_sqrt(aSquared + 1) + 1))); + } + return s * (_log1p((a / 2) + (_sqrt(1 + (1 / aSquared)) * a / 2) - 1) + (1 / LOG2E)); + }, + + atanh: function atanh(value) { + var x = Number(value); + + if (x === 0) { return x; } + if (x === -1) { return -Infinity; } + if (x === 1) { return Infinity; } + if (numberIsNaN(x) || x < -1 || x > 1) { + return NaN; + } + + var a = _abs(x); + return _sign(x) * _log1p(2 * a / (1 - a)) / 2; + }, + + cbrt: function cbrt(value) { + var x = Number(value); + if (x === 0) { return x; } + var negate = x < 0; + var result; + if (negate) { x = -x; } + if (x === Infinity) { + result = Infinity; + } else { + result = _exp(_log(x) / 3); + // from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods + result = ((x / (result * result)) + (2 * result)) / 3; + } + return negate ? -result : result; + }, + + clz32: function clz32(value) { + // See https://bugs.ecmascript.org/show_bug.cgi?id=2465 + var x = Number(value); + var number = ES.ToUint32(x); + if (number === 0) { + return 32; + } + return numberCLZ ? ES.Call(numberCLZ, number) : 31 - _floor(_log(number + 0.5) * LOG2E); + }, + + cosh: function cosh(value) { + var x = Number(value); + if (x === 0) { return 1; } // +0 or -0 + if (numberIsNaN(x)) { return NaN; } + if (!globalIsFinite(x)) { return Infinity; } + + var t = _exp(_abs(x) - 1); + return (t + (1 / (t * E * E))) * (E / 2); + }, + + expm1: function expm1(value) { + var x = Number(value); + if (x === -Infinity) { return -1; } + if (!globalIsFinite(x) || x === 0) { return x; } + if (_abs(x) > 0.5) { + return _exp(x) - 1; + } + // A more precise approximation using Taylor series expansion + // from https://github.com/paulmillr/es6-shim/issues/314#issuecomment-70293986 + var t = x; + var sum = 0; + var n = 1; + while (sum + t !== sum) { + sum += t; + n += 1; + t *= x / n; + } + return sum; + }, + + hypot: function hypot(x, y) { + var result = 0; + var largest = 0; + for (var i = 0; i < arguments.length; ++i) { + var value = _abs(Number(arguments[i])); + if (largest < value) { + result *= (largest / value) * (largest / value); + result += 1; + largest = value; + } else { + result += value > 0 ? (value / largest) * (value / largest) : value; + } + } + return largest === Infinity ? Infinity : largest * _sqrt(result); + }, + + log2: function log2(value) { + return _log(value) * LOG2E; + }, + + log10: function log10(value) { + return _log(value) * LOG10E; + }, + + log1p: _log1p, + + sign: _sign, + + sinh: function sinh(value) { + var x = Number(value); + if (!globalIsFinite(x) || x === 0) { return x; } + + var a = _abs(x); + if (a < 1) { + var u = Math.expm1(a); + return _sign(x) * u * (1 + (1 / (u + 1))) / 2; + } + var t = _exp(a - 1); + return _sign(x) * (t - (1 / (t * E * E))) * (E / 2); + }, + + tanh: function tanh(value) { + var x = Number(value); + if (numberIsNaN(x) || x === 0) { return x; } + // can exit early at +-20 as JS loses precision for true value at this integer + if (x >= 20) { return 1; } + if (x <= -20) { return -1; } + + return (Math.expm1(x) - Math.expm1(-x)) / (_exp(x) + _exp(-x)); + }, + + trunc: function trunc(value) { + var x = Number(value); + return x < 0 ? -_floor(-x) : _floor(x); + }, + + imul: function imul(x, y) { + // taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul + var a = ES.ToUint32(x); + var b = ES.ToUint32(y); + var ah = (a >>> 16) & 0xffff; + var al = a & 0xffff; + var bh = (b >>> 16) & 0xffff; + var bl = b & 0xffff; + // the shift by 0 fixes the sign on the high part + // the final |0 converts the unsigned value into a signed value + return (al * bl) + ((((ah * bl) + (al * bh)) << 16) >>> 0) | 0; + }, + + fround: function fround(x) { + var v = Number(x); + if (v === 0 || v === Infinity || v === -Infinity || numberIsNaN(v)) { + return v; + } + var sign = _sign(v); + var abs = _abs(v); + if (abs < BINARY_32_MIN_VALUE) { + return sign * roundTiesToEven(abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON; + } + // Veltkamp's splitting (?) + var a = (1 + (BINARY_32_EPSILON / Number.EPSILON)) * abs; + var result = a - (a - abs); + if (result > BINARY_32_MAX_VALUE || numberIsNaN(result)) { + return sign * Infinity; + } + return sign * result; + } + }; + + var withinULPDistance = function withinULPDistance(result, expected, distance) { + return _abs(1 - (result / expected)) / Number.EPSILON < (distance || 8); + }; + + defineProperties(Math, MathShims); + // Chrome < 40 sinh returns ∞ for large numbers + defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(710) === Infinity); + // Chrome < 40 cosh returns ∞ for large numbers + defineProperty(Math, 'cosh', MathShims.cosh, Math.cosh(710) === Infinity); + // IE 11 TP has an imprecise log1p: reports Math.log1p(-1e-17) as 0 + defineProperty(Math, 'log1p', MathShims.log1p, Math.log1p(-1e-17) !== -1e-17); + // IE 11 TP has an imprecise asinh: reports Math.asinh(-1e7) as not exactly equal to -Math.asinh(1e7) + defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(-1e7) !== -Math.asinh(1e7)); + // Chrome < 54 asinh returns ∞ for large numbers and should not + defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(1e+300) === Infinity); + // Chrome < 54 atanh incorrectly returns 0 for large numbers + defineProperty(Math, 'atanh', MathShims.atanh, Math.atanh(1e-300) === 0); + // Chrome 40 has an imprecise Math.tanh with very small numbers + defineProperty(Math, 'tanh', MathShims.tanh, Math.tanh(-2e-17) !== -2e-17); + // Chrome 40 loses Math.acosh precision with high numbers + defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity); + // Chrome < 54 has an inaccurate acosh for EPSILON deltas + defineProperty(Math, 'acosh', MathShims.acosh, !withinULPDistance(Math.acosh(1 + Number.EPSILON), Math.sqrt(2 * Number.EPSILON))); + // Firefox 38 on Windows + defineProperty(Math, 'cbrt', MathShims.cbrt, !withinULPDistance(Math.cbrt(1e-300), 1e-100)); + // node 0.11 has an imprecise Math.sinh with very small numbers + defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17); + // FF 35 on Linux reports 22025.465794806725 for Math.expm1(10) + var expm1OfTen = Math.expm1(10); + defineProperty(Math, 'expm1', MathShims.expm1, expm1OfTen > 22025.465794806719 || expm1OfTen < 22025.4657948067165168); + + var origMathRound = Math.round; + // breaks in e.g. Safari 8, Internet Explorer 11, Opera 12 + var roundHandlesBoundaryConditions = Math.round(0.5 - (Number.EPSILON / 4)) === 0 && + Math.round(-0.5 + (Number.EPSILON / 3.99)) === 1; + + // When engines use Math.floor(x + 0.5) internally, Math.round can be buggy for large integers. + // This behavior should be governed by "round to nearest, ties to even mode" + // see http://www.ecma-international.org/ecma-262/6.0/#sec-terms-and-definitions-number-type + // These are the boundary cases where it breaks. + var smallestPositiveNumberWhereRoundBreaks = inverseEpsilon + 1; + var largestPositiveNumberWhereRoundBreaks = (2 * inverseEpsilon) - 1; + var roundDoesNotIncreaseIntegers = [ + smallestPositiveNumberWhereRoundBreaks, + largestPositiveNumberWhereRoundBreaks + ].every(function (num) { + return Math.round(num) === num; + }); + defineProperty(Math, 'round', function round(x) { + var floor = _floor(x); + var ceil = floor === -1 ? -0 : floor + 1; + return x - floor < 0.5 ? floor : ceil; + }, !roundHandlesBoundaryConditions || !roundDoesNotIncreaseIntegers); + Value.preserveToString(Math.round, origMathRound); + + var origImul = Math.imul; + if (Math.imul(0xffffffff, 5) !== -5) { + // Safari 6.1, at least, reports "0" for this value + Math.imul = MathShims.imul; + Value.preserveToString(Math.imul, origImul); + } + if (Math.imul.length !== 2) { + // Safari 8.0.4 has a length of 1 + // fixed in https://bugs.webkit.org/show_bug.cgi?id=143658 + overrideNative(Math, 'imul', function imul(x, y) { + return ES.Call(origImul, Math, arguments); + }); + } + + // Promises + // Simplest possible implementation; use a 3rd-party library if you + // want the best possible speed and/or long stack traces. + var PromiseShim = (function () { + var setTimeout = globals.setTimeout; + // some environments don't have setTimeout - no way to shim here. + if (typeof setTimeout !== 'function' && typeof setTimeout !== 'object') { return; } + + ES.IsPromise = function (promise) { + if (!ES.TypeIsObject(promise)) { + return false; + } + if (typeof promise._promise === 'undefined') { + return false; // uninitialized, or missing our hidden field. + } + return true; + }; + + // "PromiseCapability" in the spec is what most promise implementations + // call a "deferred". + var PromiseCapability = function (C) { + if (!ES.IsConstructor(C)) { + throw new TypeError('Bad promise constructor'); + } + var capability = this; + var resolver = function (resolve, reject) { + if (capability.resolve !== void 0 || capability.reject !== void 0) { + throw new TypeError('Bad Promise implementation!'); + } + capability.resolve = resolve; + capability.reject = reject; + }; + // Initialize fields to inform optimizers about the object shape. + capability.resolve = void 0; + capability.reject = void 0; + capability.promise = new C(resolver); + if (!(ES.IsCallable(capability.resolve) && ES.IsCallable(capability.reject))) { + throw new TypeError('Bad promise constructor'); + } + }; + + // find an appropriate setImmediate-alike + var makeZeroTimeout; + /*global window */ + if (typeof window !== 'undefined' && ES.IsCallable(window.postMessage)) { + makeZeroTimeout = function () { + // from http://dbaron.org/log/20100309-faster-timeouts + var timeouts = []; + var messageName = 'zero-timeout-message'; + var setZeroTimeout = function (fn) { + _push(timeouts, fn); + window.postMessage(messageName, '*'); + }; + var handleMessage = function (event) { + if (event.source === window && event.data === messageName) { + event.stopPropagation(); + if (timeouts.length === 0) { return; } + var fn = _shift(timeouts); + fn(); + } + }; + window.addEventListener('message', handleMessage, true); + return setZeroTimeout; + }; + } + var makePromiseAsap = function () { + // An efficient task-scheduler based on a pre-existing Promise + // implementation, which we can use even if we override the + // global Promise below (in order to workaround bugs) + // https://github.com/Raynos/observ-hash/issues/2#issuecomment-35857671 + var P = globals.Promise; + var pr = P && P.resolve && P.resolve(); + return pr && function (task) { + return pr.then(task); + }; + }; + /*global process */ + var enqueue = ES.IsCallable(globals.setImmediate) ? + globals.setImmediate : + typeof process === 'object' && process.nextTick ? process.nextTick : makePromiseAsap() || + (ES.IsCallable(makeZeroTimeout) ? makeZeroTimeout() : function (task) { setTimeout(task, 0); }); // fallback + + // Constants for Promise implementation + var PROMISE_IDENTITY = function (x) { return x; }; + var PROMISE_THROWER = function (e) { throw e; }; + var PROMISE_PENDING = 0; + var PROMISE_FULFILLED = 1; + var PROMISE_REJECTED = 2; + // We store fulfill/reject handlers and capabilities in a single array. + var PROMISE_FULFILL_OFFSET = 0; + var PROMISE_REJECT_OFFSET = 1; + var PROMISE_CAPABILITY_OFFSET = 2; + // This is used in an optimization for chaining promises via then. + var PROMISE_FAKE_CAPABILITY = {}; + + var enqueuePromiseReactionJob = function (handler, capability, argument) { + enqueue(function () { + promiseReactionJob(handler, capability, argument); + }); + }; + + var promiseReactionJob = function (handler, promiseCapability, argument) { + var handlerResult, f; + if (promiseCapability === PROMISE_FAKE_CAPABILITY) { + // Fast case, when we don't actually need to chain through to a + // (real) promiseCapability. + return handler(argument); + } + try { + handlerResult = handler(argument); + f = promiseCapability.resolve; + } catch (e) { + handlerResult = e; + f = promiseCapability.reject; + } + f(handlerResult); + }; + + var fulfillPromise = function (promise, value) { + var _promise = promise._promise; + var length = _promise.reactionLength; + if (length > 0) { + enqueuePromiseReactionJob( + _promise.fulfillReactionHandler0, + _promise.reactionCapability0, + value + ); + _promise.fulfillReactionHandler0 = void 0; + _promise.rejectReactions0 = void 0; + _promise.reactionCapability0 = void 0; + if (length > 1) { + for (var i = 1, idx = 0; i < length; i++, idx += 3) { + enqueuePromiseReactionJob( + _promise[idx + PROMISE_FULFILL_OFFSET], + _promise[idx + PROMISE_CAPABILITY_OFFSET], + value + ); + promise[idx + PROMISE_FULFILL_OFFSET] = void 0; + promise[idx + PROMISE_REJECT_OFFSET] = void 0; + promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0; + } + } + } + _promise.result = value; + _promise.state = PROMISE_FULFILLED; + _promise.reactionLength = 0; + }; + + var rejectPromise = function (promise, reason) { + var _promise = promise._promise; + var length = _promise.reactionLength; + if (length > 0) { + enqueuePromiseReactionJob( + _promise.rejectReactionHandler0, + _promise.reactionCapability0, + reason + ); + _promise.fulfillReactionHandler0 = void 0; + _promise.rejectReactions0 = void 0; + _promise.reactionCapability0 = void 0; + if (length > 1) { + for (var i = 1, idx = 0; i < length; i++, idx += 3) { + enqueuePromiseReactionJob( + _promise[idx + PROMISE_REJECT_OFFSET], + _promise[idx + PROMISE_CAPABILITY_OFFSET], + reason + ); + promise[idx + PROMISE_FULFILL_OFFSET] = void 0; + promise[idx + PROMISE_REJECT_OFFSET] = void 0; + promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0; + } + } + } + _promise.result = reason; + _promise.state = PROMISE_REJECTED; + _promise.reactionLength = 0; + }; + + var createResolvingFunctions = function (promise) { + var alreadyResolved = false; + var resolve = function (resolution) { + var then; + if (alreadyResolved) { return; } + alreadyResolved = true; + if (resolution === promise) { + return rejectPromise(promise, new TypeError('Self resolution')); + } + if (!ES.TypeIsObject(resolution)) { + return fulfillPromise(promise, resolution); + } + try { + then = resolution.then; + } catch (e) { + return rejectPromise(promise, e); + } + if (!ES.IsCallable(then)) { + return fulfillPromise(promise, resolution); + } + enqueue(function () { + promiseResolveThenableJob(promise, resolution, then); + }); + }; + var reject = function (reason) { + if (alreadyResolved) { return; } + alreadyResolved = true; + return rejectPromise(promise, reason); + }; + return { resolve: resolve, reject: reject }; + }; + + var optimizedThen = function (then, thenable, resolve, reject) { + // Optimization: since we discard the result, we can pass our + // own then implementation a special hint to let it know it + // doesn't have to create it. (The PROMISE_FAKE_CAPABILITY + // object is local to this implementation and unforgeable outside.) + if (then === Promise$prototype$then) { + _call(then, thenable, resolve, reject, PROMISE_FAKE_CAPABILITY); + } else { + _call(then, thenable, resolve, reject); + } + }; + var promiseResolveThenableJob = function (promise, thenable, then) { + var resolvingFunctions = createResolvingFunctions(promise); + var resolve = resolvingFunctions.resolve; + var reject = resolvingFunctions.reject; + try { + optimizedThen(then, thenable, resolve, reject); + } catch (e) { + reject(e); + } + }; + + var Promise$prototype, Promise$prototype$then; + var Promise = (function () { + var PromiseShim = function Promise(resolver) { + if (!(this instanceof PromiseShim)) { + throw new TypeError('Constructor Promise requires "new"'); + } + if (this && this._promise) { + throw new TypeError('Bad construction'); + } + // see https://bugs.ecmascript.org/show_bug.cgi?id=2482 + if (!ES.IsCallable(resolver)) { + throw new TypeError('not a valid resolver'); + } + var promise = emulateES6construct(this, PromiseShim, Promise$prototype, { + _promise: { + result: void 0, + state: PROMISE_PENDING, + // The first member of the "reactions" array is inlined here, + // since most promises only have one reaction. + // We've also exploded the 'reaction' object to inline the + // "handler" and "capability" fields, since both fulfill and + // reject reactions share the same capability. + reactionLength: 0, + fulfillReactionHandler0: void 0, + rejectReactionHandler0: void 0, + reactionCapability0: void 0 + } + }); + var resolvingFunctions = createResolvingFunctions(promise); + var reject = resolvingFunctions.reject; + try { + resolver(resolvingFunctions.resolve, reject); + } catch (e) { + reject(e); + } + return promise; + }; + return PromiseShim; + }()); + Promise$prototype = Promise.prototype; + + var _promiseAllResolver = function (index, values, capability, remaining) { + var alreadyCalled = false; + return function (x) { + if (alreadyCalled) { return; } + alreadyCalled = true; + values[index] = x; + if ((--remaining.count) === 0) { + var resolve = capability.resolve; + resolve(values); // call w/ this===undefined + } + }; + }; + + var performPromiseAll = function (iteratorRecord, C, resultCapability) { + var it = iteratorRecord.iterator; + var values = []; + var remaining = { count: 1 }; + var next, nextValue; + var index = 0; + while (true) { + try { + next = ES.IteratorStep(it); + if (next === false) { + iteratorRecord.done = true; + break; + } + nextValue = next.value; + } catch (e) { + iteratorRecord.done = true; + throw e; + } + values[index] = void 0; + var nextPromise = C.resolve(nextValue); + var resolveElement = _promiseAllResolver( + index, + values, + resultCapability, + remaining + ); + remaining.count += 1; + optimizedThen(nextPromise.then, nextPromise, resolveElement, resultCapability.reject); + index += 1; + } + if ((--remaining.count) === 0) { + var resolve = resultCapability.resolve; + resolve(values); // call w/ this===undefined + } + return resultCapability.promise; + }; + + var performPromiseRace = function (iteratorRecord, C, resultCapability) { + var it = iteratorRecord.iterator; + var next, nextValue, nextPromise; + while (true) { + try { + next = ES.IteratorStep(it); + if (next === false) { + // NOTE: If iterable has no items, resulting promise will never + // resolve; see: + // https://github.com/domenic/promises-unwrapping/issues/75 + // https://bugs.ecmascript.org/show_bug.cgi?id=2515 + iteratorRecord.done = true; + break; + } + nextValue = next.value; + } catch (e) { + iteratorRecord.done = true; + throw e; + } + nextPromise = C.resolve(nextValue); + optimizedThen(nextPromise.then, nextPromise, resultCapability.resolve, resultCapability.reject); + } + return resultCapability.promise; + }; + + defineProperties(Promise, { + all: function all(iterable) { + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Promise is not object'); + } + var capability = new PromiseCapability(C); + var iterator, iteratorRecord; + try { + iterator = ES.GetIterator(iterable); + iteratorRecord = { iterator: iterator, done: false }; + return performPromiseAll(iteratorRecord, C, capability); + } catch (e) { + var exception = e; + if (iteratorRecord && !iteratorRecord.done) { + try { + ES.IteratorClose(iterator, true); + } catch (ee) { + exception = ee; + } + } + var reject = capability.reject; + reject(exception); + return capability.promise; + } + }, + + race: function race(iterable) { + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Promise is not object'); + } + var capability = new PromiseCapability(C); + var iterator, iteratorRecord; + try { + iterator = ES.GetIterator(iterable); + iteratorRecord = { iterator: iterator, done: false }; + return performPromiseRace(iteratorRecord, C, capability); + } catch (e) { + var exception = e; + if (iteratorRecord && !iteratorRecord.done) { + try { + ES.IteratorClose(iterator, true); + } catch (ee) { + exception = ee; + } + } + var reject = capability.reject; + reject(exception); + return capability.promise; + } + }, + + reject: function reject(reason) { + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad promise constructor'); + } + var capability = new PromiseCapability(C); + var rejectFunc = capability.reject; + rejectFunc(reason); // call with this===undefined + return capability.promise; + }, + + resolve: function resolve(v) { + // See https://esdiscuss.org/topic/fixing-promise-resolve for spec + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad promise constructor'); + } + if (ES.IsPromise(v)) { + var constructor = v.constructor; + if (constructor === C) { + return v; + } + } + var capability = new PromiseCapability(C); + var resolveFunc = capability.resolve; + resolveFunc(v); // call with this===undefined + return capability.promise; + } + }); + + defineProperties(Promise$prototype, { + 'catch': function (onRejected) { + return this.then(null, onRejected); + }, + + then: function then(onFulfilled, onRejected) { + var promise = this; + if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); } + var C = ES.SpeciesConstructor(promise, Promise); + var resultCapability; + var returnValueIsIgnored = arguments.length > 2 && arguments[2] === PROMISE_FAKE_CAPABILITY; + if (returnValueIsIgnored && C === Promise) { + resultCapability = PROMISE_FAKE_CAPABILITY; + } else { + resultCapability = new PromiseCapability(C); + } + // PerformPromiseThen(promise, onFulfilled, onRejected, resultCapability) + // Note that we've split the 'reaction' object into its two + // components, "capabilities" and "handler" + // "capabilities" is always equal to `resultCapability` + var fulfillReactionHandler = ES.IsCallable(onFulfilled) ? onFulfilled : PROMISE_IDENTITY; + var rejectReactionHandler = ES.IsCallable(onRejected) ? onRejected : PROMISE_THROWER; + var _promise = promise._promise; + var value; + if (_promise.state === PROMISE_PENDING) { + if (_promise.reactionLength === 0) { + _promise.fulfillReactionHandler0 = fulfillReactionHandler; + _promise.rejectReactionHandler0 = rejectReactionHandler; + _promise.reactionCapability0 = resultCapability; + } else { + var idx = 3 * (_promise.reactionLength - 1); + _promise[idx + PROMISE_FULFILL_OFFSET] = fulfillReactionHandler; + _promise[idx + PROMISE_REJECT_OFFSET] = rejectReactionHandler; + _promise[idx + PROMISE_CAPABILITY_OFFSET] = resultCapability; + } + _promise.reactionLength += 1; + } else if (_promise.state === PROMISE_FULFILLED) { + value = _promise.result; + enqueuePromiseReactionJob( + fulfillReactionHandler, + resultCapability, + value + ); + } else if (_promise.state === PROMISE_REJECTED) { + value = _promise.result; + enqueuePromiseReactionJob( + rejectReactionHandler, + resultCapability, + value + ); + } else { + throw new TypeError('unexpected Promise state'); + } + return resultCapability.promise; + } + }); + // This helps the optimizer by ensuring that methods which take + // capabilities aren't polymorphic. + PROMISE_FAKE_CAPABILITY = new PromiseCapability(Promise); + Promise$prototype$then = Promise$prototype.then; + + return Promise; + }()); + + // Chrome's native Promise has extra methods that it shouldn't have. Let's remove them. + if (globals.Promise) { + delete globals.Promise.accept; + delete globals.Promise.defer; + delete globals.Promise.prototype.chain; + } + + if (typeof PromiseShim === 'function') { + // export the Promise constructor. + defineProperties(globals, { Promise: PromiseShim }); + // In Chrome 33 (and thereabouts) Promise is defined, but the + // implementation is buggy in a number of ways. Let's check subclassing + // support to see if we have a buggy implementation. + var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) { + return S.resolve(42).then(function () {}) instanceof S; + }); + var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () { + return globals.Promise.reject(42).then(null, 5).then(null, noop); + }); + var promiseRequiresObjectContext = throwsError(function () { return globals.Promise.call(3, noop); }); + // Promise.resolve() was errata'ed late in the ES6 process. + // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1170742 + // https://code.google.com/p/v8/issues/detail?id=4161 + // It serves as a proxy for a number of other bugs in early Promise + // implementations. + var promiseResolveBroken = (function (Promise) { + var p = Promise.resolve(5); + p.constructor = {}; + var p2 = Promise.resolve(p); + try { + p2.then(null, noop).then(null, noop); // avoid "uncaught rejection" warnings in console + } catch (e) { + return true; // v8 native Promises break here https://code.google.com/p/chromium/issues/detail?id=575314 + } + return p === p2; // This *should* be false! + }(globals.Promise)); + + // Chrome 46 (probably older too) does not retrieve a thenable's .then synchronously + var getsThenSynchronously = supportsDescriptors && (function () { + var count = 0; + // eslint-disable-next-line getter-return + var thenable = Object.defineProperty({}, 'then', { get: function () { count += 1; } }); + Promise.resolve(thenable); + return count === 1; + }()); + + var BadResolverPromise = function BadResolverPromise(executor) { + var p = new Promise(executor); + executor(3, function () {}); + this.then = p.then; + this.constructor = BadResolverPromise; + }; + BadResolverPromise.prototype = Promise.prototype; + BadResolverPromise.all = Promise.all; + // Chrome Canary 49 (probably older too) has some implementation bugs + var hasBadResolverPromise = valueOrFalseIfThrows(function () { + return !!BadResolverPromise.all([1, 2]); + }); + + if (!promiseSupportsSubclassing || !promiseIgnoresNonFunctionThenCallbacks || + !promiseRequiresObjectContext || promiseResolveBroken || + !getsThenSynchronously || hasBadResolverPromise) { + /* globals Promise: true */ + /* eslint-disable no-undef, no-global-assign */ + Promise = PromiseShim; + /* eslint-enable no-undef, no-global-assign */ + /* globals Promise: false */ + overrideNative(globals, 'Promise', PromiseShim); + } + if (Promise.all.length !== 1) { + var origAll = Promise.all; + overrideNative(Promise, 'all', function all(iterable) { + return ES.Call(origAll, this, arguments); + }); + } + if (Promise.race.length !== 1) { + var origRace = Promise.race; + overrideNative(Promise, 'race', function race(iterable) { + return ES.Call(origRace, this, arguments); + }); + } + if (Promise.resolve.length !== 1) { + var origResolve = Promise.resolve; + overrideNative(Promise, 'resolve', function resolve(x) { + return ES.Call(origResolve, this, arguments); + }); + } + if (Promise.reject.length !== 1) { + var origReject = Promise.reject; + overrideNative(Promise, 'reject', function reject(r) { + return ES.Call(origReject, this, arguments); + }); + } + ensureEnumerable(Promise, 'all'); + ensureEnumerable(Promise, 'race'); + ensureEnumerable(Promise, 'resolve'); + ensureEnumerable(Promise, 'reject'); + addDefaultSpecies(Promise); + } + + // Map and Set require a true ES5 environment + // Their fast path also requires that the environment preserve + // property insertion order, which is not guaranteed by the spec. + var testOrder = function (a) { + var b = keys(_reduce(a, function (o, k) { + o[k] = true; + return o; + }, {})); + return a.join(':') === b.join(':'); + }; + var preservesInsertionOrder = testOrder(['z', 'a', 'bb']); + // some engines (eg, Chrome) only preserve insertion order for string keys + var preservesNumericInsertionOrder = testOrder(['z', 1, 'a', '3', 2]); + + if (supportsDescriptors) { + + var fastkey = function fastkey(key, skipInsertionOrderCheck) { + if (!skipInsertionOrderCheck && !preservesInsertionOrder) { + return null; + } + if (isNullOrUndefined(key)) { + return '^' + ES.ToString(key); + } else if (typeof key === 'string') { + return '$' + key; + } else if (typeof key === 'number') { + // note that -0 will get coerced to "0" when used as a property key + if (!preservesNumericInsertionOrder) { + return 'n' + key; + } + return key; + } else if (typeof key === 'boolean') { + return 'b' + key; + } + return null; + }; + + var emptyObject = function emptyObject() { + // accomodate some older not-quite-ES5 browsers + return Object.create ? Object.create(null) : {}; + }; + + var addIterableToMap = function addIterableToMap(MapConstructor, map, iterable) { + if (isArray(iterable) || Type.string(iterable)) { + _forEach(iterable, function (entry) { + if (!ES.TypeIsObject(entry)) { + throw new TypeError('Iterator value ' + entry + ' is not an entry object'); + } + map.set(entry[0], entry[1]); + }); + } else if (iterable instanceof MapConstructor) { + _call(MapConstructor.prototype.forEach, iterable, function (value, key) { + map.set(key, value); + }); + } else { + var iter, adder; + if (!isNullOrUndefined(iterable)) { + adder = map.set; + if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); } + iter = ES.GetIterator(iterable); + } + if (typeof iter !== 'undefined') { + while (true) { + var next = ES.IteratorStep(iter); + if (next === false) { break; } + var nextItem = next.value; + try { + if (!ES.TypeIsObject(nextItem)) { + throw new TypeError('Iterator value ' + nextItem + ' is not an entry object'); + } + _call(adder, map, nextItem[0], nextItem[1]); + } catch (e) { + ES.IteratorClose(iter, true); + throw e; + } + } + } + } + }; + var addIterableToSet = function addIterableToSet(SetConstructor, set, iterable) { + if (isArray(iterable) || Type.string(iterable)) { + _forEach(iterable, function (value) { + set.add(value); + }); + } else if (iterable instanceof SetConstructor) { + _call(SetConstructor.prototype.forEach, iterable, function (value) { + set.add(value); + }); + } else { + var iter, adder; + if (!isNullOrUndefined(iterable)) { + adder = set.add; + if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); } + iter = ES.GetIterator(iterable); + } + if (typeof iter !== 'undefined') { + while (true) { + var next = ES.IteratorStep(iter); + if (next === false) { break; } + var nextValue = next.value; + try { + _call(adder, set, nextValue); + } catch (e) { + ES.IteratorClose(iter, true); + throw e; + } + } + } + } + }; + + var collectionShims = { + Map: (function () { + + var empty = {}; + + var MapEntry = function MapEntry(key, value) { + this.key = key; + this.value = value; + this.next = null; + this.prev = null; + }; + + MapEntry.prototype.isRemoved = function isRemoved() { + return this.key === empty; + }; + + var isMap = function isMap(map) { + return !!map._es6map; + }; + + var requireMapSlot = function requireMapSlot(map, method) { + if (!ES.TypeIsObject(map) || !isMap(map)) { + throw new TypeError('Method Map.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(map)); + } + }; + + var MapIterator = function MapIterator(map, kind) { + requireMapSlot(map, '[[MapIterator]]'); + this.head = map._head; + this.i = this.head; + this.kind = kind; + }; + + MapIterator.prototype = { + isMapIterator: true, + next: function next() { + if (!this.isMapIterator) { + throw new TypeError('Not a MapIterator'); + } + var i = this.i; + var kind = this.kind; + var head = this.head; + if (typeof this.i === 'undefined') { + return iteratorResult(); + } + while (i.isRemoved() && i !== head) { + // back up off of removed entries + i = i.prev; + } + // advance to next unreturned element. + var result; + while (i.next !== head) { + i = i.next; + if (!i.isRemoved()) { + if (kind === 'key') { + result = i.key; + } else if (kind === 'value') { + result = i.value; + } else { + result = [i.key, i.value]; + } + this.i = i; + return iteratorResult(result); + } + } + // once the iterator is done, it is done forever. + this.i = void 0; + return iteratorResult(); + } + }; + addIterator(MapIterator.prototype); + + var Map$prototype; + var MapShim = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + if (this && this._es6map) { + throw new TypeError('Bad construction'); + } + var map = emulateES6construct(this, Map, Map$prototype, { + _es6map: true, + _head: null, + _map: OrigMap ? new OrigMap() : null, + _size: 0, + _storage: emptyObject() + }); + + var head = new MapEntry(null, null); + // circular doubly-linked list. + /* eslint no-multi-assign: 1 */ + head.next = head.prev = head; + map._head = head; + + // Optionally initialize map from iterable + if (arguments.length > 0) { + addIterableToMap(Map, map, arguments[0]); + } + return map; + }; + Map$prototype = MapShim.prototype; + + Value.getter(Map$prototype, 'size', function () { + if (typeof this._size === 'undefined') { + throw new TypeError('size method called on incompatible Map'); + } + return this._size; + }); + + defineProperties(Map$prototype, { + get: function get(key) { + requireMapSlot(this, 'get'); + var entry; + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + entry = this._storage[fkey]; + if (entry) { + return entry.value; + } else { + return; + } + } + if (this._map) { + // fast object key path + entry = origMapGet.call(this._map, key); + if (entry) { + return entry.value; + } else { + return; + } + } + var head = this._head; + var i = head; + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + return i.value; + } + } + }, + + has: function has(key) { + requireMapSlot(this, 'has'); + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + return typeof this._storage[fkey] !== 'undefined'; + } + if (this._map) { + // fast object key path + return origMapHas.call(this._map, key); + } + var head = this._head; + var i = head; + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + return true; + } + } + return false; + }, + + set: function set(key, value) { + requireMapSlot(this, 'set'); + var head = this._head; + var i = head; + var entry; + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + if (typeof this._storage[fkey] !== 'undefined') { + this._storage[fkey].value = value; + return this; + } else { + entry = this._storage[fkey] = new MapEntry(key, value); /* eslint no-multi-assign: 1 */ + i = head.prev; + // fall through + } + } else if (this._map) { + // fast object key path + if (origMapHas.call(this._map, key)) { + origMapGet.call(this._map, key).value = value; + } else { + entry = new MapEntry(key, value); + origMapSet.call(this._map, key, entry); + i = head.prev; + // fall through + } + } + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + i.value = value; + return this; + } + } + entry = entry || new MapEntry(key, value); + if (ES.SameValue(-0, key)) { + entry.key = +0; // coerce -0 to +0 in entry + } + entry.next = this._head; + entry.prev = this._head.prev; + entry.prev.next = entry; + entry.next.prev = entry; + this._size += 1; + return this; + }, + + 'delete': function (key) { + requireMapSlot(this, 'delete'); + var head = this._head; + var i = head; + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + if (typeof this._storage[fkey] === 'undefined') { + return false; + } + i = this._storage[fkey].prev; + delete this._storage[fkey]; + // fall through + } else if (this._map) { + // fast object key path + if (!origMapHas.call(this._map, key)) { + return false; + } + i = origMapGet.call(this._map, key).prev; + origMapDelete.call(this._map, key); + // fall through + } + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + i.key = empty; + i.value = empty; + i.prev.next = i.next; + i.next.prev = i.prev; + this._size -= 1; + return true; + } + } + return false; + }, + + clear: function clear() { + /* eslint no-multi-assign: 1 */ + requireMapSlot(this, 'clear'); + this._map = OrigMap ? new OrigMap() : null; + this._size = 0; + this._storage = emptyObject(); + var head = this._head; + var i = head; + var p = i.next; + while ((i = p) !== head) { + i.key = empty; + i.value = empty; + p = i.next; + i.next = i.prev = head; + } + head.next = head.prev = head; + }, + + keys: function keys() { + requireMapSlot(this, 'keys'); + return new MapIterator(this, 'key'); + }, + + values: function values() { + requireMapSlot(this, 'values'); + return new MapIterator(this, 'value'); + }, + + entries: function entries() { + requireMapSlot(this, 'entries'); + return new MapIterator(this, 'key+value'); + }, + + forEach: function forEach(callback) { + requireMapSlot(this, 'forEach'); + var context = arguments.length > 1 ? arguments[1] : null; + var it = this.entries(); + for (var entry = it.next(); !entry.done; entry = it.next()) { + if (context) { + _call(callback, context, entry.value[1], entry.value[0], this); + } else { + callback(entry.value[1], entry.value[0], this); + } + } + } + }); + addIterator(Map$prototype, Map$prototype.entries); + + return MapShim; + }()), + + Set: (function () { + var isSet = function isSet(set) { + return set._es6set && typeof set._storage !== 'undefined'; + }; + var requireSetSlot = function requireSetSlot(set, method) { + if (!ES.TypeIsObject(set) || !isSet(set)) { + // https://github.com/paulmillr/es6-shim/issues/176 + throw new TypeError('Set.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(set)); + } + }; + + // Creating a Map is expensive. To speed up the common case of + // Sets containing only string or numeric keys, we use an object + // as backing storage and lazily create a full Map only when + // required. + var Set$prototype; + var SetShim = function Set() { + if (!(this instanceof Set)) { + throw new TypeError('Constructor Set requires "new"'); + } + if (this && this._es6set) { + throw new TypeError('Bad construction'); + } + var set = emulateES6construct(this, Set, Set$prototype, { + _es6set: true, + '[[SetData]]': null, + _storage: emptyObject() + }); + if (!set._es6set) { + throw new TypeError('bad set'); + } + + // Optionally initialize Set from iterable + if (arguments.length > 0) { + addIterableToSet(Set, set, arguments[0]); + } + return set; + }; + Set$prototype = SetShim.prototype; + + var decodeKey = function (key) { + var k = key; + if (k === '^null') { + return null; + } else if (k === '^undefined') { + return void 0; + } else { + var first = k.charAt(0); + if (first === '$') { + return _strSlice(k, 1); + } else if (first === 'n') { + return +_strSlice(k, 1); + } else if (first === 'b') { + return k === 'btrue'; + } + } + return +k; + }; + // Switch from the object backing storage to a full Map. + var ensureMap = function ensureMap(set) { + if (!set['[[SetData]]']) { + var m = new collectionShims.Map(); + set['[[SetData]]'] = m; + _forEach(keys(set._storage), function (key) { + var k = decodeKey(key); + m.set(k, k); + }); + set['[[SetData]]'] = m; + } + set._storage = null; // free old backing storage + }; + + Value.getter(SetShim.prototype, 'size', function () { + requireSetSlot(this, 'size'); + if (this._storage) { + return keys(this._storage).length; + } + ensureMap(this); + return this['[[SetData]]'].size; + }); + + defineProperties(SetShim.prototype, { + has: function has(key) { + requireSetSlot(this, 'has'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + return !!this._storage[fkey]; + } + ensureMap(this); + return this['[[SetData]]'].has(key); + }, + + add: function add(key) { + requireSetSlot(this, 'add'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + this._storage[fkey] = true; + return this; + } + ensureMap(this); + this['[[SetData]]'].set(key, key); + return this; + }, + + 'delete': function (key) { + requireSetSlot(this, 'delete'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + var hasFKey = _hasOwnProperty(this._storage, fkey); + return (delete this._storage[fkey]) && hasFKey; + } + ensureMap(this); + return this['[[SetData]]']['delete'](key); + }, + + clear: function clear() { + requireSetSlot(this, 'clear'); + if (this._storage) { + this._storage = emptyObject(); + } + if (this['[[SetData]]']) { + this['[[SetData]]'].clear(); + } + }, + + values: function values() { + requireSetSlot(this, 'values'); + ensureMap(this); + return new SetIterator(this['[[SetData]]'].values()); + }, + + entries: function entries() { + requireSetSlot(this, 'entries'); + ensureMap(this); + return new SetIterator(this['[[SetData]]'].entries()); + }, + + forEach: function forEach(callback) { + requireSetSlot(this, 'forEach'); + var context = arguments.length > 1 ? arguments[1] : null; + var entireSet = this; + ensureMap(entireSet); + this['[[SetData]]'].forEach(function (value, key) { + if (context) { + _call(callback, context, key, key, entireSet); + } else { + callback(key, key, entireSet); + } + }); + } + }); + defineProperty(SetShim.prototype, 'keys', SetShim.prototype.values, true); + addIterator(SetShim.prototype, SetShim.prototype.values); + + var SetIterator = function SetIterator(it) { + this.it = it; + }; + SetIterator.prototype = { + isSetIterator: true, + next: function next() { + if (!this.isSetIterator) { + throw new TypeError('Not a SetIterator'); + } + return this.it.next(); + } + }; + addIterator(SetIterator.prototype); + + return SetShim; + }()) + }; + + var isGoogleTranslate = globals.Set && !Set.prototype['delete'] && Set.prototype.remove && Set.prototype.items && Set.prototype.map && Array.isArray(new Set().keys); + if (isGoogleTranslate) { + // special-case force removal of wildly invalid Set implementation in Google Translate iframes + // see https://github.com/paulmillr/es6-shim/issues/438 / https://twitter.com/ljharb/status/849335573114363904 + globals.Set = collectionShims.Set; + } + if (globals.Map || globals.Set) { + // Safari 8, for example, doesn't accept an iterable. + var mapAcceptsArguments = valueOrFalseIfThrows(function () { return new Map([[1, 2]]).get(1) === 2; }); + if (!mapAcceptsArguments) { + globals.Map = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + var m = new OrigMap(); + if (arguments.length > 0) { + addIterableToMap(Map, m, arguments[0]); + } + delete m.constructor; + Object.setPrototypeOf(m, globals.Map.prototype); + return m; + }; + globals.Map.prototype = create(OrigMap.prototype); + defineProperty(globals.Map.prototype, 'constructor', globals.Map, true); + Value.preserveToString(globals.Map, OrigMap); + } + var testMap = new Map(); + var mapUsesSameValueZero = (function () { + // Chrome 38-42, node 0.11/0.12, iojs 1/2 also have a bug when the Map has a size > 4 + var m = new Map([[1, 0], [2, 0], [3, 0], [4, 0]]); + m.set(-0, m); + return m.get(0) === m && m.get(-0) === m && m.has(0) && m.has(-0); + }()); + var mapSupportsChaining = testMap.set(1, 2) === testMap; + if (!mapUsesSameValueZero || !mapSupportsChaining) { + overrideNative(Map.prototype, 'set', function set(k, v) { + _call(origMapSet, this, k === 0 ? 0 : k, v); + return this; + }); + } + if (!mapUsesSameValueZero) { + defineProperties(Map.prototype, { + get: function get(k) { + return _call(origMapGet, this, k === 0 ? 0 : k); + }, + has: function has(k) { + return _call(origMapHas, this, k === 0 ? 0 : k); + } + }, true); + Value.preserveToString(Map.prototype.get, origMapGet); + Value.preserveToString(Map.prototype.has, origMapHas); + } + var testSet = new Set(); + var setUsesSameValueZero = Set.prototype['delete'] && Set.prototype.add && Set.prototype.has && (function (s) { + s['delete'](0); + s.add(-0); + return !s.has(0); + }(testSet)); + var setSupportsChaining = testSet.add(1) === testSet; + if (!setUsesSameValueZero || !setSupportsChaining) { + var origSetAdd = Set.prototype.add; + Set.prototype.add = function add(v) { + _call(origSetAdd, this, v === 0 ? 0 : v); + return this; + }; + Value.preserveToString(Set.prototype.add, origSetAdd); + } + if (!setUsesSameValueZero) { + var origSetHas = Set.prototype.has; + Set.prototype.has = function has(v) { + return _call(origSetHas, this, v === 0 ? 0 : v); + }; + Value.preserveToString(Set.prototype.has, origSetHas); + var origSetDel = Set.prototype['delete']; + Set.prototype['delete'] = function SetDelete(v) { + return _call(origSetDel, this, v === 0 ? 0 : v); + }; + Value.preserveToString(Set.prototype['delete'], origSetDel); + } + var mapSupportsSubclassing = supportsSubclassing(globals.Map, function (M) { + var m = new M([]); + // Firefox 32 is ok with the instantiating the subclass but will + // throw when the map is used. + m.set(42, 42); + return m instanceof M; + }); + // without Object.setPrototypeOf, subclassing is not possible + var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing; + var mapRequiresNew = (function () { + try { + return !(globals.Map() instanceof globals.Map); + } catch (e) { + return e instanceof TypeError; + } + }()); + if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) { + globals.Map = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + var m = new OrigMap(); + if (arguments.length > 0) { + addIterableToMap(Map, m, arguments[0]); + } + delete m.constructor; + Object.setPrototypeOf(m, Map.prototype); + return m; + }; + globals.Map.prototype = OrigMap.prototype; + defineProperty(globals.Map.prototype, 'constructor', globals.Map, true); + Value.preserveToString(globals.Map, OrigMap); + } + var setSupportsSubclassing = supportsSubclassing(globals.Set, function (S) { + var s = new S([]); + s.add(42, 42); + return s instanceof S; + }); + // without Object.setPrototypeOf, subclassing is not possible + var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing; + var setRequiresNew = (function () { + try { + return !(globals.Set() instanceof globals.Set); + } catch (e) { + return e instanceof TypeError; + } + }()); + if (globals.Set.length !== 0 || setFailsToSupportSubclassing || !setRequiresNew) { + var OrigSet = globals.Set; + globals.Set = function Set() { + if (!(this instanceof Set)) { + throw new TypeError('Constructor Set requires "new"'); + } + var s = new OrigSet(); + if (arguments.length > 0) { + addIterableToSet(Set, s, arguments[0]); + } + delete s.constructor; + Object.setPrototypeOf(s, Set.prototype); + return s; + }; + globals.Set.prototype = OrigSet.prototype; + defineProperty(globals.Set.prototype, 'constructor', globals.Set, true); + Value.preserveToString(globals.Set, OrigSet); + } + var newMap = new globals.Map(); + var mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () { + return newMap.keys().next().done; + }); + /* + - In Firefox < 23, Map#size is a function. + - In all current Firefox, Set#entries/keys/values & Map#clear do not exist + - https://bugzilla.mozilla.org/show_bug.cgi?id=869996 + - In Firefox 24, Map and Set do not implement forEach + - In Firefox 25 at least, Map and Set are callable without "new" + */ + if ( + typeof globals.Map.prototype.clear !== 'function' || + new globals.Set().size !== 0 || + newMap.size !== 0 || + typeof globals.Map.prototype.keys !== 'function' || + typeof globals.Set.prototype.keys !== 'function' || + typeof globals.Map.prototype.forEach !== 'function' || + typeof globals.Set.prototype.forEach !== 'function' || + isCallableWithoutNew(globals.Map) || + isCallableWithoutNew(globals.Set) || + typeof newMap.keys().next !== 'function' || // Safari 8 + mapIterationThrowsStopIterator || // Firefox 25 + !mapSupportsSubclassing + ) { + defineProperties(globals, { + Map: collectionShims.Map, + Set: collectionShims.Set + }, true); + } + + if (globals.Set.prototype.keys !== globals.Set.prototype.values) { + // Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190 + defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true); + } + + // Shim incomplete iterator implementations. + addIterator(Object.getPrototypeOf((new globals.Map()).keys())); + addIterator(Object.getPrototypeOf((new globals.Set()).keys())); + + if (functionsHaveNames && globals.Set.prototype.has.name !== 'has') { + // Microsoft Edge v0.11.10074.0 is missing a name on Set#has + var anonymousSetHas = globals.Set.prototype.has; + overrideNative(globals.Set.prototype, 'has', function has(key) { + return _call(anonymousSetHas, this, key); + }); + } + } + defineProperties(globals, collectionShims); + addDefaultSpecies(globals.Map); + addDefaultSpecies(globals.Set); + } + + var throwUnlessTargetIsObject = function throwUnlessTargetIsObject(target) { + if (!ES.TypeIsObject(target)) { + throw new TypeError('target must be an object'); + } + }; + + // Some Reflect methods are basically the same as + // those on the Object global, except that a TypeError is thrown if + // target isn't an object. As well as returning a boolean indicating + // the success of the operation. + var ReflectShims = { + // Apply method in a functional form. + apply: function apply() { + return ES.Call(ES.Call, null, arguments); + }, + + // New operator in a functional form. + construct: function construct(constructor, args) { + if (!ES.IsConstructor(constructor)) { + throw new TypeError('First argument must be a constructor.'); + } + var newTarget = arguments.length > 2 ? arguments[2] : constructor; + if (!ES.IsConstructor(newTarget)) { + throw new TypeError('new.target must be a constructor.'); + } + return ES.Construct(constructor, args, newTarget, 'internal'); + }, + + // When deleting a non-existent or configurable property, + // true is returned. + // When attempting to delete a non-configurable property, + // it will return false. + deleteProperty: function deleteProperty(target, key) { + throwUnlessTargetIsObject(target); + if (supportsDescriptors) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (desc && !desc.configurable) { + return false; + } + } + + // Will return true. + return delete target[key]; + }, + + has: function has(target, key) { + throwUnlessTargetIsObject(target); + return key in target; + } + }; + + if (Object.getOwnPropertyNames) { + Object.assign(ReflectShims, { + // Basically the result of calling the internal [[OwnPropertyKeys]]. + // Concatenating propertyNames and propertySymbols should do the trick. + // This should continue to work together with a Symbol shim + // which overrides Object.getOwnPropertyNames and implements + // Object.getOwnPropertySymbols. + ownKeys: function ownKeys(target) { + throwUnlessTargetIsObject(target); + var keys = Object.getOwnPropertyNames(target); + + if (ES.IsCallable(Object.getOwnPropertySymbols)) { + _pushApply(keys, Object.getOwnPropertySymbols(target)); + } + + return keys; + } + }); + } + + var callAndCatchException = function ConvertExceptionToBoolean(func) { + return !throwsError(func); + }; + + if (Object.preventExtensions) { + Object.assign(ReflectShims, { + isExtensible: function isExtensible(target) { + throwUnlessTargetIsObject(target); + return Object.isExtensible(target); + }, + preventExtensions: function preventExtensions(target) { + throwUnlessTargetIsObject(target); + return callAndCatchException(function () { + return Object.preventExtensions(target); + }); + } + }); + } + + if (supportsDescriptors) { + var internalGet = function get(target, key, receiver) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (!desc) { + var parent = Object.getPrototypeOf(target); + + if (parent === null) { + return void 0; + } + + return internalGet(parent, key, receiver); + } + + if ('value' in desc) { + return desc.value; + } + + if (desc.get) { + return ES.Call(desc.get, receiver); + } + + return void 0; + }; + + var internalSet = function set(target, key, value, receiver) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (!desc) { + var parent = Object.getPrototypeOf(target); + + if (parent !== null) { + return internalSet(parent, key, value, receiver); + } + + desc = { + value: void 0, + writable: true, + enumerable: true, + configurable: true + }; + } + + if ('value' in desc) { + if (!desc.writable) { + return false; + } + + if (!ES.TypeIsObject(receiver)) { + return false; + } + + var existingDesc = Object.getOwnPropertyDescriptor(receiver, key); + + if (existingDesc) { + return Reflect.defineProperty(receiver, key, { + value: value + }); + } else { + return Reflect.defineProperty(receiver, key, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + } + } + + if (desc.set) { + _call(desc.set, receiver, value); + return true; + } + + return false; + }; + + Object.assign(ReflectShims, { + defineProperty: function defineProperty(target, propertyKey, attributes) { + throwUnlessTargetIsObject(target); + return callAndCatchException(function () { + return Object.defineProperty(target, propertyKey, attributes); + }); + }, + + getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { + throwUnlessTargetIsObject(target); + return Object.getOwnPropertyDescriptor(target, propertyKey); + }, + + // Syntax in a functional form. + get: function get(target, key) { + throwUnlessTargetIsObject(target); + var receiver = arguments.length > 2 ? arguments[2] : target; + + return internalGet(target, key, receiver); + }, + + set: function set(target, key, value) { + throwUnlessTargetIsObject(target); + var receiver = arguments.length > 3 ? arguments[3] : target; + + return internalSet(target, key, value, receiver); + } + }); + } + + if (Object.getPrototypeOf) { + var objectDotGetPrototypeOf = Object.getPrototypeOf; + ReflectShims.getPrototypeOf = function getPrototypeOf(target) { + throwUnlessTargetIsObject(target); + return objectDotGetPrototypeOf(target); + }; + } + + if (Object.setPrototypeOf && ReflectShims.getPrototypeOf) { + var willCreateCircularPrototype = function (object, lastProto) { + var proto = lastProto; + while (proto) { + if (object === proto) { + return true; + } + proto = ReflectShims.getPrototypeOf(proto); + } + return false; + }; + + Object.assign(ReflectShims, { + // Sets the prototype of the given object. + // Returns true on success, otherwise false. + setPrototypeOf: function setPrototypeOf(object, proto) { + throwUnlessTargetIsObject(object); + if (proto !== null && !ES.TypeIsObject(proto)) { + throw new TypeError('proto must be an object or null'); + } + + // If they already are the same, we're done. + if (proto === Reflect.getPrototypeOf(object)) { + return true; + } + + // Cannot alter prototype if object not extensible. + if (Reflect.isExtensible && !Reflect.isExtensible(object)) { + return false; + } + + // Ensure that we do not create a circular prototype chain. + if (willCreateCircularPrototype(object, proto)) { + return false; + } + + Object.setPrototypeOf(object, proto); + + return true; + } + }); + } + var defineOrOverrideReflectProperty = function (key, shim) { + if (!ES.IsCallable(globals.Reflect[key])) { + defineProperty(globals.Reflect, key, shim); + } else { + var acceptsPrimitives = valueOrFalseIfThrows(function () { + globals.Reflect[key](1); + globals.Reflect[key](NaN); + globals.Reflect[key](true); + return true; + }); + if (acceptsPrimitives) { + overrideNative(globals.Reflect, key, shim); + } + } + }; + Object.keys(ReflectShims).forEach(function (key) { + defineOrOverrideReflectProperty(key, ReflectShims[key]); + }); + var originalReflectGetProto = globals.Reflect.getPrototypeOf; + if (functionsHaveNames && originalReflectGetProto && originalReflectGetProto.name !== 'getPrototypeOf') { + overrideNative(globals.Reflect, 'getPrototypeOf', function getPrototypeOf(target) { + return _call(originalReflectGetProto, globals.Reflect, target); + }); + } + if (globals.Reflect.setPrototypeOf) { + if (valueOrFalseIfThrows(function () { + globals.Reflect.setPrototypeOf(1, {}); + return true; + })) { + overrideNative(globals.Reflect, 'setPrototypeOf', ReflectShims.setPrototypeOf); + } + } + if (globals.Reflect.defineProperty) { + if (!valueOrFalseIfThrows(function () { + var basic = !globals.Reflect.defineProperty(1, 'test', { value: 1 }); + // "extensible" fails on Edge 0.12 + var extensible = typeof Object.preventExtensions !== 'function' || !globals.Reflect.defineProperty(Object.preventExtensions({}), 'test', {}); + return basic && extensible; + })) { + overrideNative(globals.Reflect, 'defineProperty', ReflectShims.defineProperty); + } + } + if (globals.Reflect.construct) { + if (!valueOrFalseIfThrows(function () { + var F = function F() {}; + return globals.Reflect.construct(function () {}, [], F) instanceof F; + })) { + overrideNative(globals.Reflect, 'construct', ReflectShims.construct); + } + } + + if (String(new Date(NaN)) !== 'Invalid Date') { + var dateToString = Date.prototype.toString; + var shimmedDateToString = function toString() { + var valueOf = +this; + if (valueOf !== valueOf) { + return 'Invalid Date'; + } + return ES.Call(dateToString, this); + }; + overrideNative(Date.prototype, 'toString', shimmedDateToString); + } + + // Annex B HTML methods + // http://www.ecma-international.org/ecma-262/6.0/#sec-additional-properties-of-the-string.prototype-object + var stringHTMLshims = { + anchor: function anchor(name) { return ES.CreateHTML(this, 'a', 'name', name); }, + big: function big() { return ES.CreateHTML(this, 'big', '', ''); }, + blink: function blink() { return ES.CreateHTML(this, 'blink', '', ''); }, + bold: function bold() { return ES.CreateHTML(this, 'b', '', ''); }, + fixed: function fixed() { return ES.CreateHTML(this, 'tt', '', ''); }, + fontcolor: function fontcolor(color) { return ES.CreateHTML(this, 'font', 'color', color); }, + fontsize: function fontsize(size) { return ES.CreateHTML(this, 'font', 'size', size); }, + italics: function italics() { return ES.CreateHTML(this, 'i', '', ''); }, + link: function link(url) { return ES.CreateHTML(this, 'a', 'href', url); }, + small: function small() { return ES.CreateHTML(this, 'small', '', ''); }, + strike: function strike() { return ES.CreateHTML(this, 'strike', '', ''); }, + sub: function sub() { return ES.CreateHTML(this, 'sub', '', ''); }, + sup: function sub() { return ES.CreateHTML(this, 'sup', '', ''); } + }; + _forEach(Object.keys(stringHTMLshims), function (key) { + var method = String.prototype[key]; + var shouldOverwrite = false; + if (ES.IsCallable(method)) { + var output = _call(method, '', ' " '); + var quotesCount = _concat([], output.match(/"/g)).length; + shouldOverwrite = output !== output.toLowerCase() || quotesCount > 2; + } else { + shouldOverwrite = true; + } + if (shouldOverwrite) { + overrideNative(String.prototype, key, stringHTMLshims[key]); + } + }); + + var JSONstringifiesSymbols = (function () { + // Microsoft Edge v0.12 stringifies Symbols incorrectly + if (!hasSymbols) { return false; } // Symbols are not supported + var stringify = typeof JSON === 'object' && typeof JSON.stringify === 'function' ? JSON.stringify : null; + if (!stringify) { return false; } // JSON.stringify is not supported + if (typeof stringify(Symbol()) !== 'undefined') { return true; } // Symbols should become `undefined` + if (stringify([Symbol()]) !== '[null]') { return true; } // Symbols in arrays should become `null` + var obj = { a: Symbol() }; + obj[Symbol()] = true; + if (stringify(obj) !== '{}') { return true; } // Symbol-valued keys *and* Symbol-valued properties should be omitted + return false; + }()); + var JSONstringifyAcceptsObjectSymbol = valueOrFalseIfThrows(function () { + // Chrome 45 throws on stringifying object symbols + if (!hasSymbols) { return true; } // Symbols are not supported + return JSON.stringify(Object(Symbol())) === '{}' && JSON.stringify([Object(Symbol())]) === '[{}]'; + }); + if (JSONstringifiesSymbols || !JSONstringifyAcceptsObjectSymbol) { + var origStringify = JSON.stringify; + overrideNative(JSON, 'stringify', function stringify(value) { + if (typeof value === 'symbol') { return; } + var replacer; + if (arguments.length > 1) { + replacer = arguments[1]; + } + var args = [value]; + if (!isArray(replacer)) { + var replaceFn = ES.IsCallable(replacer) ? replacer : null; + var wrappedReplacer = function (key, val) { + var parsedValue = replaceFn ? _call(replaceFn, this, key, val) : val; + if (typeof parsedValue !== 'symbol') { + if (Type.symbol(parsedValue)) { + return assignTo({})(parsedValue); + } else { + return parsedValue; + } + } + }; + args.push(wrappedReplacer); + } else { + // create wrapped replacer that handles an array replacer? + args.push(replacer); + } + if (arguments.length > 2) { + args.push(arguments[2]); + } + return origStringify.apply(this, args); + }); + } + + return globals; +})); diff --git a/node_modules/es6-shim/es6-shim.map b/node_modules/es6-shim/es6-shim.map new file mode 100644 index 0000000..310db97 --- /dev/null +++ b/node_modules/es6-shim/es6-shim.map @@ -0,0 +1 @@ +{"version":3,"sources":["es6-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","_apply","Function","call","bind","apply","_call","isArray","Array","keys","Object","not","notThunker","func","notThunk","arguments","throwsError","e","valueOrFalseIfThrows","isCallableWithoutNew","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","functionsHaveNames","foo","name","_forEach","prototype","forEach","_reduce","reduce","_filter","filter","_some","some","object","value","force","configurable","enumerable","writable","defineProperties","map","forceOverride","method","_toString","toString","isCallable","IsCallableSlow","x","IsCallableFast","Value","getter","TypeError","proxy","originalObject","key","targetObject","originalDescriptor","getOwnPropertyDescriptor","getKey","set","setKey","redefine","property","newValue","descriptor","defineByDescriptor","preserveToString","target","source","create","properties","Prototype","supportsSubclassing","C","f","setPrototypeOf","Sub","Subclass","arg","o","constructor","getGlobal","self","window","global","Error","globals","globalIsFinite","isFinite","_indexOf","String","indexOf","_arrayIndexOfApply","_concat","concat","_strSlice","slice","_push","push","_pushApply","_shift","shift","_max","Math","max","_min","min","_floor","floor","_abs","abs","_exp","exp","_log","log","_sqrt","sqrt","_hasOwnProperty","hasOwnProperty","ArrayIterator","noop","OrigMap","Map","origMapDelete","origMapGet","origMapHas","has","origMapSet","Symbol","symbolSpecies","species","numberIsNaN","Number","isNaN","numberIsFinite","_sign","sign","number","_log1p","log1p","NaN","Infinity","isStandardArguments","isArguments","isLegacyArguments","length","callee","Type","primitive","string","regex","symbol","overrideNative","replacement","original","hasSymbols","$iterator$","iterator","Set","Reflect","$String","domAll","document","all","isNullOrUndefined","isNullOrUndefinedAndNotDocumentAll","ES","Call","F","V","args","IsCallable","RequireObjectCoercible","optMessage","TypeIsObject","ToObject","IsConstructor","ToInt32","ToNumber","ToUint32","ToInteger","ToLength","len","MAX_SAFE_INTEGER","SameValue","a","b","SameValueZero","IsIterable","GetIterator","itFn","GetMethod","it","p","IteratorComplete","iterResult","done","IteratorClose","completionIsThrow","returnMethod","innerResult","innerException","IteratorNext","result","next","IteratorStep","Construct","newTarget","isES6internal","construct","proto","obj","SpeciesConstructor","O","defaultConstructor","S","CreateHTML","tag","attribute","ToString","p1","escapedV","replace","p2","p3","IsRegExp","argument","isRegExp","match","defineWellKnownSymbol","sym","search","symbolSearch","originalSearch","RegExp","searchShim","regexp","searcher","symbolReplace","originalReplace","replaceValue","replaceShim","searchValue","replacer","split","symbolSplit","originalSplit","limit","splitShim","separator","splitter","symbolMatchExists","stringMatchIgnoresSymbolMatch","symbolMatch","originalMatch","matchShim","matcher","wrapConstructor","keysToSkip","getOwnPropertyNames","defaultSpeciesGetter","addDefaultSpecies","addIterator","impl","implementation","createDataProperty","createDataPropertyOrThrow","emulateES6construct","defaultNewTarget","defaultProto","slots","fromCodePoint","originalFromCodePoint","codePoints","StringShims","i","RangeError","fromCharCode","join","raw","callSite","cooked","rawString","literalsegments","stringElements","nextIndex","nextKey","nextSeg","nextSub","0","1","stringRepeat","repeat","s","times","half","stringMaxLength","StringPrototypeShims","thisStr","numTimes","startsWith","searchString","searchStr","position","start","endsWith","endPosition","pos","end","includes","codePointAt","first","charCodeAt","isEnd","second","startsWithRejectsRegex","startsWithHandlesInfinity","startsWithSupportsSymbolMatch","re","endsWithSupportsSymbolMatch","includesSupportsSymbolMatch","ws","trimRegexp","trimShim","trim","nonWS","nonWSregex","isBadHexRegex","hasStringTrimBug","iteratorResult","StringIterator","_s","_i","substr","ArrayShims","from","items","mapFn","mapping","T","usingIterator","nextValue","arrayLike","of","A","k","array","kind","retval","arrayOfSupportsSubclassing","Foo","fooArr","ArrayPrototypeShims","copyWithin","relativeTarget","relativeStart","to","relativeEnd","finalItem","count","direction","fill","find","predicate","list","thisArg","findIndex","values","entries","unscopables","originalArrayPrototypeValues","searchElement","getPrototypeOf","arrayFromSwallowsNegativeLengths","arrayFromHandlesIterables","arr","arrayFromHandlesUndefinedMapFunction","origArrayFrom","int32sAsOne","pow","toLengthsCorrectly","reversed","originalForEach","callbackFn","originalMap","originalFilter","originalSome","every","originalEvery","originalReduce","reduceRight","originalReduceRight","lacksOctalSupport","lacksBinarySupport","trimsNonWhitespace","c","OrigNumber","binaryRegex","octalRegex","isBinary","test","isOctal","toPrimitive","valueOf","hasNonWS","isBadHex","NumberShim","primValue","parseInt","receiver","valueOfSucceeds","MAX_VALUE","MIN_VALUE","NEGATIVE_INFINITY","POSITIVE_INFINITY","maxSafeInteger","MIN_SAFE_INTEGER","EPSILON","parseFloat","isInteger","isSafeInteger","isEnumerableOn","propertyIsEnumerable","ensureEnumerable","prop","sliceArgs","initial","desiredArgCount","assignTo","assignToSource","assignReducer","sourceKeys","symbols","getOwnPropertySymbols","ObjectShims","assign","is","assignHasPendingExceptions","preventExtensions","thrower","ES5ObjectShims","magic","checkArgs","polyfill","FAKENULL","gpo","spo","objectKeysAcceptsPrimitives","originalObjectKeys","objectKeysRejectsRegex","regexRejectingObjectKeys","regexKeys","objectGOPNAcceptsPrimitives","cachedWindowNames","originalObjectGetOwnPropertyNames","val","objectGOPDAcceptsPrimitives","originalObjectGetOwnPropertyDescriptor","seal","objectSealAcceptsPrimitives","originalObjectSeal","isSealed","objectIsSealedAcceptsPrimitives","originalObjectIsSealed","freeze","objectFreezeAcceptsPrimitives","originalObjectFreeze","isFrozen","objectIsFrozenAcceptsPrimitives","originalObjectIsFrozen","objectPreventExtensionsAcceptsPrimitives","originalObjectPreventExtensions","isExtensible","objectIsExtensibleAcceptsPrimitives","originalObjectIsExtensible","objectGetProtoAcceptsPrimitives","originalGetProto","hasFlags","desc","regExpFlagsGetter","flags","ignoreCase","multiline","unicode","sticky","regExpSupportsFlagsWithRegex","regExpNeedsToSupportSymbolMatch","regexToStringIsGeneric","regexToStringSupportsGenericFlags","origRegExpToString","R","pattern","flagsGetter","sourceDesc","legacySourceGetter","sourceGetter","OrigRegExp","RegExpShim","patternIsRegExp","calledWithNew","P","$input","regexGlobals","input","lastMatch","lastParen","leftContext","rightContext","inverseEpsilon","roundTiesToEven","n","BINARY_32_EPSILON","BINARY_32_MAX_VALUE","BINARY_32_MIN_VALUE","E","LOG2E","LOG10E","numberCLZ","clz","MathShims","acosh","xInvSquared","halfX","asinh","aSquared","atanh","cbrt","negate","clz32","cosh","t","expm1","sum","hypot","y","largest","log2","log10","sinh","u","tanh","trunc","imul","ah","al","bh","bl","fround","v","withinULPDistance","expected","distance","expm1OfTen","origMathRound","round","roundHandlesBoundaryConditions","smallestPositiveNumberWhereRoundBreaks","largestPositiveNumberWhereRoundBreaks","roundDoesNotIncreaseIntegers","num","ceil","origImul","PromiseShim","setTimeout","IsPromise","promise","_promise","PromiseCapability","capability","resolver","resolve","reject","makeZeroTimeout","postMessage","timeouts","messageName","setZeroTimeout","fn","handleMessage","event","data","stopPropagation","addEventListener","makePromiseAsap","Promise","pr","task","then","enqueue","setImmediate","process","nextTick","PROMISE_IDENTITY","PROMISE_THROWER","PROMISE_PENDING","PROMISE_FULFILLED","PROMISE_REJECTED","PROMISE_FULFILL_OFFSET","PROMISE_REJECT_OFFSET","PROMISE_CAPABILITY_OFFSET","PROMISE_FAKE_CAPABILITY","enqueuePromiseReactionJob","handler","promiseReactionJob","promiseCapability","handlerResult","fulfillPromise","reactionLength","fulfillReactionHandler0","reactionCapability0","rejectReactions0","idx","state","rejectPromise","reason","rejectReactionHandler0","createResolvingFunctions","alreadyResolved","resolution","promiseResolveThenableJob","optimizedThen","thenable","Promise$prototype$then","resolvingFunctions","Promise$prototype","_promiseAllResolver","index","remaining","alreadyCalled","performPromiseAll","iteratorRecord","resultCapability","nextPromise","resolveElement","performPromiseRace","iterable","exception","ee","race","rejectFunc","resolveFunc","catch","onRejected","onFulfilled","returnValueIsIgnored","fulfillReactionHandler","rejectReactionHandler","accept","defer","chain","promiseSupportsSubclassing","promiseIgnoresNonFunctionThenCallbacks","promiseRequiresObjectContext","promiseResolveBroken","getsThenSynchronously","BadResolverPromise","executor","hasBadResolverPromise","origAll","origRace","origResolve","origReject","r","testOrder","preservesInsertionOrder","preservesNumericInsertionOrder","fastkey","skipInsertionOrderCheck","emptyObject","addIterableToMap","MapConstructor","entry","iter","adder","nextItem","addIterableToSet","SetConstructor","add","collectionShims","empty","MapEntry","prev","isRemoved","isMap","_es6map","requireMapSlot","MapIterator","head","_head","isMapIterator","Map$prototype","MapShim","_map","_size","_storage","fkey","delete","clear","callback","context","isSet","_es6set","requireSetSlot","Set$prototype","SetShim","[[SetData]]","decodeKey","charAt","ensureMap","m","size","hasFKey","SetIterator","entireSet","isSetIterator","isGoogleTranslate","remove","mapAcceptsArguments","testMap","mapUsesSameValueZero","mapSupportsChaining","testSet","setUsesSameValueZero","setSupportsChaining","origSetAdd","origSetHas","origSetDel","SetDelete","mapSupportsSubclassing","M","mapFailsToSupportSubclassing","mapRequiresNew","setSupportsSubclassing","setFailsToSupportSubclassing","setRequiresNew","OrigSet","newMap","mapIterationThrowsStopIterator","anonymousSetHas","throwUnlessTargetIsObject","ReflectShims","deleteProperty","ownKeys","callAndCatchException","ConvertExceptionToBoolean","internalGet","parent","internalSet","existingDesc","propertyKey","attributes","objectDotGetPrototypeOf","willCreateCircularPrototype","lastProto","defineOrOverrideReflectProperty","shim","acceptsPrimitives","originalReflectGetProto","basic","extensible","Date","dateToString","shimmedDateToString","stringHTMLshims","anchor","big","blink","bold","fixed","fontcolor","color","fontsize","italics","link","url","small","strike","sub","sup","shouldOverwrite","output","quotesCount","toLowerCase","JSONstringifiesSymbols","stringify","JSON","JSONstringifyAcceptsObjectSymbol","origStringify","replaceFn","wrappedReplacer","parsedValue"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAEA,IAAIC,GAASC,SAASC,KAAKC,KAAKF,SAASG,MACzC,IAAIC,GAAQJ,SAASC,KAAKC,KAAKF,SAASC,KACxC,IAAII,GAAUC,MAAMD,OACpB,IAAIE,GAAOC,OAAOD,IAElB,IAAIE,GAAM,QAASC,YAAWC,GAC5B,MAAO,SAASC,YACd,OAAQb,EAAOY,EAAMb,KAAMe,YAG/B,IAAIC,GAAc,SAAUH,GAC1B,IACEA,GACA,OAAO,OACP,MAAOI,GACP,MAAO,OAGX,IAAIC,GAAuB,QAASA,sBAAqBL,GACvD,IACE,MAAOA,KACP,MAAOI,GACP,MAAO,QAIX,IAAIE,GAAuBR,EAAIK,EAC/B,IAAII,GAAkC,WAEpC,OAAQJ,EAAY,WAClB,MAAON,QAAOW,kBAAmB,KAAOC,IAAK,iBAGjD,IAAIC,KAAwBb,OAAOW,gBAAkBD,GACrD,IAAII,GAAqB,QAAUC,SAA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,GAAIvO,UAAUqI,OAAS,EAAG,CACxByB,EAAKxE,KAAKtF,UAAU,IAEtB,MAAOuwB,IAAcjxB,MAAML,KAAM6K,KAIrC,MAAOpF"} \ No newline at end of file diff --git a/node_modules/es6-shim/es6-shim.min.js b/node_modules/es6-shim/es6-shim.min.js new file mode 100644 index 0000000..aac1e6e --- /dev/null +++ b/node_modules/es6-shim/es6-shim.min.js @@ -0,0 +1,12 @@ +/*! + * https://github.com/paulmillr/es6-shim + * @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com) + * and contributors, MIT License + * es6-shim: v0.35.4 + * see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE + * Details and documentation: + * https://github.com/paulmillr/es6-shim/ + */ +(function(e,t){if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){"use strict";var e=Function.call.bind(Function.apply);var t=Function.call.bind(Function.call);var r=Array.isArray;var n=Object.keys;var o=function notThunker(t){return function notThunk(){return!e(t,this,arguments)}};var i=function(e){try{e();return false}catch(t){return true}};var a=function valueOrFalseIfThrows(e){try{return e()}catch(t){return false}};var u=o(i);var f=function(){return!i(function(){return Object.defineProperty({},"x",{get:function(){}})})};var s=!!Object.defineProperty&&f();var c=function foo(){}.name==="foo";var l=Function.call.bind(Array.prototype.forEach);var p=Function.call.bind(Array.prototype.reduce);var v=Function.call.bind(Array.prototype.filter);var y=Function.call.bind(Array.prototype.some);var h=function(e,t,r,n){if(!n&&t in e){return}if(s){Object.defineProperty(e,t,{configurable:true,enumerable:false,writable:true,value:r})}else{e[t]=r}};var b=function(e,t,r){l(n(t),function(n){var o=t[n];h(e,n,o,!!r)})};var g=Function.call.bind(Object.prototype.toString);var d=typeof/abc/==="function"?function IsCallableSlow(e){return typeof e==="function"&&g(e)==="[object Function]"}:function IsCallableFast(e){return typeof e==="function"};var m={getter:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}Object.defineProperty(e,t,{configurable:true,enumerable:false,get:r})},proxy:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,{configurable:n.configurable,enumerable:n.enumerable,get:function getKey(){return e[t]},set:function setKey(r){e[t]=r}})},redefine:function(e,t,r){if(s){var n=Object.getOwnPropertyDescriptor(e,t);n.value=r;Object.defineProperty(e,t,n)}else{e[t]=r}},defineByDescriptor:function(e,t,r){if(s){Object.defineProperty(e,t,r)}else if("value"in r){e[t]=r.value}},preserveToString:function(e,t){if(t&&d(t.toString)){h(e,"toString",t.toString.bind(t),true)}}};var O=Object.create||function(e,t){var r=function Prototype(){};r.prototype=e;var o=new r;if(typeof t!=="undefined"){n(t).forEach(function(e){m.defineByDescriptor(o,e,t[e])})}return o};var w=function(e,t){if(!Object.setPrototypeOf){return false}return a(function(){var r=function Subclass(t){var r=new e(t);Object.setPrototypeOf(r,Subclass.prototype);return r};Object.setPrototypeOf(r,e);r.prototype=O(e.prototype,{constructor:{value:r}});return t(r)})};var j=function(){if(typeof self!=="undefined"){return self}if(typeof window!=="undefined"){return window}if(typeof global!=="undefined"){return global}throw new Error("unable to locate global object")};var S=j();var T=S.isFinite;var I=Function.call.bind(String.prototype.indexOf);var E=Function.apply.bind(Array.prototype.indexOf);var P=Function.call.bind(Array.prototype.concat);var C=Function.call.bind(String.prototype.slice);var M=Function.call.bind(Array.prototype.push);var x=Function.apply.bind(Array.prototype.push);var N=Function.call.bind(Array.prototype.shift);var A=Math.max;var R=Math.min;var _=Math.floor;var k=Math.abs;var L=Math.exp;var F=Math.log;var D=Math.sqrt;var z=Function.call.bind(Object.prototype.hasOwnProperty);var q;var W=function(){};var G=S.Map;var H=G&&G.prototype["delete"];var V=G&&G.prototype.get;var B=G&&G.prototype.has;var U=G&&G.prototype.set;var $=S.Symbol||{};var J=$.species||"@@species";var X=Number.isNaN||function isNaN(e){return e!==e};var K=Number.isFinite||function isFinite(e){return typeof e==="number"&&T(e)};var Z=d(Math.sign)?Math.sign:function sign(e){var t=Number(e);if(t===0){return t}if(X(t)){return t}return t<0?-1:1};var Y=function log1p(e){var t=Number(e);if(t<-1||X(t)){return NaN}if(t===0||t===Infinity){return t}if(t===-1){return-Infinity}return 1+t-1===0?t:t*(F(1+t)/(1+t-1))};var Q=function isArguments(e){return g(e)==="[object Arguments]"};var ee=function isArguments(e){return e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&g(e)!=="[object Array]"&&g(e.callee)==="[object Function]"};var te=Q(arguments)?Q:ee;var re={primitive:function(e){return e===null||typeof e!=="function"&&typeof e!=="object"},string:function(e){return g(e)==="[object String]"},regex:function(e){return g(e)==="[object RegExp]"},symbol:function(e){return typeof S.Symbol==="function"&&typeof e==="symbol"}};var ne=function overrideNative(e,t,r){var n=e[t];h(e,t,r,true);m.preserveToString(e[t],n)};var oe=typeof $==="function"&&typeof $["for"]==="function"&&re.symbol($());var ie=re.symbol($.iterator)?$.iterator:"_es6-shim iterator_";if(S.Set&&typeof(new S.Set)["@@iterator"]==="function"){ie="@@iterator"}if(!S.Reflect){h(S,"Reflect",{},true)}var ae=S.Reflect;var ue=String;var fe=typeof document==="undefined"||!document?null:document.all;var se=fe==null?function isNullOrUndefined(e){return e==null}:function isNullOrUndefinedAndNotDocumentAll(e){return e==null&&e!==fe};var ce={Call:function Call(t,r){var n=arguments.length>2?arguments[2]:[];if(!ce.IsCallable(t)){throw new TypeError(t+" is not a function")}return e(t,r,n)},RequireObjectCoercible:function(e,t){if(se(e)){throw new TypeError(t||"Cannot call method on "+e)}return e},TypeIsObject:function(e){if(e===void 0||e===null||e===true||e===false){return false}return typeof e==="function"||typeof e==="object"||e===fe},ToObject:function(e,t){return Object(ce.RequireObjectCoercible(e,t))},IsCallable:d,IsConstructor:function(e){return ce.IsCallable(e)},ToInt32:function(e){return ce.ToNumber(e)>>0},ToUint32:function(e){return ce.ToNumber(e)>>>0},ToNumber:function(e){if(g(e)==="[object Symbol]"){throw new TypeError("Cannot convert a Symbol value to a number")}return+e},ToInteger:function(e){var t=ce.ToNumber(e);if(X(t)){return 0}if(t===0||!K(t)){return t}return(t>0?1:-1)*_(k(t))},ToLength:function(e){var t=ce.ToInteger(e);if(t<=0){return 0}if(t>Number.MAX_SAFE_INTEGER){return Number.MAX_SAFE_INTEGER}return t},SameValue:function(e,t){if(e===t){if(e===0){return 1/e===1/t}return true}return X(e)&&X(t)},SameValueZero:function(e,t){return e===t||X(e)&&X(t)},IsIterable:function(e){return ce.TypeIsObject(e)&&(typeof e[ie]!=="undefined"||te(e))},GetIterator:function(e){if(te(e)){return new q(e,"value")}var t=ce.GetMethod(e,ie);if(!ce.IsCallable(t)){throw new TypeError("value is not an iterable")}var r=ce.Call(t,e);if(!ce.TypeIsObject(r)){throw new TypeError("bad iterator")}return r},GetMethod:function(e,t){var r=ce.ToObject(e)[t];if(se(r)){return void 0}if(!ce.IsCallable(r)){throw new TypeError("Method not callable: "+t)}return r},IteratorComplete:function(e){return!!e.done},IteratorClose:function(e,t){var r=ce.GetMethod(e,"return");if(r===void 0){return}var n,o;try{n=ce.Call(r,e)}catch(i){o=i}if(t){return}if(o){throw o}if(!ce.TypeIsObject(n)){throw new TypeError("Iterator's return method returned a non-object.")}},IteratorNext:function(e){var t=arguments.length>1?e.next(arguments[1]):e.next();if(!ce.TypeIsObject(t)){throw new TypeError("bad iterator")}return t},IteratorStep:function(e){var t=ce.IteratorNext(e);var r=ce.IteratorComplete(t);return r?false:t},Construct:function(e,t,r,n){var o=typeof r==="undefined"?e:r;if(!n&&ae.construct){return ae.construct(e,t,o)}var i=o.prototype;if(!ce.TypeIsObject(i)){i=Object.prototype}var a=O(i);var u=ce.Call(e,a,t);return ce.TypeIsObject(u)?u:a},SpeciesConstructor:function(e,t){var r=e.constructor;if(r===void 0){return t}if(!ce.TypeIsObject(r)){throw new TypeError("Bad constructor")}var n=r[J];if(se(n)){return t}if(!ce.IsConstructor(n)){throw new TypeError("Bad @@species")}return n},CreateHTML:function(e,t,r,n){var o=ce.ToString(e);var i="<"+t;if(r!==""){var a=ce.ToString(n);var u=a.replace(/"/g,""");i+=" "+r+'="'+u+'"'}var f=i+">";var s=f+o;return s+""},IsRegExp:function IsRegExp(e){if(!ce.TypeIsObject(e)){return false}var t=e[$.match];if(typeof t!=="undefined"){return!!t}return re.regex(e)},ToString:function ToString(e){return ue(e)}};if(s&&oe){var le=function defineWellKnownSymbol(e){if(re.symbol($[e])){return $[e]}var t=$["for"]("Symbol."+e);Object.defineProperty($,e,{configurable:false,enumerable:false,writable:false,value:t});return t};if(!re.symbol($.search)){var pe=le("search");var ve=String.prototype.search;h(RegExp.prototype,pe,function search(e){return ce.Call(ve,e,[this])});var ye=function search(e){var t=ce.RequireObjectCoercible(this);if(!se(e)){var r=ce.GetMethod(e,pe);if(typeof r!=="undefined"){return ce.Call(r,e,[t])}}return ce.Call(ve,t,[ce.ToString(e)])};ne(String.prototype,"search",ye)}if(!re.symbol($.replace)){var he=le("replace");var be=String.prototype.replace;h(RegExp.prototype,he,function replace(e,t){return ce.Call(be,e,[this,t])});var ge=function replace(e,t){var r=ce.RequireObjectCoercible(this);if(!se(e)){var n=ce.GetMethod(e,he);if(typeof n!=="undefined"){return ce.Call(n,e,[r,t])}}return ce.Call(be,r,[ce.ToString(e),t])};ne(String.prototype,"replace",ge)}if(!re.symbol($.split)){var de=le("split");var me=String.prototype.split;h(RegExp.prototype,de,function split(e,t){return ce.Call(me,e,[this,t])});var Oe=function split(e,t){var r=ce.RequireObjectCoercible(this);if(!se(e)){var n=ce.GetMethod(e,de);if(typeof n!=="undefined"){return ce.Call(n,e,[r,t])}}return ce.Call(me,r,[ce.ToString(e),t])};ne(String.prototype,"split",Oe)}var we=re.symbol($.match);var je=we&&function(){var e={};e[$.match]=function(){return 42};return"a".match(e)!==42}();if(!we||je){var Se=le("match");var Te=String.prototype.match;h(RegExp.prototype,Se,function match(e){return ce.Call(Te,e,[this])});var Ie=function match(e){var t=ce.RequireObjectCoercible(this);if(!se(e)){var r=ce.GetMethod(e,Se);if(typeof r!=="undefined"){return ce.Call(r,e,[t])}}return ce.Call(Te,t,[ce.ToString(e)])};ne(String.prototype,"match",Ie)}}var Ee=function wrapConstructor(e,t,r){m.preserveToString(t,e);if(Object.setPrototypeOf){Object.setPrototypeOf(e,t)}if(s){l(Object.getOwnPropertyNames(e),function(n){if(n in W||r[n]){return}m.proxy(e,n,t)})}else{l(Object.keys(e),function(n){if(n in W||r[n]){return}t[n]=e[n]})}t.prototype=e.prototype;m.redefine(e.prototype,"constructor",t)};var Pe=function(){return this};var Ce=function(e){if(s&&!z(e,J)){m.getter(e,J,Pe)}};var Me=function(e,t){var r=t||function iterator(){return this};h(e,ie,r);if(!e[ie]&&re.symbol(ie)){e[ie]=r}};var xe=function createDataProperty(e,t,r){if(s){Object.defineProperty(e,t,{configurable:true,enumerable:true,writable:true,value:r})}else{e[t]=r}};var Ne=function createDataPropertyOrThrow(e,t,r){xe(e,t,r);if(!ce.SameValue(e[t],r)){throw new TypeError("property is nonconfigurable")}};var Ae=function(e,t,r,n){if(!ce.TypeIsObject(e)){throw new TypeError("Constructor requires `new`: "+t.name)}var o=t.prototype;if(!ce.TypeIsObject(o)){o=r}var i=O(o);for(var a in n){if(z(n,a)){var u=n[a];h(i,a,u,true)}}return i};if(String.fromCodePoint&&String.fromCodePoint.length!==1){var Re=String.fromCodePoint;ne(String,"fromCodePoint",function fromCodePoint(e){return ce.Call(Re,this,arguments)})}var _e={fromCodePoint:function fromCodePoint(e){var t=[];var r;for(var n=0,o=arguments.length;n1114111){throw new RangeError("Invalid code point "+r)}if(r<65536){M(t,String.fromCharCode(r))}else{r-=65536;M(t,String.fromCharCode((r>>10)+55296));M(t,String.fromCharCode(r%1024+56320))}}return t.join("")},raw:function raw(e){var t=ce.ToObject(e,"bad callSite");var r=ce.ToObject(t.raw,"bad raw value");var n=r.length;var o=ce.ToLength(n);if(o<=0){return""}var i=[];var a=0;var u,f,s,c;while(a=o){break}f=a+1=Le){throw new RangeError("repeat count must be less than infinity and not overflow maximum string size")}return ke(t,r)},startsWith:function startsWith(e){var t=ce.ToString(ce.RequireObjectCoercible(this));if(ce.IsRegExp(e)){throw new TypeError('Cannot call method "startsWith" with a regex')}var r=ce.ToString(e);var n;if(arguments.length>1){n=arguments[1]}var o=A(ce.ToInteger(n),0);return C(t,o,o+r.length)===r},endsWith:function endsWith(e){var t=ce.ToString(ce.RequireObjectCoercible(this));if(ce.IsRegExp(e)){throw new TypeError('Cannot call method "endsWith" with a regex')}var r=ce.ToString(e);var n=t.length;var o;if(arguments.length>1){o=arguments[1]}var i=typeof o==="undefined"?n:ce.ToInteger(o);var a=R(A(i,0),n);return C(t,a-r.length,a)===r},includes:function includes(e){if(ce.IsRegExp(e)){throw new TypeError('"includes" does not accept a RegExp')}var t=ce.ToString(e);var r;if(arguments.length>1){r=arguments[1]}return I(this,t,r)!==-1},codePointAt:function codePointAt(e){var t=ce.ToString(ce.RequireObjectCoercible(this));var r=ce.ToInteger(e);var n=t.length;if(r>=0&&r56319||i){return o}var a=t.charCodeAt(r+1);if(a<56320||a>57343){return o}return(o-55296)*1024+(a-56320)+65536}}};if(String.prototype.includes&&"a".includes("a",Infinity)!==false){ne(String.prototype,"includes",Fe.includes)}if(String.prototype.startsWith&&String.prototype.endsWith){var De=i(function(){return"/a/".startsWith(/a/)});var ze=a(function(){return"abc".startsWith("a",Infinity)===false});if(!De||!ze){ne(String.prototype,"startsWith",Fe.startsWith);ne(String.prototype,"endsWith",Fe.endsWith)}}if(oe){var qe=a(function(){var e=/a/;e[$.match]=false;return"/a/".startsWith(e)});if(!qe){ne(String.prototype,"startsWith",Fe.startsWith)}var We=a(function(){var e=/a/;e[$.match]=false;return"/a/".endsWith(e)});if(!We){ne(String.prototype,"endsWith",Fe.endsWith)}var Ge=a(function(){var e=/a/;e[$.match]=false;return"/a/".includes(e)});if(!Ge){ne(String.prototype,"includes",Fe.includes)}}b(String.prototype,Fe);var He=["\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"].join("");var Ve=new RegExp("(^["+He+"]+)|(["+He+"]+$)","g");var Be=function trim(){return ce.ToString(ce.RequireObjectCoercible(this)).replace(Ve,"")};var Ue=["\x85","\u200b","\ufffe"].join("");var $e=new RegExp("["+Ue+"]","g");var Je=/^[-+]0x[0-9a-f]+$/i;var Xe=Ue.trim().length!==Ue.length;h(String.prototype,"trim",Be,Xe);var Ke=function(e){return{value:e,done:arguments.length===0}};var Ze=function(e){ce.RequireObjectCoercible(e);this._s=ce.ToString(e);this._i=0};Ze.prototype.next=function(){var e=this._s;var t=this._i;if(typeof e==="undefined"||t>=e.length){this._s=void 0;return Ke()}var r=e.charCodeAt(t);var n,o;if(r<55296||r>56319||t+1===e.length){o=1}else{n=e.charCodeAt(t+1);o=n<56320||n>57343?1:2}this._i=t+o;return Ke(e.substr(t,o))};Me(Ze.prototype);Me(String.prototype,function(){return new Ze(this)});var Ye={from:function from(e){var r=this;var n;if(arguments.length>1){n=arguments[1]}var o,i;if(typeof n==="undefined"){o=false}else{if(!ce.IsCallable(n)){throw new TypeError("Array.from: when provided, the second argument must be a function")}if(arguments.length>2){i=arguments[2]}o=true}var a=typeof(te(e)||ce.GetMethod(e,ie))!=="undefined";var u,f,s;if(a){f=ce.IsConstructor(r)?Object(new r):[];var c=ce.GetIterator(e);var l,p;s=0;while(true){l=ce.IteratorStep(c);if(l===false){break}p=l.value;try{if(o){p=typeof i==="undefined"?n(p,s):t(n,i,p,s)}f[s]=p}catch(v){ce.IteratorClose(c,true);throw v}s+=1}u=s}else{var y=ce.ToObject(e);u=ce.ToLength(y.length);f=ce.IsConstructor(r)?Object(new r(u)):new Array(u);var h;for(s=0;s2){f=arguments[2]}var s=typeof f==="undefined"?n:ce.ToInteger(f);var c=s<0?A(n+s,0):R(s,n);var l=R(c-u,n-a);var p=1;if(u0){if(u in r){r[a]=r[u]}else{delete r[a]}u+=p;a+=p;l-=1}return r},fill:function fill(e){var t;if(arguments.length>1){t=arguments[1]}var r;if(arguments.length>2){r=arguments[2]}var n=ce.ToObject(this);var o=ce.ToLength(n.length);t=ce.ToInteger(typeof t==="undefined"?0:t);r=ce.ToInteger(typeof r==="undefined"?o:r);var i=t<0?A(o+t,0):R(t,o);var a=r<0?o+r:r;for(var u=i;u1?arguments[1]:null;for(var i=0,a;i1?arguments[1]:null;for(var i=0;i1&&typeof arguments[1]!=="undefined"){return ce.Call(it,this,arguments)}else{return t(it,this,e)}})}var at=-(Math.pow(2,32)-1);var ut=function(e,r){var n={length:at};n[r?(n.length>>>0)-1:0]=true;return a(function(){t(e,n,function(){throw new RangeError("should not reach here")},[]);return true})};if(!ut(Array.prototype.forEach)){var ft=Array.prototype.forEach;ne(Array.prototype,"forEach",function forEach(e){return ce.Call(ft,this.length>=0?this:[],arguments)},true)}if(!ut(Array.prototype.map)){var st=Array.prototype.map;ne(Array.prototype,"map",function map(e){return ce.Call(st,this.length>=0?this:[],arguments)},true)}if(!ut(Array.prototype.filter)){var ct=Array.prototype.filter;ne(Array.prototype,"filter",function filter(e){return ce.Call(ct,this.length>=0?this:[],arguments)},true)}if(!ut(Array.prototype.some)){var lt=Array.prototype.some;ne(Array.prototype,"some",function some(e){return ce.Call(lt,this.length>=0?this:[],arguments)},true)}if(!ut(Array.prototype.every)){var pt=Array.prototype.every;ne(Array.prototype,"every",function every(e){return ce.Call(pt,this.length>=0?this:[],arguments)},true)}if(!ut(Array.prototype.reduce)){var vt=Array.prototype.reduce;ne(Array.prototype,"reduce",function reduce(e){return ce.Call(vt,this.length>=0?this:[],arguments)},true)}if(!ut(Array.prototype.reduceRight,true)){var yt=Array.prototype.reduceRight;ne(Array.prototype,"reduceRight",function reduceRight(e){return ce.Call(yt,this.length>=0?this:[],arguments)},true)}var ht=Number("0o10")!==8;var bt=Number("0b10")!==2;var gt=y(Ue,function(e){return Number(e+0+e)===0});if(ht||bt||gt){var dt=Number;var mt=/^0b[01]+$/i;var Ot=/^0o[0-7]+$/i;var wt=mt.test.bind(mt);var jt=Ot.test.bind(Ot);var St=function(e){var t;if(typeof e.valueOf==="function"){t=e.valueOf();if(re.primitive(t)){return t}}if(typeof e.toString==="function"){t=e.toString();if(re.primitive(t)){return t}}throw new TypeError("No default value")};var Tt=$e.test.bind($e);var It=Je.test.bind(Je);var Et=function(){var e=function Number(t){var r;if(arguments.length>0){r=re.primitive(t)?t:St(t,"number")}else{r=0}if(typeof r==="string"){r=ce.Call(Be,r);if(wt(r)){r=parseInt(C(r,2),2)}else if(jt(r)){r=parseInt(C(r,2),8)}else if(Tt(r)||It(r)){r=NaN}}var n=this;var o=a(function(){dt.prototype.valueOf.call(n);return true});if(n instanceof e&&!o){return new dt(r)}return dt(r)};return e}();Ee(dt,Et,{});b(Et,{NaN:dt.NaN,MAX_VALUE:dt.MAX_VALUE,MIN_VALUE:dt.MIN_VALUE,NEGATIVE_INFINITY:dt.NEGATIVE_INFINITY,POSITIVE_INFINITY:dt.POSITIVE_INFINITY});Number=Et;m.redefine(S,"Number",Et)}var Pt=Math.pow(2,53)-1;b(Number,{MAX_SAFE_INTEGER:Pt,MIN_SAFE_INTEGER:-Pt,EPSILON:2.220446049250313e-16,parseInt:S.parseInt,parseFloat:S.parseFloat,isFinite:K,isInteger:function isInteger(e){return K(e)&&ce.ToInteger(e)===e},isSafeInteger:function isSafeInteger(e){return Number.isInteger(e)&&k(e)<=Number.MAX_SAFE_INTEGER},isNaN:X});h(Number,"parseInt",S.parseInt,Number.parseInt!==S.parseInt);if([,1].find(function(){return true})===1){ne(Array.prototype,"find",et.find)}if([,1].findIndex(function(){return true})!==0){ne(Array.prototype,"findIndex",et.findIndex)}var Ct=Function.bind.call(Function.bind,Object.prototype.propertyIsEnumerable);var Mt=function ensureEnumerable(e,t){if(s&&Ct(e,t)){Object.defineProperty(e,t,{enumerable:false})}};var xt=function sliceArgs(){var e=Number(this);var t=arguments.length;var r=t-e;var n=new Array(r<0?0:r);for(var o=e;o1){return NaN}var r=k(t);return Z(t)*Y(2*r/(1-r))/2},cbrt:function cbrt(e){var t=Number(e);if(t===0){return t}var r=t<0;var n;if(r){t=-t}if(t===Infinity){n=Infinity}else{n=L(F(t)/3);n=(t/(n*n)+2*n)/3}return r?-n:n},clz32:function clz32(e){var t=Number(e);var r=ce.ToUint32(t);if(r===0){return 32}return Pr?ce.Call(Pr,r):31-_(F(r+.5)*Ir)},cosh:function cosh(e){var t=Number(e);if(t===0){return 1}if(X(t)){return NaN}if(!T(t)){return Infinity}var r=L(k(t)-1);return(r+1/(r*Tr*Tr))*(Tr/2)},expm1:function expm1(e){var t=Number(e);if(t===-Infinity){return-1}if(!T(t)||t===0){return t}if(k(t)>.5){return L(t)-1}var r=t;var n=0;var o=1;while(n+r!==n){n+=r;o+=1;r*=t/o}return n},hypot:function hypot(e,t){var r=0;var n=0;for(var o=0;o0?i/n*(i/n):i}}return n===Infinity?Infinity:n*D(r)},log2:function log2(e){return F(e)*Ir},log10:function log10(e){return F(e)*Er},log1p:Y,sign:Z,sinh:function sinh(e){var t=Number(e);if(!T(t)||t===0){return t}var r=k(t);if(r<1){var n=Math.expm1(r);return Z(t)*n*(1+1/(n+1))/2}var o=L(r-1);return Z(t)*(o-1/(o*Tr*Tr))*(Tr/2)},tanh:function tanh(e){var t=Number(e);if(X(t)||t===0){return t}if(t>=20){return 1}if(t<=-20){return-1}return(Math.expm1(t)-Math.expm1(-t))/(L(t)+L(-t))},trunc:function trunc(e){var t=Number(e);return t<0?-_(-t):_(t)},imul:function imul(e,t){var r=ce.ToUint32(e);var n=ce.ToUint32(t);var o=r>>>16&65535;var i=r&65535;var a=n>>>16&65535;var u=n&65535;return i*u+(o*u+i*a<<16>>>0)|0},fround:function fround(e){var t=Number(e);if(t===0||t===Infinity||t===-Infinity||X(t)){return t}var r=Z(t);var n=k(t);if(njr||X(i)){return r*Infinity}return r*i}};var Mr=function withinULPDistance(e,t,r){return k(1-e/t)/Number.EPSILON<(r||8)};b(Math,Cr);h(Math,"sinh",Cr.sinh,Math.sinh(710)===Infinity);h(Math,"cosh",Cr.cosh,Math.cosh(710)===Infinity);h(Math,"log1p",Cr.log1p,Math.log1p(-1e-17)!==-1e-17);h(Math,"asinh",Cr.asinh,Math.asinh(-1e7)!==-Math.asinh(1e7));h(Math,"asinh",Cr.asinh,Math.asinh(1e300)===Infinity);h(Math,"atanh",Cr.atanh,Math.atanh(1e-300)===0);h(Math,"tanh",Cr.tanh,Math.tanh(-2e-17)!==-2e-17); +h(Math,"acosh",Cr.acosh,Math.acosh(Number.MAX_VALUE)===Infinity);h(Math,"acosh",Cr.acosh,!Mr(Math.acosh(1+Number.EPSILON),Math.sqrt(2*Number.EPSILON)));h(Math,"cbrt",Cr.cbrt,!Mr(Math.cbrt(1e-300),1e-100));h(Math,"sinh",Cr.sinh,Math.sinh(-2e-17)!==-2e-17);var xr=Math.expm1(10);h(Math,"expm1",Cr.expm1,xr>22025.465794806718||xr<22025.465794806718);var Nr=Math.round;var Ar=Math.round(.5-Number.EPSILON/4)===0&&Math.round(-.5+Number.EPSILON/3.99)===1;var Rr=mr+1;var _r=2*mr-1;var kr=[Rr,_r].every(function(e){return Math.round(e)===e});h(Math,"round",function round(e){var t=_(e);var r=t===-1?-0:t+1;return e-t<.5?t:r},!Ar||!kr);m.preserveToString(Math.round,Nr);var Lr=Math.imul;if(Math.imul(4294967295,5)!==-5){Math.imul=Cr.imul;m.preserveToString(Math.imul,Lr)}if(Math.imul.length!==2){ne(Math,"imul",function imul(e,t){return ce.Call(Lr,Math,arguments)})}var Fr=function(){var e=S.setTimeout;if(typeof e!=="function"&&typeof e!=="object"){return}ce.IsPromise=function(e){if(!ce.TypeIsObject(e)){return false}if(typeof e._promise==="undefined"){return false}return true};var r=function(e){if(!ce.IsConstructor(e)){throw new TypeError("Bad promise constructor")}var t=this;var r=function(e,r){if(t.resolve!==void 0||t.reject!==void 0){throw new TypeError("Bad Promise implementation!")}t.resolve=e;t.reject=r};t.resolve=void 0;t.reject=void 0;t.promise=new e(r);if(!(ce.IsCallable(t.resolve)&&ce.IsCallable(t.reject))){throw new TypeError("Bad promise constructor")}};var n;if(typeof window!=="undefined"&&ce.IsCallable(window.postMessage)){n=function(){var e=[];var t="zero-timeout-message";var r=function(r){M(e,r);window.postMessage(t,"*")};var n=function(r){if(r.source===window&&r.data===t){r.stopPropagation();if(e.length===0){return}var n=N(e);n()}};window.addEventListener("message",n,true);return r}}var o=function(){var e=S.Promise;var t=e&&e.resolve&&e.resolve();return t&&function(e){return t.then(e)}};var i=ce.IsCallable(S.setImmediate)?S.setImmediate:typeof process==="object"&&process.nextTick?process.nextTick:o()||(ce.IsCallable(n)?n():function(t){e(t,0)});var a=function(e){return e};var u=function(e){throw e};var f=0;var s=1;var c=2;var l=0;var p=1;var v=2;var y={};var h=function(e,t,r){i(function(){g(e,t,r)})};var g=function(e,t,r){var n,o;if(t===y){return e(r)}try{n=e(r);o=t.resolve}catch(i){n=i;o=t.reject}o(n)};var d=function(e,t){var r=e._promise;var n=r.reactionLength;if(n>0){h(r.fulfillReactionHandler0,r.reactionCapability0,t);r.fulfillReactionHandler0=void 0;r.rejectReactions0=void 0;r.reactionCapability0=void 0;if(n>1){for(var o=1,i=0;o0){h(r.rejectReactionHandler0,r.reactionCapability0,t);r.fulfillReactionHandler0=void 0;r.rejectReactions0=void 0;r.reactionCapability0=void 0;if(n>1){for(var o=1,i=0;o2&&arguments[2]===y;if(b&&o===E){i=y}else{i=new r(o)}var g=ce.IsCallable(e)?e:a;var d=ce.IsCallable(t)?t:u;var m=n._promise;var O;if(m.state===f){if(m.reactionLength===0){m.fulfillReactionHandler0=g;m.rejectReactionHandler0=d;m.reactionCapability0=i}else{var w=3*(m.reactionLength-1);m[w+l]=g;m[w+p]=d;m[w+v]=i}m.reactionLength+=1}else if(m.state===s){O=m.result;h(g,i,O)}else if(m.state===c){O=m.result;h(d,i,O)}else{throw new TypeError("unexpected Promise state")}return i.promise}});y=new r(E);I=T.then;return E}();if(S.Promise){delete S.Promise.accept;delete S.Promise.defer;delete S.Promise.prototype.chain}if(typeof Fr==="function"){b(S,{Promise:Fr});var Dr=w(S.Promise,function(e){return e.resolve(42).then(function(){})instanceof e});var zr=!i(function(){return S.Promise.reject(42).then(null,5).then(null,W)});var qr=i(function(){return S.Promise.call(3,W)});var Wr=function(e){var t=e.resolve(5);t.constructor={};var r=e.resolve(t);try{r.then(null,W).then(null,W)}catch(n){return true}return t===r}(S.Promise);var Gr=s&&function(){var e=0;var t=Object.defineProperty({},"then",{get:function(){e+=1}});Promise.resolve(t);return e===1}();var Hr=function BadResolverPromise(e){var t=new Promise(e);e(3,function(){});this.then=t.then;this.constructor=BadResolverPromise};Hr.prototype=Promise.prototype;Hr.all=Promise.all;var Vr=a(function(){return!!Hr.all([1,2])});if(!Dr||!zr||!qr||Wr||!Gr||Vr){Promise=Fr;ne(S,"Promise",Fr)}if(Promise.all.length!==1){var Br=Promise.all;ne(Promise,"all",function all(e){return ce.Call(Br,this,arguments)})}if(Promise.race.length!==1){var Ur=Promise.race;ne(Promise,"race",function race(e){return ce.Call(Ur,this,arguments)})}if(Promise.resolve.length!==1){var $r=Promise.resolve;ne(Promise,"resolve",function resolve(e){return ce.Call($r,this,arguments)})}if(Promise.reject.length!==1){var Jr=Promise.reject;ne(Promise,"reject",function reject(e){return ce.Call(Jr,this,arguments)})}Mt(Promise,"all");Mt(Promise,"race");Mt(Promise,"resolve");Mt(Promise,"reject");Ce(Promise)}var Xr=function(e){var t=n(p(e,function(e,t){e[t]=true;return e},{}));return e.join(":")===t.join(":")};var Kr=Xr(["z","a","bb"]);var Zr=Xr(["z",1,"a","3",2]);if(s){var Yr=function fastkey(e,t){if(!t&&!Kr){return null}if(se(e)){return"^"+ce.ToString(e)}else if(typeof e==="string"){return"$"+e}else if(typeof e==="number"){if(!Zr){return"n"+e}return e}else if(typeof e==="boolean"){return"b"+e}return null};var Qr=function emptyObject(){return Object.create?Object.create(null):{}};var en=function addIterableToMap(e,n,o){if(r(o)||re.string(o)){l(o,function(e){if(!ce.TypeIsObject(e)){throw new TypeError("Iterator value "+e+" is not an entry object")}n.set(e[0],e[1])})}else if(o instanceof e){t(e.prototype.forEach,o,function(e,t){n.set(t,e)})}else{var i,a;if(!se(o)){a=n.set;if(!ce.IsCallable(a)){throw new TypeError("bad map")}i=ce.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=ce.IteratorStep(i);if(u===false){break}var f=u.value;try{if(!ce.TypeIsObject(f)){throw new TypeError("Iterator value "+f+" is not an entry object")}t(a,n,f[0],f[1])}catch(s){ce.IteratorClose(i,true);throw s}}}}};var tn=function addIterableToSet(e,n,o){if(r(o)||re.string(o)){l(o,function(e){n.add(e)})}else if(o instanceof e){t(e.prototype.forEach,o,function(e){n.add(e)})}else{var i,a;if(!se(o)){a=n.add;if(!ce.IsCallable(a)){throw new TypeError("bad set")}i=ce.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=ce.IteratorStep(i);if(u===false){break}var f=u.value;try{t(a,n,f)}catch(s){ce.IteratorClose(i,true);throw s}}}}};var rn={Map:function(){var e={};var r=function MapEntry(e,t){this.key=e;this.value=t;this.next=null;this.prev=null};r.prototype.isRemoved=function isRemoved(){return this.key===e};var n=function isMap(e){return!!e._es6map};var o=function requireMapSlot(e,t){if(!ce.TypeIsObject(e)||!n(e)){throw new TypeError("Method Map.prototype."+t+" called on incompatible receiver "+ce.ToString(e))}};var i=function MapIterator(e,t){o(e,"[[MapIterator]]");this.head=e._head;this.i=this.head;this.kind=t};i.prototype={isMapIterator:true,next:function next(){if(!this.isMapIterator){throw new TypeError("Not a MapIterator")}var e=this.i;var t=this.kind;var r=this.head;if(typeof this.i==="undefined"){return Ke()}while(e.isRemoved()&&e!==r){e=e.prev}var n;while(e.next!==r){e=e.next;if(!e.isRemoved()){if(t==="key"){n=e.key}else if(t==="value"){n=e.value}else{n=[e.key,e.value]}this.i=e;return Ke(n)}}this.i=void 0;return Ke()}};Me(i.prototype);var a;var u=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}if(this&&this._es6map){throw new TypeError("Bad construction")}var e=Ae(this,Map,a,{_es6map:true,_head:null,_map:G?new G:null,_size:0,_storage:Qr()});var t=new r(null,null);t.next=t.prev=t;e._head=t;if(arguments.length>0){en(Map,e,arguments[0])}return e};a=u.prototype;m.getter(a,"size",function(){if(typeof this._size==="undefined"){throw new TypeError("size method called on incompatible Map")}return this._size});b(a,{get:function get(e){o(this,"get");var t;var r=Yr(e,true);if(r!==null){t=this._storage[r];if(t){return t.value}else{return}}if(this._map){t=V.call(this._map,e);if(t){return t.value}else{return}}var n=this._head;var i=n;while((i=i.next)!==n){if(ce.SameValueZero(i.key,e)){return i.value}}},has:function has(e){o(this,"has");var t=Yr(e,true);if(t!==null){return typeof this._storage[t]!=="undefined"}if(this._map){return B.call(this._map,e)}var r=this._head;var n=r;while((n=n.next)!==r){if(ce.SameValueZero(n.key,e)){return true}}return false},set:function set(e,t){o(this,"set");var n=this._head;var i=n;var a;var u=Yr(e,true);if(u!==null){if(typeof this._storage[u]!=="undefined"){this._storage[u].value=t;return this}else{a=this._storage[u]=new r(e,t);i=n.prev}}else if(this._map){if(B.call(this._map,e)){V.call(this._map,e).value=t}else{a=new r(e,t);U.call(this._map,e,a);i=n.prev}}while((i=i.next)!==n){if(ce.SameValueZero(i.key,e)){i.value=t;return this}}a=a||new r(e,t);if(ce.SameValue(-0,e)){a.key=+0}a.next=this._head;a.prev=this._head.prev;a.prev.next=a;a.next.prev=a;this._size+=1;return this},"delete":function(t){o(this,"delete");var r=this._head;var n=r;var i=Yr(t,true);if(i!==null){if(typeof this._storage[i]==="undefined"){return false}n=this._storage[i].prev;delete this._storage[i]}else if(this._map){if(!B.call(this._map,t)){return false}n=V.call(this._map,t).prev;H.call(this._map,t)}while((n=n.next)!==r){if(ce.SameValueZero(n.key,t)){n.key=e;n.value=e;n.prev.next=n.next;n.next.prev=n.prev;this._size-=1;return true}}return false},clear:function clear(){o(this,"clear");this._map=G?new G:null;this._size=0;this._storage=Qr();var t=this._head;var r=t;var n=r.next;while((r=n)!==t){r.key=e;r.value=e;n=r.next;r.next=r.prev=t}t.next=t.prev=t},keys:function keys(){o(this,"keys");return new i(this,"key")},values:function values(){o(this,"values");return new i(this,"value")},entries:function entries(){o(this,"entries");return new i(this,"key+value")},forEach:function forEach(e){o(this,"forEach");var r=arguments.length>1?arguments[1]:null;var n=this.entries();for(var i=n.next();!i.done;i=n.next()){if(r){t(e,r,i.value[1],i.value[0],this)}else{e(i.value[1],i.value[0],this)}}}});Me(a,a.entries);return u}(),Set:function(){var e=function isSet(e){return e._es6set&&typeof e._storage!=="undefined"};var r=function requireSetSlot(t,r){if(!ce.TypeIsObject(t)||!e(t)){throw new TypeError("Set.prototype."+r+" called on incompatible receiver "+ce.ToString(t))}};var o;var i=function Set(){if(!(this instanceof Set)){throw new TypeError('Constructor Set requires "new"')}if(this&&this._es6set){throw new TypeError("Bad construction")}var e=Ae(this,Set,o,{_es6set:true,"[[SetData]]":null,_storage:Qr()});if(!e._es6set){throw new TypeError("bad set")}if(arguments.length>0){tn(Set,e,arguments[0])}return e};o=i.prototype;var a=function(e){var t=e;if(t==="^null"){return null}else if(t==="^undefined"){return void 0}else{var r=t.charAt(0);if(r==="$"){return C(t,1)}else if(r==="n"){return+C(t,1)}else if(r==="b"){return t==="btrue"}}return+t};var u=function ensureMap(e){if(!e["[[SetData]]"]){var t=new rn.Map;e["[[SetData]]"]=t;l(n(e._storage),function(e){var r=a(e);t.set(r,r)});e["[[SetData]]"]=t}e._storage=null};m.getter(i.prototype,"size",function(){r(this,"size");if(this._storage){return n(this._storage).length}u(this);return this["[[SetData]]"].size});b(i.prototype,{has:function has(e){r(this,"has");var t;if(this._storage&&(t=Yr(e))!==null){return!!this._storage[t]}u(this);return this["[[SetData]]"].has(e)},add:function add(e){r(this,"add");var t;if(this._storage&&(t=Yr(e))!==null){this._storage[t]=true;return this}u(this);this["[[SetData]]"].set(e,e);return this},"delete":function(e){r(this,"delete");var t;if(this._storage&&(t=Yr(e))!==null){var n=z(this._storage,t);return delete this._storage[t]&&n}u(this);return this["[[SetData]]"]["delete"](e)},clear:function clear(){r(this,"clear");if(this._storage){this._storage=Qr()}if(this["[[SetData]]"]){this["[[SetData]]"].clear()}},values:function values(){r(this,"values");u(this);return new f(this["[[SetData]]"].values())},entries:function entries(){r(this,"entries");u(this);return new f(this["[[SetData]]"].entries())},forEach:function forEach(e){r(this,"forEach");var n=arguments.length>1?arguments[1]:null;var o=this;u(o);this["[[SetData]]"].forEach(function(r,i){if(n){t(e,n,i,i,o)}else{e(i,i,o)}})}});h(i.prototype,"keys",i.prototype.values,true);Me(i.prototype,i.prototype.values);var f=function SetIterator(e){this.it=e};f.prototype={isSetIterator:true,next:function next(){if(!this.isSetIterator){throw new TypeError("Not a SetIterator")}return this.it.next()}};Me(f.prototype);return i}()};var nn=S.Set&&!Set.prototype["delete"]&&Set.prototype.remove&&Set.prototype.items&&Set.prototype.map&&Array.isArray((new Set).keys);if(nn){S.Set=rn.Set}if(S.Map||S.Set){var on=a(function(){return new Map([[1,2]]).get(1)===2});if(!on){S.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new G;if(arguments.length>0){en(Map,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,S.Map.prototype);return e};S.Map.prototype=O(G.prototype);h(S.Map.prototype,"constructor",S.Map,true);m.preserveToString(S.Map,G)}var an=new Map;var un=function(){var e=new Map([[1,0],[2,0],[3,0],[4,0]]);e.set(-0,e);return e.get(0)===e&&e.get(-0)===e&&e.has(0)&&e.has(-0)}();var fn=an.set(1,2)===an;if(!un||!fn){ne(Map.prototype,"set",function set(e,r){t(U,this,e===0?0:e,r);return this})}if(!un){b(Map.prototype,{get:function get(e){return t(V,this,e===0?0:e)},has:function has(e){return t(B,this,e===0?0:e)}},true);m.preserveToString(Map.prototype.get,V);m.preserveToString(Map.prototype.has,B)}var sn=new Set;var cn=Set.prototype["delete"]&&Set.prototype.add&&Set.prototype.has&&function(e){e["delete"](0);e.add(-0);return!e.has(0)}(sn);var ln=sn.add(1)===sn;if(!cn||!ln){var pn=Set.prototype.add;Set.prototype.add=function add(e){t(pn,this,e===0?0:e);return this};m.preserveToString(Set.prototype.add,pn)}if(!cn){var vn=Set.prototype.has;Set.prototype.has=function has(e){return t(vn,this,e===0?0:e)};m.preserveToString(Set.prototype.has,vn);var yn=Set.prototype["delete"];Set.prototype["delete"]=function SetDelete(e){return t(yn,this,e===0?0:e)};m.preserveToString(Set.prototype["delete"],yn)}var hn=w(S.Map,function(e){var t=new e([]);t.set(42,42);return t instanceof e});var bn=Object.setPrototypeOf&&!hn;var gn=function(){try{return!(S.Map()instanceof S.Map)}catch(e){return e instanceof TypeError}}();if(S.Map.length!==0||bn||!gn){S.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new G;if(arguments.length>0){en(Map,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,Map.prototype);return e};S.Map.prototype=G.prototype;h(S.Map.prototype,"constructor",S.Map,true);m.preserveToString(S.Map,G)}var dn=w(S.Set,function(e){var t=new e([]);t.add(42,42);return t instanceof e});var mn=Object.setPrototypeOf&&!dn;var On=function(){try{return!(S.Set()instanceof S.Set)}catch(e){return e instanceof TypeError}}();if(S.Set.length!==0||mn||!On){var wn=S.Set;S.Set=function Set(){if(!(this instanceof Set)){throw new TypeError('Constructor Set requires "new"')}var e=new wn;if(arguments.length>0){tn(Set,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,Set.prototype);return e};S.Set.prototype=wn.prototype;h(S.Set.prototype,"constructor",S.Set,true);m.preserveToString(S.Set,wn)}var jn=new S.Map;var Sn=!a(function(){return jn.keys().next().done});if(typeof S.Map.prototype.clear!=="function"||(new S.Set).size!==0||jn.size!==0||typeof S.Map.prototype.keys!=="function"||typeof S.Set.prototype.keys!=="function"||typeof S.Map.prototype.forEach!=="function"||typeof S.Set.prototype.forEach!=="function"||u(S.Map)||u(S.Set)||typeof jn.keys().next!=="function"||Sn||!hn){b(S,{Map:rn.Map,Set:rn.Set},true)}if(S.Set.prototype.keys!==S.Set.prototype.values){h(S.Set.prototype,"keys",S.Set.prototype.values,true)}Me(Object.getPrototypeOf((new S.Map).keys()));Me(Object.getPrototypeOf((new S.Set).keys()));if(c&&S.Set.prototype.has.name!=="has"){var Tn=S.Set.prototype.has;ne(S.Set.prototype,"has",function has(e){return t(Tn,this,e)})}}b(S,rn);Ce(S.Map);Ce(S.Set)}var In=function throwUnlessTargetIsObject(e){if(!ce.TypeIsObject(e)){throw new TypeError("target must be an object")}};var En={apply:function apply(){return ce.Call(ce.Call,null,arguments)},construct:function construct(e,t){if(!ce.IsConstructor(e)){throw new TypeError("First argument must be a constructor.")}var r=arguments.length>2?arguments[2]:e;if(!ce.IsConstructor(r)){throw new TypeError("new.target must be a constructor.")}return ce.Construct(e,t,r,"internal")},deleteProperty:function deleteProperty(e,t){In(e);if(s){var r=Object.getOwnPropertyDescriptor(e,t);if(r&&!r.configurable){return false}}return delete e[t]},has:function has(e,t){In(e);return t in e}};if(Object.getOwnPropertyNames){Object.assign(En,{ownKeys:function ownKeys(e){In(e);var t=Object.getOwnPropertyNames(e);if(ce.IsCallable(Object.getOwnPropertySymbols)){x(t,Object.getOwnPropertySymbols(e))}return t}})}var Pn=function ConvertExceptionToBoolean(e){return!i(e)};if(Object.preventExtensions){Object.assign(En,{isExtensible:function isExtensible(e){In(e);return Object.isExtensible(e)},preventExtensions:function preventExtensions(e){In(e);return Pn(function(){return Object.preventExtensions(e)})}})}if(s){var Cn=function get(e,t,r){var n=Object.getOwnPropertyDescriptor(e,t);if(!n){var o=Object.getPrototypeOf(e);if(o===null){return void 0}return Cn(o,t,r)}if("value"in n){return n.value}if(n.get){return ce.Call(n.get,r)}return void 0};var Mn=function set(e,r,n,o){var i=Object.getOwnPropertyDescriptor(e,r);if(!i){var a=Object.getPrototypeOf(e);if(a!==null){return Mn(a,r,n,o)}i={value:void 0,writable:true,enumerable:true,configurable:true}}if("value"in i){if(!i.writable){return false}if(!ce.TypeIsObject(o)){return false}var u=Object.getOwnPropertyDescriptor(o,r);if(u){return ae.defineProperty(o,r,{value:n})}else{return ae.defineProperty(o,r,{value:n,writable:true,enumerable:true,configurable:true})}}if(i.set){t(i.set,o,n);return true}return false};Object.assign(En,{defineProperty:function defineProperty(e,t,r){In(e);return Pn(function(){return Object.defineProperty(e,t,r)})},getOwnPropertyDescriptor:function getOwnPropertyDescriptor(e,t){In(e);return Object.getOwnPropertyDescriptor(e,t)},get:function get(e,t){In(e);var r=arguments.length>2?arguments[2]:e;return Cn(e,t,r)},set:function set(e,t,r){In(e);var n=arguments.length>3?arguments[3]:e;return Mn(e,t,r,n)}})}if(Object.getPrototypeOf){var xn=Object.getPrototypeOf;En.getPrototypeOf=function getPrototypeOf(e){In(e);return xn(e)}}if(Object.setPrototypeOf&&En.getPrototypeOf){var Nn=function(e,t){var r=t;while(r){if(e===r){return true}r=En.getPrototypeOf(r)}return false};Object.assign(En,{setPrototypeOf:function setPrototypeOf(e,t){In(e);if(t!==null&&!ce.TypeIsObject(t)){throw new TypeError("proto must be an object or null")}if(t===ae.getPrototypeOf(e)){return true}if(ae.isExtensible&&!ae.isExtensible(e)){return false}if(Nn(e,t)){return false}Object.setPrototypeOf(e,t);return true}})}var An=function(e,t){if(!ce.IsCallable(S.Reflect[e])){h(S.Reflect,e,t)}else{var r=a(function(){S.Reflect[e](1);S.Reflect[e](NaN);S.Reflect[e](true);return true});if(r){ne(S.Reflect,e,t)}}};Object.keys(En).forEach(function(e){An(e,En[e])});var Rn=S.Reflect.getPrototypeOf;if(c&&Rn&&Rn.name!=="getPrototypeOf"){ne(S.Reflect,"getPrototypeOf",function getPrototypeOf(e){return t(Rn,S.Reflect,e)})}if(S.Reflect.setPrototypeOf){if(a(function(){S.Reflect.setPrototypeOf(1,{});return true})){ne(S.Reflect,"setPrototypeOf",En.setPrototypeOf)}}if(S.Reflect.defineProperty){if(!a(function(){var e=!S.Reflect.defineProperty(1,"test",{value:1});var t=typeof Object.preventExtensions!=="function"||!S.Reflect.defineProperty(Object.preventExtensions({}),"test",{});return e&&t})){ne(S.Reflect,"defineProperty",En.defineProperty)}}if(S.Reflect.construct){if(!a(function(){var e=function F(){};return S.Reflect.construct(function(){},[],e)instanceof e})){ne(S.Reflect,"construct",En.construct)}}if(String(new Date(NaN))!=="Invalid Date"){var _n=Date.prototype.toString;var kn=function toString(){var e=+this;if(e!==e){return"Invalid Date"}return ce.Call(_n,this)};ne(Date.prototype,"toString",kn)}var Ln={anchor:function anchor(e){return ce.CreateHTML(this,"a","name",e)},big:function big(){return ce.CreateHTML(this,"big","","")},blink:function blink(){return ce.CreateHTML(this,"blink","","")},bold:function bold(){return ce.CreateHTML(this,"b","","")},fixed:function fixed(){return ce.CreateHTML(this,"tt","","")},fontcolor:function fontcolor(e){return ce.CreateHTML(this,"font","color",e)},fontsize:function fontsize(e){return ce.CreateHTML(this,"font","size",e)},italics:function italics(){return ce.CreateHTML(this,"i","","")},link:function link(e){return ce.CreateHTML(this,"a","href",e)},small:function small(){return ce.CreateHTML(this,"small","","")},strike:function strike(){return ce.CreateHTML(this,"strike","","")},sub:function sub(){return ce.CreateHTML(this,"sub","","")},sup:function sub(){return ce.CreateHTML(this,"sup","","")}};l(Object.keys(Ln),function(e){var r=String.prototype[e];var n=false;if(ce.IsCallable(r)){var o=t(r,"",' " ');var i=P([],o.match(/"/g)).length;n=o!==o.toLowerCase()||i>2}else{n=true}if(n){ne(String.prototype,e,Ln[e])}});var Fn=function(){if(!oe){return false}var e=typeof JSON==="object"&&typeof JSON.stringify==="function"?JSON.stringify:null;if(!e){return false}if(typeof e($())!=="undefined"){return true}if(e([$()])!=="[null]"){return true}var t={a:$()};t[$()]=true;if(e(t)!=="{}"){return true}return false}();var Dn=a(function(){if(!oe){return true}return JSON.stringify(Object($()))==="{}"&&JSON.stringify([Object($())])==="[{}]"});if(Fn||!Dn){var zn=JSON.stringify;ne(JSON,"stringify",function stringify(e){if(typeof e==="symbol"){return}var n;if(arguments.length>1){n=arguments[1]}var o=[e];if(!r(n)){var i=ce.IsCallable(n)?n:null;var a=function(e,r){var n=i?t(i,this,e,r):r;if(typeof n!=="symbol"){if(re.symbol(n)){return Nt({})(n)}else{return n}}};o.push(a)}else{o.push(n)}if(arguments.length>2){o.push(arguments[2])}return zn.apply(this,o)})}return S}); +//# sourceMappingURL=es6-shim.map diff --git a/node_modules/es6-shim/package.json b/node_modules/es6-shim/package.json new file mode 100644 index 0000000..e49f485 --- /dev/null +++ b/node_modules/es6-shim/package.json @@ -0,0 +1,110 @@ +{ + "_from": "es6-shim", + "_id": "es6-shim@0.35.5", + "_inBundle": false, + "_integrity": "sha512-E9kK/bjtCQRpN1K28Xh4BlmP8egvZBGJJ+9GtnzOwt7mdqtrjHFuVGr7QJfdjBIKqrlU5duPf3pCBoDrkjVYFg==", + "_location": "/es6-shim", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "es6-shim", + "name": "es6-shim", + "escapedName": "es6-shim", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.5.tgz", + "_shasum": "46f59dc0a84a1c5029e8ff1166ca0a902077a9ab", + "_spec": "es6-shim", + "_where": "C:\\Users\\knh94\\Documents\\GitHub\\welsonjs\\node_modules", + "author": { + "name": "Paul Miller", + "url": "http://paulmillr.com" + }, + "bugs": { + "url": "https://github.com/paulmillr/es6-shim/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", + "devDependencies": { + "@ljharb/eslint-config": "^13.1.1", + "chai": "^3.5.0", + "es5-shim": "^4.5.12", + "eslint": "^5.15.1", + "evalmd": "^0.0.17", + "grunt": "^0.4.5", + "grunt-contrib-connect": "^1.0.2", + "grunt-contrib-watch": "^1.1.0", + "grunt-saucelabs": "^8.6.3", + "mocha": "^3.5.3", + "promises-aplus-tests": "^2.1.2", + "promises-es6-tests": "^0.5.0", + "safe-publish-latest": "^1.1.2", + "uglify-js": "2.7.3" + }, + "homepage": "https://github.com/paulmillr/es6-shim/", + "keywords": [ + "ecmascript", + "harmony", + "es6", + "shim", + "promise", + "promises", + "setPrototypeOf", + "map", + "set", + "__proto__" + ], + "license": "MIT", + "main": "es6-shim", + "name": "es6-shim", + "repository": { + "type": "git", + "url": "git://github.com/paulmillr/es6-shim.git" + }, + "scripts": { + "lint": "npm run lint:shim && npm run lint:sham", + "lint:sham": "eslint es6-sham.js test-sham/*.js", + "lint:shim": "eslint es6-shim.js test/*.js test/*/*.js", + "minify": "npm run minify:shim && npm run minify:sham", + "minify:sham": "uglifyjs es6-sham.js --support-ie8 --keep-fnames --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js", + "minify:shim": "uglifyjs es6-shim.js --support-ie8 --keep-fnames --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js", + "prepublish": "safe-publish-latest && npm run minify", + "pretest": "npm run lint && evalmd *.md", + "sauce": "npm run sauce-connect && grunt sauce", + "sauce-connect": "curl -L https://gist.githubusercontent.com/henrikhodne/9322897/raw/sauce-connect.sh | bash && export TRAVIS_SAUCE_CONNECT=true", + "test": "npm run tests-only", + "test:native": "NO_ES6_SHIM=1 npm run tests-only", + "test:sham": "mocha test-sham/*.js", + "test:shim": "mocha test/*.js test/*/*.js", + "tests-only": "npm run test:shim && npm run test:sham" + }, + "testling": { + "html": "testling.html", + "browsers": [ + "iexplore/6.0..latest", + "firefox/3.0..6.0", + "firefox/10.0", + "firefox/15.0..latest", + "firefox/nightly", + "chrome/4.0..10.0", + "chrome/20.0..latest", + "chrome/canary", + "opera/10.0..latest", + "opera/next", + "safari/4.0..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "0.35.5" +} diff --git a/node_modules/es6-shim/test-sham/.eslintrc b/node_modules/es6-shim/test-sham/.eslintrc new file mode 100644 index 0000000..1a13a3e --- /dev/null +++ b/node_modules/es6-shim/test-sham/.eslintrc @@ -0,0 +1,8 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "expect": false + } +} diff --git a/node_modules/es6-shim/test-sham/function.js b/node_modules/es6-shim/test-sham/function.js new file mode 100644 index 0000000..bbf5e8a --- /dev/null +++ b/node_modules/es6-shim/test-sham/function.js @@ -0,0 +1,58 @@ +var identity = function (x) { return x; }; + +describe('Function', function () { + describe('#name', function () { + it('returns the name for named functions', function () { + var foo = function bar() {}; + expect(foo.name).to.equal('bar'); + + // pre-ES6, this property is nonconfigurable. + var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(foo, 'name').configurable : false; + + expect(foo).to.have.ownPropertyDescriptor('name', { + configurable: !!configurable, + enumerable: false, + writable: false, + value: 'bar' + }); + }); + + it('does not poison every name when accessed on Function.prototype', function () { + expect((function foo() {}).name).to.equal('foo'); + expect(Function.prototype.name).to.equal(''); + expect((function foo() {}).name).to.equal('foo'); + }); + + it('returns empty string for anonymous functions', function () { + var anon = identity(function () {}); + expect(anon.name).to.equal(''); + + // pre-ES6, this property is nonconfigurable. + var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(anon, 'name').configurable : false; + + expect(anon).to.have.ownPropertyDescriptor('name', { + configurable: !!configurable, + enumerable: false, + writable: false, + value: '' + }); + }); + + it('returns "anomymous" for Function functions', function () { + // eslint-disable-next-line no-new-func + var func = identity(Function('')); + expect(typeof func.name).to.equal('string'); + expect(func.name === 'anonymous' || func.name === '').to.equal(true); + + // pre-ES6, this property is nonconfigurable. + var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(func, 'name').configurable : false; + + expect(func).to.have.ownPropertyDescriptor('name', { + configurable: !!configurable, + enumerable: false, + writable: false, + value: func.name + }); + }); + }); +}); diff --git a/node_modules/es6-shim/test-sham/index.html b/node_modules/es6-shim/test-sham/index.html new file mode 100644 index 0000000..2919ad4 --- /dev/null +++ b/node_modules/es6-shim/test-sham/index.html @@ -0,0 +1,23 @@ + + + + + es6-shim tests + + + + + + + + + + + + + + +
    + + + diff --git a/node_modules/es6-shim/test-sham/set-prototype-of.js b/node_modules/es6-shim/test-sham/set-prototype-of.js new file mode 100644 index 0000000..ac044a1 --- /dev/null +++ b/node_modules/es6-shim/test-sham/set-prototype-of.js @@ -0,0 +1,26 @@ +/* global expect, describe, it */ + +describe('Object.setPrototypeOf(o, p)', function () { + 'use strict'; + + it('changes prototype to regular objects', function () { + var obj = { a: 123 }; + expect(obj instanceof Object).to.equal(true); + // sham requires assignment to work cross browser + obj = Object.setPrototypeOf(obj, null); + expect(obj instanceof Object).to.equal(false); + expect(obj.a).to.equal(123); + }); + + it('changes prototype to null objects', function () { + var obj = Object.create(null); + obj.a = 456; + expect(obj instanceof Object).to.equal(false); + expect(obj.a).to.equal(456); + // sham requires assignment to work cross browser + obj = Object.setPrototypeOf(obj, { b: 789 }); + expect(obj instanceof Object).to.equal(true); + expect(obj.a).to.equal(456); + expect(obj.b).to.equal(789); + }); +}); diff --git a/node_modules/es6-shim/test/.eslintrc b/node_modules/es6-shim/test/.eslintrc new file mode 100644 index 0000000..cf28ac6 --- /dev/null +++ b/node_modules/es6-shim/test/.eslintrc @@ -0,0 +1,21 @@ +{ + "rules": { + "array-callback-return": 0, + "func-name-matching": 0, + "max-lines-per-function": 0, + "max-statements-per-line": [2, { "max": 2 }], + "no-restricted-properties": 1, + "symbol-description": 0, + "prefer-promise-reject-errors": 0, + "consistent-return": 0, + }, + "env": { + "mocha": true + }, + "globals": { + "Symbol": false, + "Promise": false, + "expect": false, + "assert": false + } +} diff --git a/node_modules/es6-shim/test/array.js b/node_modules/es6-shim/test/array.js new file mode 100644 index 0000000..67afe08 --- /dev/null +++ b/node_modules/es6-shim/test/array.js @@ -0,0 +1,1009 @@ +var runArrayTests = function (it) { + 'use strict'; + + var Sym = typeof Symbol === 'undefined' ? {} : Symbol; + var isSymbol = function (sym) { + return typeof Sym === 'function' && typeof sym === 'symbol'; + }; + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : it.skip; + var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : it.skip; + var ifSymbolIteratorAndArrayValuesIt = isSymbol(Sym.iterator) && Array.prototype.values ? it : it.skip; + var ifSymbolUnscopablesIt = isSymbol(Sym.unscopables) ? it : it.skip; + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + var ifSupportsDescriptorsIt = Object.getOwnPropertyDescriptor ? it : it.skip; + + var isNegativeZero = function (x) { + return (1 / x) < 0; + }; + + describe('Array', function () { + var list = [5, 10, 15, 20]; + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Array).to.equal(Array); + }); + + describe('@@iterator', function () { + ifSymbolIteratorIt('uses Symbol.iterator if available', function () { + var b = {}; + var c = {}; + var a = [b, c]; + var iteratorFn = a[Sym.iterator]; + var iterator = iteratorFn.call(a); + expect(iterator.next()).to.eql({ done: false, value: b }); + expect(iterator.next()).to.eql({ done: false, value: c }); + expect(iterator.next()).to.eql({ done: true, value: undefined }); + }); + + ifSymbolIteratorAndArrayValuesIt('has the right default iteration function', function () { + // fixed in Webkit https://bugs.webkit.org/show_bug.cgi?id=143838 + expect(Array.prototype).to.have.property(Sym.iterator, Array.prototype.values); + }); + }); + + describe('.from()', function () { + if (!Object.prototype.hasOwnProperty.call(Array, 'from')) { + return it('exists', function () { + expect(Array).to.have.property('from'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.from).to.have.property('name', 'from'); + }); + + it('has the right arity', function () { + expect(Array.from).to.have.property('length', 1); + }); + + it('is not enumerable', function () { + expect(Array).ownPropertyDescriptor('from').to.have.property('enumerable', false); + }); + + it('works with primitives', function () { + expect(Array.from(false)).to.eql([]); + expect(Array.from(true)).to.eql([]); + expect(Array.from(-Infinity)).to.eql([]); + expect(Array.from(-0)).to.eql([]); + expect(Array.from(0)).to.eql([]); + expect(Array.from(1)).to.eql([]); + expect(Array.from(Infinity)).to.eql([]); + }); + + it('should create correct array from iterable', function () { + (function () { + expect(Array.from(arguments)).to.eql([0, 1, 2]); + }(0, 1, 2)); + + expect(Array.from([null, undefined, 0.1248, -0, 0])).to.eql([null, undefined, 0.1248, -0, 0]); + + if (Array.prototype.values) { + expect(Array.from([null, undefined, 0.1248, -0, 0].values())).to.eql([null, undefined, 0.1248, -0, 0]); + } + }); + + it('works with arraylike objects', function () { + expect(Array.from({ length: 1 })).to.eql([undefined]); + expect(Array.from({ 0: 'a', 1: 'b', length: 2 })).to.eql(['a', 'b']); + }); + + it('swallows negative lengths', function () { + expect(Array.from({ length: -1 })).to.have.property('length', 0); + expect(Array.from({ length: -Infinity })).to.have.property('length', 0); + expect(Array.from({ length: -0 })).to.have.property('length', 0); + expect(Array.from({ length: -42 })).to.have.property('length', 0); + }); + + it('works with strings', function () { + expect(Array.from('')).to.eql([]); + expect(Array.from('abc')).to.eql('abc'.split('')); + }); + + it('should handle empty iterables correctly', function () { + (function () { + expect(Array.from(arguments)).to.eql([]); + }()); + expect(Array.from([])).to.eql([]); + expect(Array.from({})).to.eql([]); + expect(Array.from({ a: 1 })).to.eql([]); + }); + + it('should work with other constructors', function () { + var Foo = function FooBar(length, args) { + this.args = args; + this.length = length; + }; + var args = ['a', 'b', 'c']; + var expected = new Foo(args.length); + args.forEach(function (arg, index) { + expected[index] = arg; + }); + expect(Array.from.call(Foo, args)).to.be.an.instanceOf(Foo); + expect(Array.from.call(Foo, args)).to.eql(expected); + }); + + describe('map functions', function () { + it('supports a map function', function () { + var original = [1, 2, 3]; + var mapper = function (item) { + return item * 2; + }; + var mapped = Array.from(original, mapper); + expect(mapped).to.eql([2, 4, 6]); + }); + + it('passes both (and only) the item and the current index to the map function', function () { + var original = [1, 2, 3]; + var expectedItems = [1, 2, 3]; + var expectedIndices = [0, 1, 2]; + + var actualItems = []; + var actualIndices = []; + var mapper = function (item, index) { + actualItems.push(item); + actualIndices.push(index); + expect(arguments).to.have.property('length', 2); + return item; + }; + + var mapped = Array.from(original, mapper); + expect(mapped).to.eql(expectedItems); + expect(actualItems).to.eql(expectedItems); + expect(actualIndices).to.eql(expectedIndices); + }); + + it('passes both the item and the current index to the map function with a "this" value', function () { + var original = [1, 2, 3]; + var expectedItems = [1, 2, 3]; + var expectedIndices = [0, 1, 2]; + var expectedContext = {}; + + var actualItems = []; + var actualIndices = []; + var mapper = function (item, index) { + actualItems.push(item); + actualIndices.push(index); + expect(arguments).to.have.property('length', 2); + expect(this).to.eql(expectedContext); + return item; + }; + + var mapped = Array.from(original, mapper, expectedContext); + expect(mapped).to.eql(expectedItems); + expect(actualItems).to.eql(expectedItems); + expect(actualIndices).to.eql(expectedIndices); + }); + + it('accepts an object thisArg', function () { + var context = {}; + Array.from([1, 2, 3], function () { + expect(this).to.equal(context); + }, context); + }); + + it('accepts a primitive thisArg', function () { + Array.from([1, 2, 3], function () { + expect(this.valueOf()).to.equal(42); + expect(Object.prototype.toString.call(this)).to.equal('[object Number]'); + }, 42); + }); + + it('accepts a falsy thisArg', function () { + Array.from([1, 2, 3], function () { + expect(this.valueOf()).to.equal(false); + expect(Object.prototype.toString.call(this)).to.equal('[object Boolean]'); + }, false); + }); + }); + + it('does not throw when provided an undefined second arg', function () { + expect(Array.from([], undefined)).to.eql([]); + }); + + it('throws when provided a nonfunction second arg', function () { + expect(function () { Array.from([], null); }).to['throw'](TypeError); + expect(function () { Array.from([], false); }).to['throw'](TypeError); + expect(function () { Array.from([], true); }).to['throw'](TypeError); + expect(function () { Array.from([], /a/g); }).to['throw'](TypeError); + expect(function () { Array.from([], {}); }).to['throw'](TypeError); + expect(function () { Array.from([], []); }).to['throw'](TypeError); + expect(function () { Array.from([], ''); }).to['throw'](TypeError); + expect(function () { Array.from([], 3); }).to['throw'](TypeError); + }); + + it('supports a this arg', function () { + var original = [1, 2, 3]; + var context = {}; + var mapper = function (item) { + expect(this).to.equal(context); + return item * 2; + }; + var mapped = Array.from(original, mapper, context); + expect(mapped).to.eql([2, 4, 6]); + }); + + it('throws when provided null or undefined', function () { + expect(function () { Array.from(); }).to['throw'](TypeError); + expect(function () { Array.from(undefined); }).to['throw'](TypeError); + expect(function () { Array.from(null); }).to['throw'](TypeError); + }); + + it('removes holes', function () { + /* eslint-disable no-sparse-arrays */ + var input = [0, , 2]; + var result = Array.from([0, , 2]); + /* eslint-enable no-sparse-arrays */ + expect(1 in input).to.equal(false); + expect(1 in result).to.equal(true); + expect(result).to.eql([0, undefined, 2]); + }); + + it('works with this flaky example', function () { + expect(Array.from([1, NaN, false])).to.eql([1, NaN, false]); + }); + + ifSupportsDescriptorsIt('works when Object.prototype has a throwing setter', function () { + // TODO: breaks in Chrome 17, IE 9, Safari 5.1-6 + var key = 10; + /* eslint no-extend-native: 0 */ + Object.defineProperty(Object.prototype, key, { + configurable: true, + get: function () {}, // eslint-disable-line getter-return + set: function (v) { throw new EvalError('boom'); } + }); + expect(function () { + var arr = []; + arr[key] = 42; + }).to['throw'](EvalError); // assert thrower + + expect(function () { Array.from({ length: key + 1 }); }).not.to['throw'](); + + delete Object.prototype[key]; + expect(key in Object.prototype).to.equal(false); // assert cleanup + }); + }); + + describe('.of()', function () { + if (!Object.prototype.hasOwnProperty.call(Array, 'of')) { + return it('exists', function () { + expect(Array).to.have.property('of'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.of).to.have.property('name', 'of'); + }); + + it('has the right arity', function () { + expect(Array.of).to.have.property('length', 0); + }); + + it('is not enumerable', function () { + expect(Array).ownPropertyDescriptor('of').to.have.property('enumerable', false); + }); + + it('should create correct array from arguments', function () { + expect(Array.of(1, null, undefined)).to.eql([1, null, undefined]); + }); + + it('should work with other constructors', function () { + var Foo = function FooBar(length) { + this.args = Array.prototype.slice.call(arguments, 1); + this.length = length; + }; + var args = ['a', 'b', 'c']; + var expected = new Foo(args.length); + args.forEach(function (arg, index) { + expected[index] = arg; + }); + expect(Array.of.apply(Foo, args)).to.be.an.instanceOf(Foo); + expect(Array.of.apply(Foo, args)).to.eql(expected); + }); + + describe('without Array.from', function () { + var originalFrom = Array.from; + beforeEach(function () { + Array.from = 42; + }); + + afterEach(function () { + Array.from = originalFrom; + }); + + it('still works', function () { + expect(Array.of(1, 2, 3)).to.eql([1, 2, 3]); + }); + }); + }); + + describe('#copyWithin()', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'copyWithin')) { + return it('exists', function () { + expect(Array.prototype).to.have.property('copyWithin'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.prototype.copyWithin).to.have.property('name', 'copyWithin'); + }); + + it('has the right arity', function () { + expect(Array.prototype.copyWithin).to.have.property('length', 2); + }); + + it('is not enumerable', function () { + expect(Array.prototype).ownPropertyDescriptor('copyWithin').to.have.property('enumerable', false); + }); + + it('modifies the object in-place', function () { + var arr = [1, 2, 3, 4, 5]; + expect(arr.copyWithin(0, 3)).to.eql([4, 5, 3, 4, 5]); + expect(arr).to.eql([4, 5, 3, 4, 5]); + }); + + it('works with 2 args', function () { + expect([1, 2, 3, 4, 5].copyWithin(0, 3)).to.eql([4, 5, 3, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(1, 3)).to.eql([1, 4, 5, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(1, 2)).to.eql([1, 3, 4, 5, 5]); + expect([1, 2, 3, 4, 5].copyWithin(2, 2)).to.eql([1, 2, 3, 4, 5]); + }); + + it('works with 3 args', function () { + expect([1, 2, 3, 4, 5].copyWithin(0, 3, 4)).to.eql([4, 2, 3, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(1, 3, 4)).to.eql([1, 4, 3, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(1, 2, 4)).to.eql([1, 3, 4, 4, 5]); + }); + + it('works with negative args', function () { + expect([1, 2, 3, 4, 5].copyWithin(0, -2)).to.eql([4, 5, 3, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(0, -2, -1)).to.eql([4, 2, 3, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(-4, -3, -2)).to.eql([1, 3, 3, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(-4, -3, -1)).to.eql([1, 3, 4, 4, 5]); + expect([1, 2, 3, 4, 5].copyWithin(-4, -3)).to.eql([1, 3, 4, 5, 5]); + }); + + it('works with arraylike objects', function () { + var args = (function () { return arguments; }(1, 2, 3)); + expect(Array.isArray(args)).to.equal(false); + var argsClass = Object.prototype.toString.call(args); + expect(Array.prototype.slice.call(args)).to.eql([1, 2, 3]); + Array.prototype.copyWithin.call(args, -2, 0); + expect(Array.prototype.slice.call(args)).to.eql([1, 1, 2]); + expect(Object.prototype.toString.call(args)).to.equal(argsClass); + }); + + ifSymbolUnscopablesIt('should be unscopable if Symbols exist', function () { + var unscopables = Array.prototype[Sym.unscopables]; + expect(!!unscopables).to.equal(true); + expect(unscopables.copyWithin).to.equal(true); + }); + + it('should delete the target key if the source key is not present', function () { + /* eslint-disable no-sparse-arrays */ + expect([, 1, 2].copyWithin(1, 0)).to.eql([, , 1]); + /* eslint-enable no-sparse-arrays */ + }); + + it('should check inherited properties as well', function () { + var Parent = function Parent() {}; + Parent.prototype[0] = 'foo'; + var sparse = new Parent(); + sparse[1] = 1; + sparse[2] = 2; + sparse.length = 3; + var result = Array.prototype.copyWithin.call(sparse, 1, 0); + expect(result).to.have.property('0'); + expect(result).not.to.have.ownProperty('0'); + expect(result).to.have.ownProperty('1'); + expect(result).to.eql({ 0: 'foo', 1: 'foo', 2: 1, length: 3 }); + }); + }); + + describe('#find()', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'find')) { + return it('exists', function () { + expect(Array.prototype).to.have.property('find'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.prototype.find).to.have.property('name', 'find'); + }); + + it('should have the right arity', function () { + expect(Array.prototype.find).to.have.property('length', 1); + }); + + it('is not enumerable', function () { + expect(Array.prototype).ownPropertyDescriptor('find').to.have.property('enumerable', false); + }); + + it('should find item by predicate', function () { + var result = list.find(function (item) { return item === 15; }); + expect(result).to.equal(15); + }); + + it('should return undefined when nothing matched', function () { + var result = list.find(function (item) { return item === 'a'; }); + expect(result).to.equal(undefined); + }); + + it('should throw TypeError when function was not passed', function () { + expect(function () { list.find(); }).to['throw'](TypeError); + }); + + it('should receive all three parameters', function () { + var foundIndex = list.find(function (value, index, arr) { + expect(list).to.have.property(index, value); + expect(list).to.eql(arr); + return false; + }); + expect(foundIndex).to.equal(undefined); + }); + + it('should work with the context argument', function () { + var context = {}; + [1].find(function () { expect(this).to.equal(context); }, context); + }); + + it('should work with an array-like object', function () { + var obj = { 0: 1, 1: 2, 2: 3, length: 3 }; + var found = Array.prototype.find.call(obj, function (item) { return item === 2; }); + expect(found).to.equal(2); + }); + + it('should work with an array-like object with negative length', function () { + var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; + var found = Array.prototype.find.call(obj, function () { + throw new Error('should not reach here'); + }); + expect(found).to.equal(undefined); + }); + + it('should work with a sparse array', function () { + /* eslint-disable no-sparse-arrays */ + var obj = [1, , undefined]; + /* eslint-enable no-sparse-arrays */ + expect(1 in obj).to.equal(false); + var seen = []; + var found = obj.find(function (item, idx) { + seen.push([idx, item]); + return false; + }); + expect(found).to.equal(undefined); + expect(seen).to.eql([[0, 1], [1, undefined], [2, undefined]]); + }); + + it('should work with a sparse array-like object', function () { + var obj = { 0: 1, 2: undefined, length: 3.2 }; + var seen = []; + var found = Array.prototype.find.call(obj, function (item, idx) { + seen.push([idx, item]); + return false; + }); + expect(found).to.equal(undefined); + expect(seen).to.eql([[0, 1], [1, undefined], [2, undefined]]); + }); + + ifSymbolUnscopablesIt('should be unscopable if Symbols exist', function () { + var unscopables = Array.prototype[Sym.unscopables]; + expect(!!unscopables).to.equal(true); + expect(unscopables.find).to.equal(true); + }); + }); + + describe('#findIndex()', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'findIndex')) { + return it('exists', function () { + expect(Array.prototype).to.have.property('findIndex'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.prototype.findIndex).to.have.property('name', 'findIndex'); + }); + + it('should have the right arity', function () { + expect(Array.prototype.findIndex).to.have.property('length', 1); + }); + + it('is not enumerable', function () { + expect(Array.prototype).ownPropertyDescriptor('findIndex').to.have.property('enumerable', false); + }); + + it('should find item key by predicate', function () { + var result = list.findIndex(function (item) { return item === 15; }); + expect(result).to.equal(2); + }); + + it('should return -1 when nothing matched', function () { + var result = list.findIndex(function (item) { return item === 'a'; }); + expect(result).to.equal(-1); + }); + + it('should throw TypeError when function was not passed', function () { + expect(function () { list.findIndex(); }).to['throw'](TypeError); + }); + + it('should receive all three parameters', function () { + var foundIndex = list.findIndex(function (value, index, arr) { + expect(list[index]).to.equal(value); + expect(list).to.eql(arr); + return false; + }); + expect(foundIndex).to.equal(-1); + }); + + it('should work with the context argument', function () { + var context = {}; + [1].findIndex(function () { expect(this).to.equal(context); }, context); + }); + + it('should work with an array-like object', function () { + var obj = { 0: 1, 1: 2, 2: 3, length: 3 }; + var foundIndex = Array.prototype.findIndex.call(obj, function (item) { return item === 2; }); + expect(foundIndex).to.equal(1); + }); + + it('should work with an array-like object with negative length', function () { + var obj = { 0: 1, 1: 2, 2: 3, length: -3 }; + var foundIndex = Array.prototype.findIndex.call(obj, function () { + throw new Error('should not reach here'); + }); + expect(foundIndex).to.equal(-1); + }); + + it('should work with a sparse array', function () { + /* eslint-disable no-sparse-arrays */ + var obj = [1, , undefined]; + /* eslint-enable no-sparse-arrays */ + expect(1 in obj).to.equal(false); + var seen = []; + var foundIndex = obj.findIndex(function (item, idx) { + seen.push([idx, item]); + return item === undefined && idx === 2; + }); + expect(foundIndex).to.equal(2); + expect(seen).to.eql([[0, 1], [1, undefined], [2, undefined]]); + }); + + it('should work with a sparse array-like object', function () { + var obj = { 0: 1, 2: undefined, length: 3.2 }; + var seen = []; + var foundIndex = Array.prototype.findIndex.call(obj, function (item, idx) { + seen.push([idx, item]); + return false; + }); + expect(foundIndex).to.equal(-1); + expect(seen).to.eql([[0, 1], [1, undefined], [2, undefined]]); + }); + + ifSymbolUnscopablesIt('should be unscopable if Symbols exist', function () { + var unscopables = Array.prototype[Sym.unscopables]; + expect(!!unscopables).to.equal(true); + expect(unscopables.findIndex).to.equal(true); + }); + }); + + describe('ArrayIterator', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'keys')) { + return it('can be tested', function () { + expect(Array.prototype).to.have.property('keys'); + }); + } + + var arrayIterator; + beforeEach(function () { + arrayIterator = [1, 2, 3].keys(); + }); + + describe('#next()', function () { + it('should work when applied to an ArrayIterator', function () { + expect(arrayIterator.next.apply(arrayIterator)).to.eql({ value: 0, done: false }); + expect(arrayIterator.next.apply(arrayIterator)).to.eql({ value: 1, done: false }); + expect(arrayIterator.next.apply(arrayIterator)).to.eql({ value: 2, done: false }); + expect(arrayIterator.next.apply(arrayIterator)).to.eql({ value: undefined, done: true }); + }); + + it('throws when not applied to an ArrayIterator', function () { + expect(function () { arrayIterator.next.apply({}); }).to['throw'](TypeError); + }); + }); + }); + + describe('#keys()', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'keys')) { + return it('exists', function () { + expect(Array.prototype).to.have.property('keys'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.prototype.keys).to.have.property('name', 'keys'); + }); + + it('should have the right arity ', function () { + expect(Array.prototype.keys.length).to.equal(0); + }); + + it('is not enumerable', function () { + expect(Array.prototype).ownPropertyDescriptor('keys').to.have.property('enumerable', false); + }); + + describe('basic keys iteration', function () { + var mylist = [5, 10, 15, 20]; + var keys; + beforeEach(function () { + if (!keys) { + keys = mylist.keys(); + } + }); + + it('should return 0 on first object', function () { + expect(keys.next()).to.eql({ value: 0, done: false }); + }); + + it('should return 1 on second object', function () { + expect(keys.next()).to.eql({ value: 1, done: false }); + }); + + it('should return 2 on third object', function () { + expect(keys.next()).to.eql({ value: 2, done: false }); + }); + + it('should return 3 on fourth object', function () { + expect(keys.next()).to.eql({ value: 3, done: false }); + }); + + it('should set done on completing iteration', function () { + expect(keys.next()).to.eql({ value: undefined, done: true }); + }); + + it('once done it should stay done', function () { + mylist.push(4); + expect(keys.next()).to.eql({ value: undefined, done: true }); + }); + }); + + it('should not skip sparse keys', function () { + var sparse = [1]; + sparse[2] = 3; + var keys = sparse.keys(); + expect(keys.next()).to.eql({ value: 0, done: false }); + expect(keys.next()).to.eql({ value: 1, done: false }); + expect(keys.next()).to.eql({ value: 2, done: false }); + expect(keys.next()).to.eql({ value: undefined, done: true }); + }); + + ifSymbolUnscopablesIt('should be unscopable if Symbols exist', function () { + var unscopables = Array.prototype[Sym.unscopables]; + expect(!!unscopables).to.equal(true); + expect(unscopables.keys).to.equal(true); + }); + }); + + describe('#values()', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'values')) { + return it('exists', function () { + expect(Array.prototype).to.have.property('values'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.prototype.values).to.have.property('name', 'values'); + }); + + it('has the right arity', function () { + expect(Array.prototype.values).to.have.property('length', 0); + }); + + it('is not enumerable', function () { + expect(Array.prototype).ownPropertyDescriptor('values').to.have.property('enumerable', false); + }); + + describe('basic list iteration', function () { + var mylist = [5, 10, 15, 20]; + var values; + beforeEach(function () { + if (!values) { + values = mylist.values(); + } + }); + + it('should return 5 on first object', function () { + expect(values.next()).to.eql({ value: 5, done: false }); + }); + + it('should return 10 on second object', function () { + expect(values.next()).to.eql({ value: 10, done: false }); + }); + + it('should return 15 on third object', function () { + expect(values.next()).to.eql({ value: 15, done: false }); + }); + + it('should return 20 on fourth object', function () { + expect(values.next()).to.eql({ value: 20, done: false }); + }); + + it('should set done on completing iteration', function () { + expect(values.next()).to.eql({ value: undefined, done: true }); + }); + + it('once done it should stay done', function () { + mylist.push(4); + expect(values.next()).to.eql({ value: undefined, done: true }); + }); + }); + + it('should not skip sparse values', function () { + var sparse = [1]; + sparse[2] = 3; + var values = sparse.values(); + expect(values.next()).to.eql({ value: 1, done: false }); + expect(values.next()).to.eql({ value: undefined, done: false }); + expect(values.next()).to.eql({ value: 3, done: false }); + expect(values.next()).to.eql({ value: undefined, done: true }); + }); + + ifSymbolUnscopablesIt('should be unscopable if Symbols exist', function () { + var unscopables = Array.prototype[Sym.unscopables]; + expect(!!unscopables).to.equal(true); + expect(unscopables.values).to.equal(true); + }); + }); + + describe('#entries()', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'entries')) { + return it('exists', function () { + expect(Array.prototype).to.have.property('entries'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.prototype.entries).to.have.property('name', 'entries'); + }); + + it('has the right arity', function () { + expect(Array.prototype.entries).to.have.property('length', 0); + }); + + it('is not enumerable', function () { + expect(Array.prototype).ownPropertyDescriptor('entries').to.have.property('enumerable', false); + }); + + describe('basic list iteration', function () { + var mylist = [5, 10, 15, 20]; + var entries; + beforeEach(function () { + if (!entries) { + entries = mylist.entries(); + } + }); + + it('should return [0, 5] on first object', function () { + var val = entries.next(); + expect(val).to.eql({ value: [0, 5], done: false }); + }); + + it('should return [1, 10] on second object', function () { + var val = entries.next(); + expect(val).to.eql({ value: [1, 10], done: false }); + }); + + it('should return [2, 15] on third object', function () { + var val = entries.next(); + expect(val).to.eql({ value: [2, 15], done: false }); + }); + + it('should return [3, 20] on fourth object', function () { + var val = entries.next(); + expect(val).to.eql({ value: [3, 20], done: false }); + }); + + it('should set done on completing iteration', function () { + var val = entries.next(); + expect(val).to.eql({ value: undefined, done: true }); + }); + + it('once done it should stay done', function () { + mylist.push(4); + var val = entries.next(); + expect(val).to.eql({ value: undefined, done: true }); + }); + }); + + it('should not skip sparse entries', function () { + var sparse = [1]; + sparse[2] = 3; + var entries = sparse.entries(); + expect(entries.next()).to.eql({ value: [0, 1], done: false }); + expect(entries.next()).to.eql({ value: [1, undefined], done: false }); + expect(entries.next()).to.eql({ value: [2, 3], done: false }); + expect(entries.next()).to.eql({ value: undefined, done: true }); + }); + + ifSymbolUnscopablesIt('should be unscopable if Symbols exist', function () { + var unscopables = Array.prototype[Sym.unscopables]; + expect(!!unscopables).to.equal(true); + expect(unscopables.entries).to.equal(true); + }); + }); + + describe('#fill()', function () { + if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'fill')) { + return it('exists', function () { + expect(Array.prototype).to.have.property('fill'); + }); + } + + ifFunctionsHaveNamesIt('has the correct name', function () { + expect(Array.prototype.fill).to.have.property('name', 'fill'); + }); + + it('has the right arity', function () { + expect(Array.prototype.fill).to.have.property('length', 1); + }); + + it('is not enumerable', function () { + expect(Array.prototype).ownPropertyDescriptor('fill').to.have.property('enumerable', false); + }); + + it('works with just a value', function () { + var original = [1, 2, 3, 4, 5, 6]; + var filled = [-1, -1, -1, -1, -1, -1]; + + expect(original.fill(-1)).to.eql(filled); + }); + + it('accepts a positive start index', function () { + var original = [1, 2, 3, 4, 5, 6]; + var filled = [1, 2, 3, -1, -1, -1]; + + expect(original.fill(-1, 3)).to.eql(filled); + }); + + it('accepts a negative start index', function () { + var original = [1, 2, 3, 4, 5, 6]; + var filled = [1, 2, 3, -1, -1, -1]; + + expect(original.fill(-1, -3)).to.eql(filled); + }); + + it('accepts a negative end index', function () { + var original = [1, 2, 3]; + var filled = [4, 2, 3]; + + expect(original.fill(4, -3, -2)).to.eql(filled); + }); + + it('accepts a large start index', function () { + var original = [1, 2, 3, 4, 5, 6]; + var filled = [1, 2, 3, 4, 5, 6]; + + expect(original.fill(-1, 9)).to.eql(filled); + }); + + ifSymbolUnscopablesIt('should be unscopable if Symbols exist', function () { + var unscopables = Array.prototype[Sym.unscopables]; + expect(!!unscopables).to.equal(true); + expect(unscopables.fill).to.equal(true); + }); + }); + + // this length converts to "1", preventing a crazy crash in older FF + var negativeLength = { 0: 1, length: -Math.pow(2, 32) + 1 }; + var throwRangeError = function (v, i) { + if (i === negativeLength.length >>> 0) { + return v; + } + // note: in nonconforming browsers, this will be called + // -1 >>> 0 times, which is 4294967295, so the throw matters. + throw new RangeError('should not reach here: length of -1 should clamp to length of 0'); + }; + var throwRangeErrorReduce = function throwRangeErrorReduce(acc, v, i) { + return throwRangeErrorReduce(v, i); + }; + + describe('#forEach()', function () { + it('uses ToLength to clamp negative values to zero', function () { + expect(function () { + Array.prototype.forEach.call(negativeLength, throwRangeError); + }).not.to['throw'](); + }); + }); + + describe('#map()', function () { + it('uses ToLength to clamp negative values to zero', function () { + var mapped; + expect(function () { + mapped = Array.prototype.map.call(negativeLength, throwRangeError); + }).not.to['throw'](); + expect(mapped).to.eql([]); + }); + }); + + describe('#filter()', function () { + it('uses ToLength to clamp negative values to zero', function () { + var filtered; + expect(function () { + filtered = Array.prototype.filter.call(negativeLength, throwRangeError); + }).not.to['throw'](); + expect(filtered).to.eql([]); + }); + }); + + describe('#some()', function () { + it('uses ToLength to clamp negative values to zero', function () { + var result; + expect(function () { + result = Array.prototype.some.call(negativeLength, throwRangeError); + }).not.to['throw'](); + expect(result).to.equal([].some(Object)); + }); + }); + + describe('#every()', function () { + it('uses ToLength to clamp negative values to zero', function () { + var result; + expect(function () { + result = Array.prototype.every.call(negativeLength, throwRangeError); + }).not.to['throw'](); + expect(result).to.equal([].every(Object)); + }); + }); + + describe('#reduce()', function () { + it('uses ToLength to clamp negative values to zero', function () { + var accumulator = {}; + var reduced; + expect(function () { + reduced = Array.prototype.reduce.call(negativeLength, throwRangeErrorReduce, accumulator); + }).not.to['throw'](); + expect(reduced).to.equal(accumulator); + }); + }); + + describe('#reduceRight()', function () { + it('uses ToLength to clamp negative values to zero', function () { + var negativeOneToUint32minusOne = (-1 >>> 0) - 1; + var obj = { length: -1 }; + obj[negativeOneToUint32minusOne] = true; + var accumulator = {}; + var reduced; + expect(function () { + reduced = Array.prototype.reduceRight.call(obj, throwRangeErrorReduce, accumulator); + }).not.to['throw'](); + expect(reduced).to.equal(accumulator); + }); + }); + + describe('#indexOf()', function () { + it('converts second argument from -0 to +0', function () { + expect(isNegativeZero([true].indexOf(true, -0))).to.equal(false); + }); + }); + }); +}; + +describe('clean Object.prototype', function () { + 'use strict'; + + runArrayTests.call(this, it); +}); + +describe('polluted Object.prototype', function () { + 'use strict'; + + var shimmedIt = function () { + /* eslint-disable no-extend-native */ + Object.prototype[1] = 42; + /* eslint-enable no-extend-native */ + it.apply(this, arguments); + delete Object.prototype[1]; + }; + shimmedIt.skip = it.skip; + return runArrayTests.call(this, shimmedIt); +}); diff --git a/node_modules/es6-shim/test/browser-onload.js b/node_modules/es6-shim/test/browser-onload.js new file mode 100644 index 0000000..7a83647 --- /dev/null +++ b/node_modules/es6-shim/test/browser-onload.js @@ -0,0 +1,45 @@ +/* global window, mocha */ + +if (typeof window !== 'undefined') { + window.completedTests = 0; + window.sawFail = false; + window.onload = function () { + window.testsPassed = null; + var handleResults = function (runner) { + var failedTests = []; + if (runner.stats.end) { + window.testsPassed = runner.stats.failures === 0; + } + runner.on('pass', function () { + window.completedTests += 1; + }); + runner.on('fail', function (test, err) { + window.sawFail = true; + var flattenTitles = function (testToFlatten) { + var titles = []; + var currentTest = testToFlatten; + while (currentTest.parent.title) { + titles.push(currentTest.parent.title); + currentTest = currentTest.parent; + } + return titles.reverse(); + }; + failedTests.push({ + name: test.title, + result: false, + message: err.message, + stack: err.stack, + titles: flattenTitles(test) + }); + }); + runner.on('end', function () { + window.testsPassed = !window.sawFail; + // for sauce + window.mochaResults = runner.stats; + window.mochaResults.reports = failedTests; + }); + return runner; + }; + handleResults(mocha.run()); + }; +} diff --git a/node_modules/es6-shim/test/browser-setup.js b/node_modules/es6-shim/test/browser-setup.js new file mode 100644 index 0000000..bb41706 --- /dev/null +++ b/node_modules/es6-shim/test/browser-setup.js @@ -0,0 +1,11 @@ +/* global window, chai, mocha */ + +if (typeof window !== 'undefined') { + chai.config.includeStack = true; + window.expect = chai.expect; + window.assert = chai.assert; + mocha.setup('bdd'); + window.require = function () { + return window; + }; +} diff --git a/node_modules/es6-shim/test/date.js b/node_modules/es6-shim/test/date.js new file mode 100644 index 0000000..5e5f640 --- /dev/null +++ b/node_modules/es6-shim/test/date.js @@ -0,0 +1,5 @@ +describe('Date', function () { + it('when invalid, dates should toString to "Invalid Date"', function () { + expect(String(new Date(NaN))).to.equal('Invalid Date'); + }); +}); diff --git a/node_modules/es6-shim/test/google-translate.html b/node_modules/es6-shim/test/google-translate.html new file mode 100644 index 0000000..4c505af --- /dev/null +++ b/node_modules/es6-shim/test/google-translate.html @@ -0,0 +1,46 @@ + + + + + es6-shim tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + diff --git a/node_modules/es6-shim/test/index.html b/node_modules/es6-shim/test/index.html new file mode 100644 index 0000000..f2e14a7 --- /dev/null +++ b/node_modules/es6-shim/test/index.html @@ -0,0 +1,42 @@ + + + + + es6-shim tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + diff --git a/node_modules/es6-shim/test/json.js b/node_modules/es6-shim/test/json.js new file mode 100644 index 0000000..765d747 --- /dev/null +++ b/node_modules/es6-shim/test/json.js @@ -0,0 +1,77 @@ +describe('JSON', function () { + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; + var ifSymbolsIt = hasSymbols ? it : xit; + var ifSymbolsDescribe = hasSymbols ? describe : xit; + + describe('.stringify()', function () { + ifFunctionsHaveNamesIt('has the right name', function () { + expect(JSON.stringify.name).to.equal('stringify'); + }); + + ifSymbolsIt('serializes a Symbol to undefined', function () { + expect(JSON.stringify(Symbol())).to.equal(undefined); + }); + + ifSymbolsIt('serializes a Symbol object to {}', function () { + expect(function stringifyObjectSymbol() { JSON.stringify(Object(Symbol())); }).not.to['throw'](); + expect(JSON.stringify(Object(Symbol()))).to.equal('{}'); + }); + + ifSymbolsIt('serializes Symbols in an Array to null', function () { + expect(JSON.stringify([Symbol('foo')])).to.equal('[null]'); + }); + + ifSymbolsIt('serializes Symbol objects in an Array to {}', function () { + expect(function stringifyObjectSymbolInArray() { JSON.stringify([Object(Symbol('foo'))]); }).not.to['throw'](); + expect(JSON.stringify([Object(Symbol('foo'))])).to.equal('[{}]'); + }); + + ifSymbolsDescribe('skips symbol properties and values in an object', function () { + var enumSym = Symbol('enumerable'); + var nonenum = Symbol('non-enumerable'); + var createObject = function () { + var obj = { a: 1 }; + obj[enumSym] = true; + obj.sym = enumSym; + Object.defineProperty(obj, nonenum, { enumerable: false, value: true }); + expect(Object.getOwnPropertySymbols(obj)).to.eql([enumSym, nonenum]); + return obj; + }; + + it('works with no replacer', function () { + var obj = createObject(); + expect(JSON.stringify(obj)).to.equal('{"a":1}'); + expect(JSON.stringify(obj, null, '|')).to.equal('{\n|"a": 1\n}'); + }); + + it('works with a replacer function', function () { + var tuples = []; + var replacer = function (key, value) { + tuples.push([this, key, value]); + return value; + }; + var obj = createObject(); + expect(JSON.stringify(obj, replacer, '|')).to.equal('{\n|"a": 1\n}'); // populate `tuples` array + expect(tuples).to.eql([ + [{ '': obj }, '', obj], + [obj, 'a', 1], + [obj, 'sym', enumSym] + ]); + }); + + it('works with a replacer array', function () { + var obj = createObject(); + obj.foo = 'bar'; + obj[Symbol.prototype.toString.call(enumSym)] = 'tricksy'; + expect(JSON.stringify(obj, ['a', enumSym])).to.equal('{"a":1}'); + expect(JSON.stringify(obj, ['a', enumSym], '|')).to.equal('{\n|"a": 1\n}'); + }); + + it('ignores a non-array non-callable replacer object', function () { + expect(JSON.stringify('z', { test: null })).to.equal('"z"'); + }); + }); + }); +}); diff --git a/node_modules/es6-shim/test/map.js b/node_modules/es6-shim/test/map.js new file mode 100644 index 0000000..35f4197 --- /dev/null +++ b/node_modules/es6-shim/test/map.js @@ -0,0 +1,622 @@ +// Big thanks to V8 folks for test ideas. +// v8/test/mjsunit/harmony/collections.js + +var Assertion = expect().constructor; +Assertion.addMethod('theSameSet', function (otherArray) { + var array = this._obj; + + expect(Array.isArray(array)).to.equal(true); + expect(Array.isArray(otherArray)).to.equal(true); + + var diff = array.filter(function (value) { + return otherArray.every(function (otherValue) { + var areBothNaN = typeof value === 'number' && typeof otherValue === 'number' && value !== value && otherValue !== otherValue; + return !areBothNaN && value !== otherValue; + }); + }); + + this.assert( + diff.length === 0, + 'expected #{this} to be equal to #{exp} (as sets, i.e. no order)', + array, + otherArray + ); +}); + +Assertion.addMethod('entries', function (expected) { + var collection = this._obj; + + expect(Array.isArray(expected)).to.equal(true); + var expectedEntries = expected.slice(); + + var iterator = collection.entries(); + var result; + do { + result = iterator.next(); + expect(result.value).to.be.eql(expectedEntries.shift()); + } while (!result.done); +}); + +describe('Map', function () { + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + var ifGetPrototypeOfIt = Object.getPrototypeOf ? it : xit; + + var range = function range(from, to) { + var result = []; + for (var value = from; value < to; value++) { + result.push(value); + } + return result; + }; + + var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype'); + var expectNotEnumerable = function (object) { + if (prototypePropIsEnumerable && typeof object === 'function') { + expect(Object.keys(object)).to.eql(['prototype']); + } else { + expect(Object.keys(object)).to.eql([]); + } + }; + + var Sym = typeof Symbol === 'undefined' ? {} : Symbol; + var isSymbol = function (sym) { + return typeof Sym === 'function' && typeof sym === 'symbol'; + }; + var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit; + + var testMapping = function (map, key, value) { + expect(map.has(key)).to.equal(false); + expect(map.get(key)).to.equal(undefined); + expect(map.set(key, value)).to.equal(map); + expect(map.get(key)).to.equal(value); + expect(map.has(key)).to.equal(true); + }; + + if (typeof Map === 'undefined') { + return it('exists', function () { + expect(typeof Map).to.equal('function'); + }); + } + + var map; + beforeEach(function () { + map = new Map(); + }); + + afterEach(function () { + map = null; + }); + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Map).to.equal(Map); + }); + + it('should exist in global namespace', function () { + expect(typeof Map).to.equal('function'); + }); + + it('should have the right arity', function () { + expect(Map).to.have.property('length', 0); + }); + + it('should has valid getter and setter calls', function () { + ['get', 'set', 'has', 'delete'].forEach(function (method) { + expect(function () { + map[method]({}); + }).to.not['throw'](); + }); + }); + + it('should accept an iterable as argument', function () { + testMapping(map, 'a', 'b'); + testMapping(map, 'c', 'd'); + var map2; + expect(function () { map2 = new Map(map); }).not.to['throw'](Error); + expect(map2).to.be.an.instanceOf(Map); + expect(map2.has('a')).to.equal(true); + expect(map2.has('c')).to.equal(true); + expect(map2).to.have.entries([['a', 'b'], ['c', 'd']]); + }); + + it('should throw with iterables that return primitives', function () { + expect(function () { return new Map('123'); }).to['throw'](TypeError); + expect(function () { return new Map([1, 2, 3]); }).to['throw'](TypeError); + expect(function () { return new Map(['1', '2', '3']); }).to['throw'](TypeError); + expect(function () { return new Map([true]); }).to['throw'](TypeError); + }); + + it('should not be callable without "new"', function () { + expect(Map).to['throw'](TypeError); + }); + + it('should be subclassable', function () { + if (!Object.setPrototypeOf) { return; } // skip test if on IE < 11 + var MyMap = function MyMap() { + var testMap = new Map([['a', 'b']]); + Object.setPrototypeOf(testMap, MyMap.prototype); + return testMap; + }; + Object.setPrototypeOf(MyMap, Map); + MyMap.prototype = Object.create(Map.prototype, { + constructor: { value: MyMap } + }); + + var myMap = new MyMap(); + testMapping(myMap, 'c', 'd'); + expect(myMap).to.have.entries([['a', 'b'], ['c', 'd']]); + }); + + it('uses SameValueZero even on a Map of size > 4', function () { + // Chrome 38-42, node 0.11/0.12, iojs 1/2 have a bug when the Map has a size > 4 + var firstFour = [[1, 0], [2, 0], [3, 0], [4, 0]]; + var fourMap = new Map(firstFour); + expect(fourMap.size).to.equal(4); + expect(fourMap.has(-0)).to.equal(false); + expect(fourMap.has(0)).to.equal(false); + + fourMap.set(-0, fourMap); + + expect(fourMap.has(0)).to.equal(true); + expect(fourMap.has(-0)).to.equal(true); + }); + + it('treats positive and negative zero the same', function () { + var value1 = {}; + var value2 = {}; + testMapping(map, +0, value1); + expect(map.has(-0)).to.equal(true); + expect(map.get(-0)).to.equal(value1); + expect(map.set(-0, value2)).to.equal(map); + expect(map.get(-0)).to.equal(value2); + expect(map.get(+0)).to.equal(value2); + }); + + it('should map values correctly', function () { + // Run this test twice, one with the "fast" implementation (which only + // allows string and numeric keys) and once with the "slow" impl. + [true, false].forEach(function (slowkeys) { + map = new Map(); + + range(1, 20).forEach(function (number) { + if (slowkeys) { testMapping(map, number, {}); } + testMapping(map, number / 100, {}); + testMapping(map, 'key-' + number, {}); + testMapping(map, String(number), {}); + if (slowkeys) { testMapping(map, Object(String(number)), {}); } + }); + + var testkeys = [Infinity, -Infinity, NaN]; + if (slowkeys) { + testkeys.push(true, false, null, undefined); + } + testkeys.forEach(function (key) { + testMapping(map, key, {}); + testMapping(map, String(key), {}); + }); + testMapping(map, '', {}); + + // verify that properties of Object don't peek through. + [ + 'hasOwnProperty', + 'constructor', + 'toString', + 'isPrototypeOf', + '__proto__', + '__parent__', + '__count__' + ].forEach(function (key) { + testMapping(map, key, {}); + }); + }); + }); + + it('should map empty values correctly', function () { + testMapping(map, {}, true); + testMapping(map, null, true); + testMapping(map, undefined, true); + testMapping(map, '', true); + testMapping(map, NaN, true); + testMapping(map, 0, true); + }); + + it('should has correct querying behavior', function () { + var key = {}; + testMapping(map, key, 'to-be-present'); + expect(map.has(key)).to.equal(true); + expect(map.has({})).to.equal(false); + expect(map.set(key, void 0)).to.equal(map); + expect(map.get(key)).to.equal(undefined); + expect(map.has(key)).to.equal(true); + expect(map.has({})).to.equal(false); + }); + + it('should allow NaN values as keys', function () { + expect(map.has(NaN)).to.equal(false); + expect(map.has(NaN + 1)).to.equal(false); + expect(map.has(23)).to.equal(false); + expect(map.set(NaN, 'value')).to.equal(map); + expect(map.has(NaN)).to.equal(true); + expect(map.has(NaN + 1)).to.equal(true); + expect(map.has(23)).to.equal(false); + }); + + it('should not have [[Enumerable]] props', function () { + expectNotEnumerable(Map); + expectNotEnumerable(Map.prototype); + expectNotEnumerable(new Map()); + }); + + it('should not have an own constructor', function () { + var m = new Map(); + expect(m).not.to.haveOwnPropertyDescriptor('constructor'); + expect(m.constructor).to.equal(Map); + }); + + it('should allow common ecmascript idioms', function () { + expect(map).to.be.an.instanceOf(Map); + expect(typeof Map.prototype.get).to.equal('function'); + expect(typeof Map.prototype.set).to.equal('function'); + expect(typeof Map.prototype.has).to.equal('function'); + expect(typeof Map.prototype['delete']).to.equal('function'); + }); + + it('should have a unique constructor', function () { + expect(Map.prototype).to.not.equal(Object.prototype); + }); + + describe('#clear()', function () { + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Map.prototype.clear).to.have.property('name', 'clear'); + }); + + it('is not enumerable', function () { + expect(Map.prototype).ownPropertyDescriptor('clear').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Map.prototype.clear).to.have.property('length', 0); + }); + + it('should have #clear method', function () { + expect(map.set(1, 2)).to.equal(map); + expect(map.set(5, 2)).to.equal(map); + expect(map.size).to.equal(2); + expect(map.has(5)).to.equal(true); + map.clear(); + expect(map.size).to.equal(0); + expect(map.has(5)).to.equal(false); + }); + }); + + describe('#keys()', function () { + if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'keys')) { + return it('exists', function () { + expect(Map.prototype).to.have.property('keys'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Map.prototype.keys).to.have.property('name', 'keys'); + }); + + it('is not enumerable', function () { + expect(Map.prototype).ownPropertyDescriptor('keys').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Map.prototype.keys).to.have.property('length', 0); + }); + }); + + describe('#values()', function () { + if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'values')) { + return it('exists', function () { + expect(Map.prototype).to.have.property('values'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Map.prototype.values).to.have.property('name', 'values'); + }); + + it('is not enumerable', function () { + expect(Map.prototype).ownPropertyDescriptor('values').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Map.prototype.values).to.have.property('length', 0); + }); + }); + + describe('#entries()', function () { + if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'entries')) { + return it('exists', function () { + expect(Map.prototype).to.have.property('entries'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Map.prototype.entries).to.have.property('name', 'entries'); + }); + + it('is not enumerable', function () { + expect(Map.prototype).ownPropertyDescriptor('entries').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Map.prototype.entries).to.have.property('length', 0); + }); + + it('throws when called on a non-Map', function () { + var expectedMessage = /^(Method )?Map.prototype.entries called on incompatible receiver |^entries method called on incompatible |^Cannot create a Map entry iterator for a non-Map object.|^Map\.prototype\.entries: 'this' is not a Map object$|^std_Map_iterator method called on incompatible \w+$/; + var nonMaps = [true, false, 'abc', NaN, new Set([1, 2]), { a: true }, [1], Object('abc'), Object(NaN)]; + nonMaps.forEach(function (nonMap) { + expect(function () { return Map.prototype.entries.call(nonMap); }).to['throw'](TypeError, expectedMessage); + }); + }); + }); + + describe('#size', function () { + it('throws TypeError when accessed directly', function () { + // see https://github.com/paulmillr/es6-shim/issues/176 + expect(function () { return Map.prototype.size; }).to['throw'](TypeError); + expect(function () { return Map.prototype.size; }).to['throw'](TypeError); + }); + + it('is an accessor function on the prototype', function () { + expect(Map.prototype).ownPropertyDescriptor('size').to.have.property('get'); + expect(typeof Object.getOwnPropertyDescriptor(Map.prototype, 'size').get).to.equal('function'); + expect(new Map()).not.to.haveOwnPropertyDescriptor('size'); + }); + }); + + it('should return false when deleting a nonexistent key', function () { + expect(map.has('a')).to.equal(false); + expect(map['delete']('a')).to.equal(false); + }); + + it('should have keys, values and size props', function () { + expect(map.set('a', 1)).to.equal(map); + expect(map.set('b', 2)).to.equal(map); + expect(map.set('c', 3)).to.equal(map); + expect(typeof map.keys).to.equal('function'); + expect(typeof map.values).to.equal('function'); + expect(map.size).to.equal(3); + expect(map['delete']('a')).to.equal(true); + expect(map.size).to.equal(2); + }); + + it('should have an iterator that works with Array.from', function () { + expect(Array).to.have.property('from'); + + expect(map.set('a', 1)).to.equal(map); + expect(map.set('b', NaN)).to.equal(map); + expect(map.set('c', false)).to.equal(map); + expect(Array.from(map)).to.eql([['a', 1], ['b', NaN], ['c', false]]); + expect(Array.from(map.keys())).to.eql(['a', 'b', 'c']); + expect(Array.from(map.values())).to.eql([1, NaN, false]); + expect(map).to.have.entries(Array.from(map.entries())); + }); + + ifSymbolIteratorIt('has the right default iteration function', function () { + // fixed in Webkit https://bugs.webkit.org/show_bug.cgi?id=143838 + expect(Map.prototype).to.have.property(Sym.iterator, Map.prototype.entries); + }); + + describe('#forEach', function () { + var mapToIterate; + + beforeEach(function () { + mapToIterate = new Map(); + expect(mapToIterate.set('a', 1)).to.equal(mapToIterate); + expect(mapToIterate.set('b', 2)).to.equal(mapToIterate); + expect(mapToIterate.set('c', 3)).to.equal(mapToIterate); + }); + + afterEach(function () { + mapToIterate = null; + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Map.prototype.forEach).to.have.property('name', 'forEach'); + }); + + it('is not enumerable', function () { + expect(Map.prototype).ownPropertyDescriptor('forEach').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Map.prototype.forEach).to.have.property('length', 1); + }); + + it('should be iterable via forEach', function () { + var expectedMap = { + a: 1, + b: 2, + c: 3 + }; + var foundMap = {}; + mapToIterate.forEach(function (value, key, entireMap) { + expect(entireMap).to.equal(mapToIterate); + foundMap[key] = value; + }); + expect(foundMap).to.eql(expectedMap); + }); + + it('should iterate over empty keys', function () { + var mapWithEmptyKeys = new Map(); + var expectedKeys = [{}, null, undefined, '', NaN, 0]; + expectedKeys.forEach(function (key) { + expect(mapWithEmptyKeys.set(key, true)).to.equal(mapWithEmptyKeys); + }); + var foundKeys = []; + mapWithEmptyKeys.forEach(function (value, key, entireMap) { + expect(entireMap.get(key)).to.equal(value); + foundKeys.push(key); + }); + expect(foundKeys).to.be.theSameSet(expectedKeys); + }); + + it('should support the thisArg', function () { + var context = function () {}; + mapToIterate.forEach(function () { + expect(this).to.equal(context); + }, context); + }); + + it('should have a length of 1', function () { + expect(Map.prototype.forEach.length).to.equal(1); + }); + + it('should not revisit modified keys', function () { + var hasModifiedA = false; + mapToIterate.forEach(function (value, key) { + if (!hasModifiedA && key === 'a') { + expect(mapToIterate.set('a', 4)).to.equal(mapToIterate); + hasModifiedA = true; + } else { + expect(key).not.to.equal('a'); + } + }); + }); + + it('returns the map from #set() for chaining', function () { + expect(mapToIterate.set({}, {})).to.equal(mapToIterate); + expect(mapToIterate.set(42, {})).to.equal(mapToIterate); + expect(mapToIterate.set(0, {})).to.equal(mapToIterate); + expect(mapToIterate.set(NaN, {})).to.equal(mapToIterate); + expect(mapToIterate.set(-0, {})).to.equal(mapToIterate); + }); + + it('visits keys added in the iterator', function () { + var hasAdded = false; + var hasFoundD = false; + mapToIterate.forEach(function (value, key) { + if (!hasAdded) { + mapToIterate.set('d', 5); + hasAdded = true; + } else if (key === 'd') { + hasFoundD = true; + } + }); + expect(hasFoundD).to.equal(true); + }); + + it('visits keys added in the iterator when there is a deletion', function () { + var hasSeenFour = false; + var mapToMutate = new Map(); + mapToMutate.set('0', 42); + mapToMutate.forEach(function (value, key) { + if (key === '0') { + expect(mapToMutate['delete']('0')).to.equal(true); + mapToMutate.set('4', 'a value'); + } else if (key === '4') { + hasSeenFour = true; + } + }); + expect(hasSeenFour).to.equal(true); + }); + + it('does not visit keys deleted before a visit', function () { + var hasVisitedC = false; + var hasDeletedC = false; + mapToIterate.forEach(function (value, key) { + if (key === 'c') { + hasVisitedC = true; + } + if (!hasVisitedC && !hasDeletedC) { + hasDeletedC = mapToIterate['delete']('c'); + expect(hasDeletedC).to.equal(true); + } + }); + expect(hasVisitedC).to.equal(false); + }); + + it('should work after deletion of the current key', function () { + var expectedMap = { + a: 1, + b: 2, + c: 3 + }; + var foundMap = {}; + mapToIterate.forEach(function (value, key) { + foundMap[key] = value; + expect(mapToIterate['delete'](key)).to.equal(true); + }); + expect(foundMap).to.eql(expectedMap); + }); + + it('should convert key -0 to +0', function () { + var zeroMap = new Map(); + var result = []; + zeroMap.set(-0, 'a'); + zeroMap.forEach(function (value, key) { + result.push(String(1 / key) + ' ' + value); + }); + zeroMap.set(1, 'b'); + zeroMap.set(0, 'c'); // shouldn't cause reordering + zeroMap.forEach(function (value, key) { + result.push(String(1 / key) + ' ' + value); + }); + expect(result.join(', ')).to.equal('Infinity a, Infinity c, 1 b'); + }); + }); + + it('should preserve insertion order', function () { + var convertToPairs = function (item) { return [item, true]; }; + var arr1 = ['d', 'a', 'b']; + var arr2 = [3, 2, 'z', 'a', 1]; + var arr3 = [3, 2, 'z', {}, 'a', 1]; + + [arr1, arr2, arr3].forEach(function (array) { + var entries = array.map(convertToPairs); + expect(new Map(entries)).to.have.entries(entries); + }); + }); + + it('map iteration', function () { + var map = new Map(); + map.set('a', 1); + map.set('b', 2); + map.set('c', 3); + map.set('d', 4); + + var keys = []; + var iterator = map.keys(); + keys.push(iterator.next().value); + expect(map['delete']('a')).to.equal(true); + expect(map['delete']('b')).to.equal(true); + expect(map['delete']('c')).to.equal(true); + map.set('e'); + keys.push(iterator.next().value); + keys.push(iterator.next().value); + + expect(iterator.next().done).to.equal(true); + map.set('f'); + expect(iterator.next().done).to.equal(true); + expect(keys).to.eql(['a', 'd', 'e']); + }); + + ifGetPrototypeOfIt('MapIterator identification test prototype inequality', function () { + var mapEntriesProto = Object.getPrototypeOf(new Map().entries()); + var setEntriesProto = Object.getPrototypeOf(new Set().entries()); + expect(mapEntriesProto).to.not.equal(setEntriesProto); + }); + + it('MapIterator identification', function () { + var fnMapValues = Map.prototype.values; + var mapSentinel = new Map([[1, 'MapSentinel']]); + var testMap = new Map(); + var testMapValues = testMap.values(); + expect(testMapValues.next.call(fnMapValues.call(mapSentinel)).value).to.equal('MapSentinel'); + + var testSet = new Set(); + var testSetValues = testSet.values(); + expect(function () { + return testSetValues.next.call(fnMapValues.call(mapSentinel)).value; + }).to['throw'](TypeError); + }); +}); diff --git a/node_modules/es6-shim/test/math.js b/node_modules/es6-shim/test/math.js new file mode 100644 index 0000000..d41740e --- /dev/null +++ b/node_modules/es6-shim/test/math.js @@ -0,0 +1,889 @@ +var EPSILON = Number.EPSILON || 2.2204460492503130808472633361816e-16; + +var Assertion = expect().constructor; +Assertion.prototype.almostEqual = function (obj, precision) { + 'use strict'; + + var allowedDiff = precision || 1e-11; + return this.within(obj - allowedDiff, obj + allowedDiff); +}; + +Assertion.prototype.haveULPDistance = function (expected, distance) { + var actual = this._obj; + return this.above(Math.abs(1 - (actual / expected)) / EPSILON, distance); +}; + +describe('Math', function () { + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + + var isPositiveZero = function (zero) { + 'use strict'; + + return zero === 0 && 1 / zero === Infinity; + }; + var isNegativeZero = function (zero) { + 'use strict'; + + return zero === 0 && 1 / zero === -Infinity; + }; + var numberIsNaN = Number.isNaN || function (value) { + return value !== value; + }; + var valueOfIsNaN = { valueOf: function () { return NaN; } }; + var valueOfIsInfinity = { valueOf: function () { return Infinity; } }; + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Math).to.equal(Math); + }); + + describe('.acosh()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'acosh')) { + return it('exists', function () { + expect(Math).to.have.property('acosh'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.acosh).to.have.property('name', 'acosh'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('acosh').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.acosh).to.have.property('length', 1); + }); + + it('should be correct', function () { + expect(numberIsNaN(Math.acosh(NaN))).to.equal(true); + expect(numberIsNaN(Math.acosh(0))).to.equal(true); + expect(numberIsNaN(Math.acosh(0.9999999))).to.equal(true); + expect(numberIsNaN(Math.acosh(-1e300))).to.equal(true); + expect(Math.acosh(1e+99)).to.almostEqual(228.64907138697046); + expect(isPositiveZero(Math.acosh(1))).to.equal(true); + expect(Math.acosh(Infinity)).to.equal(Infinity); + expect(Math.acosh(1234)).to.almostEqual(7.811163220849231); + expect(Math.acosh(8.88)).to.almostEqual(2.8737631531629235); + expect(Math.acosh(1e160)).to.almostEqual(369.10676205960726); + expect(Math.acosh(Number.MAX_VALUE)).to.almostEqual(710.4758600739439); + }); + + it('works for EPSILON values near 1', function () { + var result = Math.acosh(1 + EPSILON); + var expected = Math.sqrt(2 * EPSILON); + + expect(result).to.almostEqual(expected); + expect(result).to.haveULPDistance(expected, 8); + }); + }); + + describe('.asinh()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'asinh')) { + return it('exists', function () { + expect(Math).to.have.property('asinh'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.asinh).to.have.property('name', 'asinh'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('asinh').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.asinh).to.have.property('length', 1); + }); + + it('should be correct for NaN', function () { + expect(numberIsNaN(Math.asinh(NaN))).to.equal(true); + }); + + it('should be correct for zeroes', function () { + expect(isPositiveZero(Math.asinh(+0))).to.equal(true); + expect(isNegativeZero(Math.asinh(-0))).to.equal(true); + }); + + it('should be correct for Infinities', function () { + expect(Math.asinh(Infinity)).to.equal(Infinity); + expect(Math.asinh(-Infinity)).to.equal(-Infinity); + }); + + it('should be correct', function () { + expect(Math.asinh(1234)).to.almostEqual(7.811163549201245); + expect(Math.asinh(9.99)).to.almostEqual(2.997227420191335); + expect(Math.asinh(1e150)).to.almostEqual(346.0809111296668); + expect(Math.asinh(1e7)).to.almostEqual(16.811242831518268); + expect(Math.asinh(-1e7)).to.almostEqual(-16.811242831518268); + }); + + it('is correct for extreme non-infinities', function () { + expect(Math.asinh(1e+300)).not.to.equal(Infinity); + expect(Math.asinh(1e+300)).to.almostEqual(691.4686750787736); + }); + }); + + describe('.atanh()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'atanh')) { + return it('exists', function () { + expect(Math).to.have.property('atanh'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.atanh).to.have.property('name', 'atanh'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('atanh').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.atanh).to.have.property('length', 1); + }); + + it('should be correct', function () { + expect(numberIsNaN(Math.atanh(NaN))).to.equal(true); + expect(numberIsNaN(Math.atanh(-1.00000001))).to.equal(true); + expect(numberIsNaN(Math.atanh(1.00000001))).to.equal(true); + expect(numberIsNaN(Math.atanh(-1e300))).to.equal(true); + expect(numberIsNaN(Math.atanh(1e300))).to.equal(true); + expect(Math.atanh(-1)).to.equal(-Infinity); + expect(Math.atanh(1)).to.equal(Infinity); + expect(isPositiveZero(Math.atanh(+0))).to.equal(true); + expect(isNegativeZero(Math.atanh(-0))).to.equal(true); + expect(Math.atanh(0.5)).to.almostEqual(0.5493061443340549); + expect(Math.atanh(-0.5)).to.almostEqual(-0.5493061443340549); + expect(Math.atanh(-0.5)).to.almostEqual(-0.5493061443340549); + expect(Math.atanh(0.444)).to.almostEqual(0.47720201260109457); + }); + + it('is correct for extreme non-infinities', function () { + expect(Math.atanh(1e-300)).not.to.equal(0); + expect(Math.atanh(1e-300)).to.almostEqual(1e-300); + }); + }); + + describe('.cbrt()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'cbrt')) { + return it('exists', function () { + expect(Math).to.have.property('cbrt'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.cbrt).to.have.property('name', 'cbrt'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('cbrt').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.cbrt).to.have.property('length', 1); + }); + + it('should be correct', function () { + expect(isNaN(Math.cbrt(NaN))).to.equal(true); + expect(isPositiveZero(Math.cbrt(+0))).to.equal(true); + expect(isNegativeZero(Math.cbrt(-0))).to.equal(true); + expect(Math.cbrt(Infinity)).to.equal(Infinity); + expect(Math.cbrt(-Infinity)).to.equal(-Infinity); + expect(Math.cbrt(-8)).to.almostEqual(-2); + expect(Math.cbrt(8)).to.almostEqual(2); + expect(Math.cbrt(-1000)).to.almostEqual(-10); + expect(Math.cbrt(1000)).to.almostEqual(10); + }); + + it('is correct at extremes', function () { + var result = Math.cbrt(1e-300); + var expected = 1e-100; + expect(result).to.almostEqual(expected); + expect(result).to.haveULPDistance(expected, 8); + + expect(Math.cbrt(-1e-300)).to.almostEqual(-1e-100); + expect(Math.cbrt(-1e+300)).to.almostEqual(-1e+100); + expect(Math.cbrt(1e+300)).to.almostEqual(1e+100); + }); + }); + + describe('.clz32()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'clz32')) { + return it('exists', function () { + expect(Math).to.have.property('clz32'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.clz32).to.have.property('name', 'clz32'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('clz32').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.clz32).to.have.property('length', 1); + }); + + it('should have proper uint32 conversion', function () { + var integers = [5295, -5295, -9007199254740991, 9007199254740991, 0, -0]; + var nonNumbers = [undefined, true, null, {}, [], 'str']; + var nonIntegers = [-9007199254741992, 9007199254741992, 5.9]; + + integers.forEach(function (item) { + expect(Math.clz32(item)).to.be.within(0, 32); + }); + nonIntegers.forEach(function (item) { + expect(Math.clz32(item)).to.be.within(0, 32); + }); + nonNumbers.forEach(function (item) { + expect(Math.clz32(item)).to.equal(item === true ? 31 : 32); + }); + expect(Math.clz32(true)).to.equal(Math.clz32(1)); + expect(Math.clz32('')).to.equal(Math.clz32(0)); + expect(Math.clz32('10')).to.equal(Math.clz32(10)); + expect(Math.clz32(0.1)).to.equal(32); + expect(Math.clz32(-1)).to.equal(0); + expect(Math.clz32(1)).to.equal(31); + expect(Math.clz32(0xFFFFFFFF)).to.equal(0); + expect(Math.clz32(0x1FFFFFFFF)).to.equal(0); + expect(Math.clz32(0x111111111)).to.equal(3); + expect(Math.clz32(0x11111111)).to.equal(3); + }); + + it('returns 32 for numbers that coerce to 0', function () { + var zeroishes = [ + 0, + -0, + NaN, + Infinity, + -Infinity, + 0x100000000, + undefined, + null, + false, + '', + 'str', + {}, + [], + [1, 2] + ]; + zeroishes.forEach(function (zeroish) { + expect(Math.clz32(zeroish)).to.equal(32); + }); + }); + }); + + describe('.cosh()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'cosh')) { + return it('exists', function () { + expect(Math).to.have.property('cosh'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.cosh).to.have.property('name', 'cosh'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('cosh').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.cosh).to.have.property('length', 1); + }); + + it('should be correct for NaN', function () { + expect(numberIsNaN(Math.cosh(NaN))).to.equal(true); + }); + + it('should be correct for Infinities', function () { + expect(Math.cosh(Infinity)).to.equal(Infinity); + expect(Math.cosh(-Infinity)).to.equal(Infinity); + }); + + it('should be correct for zeroes', function () { + expect(Math.cosh(-0)).to.equal(1); + expect(Math.cosh(+0)).to.equal(1); + }); + + it('should be correct', function () { + // Overridden precision values here are for Chrome, as of v25.0.1364.172 + // Broadened slightly for Firefox 31 + expect(Math.cosh(12)).to.almostEqual(81377.39571257407, 9e-11); + expect(Math.cosh(22)).to.almostEqual(1792456423.065795780980053377, 1e-5); + expect(Math.cosh(-10)).to.almostEqual(11013.23292010332313972137); + expect(Math.cosh(-23)).to.almostEqual(4872401723.1244513000, 1e-5); + expect(Math.cosh(-2e-17)).to.equal(1); + }); + + it('is correct for extreme non-infinities', function () { + expect(Math.cosh(710)).not.to.equal(Infinity); + expect(Math.cosh(710) / 1e+308).to.almostEqual(1.1169973830808557); + }); + }); + + describe('.expm1()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'expm1')) { + return it('exists', function () { + expect(Math).to.have.property('expm1'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.expm1).to.have.property('name', 'expm1'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('expm1').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.expm1).to.have.property('length', 1); + }); + + it('should be correct for NaN', function () { + expect(numberIsNaN(Math.expm1(NaN))).to.equal(true); + }); + + it('should be correct for zeroes', function () { + expect(isPositiveZero(Math.expm1(+0))).to.equal(true); + expect(isNegativeZero(Math.expm1(-0))).to.equal(true); + }); + + it('should be correct for Infinity', function () { + expect(Math.expm1(Infinity)).to.equal(Infinity); + expect(Math.expm1(-Infinity)).to.equal(-1); + }); + + it('should be correct for arbitrary numbers', function () { + expect(Math.expm1(10)).to.almostEqual(22025.465794806716516957900645284244366353512618556781); + expect(Math.expm1(-10)).to.almostEqual(-0.99995460007023751514846440848443944938976208191113); + expect(Math.expm1(-2e-17)).to.almostEqual(-2e-17); + }); + + it('works with very negative numbers', function () { + expect(Math.expm1(-38)).to.almostEqual(-1); + expect(Math.expm1(-8675309)).to.almostEqual(-1); + expect(Math.expm1(-4815162342)).to.almostEqual(-1); + }); + }); + + describe('.hypot()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'hypot')) { + return it('exists', function () { + expect(Math).to.have.property('hypot'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.hypot).to.have.property('name', 'hypot'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('hypot').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.hypot).to.have.property('length', 2); + }); + + it('should be correct', function () { + expect(Math.hypot(Infinity)).to.equal(Infinity); + expect(Math.hypot(-Infinity)).to.equal(Infinity); + expect(Math.hypot(Infinity, NaN)).to.equal(Infinity); + expect(Math.hypot(NaN, Infinity)).to.equal(Infinity); + expect(Math.hypot(-Infinity, 'Hello')).to.equal(Infinity); + expect(Math.hypot(1, 2, Infinity)).to.equal(Infinity); + expect(numberIsNaN(Math.hypot(NaN, 1))).to.equal(true); + expect(isPositiveZero(Math.hypot())).to.equal(true); + expect(isPositiveZero(Math.hypot(0, 0, 0))).to.equal(true); + expect(isPositiveZero(Math.hypot(0, -0, 0))).to.equal(true); + expect(isPositiveZero(Math.hypot(-0, -0, -0))).to.equal(true); + expect(Math.hypot(66, 66)).to.almostEqual(93.33809511662427); + expect(Math.hypot(0.1, 100)).to.almostEqual(100.0000499999875); + }); + + it('should coerce to a number', function () { + expect(Math.hypot('Infinity', 0)).to.equal(Infinity); + expect(Math.hypot('3', '3', '3', '3')).to.equal(6); + }); + + it('should take more than 3 arguments', function () { + expect(Math.hypot(66, 66, 66)).to.almostEqual(114.3153532995459); + expect(Math.hypot(66, 66, 66, 66)).to.equal(132); + }); + + it('should have the right length', function () { + expect(Math.hypot.length).to.equal(2); + }); + + it('works for very large or small numbers', function () { + expect(Math.hypot(1e+300, 1e+300)).to.almostEqual(1.4142135623730952e+300); + expect(Math.hypot(1e-300, 1e-300)).to.almostEqual(1.4142135623730952e-300); + expect(Math.hypot(1e+300, 1e+300, 2, 3)).to.almostEqual(1.4142135623730952e+300); + }); + }); + + describe('.log2()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'log2')) { + return it('exists', function () { + expect(Math).to.have.property('log2'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.log2).to.have.property('name', 'log2'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('log2').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.log2).to.have.property('length', 1); + }); + + it('is correct for small numbers', function () { + expect(numberIsNaN(Math.log2(-1e-50))).to.equal(true); + }); + + it('is correct for edge cases', function () { + expect(numberIsNaN(Math.log2(NaN))).to.equal(true); + expect(Math.log2(+0)).to.equal(-Infinity); + expect(Math.log2(-0)).to.equal(-Infinity); + expect(isPositiveZero(Math.log2(1))).to.equal(true); + expect(Math.log2(Infinity)).to.equal(Infinity); + }); + + it('should have the right precision', function () { + expect(Math.log2(5)).to.almostEqual(2.321928094887362); + expect(Math.log2(32)).to.almostEqual(5); + }); + }); + + describe('.log10', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'log10')) { + return it('exists', function () { + expect(Math).to.have.property('log10'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.log10).to.have.property('name', 'log10'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('log10').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.log10).to.have.property('length', 1); + }); + + it('should be correct for edge cases', function () { + expect(numberIsNaN(Math.log10(NaN))).to.equal(true); + expect(numberIsNaN(Math.log10(-1e-50))).to.equal(true); + expect(Math.log10(+0)).to.equal(-Infinity); + expect(Math.log10(-0)).to.equal(-Infinity); + expect(isPositiveZero(Math.log10(1))).to.equal(true); + expect(Math.log10(Infinity)).to.equal(Infinity); + }); + + it('should have the right precision', function () { + expect(Math.log10(5)).to.almostEqual(0.698970004336018); + expect(Math.log10(50)).to.almostEqual(1.6989700043360187); + }); + }); + + describe('.log1p', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'log1p')) { + return it('exists', function () { + expect(Math).to.have.property('log1p'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.log1p).to.have.property('name', 'log1p'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('log1p').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.log1p).to.have.property('length', 1); + }); + + it('should be correct', function () { + expect(numberIsNaN(Math.log1p(NaN))).to.equal(true); + expect(numberIsNaN(Math.log1p(-1.000000001))).to.equal(true); + expect(Math.log1p(-1)).to.equal(-Infinity); + expect(isPositiveZero(Math.log1p(+0))).to.equal(true); + expect(isNegativeZero(Math.log1p(-0))).to.equal(true); + expect(Math.log1p(Infinity)).to.equal(Infinity); + + expect(Math.log1p(5)).to.almostEqual(1.791759469228055); + expect(Math.log1p(50)).to.almostEqual(3.9318256327243257); + expect(Math.log1p(-1e-17)).to.equal(-1e-17); + expect(Math.log1p(-2e-17)).to.equal(-2e-17); + }); + }); + + describe('.sign()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'sign')) { + return it('exists', function () { + expect(Math).to.have.property('sign'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.sign).to.have.property('name', 'sign'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('sign').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.sign).to.have.property('length', 1); + }); + + it('should be correct', function () { + // we also verify that [[ToNumber]] is being called + [Infinity, 1].forEach(function (value) { + expect(Math.sign(value)).to.equal(1); + expect(Math.sign(String(value))).to.equal(1); + }); + expect(Math.sign(true)).to.equal(1); + + [-Infinity, -1].forEach(function (value) { + expect(Math.sign(value)).to.equal(-1); + expect(Math.sign(String(value))).to.equal(-1); + }); + + expect(isPositiveZero(Math.sign(+0))).to.equal(true); + expect(isPositiveZero(Math.sign('0'))).to.equal(true); + expect(isPositiveZero(Math.sign('+0'))).to.equal(true); + expect(isPositiveZero(Math.sign(''))).to.equal(true); + expect(isPositiveZero(Math.sign(' '))).to.equal(true); + expect(isPositiveZero(Math.sign(null))).to.equal(true); + expect(isPositiveZero(Math.sign(false))).to.equal(true); + expect(isNegativeZero(Math.sign(-0))).to.equal(true); + expect(isNegativeZero(Math.sign('-0'))).to.equal(true); + expect(numberIsNaN(Math.sign(NaN))).to.equal(true); + expect(numberIsNaN(Math.sign('NaN'))).to.equal(true); + expect(numberIsNaN(Math.sign(undefined))).to.equal(true); + }); + }); + + describe('.sinh()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'sinh')) { + return it('exists', function () { + expect(Math).to.have.property('sinh'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.sinh).to.have.property('name', 'sinh'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('sinh').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.sinh).to.have.property('length', 1); + }); + + it('should be correct', function () { + expect(numberIsNaN(Math.sinh(NaN))).to.equal(true); + expect(isPositiveZero(Math.sinh(+0))).to.equal(true); + expect(isNegativeZero(Math.sinh(-0))).to.equal(true); + expect(Math.sinh(Infinity)).to.equal(Infinity); + expect(Math.sinh(-Infinity)).to.equal(-Infinity); + expect(Math.sinh(-5)).to.almostEqual(-74.20321057778875); + expect(Math.sinh(2)).to.almostEqual(3.6268604078470186); + expect(Math.sinh(-2e-17)).to.equal(-2e-17); + }); + + it('is correct for extreme non-infinities', function () { + expect(Math.sinh(710)).not.to.equal(Infinity); + expect(Math.sinh(710) / 1e+308).to.almostEqual(1.1169973830808557); + }); + }); + + describe('.tanh()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'tanh')) { + return it('exists', function () { + expect(Math).to.have.property('tanh'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.tanh).to.have.property('name', 'tanh'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('tanh').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.tanh).to.have.property('length', 1); + }); + + it('should be correct', function () { + expect(numberIsNaN(Math.tanh(NaN))).to.equal(true); + expect(isPositiveZero(Math.tanh(+0))).to.equal(true); + expect(isNegativeZero(Math.tanh(-0))).to.equal(true); + expect(Math.tanh(Infinity)).to.equal(1); + expect(Math.tanh(-Infinity)).to.equal(-1); + expect(Math.tanh(19)).to.almostEqual(1); + expect(Math.tanh(-19)).to.almostEqual(-1); + expect(Math.tanh(20)).to.equal(1); // JS loses precision for true value at this integer + expect(Math.tanh(-20)).to.equal(-1); // JS loses precision for true value at this integer + expect(Math.tanh(10)).to.almostEqual(0.9999999958776927); + expect(Math.tanh(-2e-17)).to.equal(-2e-17); + }); + }); + + describe('.trunc()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'trunc')) { + return it('exists', function () { + expect(Math).to.have.property('trunc'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.trunc).to.have.property('name', 'trunc'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('trunc').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.trunc).to.have.property('length', 1); + }); + + it('should be correct', function () { + expect(numberIsNaN(Math.trunc(NaN))).to.equal(true); + expect(isNegativeZero(Math.trunc(-0))).to.equal(true); + expect(isPositiveZero(Math.trunc(+0))).to.equal(true); + expect(Math.trunc(Infinity)).to.equal(Infinity); + expect(Math.trunc(-Infinity)).to.equal(-Infinity); + expect(Math.trunc(1.01)).to.equal(1); + expect(Math.trunc(1.99)).to.equal(1); + expect(Math.trunc(-555.555)).to.equal(-555); + expect(Math.trunc(-1.99)).to.equal(-1); + }); + + it('should coerce to a number immediately', function () { + expect(Math.trunc(valueOfIsInfinity)).to.equal(Infinity); + expect(numberIsNaN(Math.trunc(valueOfIsNaN))).to.equal(true); + }); + }); + + describe('.imul()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'imul')) { + return it('exists', function () { + expect(Math).to.have.property('imul'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.imul).to.have.property('name', 'imul'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('imul').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.imul).to.have.property('length', 2); + }); + + var str = 'str'; + var obj = {}; + var arr = []; + + it('should be correct for non-numbers', function () { + expect(Math.imul(false, 7)).to.equal(0); + expect(Math.imul(7, false)).to.equal(0); + expect(Math.imul(false, false)).to.equal(0); + expect(Math.imul(true, 7)).to.equal(7); + expect(Math.imul(7, true)).to.equal(7); + expect(Math.imul(true, true)).to.equal(1); + expect(Math.imul(undefined, 7)).to.equal(0); + expect(Math.imul(7, undefined)).to.equal(0); + expect(Math.imul(undefined, undefined)).to.equal(0); + expect(Math.imul(str, 7)).to.equal(0); + expect(Math.imul(7, str)).to.equal(0); + expect(Math.imul(obj, 7)).to.equal(0); + expect(Math.imul(7, obj)).to.equal(0); + expect(Math.imul(arr, 7)).to.equal(0); + expect(Math.imul(7, arr)).to.equal(0); + }); + + it('should be correct for hex values', function () { + expect(Math.imul(0xffffffff, 5)).to.equal(-5); + expect(Math.imul(0xfffffffe, 5)).to.equal(-10); + }); + + it('should be correct', function () { + expect(Math.imul(2, 4)).to.equal(8); + expect(Math.imul(-1, 8)).to.equal(-8); + expect(Math.imul(-2, -2)).to.equal(4); + expect(Math.imul(-0, 7)).to.equal(0); + expect(Math.imul(7, -0)).to.equal(0); + expect(Math.imul(0.1, 7)).to.equal(0); + expect(Math.imul(7, 0.1)).to.equal(0); + expect(Math.imul(0.9, 7)).to.equal(0); + expect(Math.imul(7, 0.9)).to.equal(0); + expect(Math.imul(1.1, 7)).to.equal(7); + expect(Math.imul(7, 1.1)).to.equal(7); + expect(Math.imul(1.9, 7)).to.equal(7); + expect(Math.imul(7, 1.9)).to.equal(7); + }); + + it('should be correct for objects with valueOf', function () { + var x = { + x: 0, + valueOf: function () { this.x += 1; return this.x; } + }; + expect(Math.imul(x, 1)).to.equal(1); + expect(Math.imul(1, x)).to.equal(2); + expect(Math.imul(x, 1)).to.equal(3); + expect(Math.imul(1, x)).to.equal(4); + expect(Math.imul(x, 1)).to.equal(5); + }); + }); + + describe('.round()', function () { + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.round).to.have.property('name', 'round'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('round').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.round).to.have.property('length', 1); + }); + + it('works for edge cases', function () { + expect(numberIsNaN(Math.round(NaN))).to.equal(true); + expect(isPositiveZero(Math.round(0))).to.equal(true); + expect(isNegativeZero(Math.round(-0))).to.equal(true); + expect(Math.round(Infinity)).to.equal(Infinity); + expect(Math.round(-Infinity)).to.equal(-Infinity); + }); + + it('returns 0 for (0,0.5)', function () { + expect(Math.round(0.5)).not.to.equal(0); + expect(Math.round(0.5 - (EPSILON / 4))).to.equal(0); + expect(Math.round(0 + (EPSILON / 4))).to.equal(0); + }); + + it('returns -0 for (-0.5,0)', function () { + expect(Math.round(-0.5)).to.equal(0); + expect(Math.round(-0.5 - (EPSILON / 3.99))).not.to.equal(0); + expect(isNegativeZero(Math.round(-0.5 + (EPSILON / 3.99)))).to.equal(true); + expect(isNegativeZero(Math.round(0 - (EPSILON / 3.99)))).to.equal(true); + }); + + it('returns 1 / Number.EPSILON + 1 for 1 / Number.EPSILON + 1', function () { + var inverseEpsilonPlus1 = (1 / EPSILON) + 1; + expect(Math.round(inverseEpsilonPlus1)).to.equal(inverseEpsilonPlus1); + }); + + it('returns 2 / Number.EPSILON - 1 for 2 / Number.EPSILON - 1', function () { + var twiceInverseEpsilonMinus1 = (2 / EPSILON) - 1; + expect(Math.round(twiceInverseEpsilonMinus1)).to.equal(twiceInverseEpsilonMinus1); + }); + }); + + describe('.fround()', function () { + if (!Object.prototype.hasOwnProperty.call(Math, 'fround')) { + return it('exists', function () { + expect(Math).to.have.property('fround'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Math.fround).to.have.property('name', 'fround'); + }); + + it('is not enumerable', function () { + expect(Math).ownPropertyDescriptor('fround').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Math.fround).to.have.property('length', 1); + }); + + // Mozilla's reference tests: https://bug900125.bugzilla.mozilla.org/attachment.cgi?id=793163 + it('returns NaN for undefined', function () { + expect(numberIsNaN(Math.fround())).to.equal(true); + }); + + it('returns NaN for NaN', function () { + expect(numberIsNaN(Math.fround(NaN))).to.equal(true); + }); + + it('works for zeroes and infinities', function () { + expect(isPositiveZero(Math.fround(0))).to.equal(true); + expect(isPositiveZero(Math.fround({ valueOf: function () { return 0; } }))).to.equal(true); + expect(isNegativeZero(Math.fround(-0))).to.equal(true); + expect(isNegativeZero(Math.fround({ valueOf: function () { return -0; } }))).to.equal(true); + expect(Math.fround(Infinity)).to.equal(Infinity); + expect(Math.fround({ valueOf: function () { return Infinity; } })).to.equal(Infinity); + expect(Math.fround(-Infinity)).to.equal(-Infinity); + expect(Math.fround({ valueOf: function () { return -Infinity; } })).to.equal(-Infinity); + }); + + it('returns infinity for large numbers', function () { + expect(Math.fround(1.7976931348623157e+308)).to.equal(Infinity); + expect(Math.fround(-1.7976931348623157e+308)).to.equal(-Infinity); + expect(Math.fround(3.4028235677973366e+38)).to.equal(Infinity); + }); + + it('returns zero for really small numbers', function () { + expect(Number.MIN_VALUE).to.equal(5e-324); + + expect(Math.fround(Number.MIN_VALUE)).to.equal(0); + expect(Math.fround(-Number.MIN_VALUE)).to.equal(0); + }); + + it('rounds properly', function () { + expect(Math.fround(3)).to.equal(3); + expect(Math.fround(-3)).to.equal(-3); + }); + + it('rounds properly with the max float 32', function () { + var maxFloat32 = 3.4028234663852886e+38; + expect(Math.fround(maxFloat32)).to.equal(maxFloat32); + expect(Math.fround(-maxFloat32)).to.equal(-maxFloat32); + + // round-nearest rounds down to maxFloat32 + expect(Math.fround(maxFloat32 + Math.pow(2, Math.pow(2, 8 - 1) - 1 - 23 - 2))).to.equal(maxFloat32); + }); + + it('rounds properly with the min float 32', function () { + var minFloat32 = 1.401298464324817e-45; + expect(Math.fround(minFloat32)).to.equal(minFloat32); + expect(Math.fround(-minFloat32)).to.equal(-minFloat32); + expect(Math.fround(minFloat32 / 2)).to.equal(0); + expect(Math.fround(-minFloat32 / 2)).to.equal(0); + expect(Math.fround((minFloat32 / 2) + Math.pow(2, -202))).to.equal(minFloat32); + expect(Math.fround((-minFloat32 / 2) - Math.pow(2, -202))).to.equal(-minFloat32); + }); + }); +}); diff --git a/node_modules/es6-shim/test/mocha.opts b/node_modules/es6-shim/test/mocha.opts new file mode 100644 index 0000000..a7fb771 --- /dev/null +++ b/node_modules/es6-shim/test/mocha.opts @@ -0,0 +1,2 @@ +--require test/test_helpers.js + diff --git a/node_modules/es6-shim/test/native.html b/node_modules/es6-shim/test/native.html new file mode 100644 index 0000000..51f8dc0 --- /dev/null +++ b/node_modules/es6-shim/test/native.html @@ -0,0 +1,39 @@ + + + + + es6-shim tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + diff --git a/node_modules/es6-shim/test/number.js b/node_modules/es6-shim/test/number.js new file mode 100644 index 0000000..4568dd8 --- /dev/null +++ b/node_modules/es6-shim/test/number.js @@ -0,0 +1,482 @@ +describe('Number', function () { + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + + var integers = [5295, -5295, -9007199254740991, 9007199254740991, 0, -0]; + var nonIntegers = [-9007199254741992, 9007199254741992, 5.9]; + var infinities = [Infinity, -Infinity]; + + var valueOfThree = { valueOf: function () { return 3; } }; + var valueOfNaN = { valueOf: function () { return NaN; } }; + var valueOfThrows = { valueOf: function () { throw Object(17); } }; + var toStringThrows = { toString: function () { throw Object(42); } }; + var toPrimitiveThrows = { + valueOf: function () { throw Object(17); }, + toString: function () { throw Object(42); } + }; + + var nonNumbers = [ + undefined, + true, + false, + null, + {}, + [], + 'str', + '', + valueOfThree, + valueOfNaN, + valueOfThrows, + toStringThrows, + toPrimitiveThrows, + /a/g + ]; + var expectTrue = function (item) { + expect(item).to.equal(true); + }; + var expectFalse = function (item) { + expect(item).to.equal(false); + }; + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Number).to.equal(Number); + }); + + describe('Number constants', function () { + it('should have max safe integer', function () { + expect(Number).to.have.property('MAX_SAFE_INTEGER'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'MAX_SAFE_INTEGER')).to.equal(false); + expect(Number.MAX_SAFE_INTEGER).to.equal(Math.pow(2, 53) - 1); + }); + + it('should have min safe integer', function () { + expect(Number).to.have.property('MIN_SAFE_INTEGER'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'MIN_SAFE_INTEGER')).to.equal(false); + expect(Number.MIN_SAFE_INTEGER).to.equal(-Math.pow(2, 53) + 1); + }); + + it('should have epsilon', function () { + expect(Number).to.have.property('EPSILON'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'EPSILON')).to.equal(false); + expect(Number.EPSILON).to.equal(2.2204460492503130808472633361816e-16); + }); + + it('should have NaN', function () { + expect(Number).to.have.property('NaN'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'NaN')).to.equal(false); + expect(isNaN(Number.NaN)).to.equal(true); + }); + + it('should have MAX_VALUE', function () { + expect(Number).to.have.property('MAX_VALUE'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'MAX_VALUE')).to.equal(false); + expect(Number.MAX_VALUE).to.equal(1.7976931348623157e+308); + }); + + it('should have MIN_VALUE', function () { + expect(Number).to.have.property('MIN_VALUE'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'MIN_VALUE')).to.equal(false); + expect(Number.MIN_VALUE).to.equal(5e-324); + }); + + it('should have NEGATIVE_INFINITY', function () { + expect(Number).to.have.property('NEGATIVE_INFINITY'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'NEGATIVE_INFINITY')).to.equal(false); + expect(Number.NEGATIVE_INFINITY).to.equal(-Infinity); + }); + + it('should have POSITIVE_INFINITY', function () { + expect(Number).to.have.property('POSITIVE_INFINITY'); + expect(Object.prototype.propertyIsEnumerable.call(Number, 'POSITIVE_INFINITY')).to.equal(false); + expect(Number.POSITIVE_INFINITY).to.equal(Infinity); + }); + }); + + describe('.parseInt()', function () { + if (!Object.prototype.hasOwnProperty.call(Number, 'parseInt')) { + return it('exists', function () { + expect(Number).to.have.property('parseInt'); + }); + } + + it('should work', function () { + /* eslint-disable radix */ + expect(Number.parseInt('601')).to.equal(601); + /* eslint-enable radix */ + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Number.parseInt).to.have.property('name', 'parseInt'); + }); + + it('is not enumerable', function () { + expect(Number).ownPropertyDescriptor('parseInt').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + // WebKit nightly had the wrong length; fixed in https://bugs.webkit.org/show_bug.cgi?id=143657 + expect(Number.parseInt).to.have.property('length', 2); + }); + + it('is the same object as the global parseInt', function () { + // fixed in WebKit nightly in https://bugs.webkit.org/show_bug.cgi?id=143799#add_comment + expect(Number.parseInt).to.equal(parseInt); + }); + }); + + describe('.parseFloat()', function () { + if (!Object.prototype.hasOwnProperty.call(Number, 'parseFloat')) { + return it('exists', function () { + expect(Number).to.have.property('parseFloat'); + }); + } + + it('should work', function () { + expect(Number.parseFloat('5.5')).to.equal(5.5); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Number.parseFloat).to.have.property('name', 'parseFloat'); + }); + + it('is not enumerable', function () { + expect(Number).ownPropertyDescriptor('parseFloat').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Number.parseFloat).to.have.property('length', 1); + }); + }); + + describe('.isFinite()', function () { + if (!Object.prototype.hasOwnProperty.call(Number, 'isFinite')) { + return it('exists', function () { + expect(Number).to.have.property('isFinite'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Number.isFinite).to.have.property('name', 'isFinite'); + }); + + it('is not enumerable', function () { + expect(Number).ownPropertyDescriptor('isFinite').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Number.isFinite).to.have.property('length', 1); + }); + + it('should work', function () { + integers.map(Number.isFinite).forEach(expectTrue); + infinities.map(Number.isFinite).forEach(expectFalse); + expect(Number.isFinite(Infinity)).to.equal(false); + expect(Number.isFinite(-Infinity)).to.equal(false); + expect(Number.isFinite(NaN)).to.equal(false); + expect(Number.isFinite(4)).to.equal(true); + expect(Number.isFinite(4.5)).to.equal(true); + expect(Number.isFinite('hi')).to.equal(false); + expect(Number.isFinite('1.3')).to.equal(false); + expect(Number.isFinite('51')).to.equal(false); + expect(Number.isFinite(0)).to.equal(true); + expect(Number.isFinite(-0)).to.equal(true); + expect(Number.isFinite(valueOfThree)).to.equal(false); + expect(Number.isFinite(valueOfNaN)).to.equal(false); + expect(Number.isFinite(valueOfThrows)).to.equal(false); + expect(Number.isFinite(toStringThrows)).to.equal(false); + expect(Number.isFinite(toPrimitiveThrows)).to.equal(false); + }); + + it('should not be confused by type coercion', function () { + nonNumbers.map(Number.isFinite).forEach(expectFalse); + }); + }); + + describe('.isInteger()', function () { + if (!Object.prototype.hasOwnProperty.call(Number, 'isInteger')) { + return it('exists', function () { + expect(Number).to.have.property('isInteger'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Number.isInteger).to.have.property('name', 'isInteger'); + }); + + it('is not enumerable', function () { + expect(Number).ownPropertyDescriptor('isInteger').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Number.isInteger).to.have.property('length', 1); + }); + + it('should be truthy on integers', function () { + integers.map(Number.isInteger).forEach(expectTrue); + expect(Number.isInteger(4)).to.equal(true); + expect(Number.isInteger(4.0)).to.equal(true); + expect(Number.isInteger(1801439850948)).to.equal(true); + }); + + it('should be false when the type is not number', function () { + nonNumbers.forEach(function (thing) { + expect(Number.isInteger(thing)).to.equal(false); + }); + }); + + it('should be false when NaN', function () { + expect(Number.isInteger(NaN)).to.equal(false); + }); + + it('should be false when ∞', function () { + expect(Number.isInteger(Infinity)).to.equal(false); + expect(Number.isInteger(-Infinity)).to.equal(false); + }); + + it('should be false when number is not integer', function () { + expect(Number.isInteger(3.4)).to.equal(false); + expect(Number.isInteger(-3.4)).to.equal(false); + }); + + it('should be true when abs(number) is 2^53 or larger', function () { + expect(Number.isInteger(Math.pow(2, 53))).to.equal(true); + expect(Number.isInteger(Math.pow(2, 54))).to.equal(true); + expect(Number.isInteger(-Math.pow(2, 53))).to.equal(true); + expect(Number.isInteger(-Math.pow(2, 54))).to.equal(true); + }); + + it('should be true when abs(number) is less than 2^53', function () { + var safeIntegers = [0, 1, Math.pow(2, 53) - 1]; + safeIntegers.forEach(function (integer) { + expect(Number.isInteger(integer)).to.equal(true); + expect(Number.isInteger(-integer)).to.equal(true); + }); + }); + }); + + describe('.isSafeInteger()', function () { + if (!Object.prototype.hasOwnProperty.call(Number, 'isSafeInteger')) { + return it('exists', function () { + expect(Number).to.have.property('isSafeInteger'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Number.isSafeInteger).to.have.property('name', 'isSafeInteger'); + }); + + it('is not enumerable', function () { + expect(Number).ownPropertyDescriptor('isSafeInteger').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Number.isSafeInteger).to.have.property('length', 1); + }); + + it('should be truthy on integers', function () { + integers.map(Number.isSafeInteger).forEach(expectTrue); + expect(Number.isSafeInteger(4)).to.equal(true); + expect(Number.isSafeInteger(4.0)).to.equal(true); + expect(Number.isSafeInteger(1801439850948)).to.equal(true); + }); + + it('should be false when the type is not number', function () { + nonNumbers.forEach(function (thing) { + expect(Number.isSafeInteger(thing)).to.equal(false); + }); + }); + + it('should be false when NaN', function () { + expect(Number.isSafeInteger(NaN)).to.equal(false); + }); + + it('should be false when ∞', function () { + expect(Number.isSafeInteger(Infinity)).to.equal(false); + expect(Number.isSafeInteger(-Infinity)).to.equal(false); + }); + + it('should be false when number is not integer', function () { + expect(Number.isSafeInteger(3.4)).to.equal(false); + expect(Number.isSafeInteger(-3.4)).to.equal(false); + }); + + it('should be false when abs(number) is 2^53 or larger', function () { + expect(Number.isSafeInteger(Math.pow(2, 53))).to.equal(false); + expect(Number.isSafeInteger(Math.pow(2, 54))).to.equal(false); + expect(Number.isSafeInteger(-Math.pow(2, 53))).to.equal(false); + expect(Number.isSafeInteger(-Math.pow(2, 54))).to.equal(false); + }); + + it('should be true when abs(number) is less than 2^53', function () { + var safeIntegers = [0, 1, Math.pow(2, 53) - 1]; + safeIntegers.forEach(function (integer) { + expect(Number.isSafeInteger(integer)).to.equal(true); + expect(Number.isSafeInteger(-integer)).to.equal(true); + }); + }); + }); + + describe('.isNaN()', function () { + if (!Object.prototype.hasOwnProperty.call(Number, 'isNaN')) { + return it('exists', function () { + expect(Number).to.have.property('isNaN'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Number.isNaN).to.have.property('name', 'isNaN'); + }); + + it('is not enumerable', function () { + expect(Number).ownPropertyDescriptor('isNaN').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Number.isNaN).to.have.property('length', 1); + }); + + it('should be truthy only on NaN', function () { + integers.concat(nonIntegers).map(Number.isNaN).forEach(expectFalse); + nonNumbers.map(Number.isNaN).forEach(expectFalse); + expect(Number.isNaN(NaN)).to.equal(true); + expect(Number.isNaN(0 / 0)).to.equal(true); + expect(Number.isNaN(Number('NaN'))).to.equal(true); + expect(Number.isNaN(4)).to.equal(false); + expect(Number.isNaN(4.5)).to.equal(false); + expect(Number.isNaN('hi')).to.equal(false); + expect(Number.isNaN('1.3')).to.equal(false); + expect(Number.isNaN('51')).to.equal(false); + expect(Number.isNaN(0)).to.equal(false); + expect(Number.isNaN(-0)).to.equal(false); + expect(Number.isNaN(valueOfThree)).to.equal(false); + expect(Number.isNaN(valueOfNaN)).to.equal(false); + expect(Number.isNaN(valueOfThrows)).to.equal(false); + expect(Number.isNaN(toStringThrows)).to.equal(false); + expect(Number.isNaN(toPrimitiveThrows)).to.equal(false); + }); + }); + + describe('constructor', function () { + it('behaves like the builtin', function () { + expect((1).constructor).to.equal(Number); + expect(Number()).to.equal(0); + }); + + describe('strings in the constructor', function () { + it('works on normal literals', function () { + expect(Number('1')).to.equal(+'1'); + expect(Number('1.1')).to.equal(+'1.1'); + expect(Number('0xA')).to.equal(0xA); + }); + }); + + describe('when called with a receiver', function () { + it('returns a primitive when called with a primitive receiver', function () { + expect((1).constructor(2)).to.equal(2); + expect((1).constructor.call(null, 3)).to.equal(3); + expect(Object(1).constructor.call(null, 5)).to.equal(5); + }); + + it('returns a primitive when called with a different number as an object receiver', function () { + expect(Object(1).constructor(6)).to.equal(6); + expect(Object(1).constructor.call(Object(1), 7)).to.equal(7); + }); + + it('returns a primitive when called with the same number as an object receiver', function () { + expect(Object(1).constructor.call(Object(8), 8)).to.equal(8); + }); + }); + + it('works with boxed primitives', function () { + expect(1 instanceof Number).to.equal(false); + expect(Object(1) instanceof Number).to.equal(true); + }); + + it('works with `new`', function () { + /* eslint-disable no-new-wrappers */ + var one = new Number('1'); + var a = new Number('0xA'); + /* eslint-enable no-new-wrappers */ + + expect(+one).to.equal(1); + expect(one instanceof Number).to.equal(true); + expect(+a).to.equal(0xA); + expect(a instanceof Number).to.equal(true); + }); + + it('works with binary literals in string form', function () { + expect(Number('0b1')).to.equal(1); + expect(Number(' 0b1')).to.equal(1); + expect(Number('0b1 ')).to.equal(1); + + expect(Number('0b10')).to.equal(2); + expect(Number(' 0b10')).to.equal(2); + expect(Number('0b10 ')).to.equal(2); + + expect(Number('0b11')).to.equal(3); + expect(Number(' 0b11')).to.equal(3); + expect(Number('0b11 ')).to.equal(3); + + expect(Number({ + toString: function () { return '0b100'; }, + valueOf: function () { return '0b101'; } + })).to.equal(5); + }); + + it('works with octal literals in string form', function () { + expect(Number('0o7')).to.equal(7); + expect(Number('0o10')).to.equal(8); + expect(Number('0o11')).to.equal(9); + expect(Number({ + toString: function () { return '0o12'; }, + valueOf: function () { return '0o13'; } + })).to.equal(11); + }); + + it('should produce NaN', function () { + expect(String(Number('0b12'))).to.equal('NaN'); + expect(String(Number('0o18'))).to.equal('NaN'); + expect(String(Number('0x1g'))).to.equal('NaN'); + expect(String(Number('+0b1'))).to.equal('NaN'); + expect(String(Number('+0o1'))).to.equal('NaN'); + expect(String(Number('+0x1'))).to.equal('NaN'); + expect(String(Number('-0b1'))).to.equal('NaN'); + expect(String(Number('-0o1'))).to.equal('NaN'); + expect(String(Number('-0x1'))).to.equal('NaN'); + }); + + it('should work with well formed and poorly formed objects', function () { + expect(String(Number({}))).to.equal('NaN'); + expect(String(Number({ valueOf: '1.1' }))).to.equal('NaN'); + expect(Number({ valueOf: '1.1', toString: function () { return '2.2'; } })).to.equal(2.2); + expect(Number({ valueOf: function () { return '1.1'; }, toString: '2.2' })).to.equal(1.1); + expect(Number({ + valueOf: function () { return '1.1'; }, + toString: function () { return '2.2'; } + })).to.equal(1.1); + expect(String(Number({ valueOf: function () { return '-0x1a2b3c'; } }))).to.equal('NaN'); + expect(String(Number({ toString: function () { return '-0x1a2b3c'; } }))).to.equal('NaN'); + expect(Number({ valueOf: function () { return '0o12345'; } })).to.equal(5349); + expect(Number({ toString: function () { return '0o12345'; } })).to.equal(5349); + expect(Number({ valueOf: function () { return '0b101010'; } })).to.equal(42); + expect(Number({ toString: function () { return '0b101010'; } })).to.equal(42); + }); + + it('should work with correct whitespaces', function () { + // Zero-width space (zws), next line character (nel), and non-character (bom) are not whitespace. + var nonWhitespaces = ['\u0085', '\u200b', '\ufffe']; + + expect(String(Number(nonWhitespaces[0] + '0' + nonWhitespaces[0]))).to.equal('NaN'); + expect(String(Number(nonWhitespaces[1] + '1' + nonWhitespaces[1]))).to.equal('NaN'); + expect(String(Number(nonWhitespaces[2] + '2' + nonWhitespaces[2]))).to.equal('NaN'); + }); + + it.skip('it works with updated unicode values', function () { + var whitespace = ' \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'; + + expect(String(Number(whitespace + '3' + whitespace))).to.equal('3'); + }); + }); +}); diff --git a/node_modules/es6-shim/test/object.js b/node_modules/es6-shim/test/object.js new file mode 100644 index 0000000..29ed3ae --- /dev/null +++ b/node_modules/es6-shim/test/object.js @@ -0,0 +1,365 @@ +describe('Object', function () { + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Object).to.equal(Object); + }); + + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var ifExtensionsPreventable = Object.preventExtensions ? it : xit; + + var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; + var ifSymbolsIt = hasSymbols ? it : xit; + var ifBrowserIt = typeof window === 'object' && typeof document === 'object' ? it : xit; + var ifObjectGetPrototypeOfIt = typeof Object.getPrototypeOf === 'function' ? it : xit; + + if (Object.getOwnPropertyNames) { + describe('.getOwnPropertyNames()', function () { + it('throws on null or undefined', function () { + expect(function () { Object.getOwnPropertyNames(); }).to['throw'](TypeError); + expect(function () { Object.getOwnPropertyNames(undefined); }).to['throw'](TypeError); + expect(function () { Object.getOwnPropertyNames(null); }).to['throw'](TypeError); + }); + + it('works on primitives', function () { + [true, false, NaN, 42, /a/g, 'foo'].forEach(function (item) { + expect(Object.getOwnPropertyNames(item)).to.eql(Object.getOwnPropertyNames(Object(item))); + }); + }); + + ifBrowserIt('does not break when an iframe is added', function () { + /*global window, document */ + var div = document.createElement('div'); + div.innerHTML = ''; + document.body.appendChild(div); + setTimeout(function () { + document.body.removeChild(div); + }, 0); + expect(Array.isArray(Object.getOwnPropertyNames(window))).to.eql(true); + }); + }); + } + + if (Object.getOwnPropertyDescriptor) { + describe('.getOwnPropertyDescriptor()', function () { + it('throws on null or undefined', function () { + expect(function () { Object.getOwnPropertyDescriptor(); }).to['throw'](TypeError); + expect(function () { Object.getOwnPropertyDescriptor(undefined); }).to['throw'](TypeError); + expect(function () { Object.getOwnPropertyDescriptor(null); }).to['throw'](TypeError); + }); + + it('works on primitives', function () { + [true, false, NaN, 42, /a/g, 'foo'].forEach(function (item) { + expect(Object.getOwnPropertyDescriptor(item, 'foo')).to.eql(Object.getOwnPropertyDescriptor(Object(item), 'foo')); + }); + }); + }); + } + + if (Object.seal) { + describe('.seal()', function () { + it('works on primitives', function () { + [null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) { + expect(Object.seal(item)).to.eql(item); + }); + }); + }); + } + + if (Object.isSealed) { + describe('.isSealed()', function () { + it('works on primitives', function () { + [null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) { + expect(Object.isSealed(item)).to.equal(true); + }); + }); + }); + } + + if (Object.freeze) { + describe('.freeze()', function () { + it('works on primitives', function () { + [null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) { + expect(Object.freeze(item)).to.eql(item); + }); + }); + }); + } + + if (Object.isFrozen) { + describe('.isFrozen()', function () { + it('works on primitives', function () { + [null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) { + expect(Object.isFrozen(item)).to.equal(true); + }); + }); + }); + } + + if (Object.preventExtensions) { + describe('.preventExtensions()', function () { + it('works on primitives', function () { + [null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) { + expect(Object.preventExtensions(item)).to.eql(item); + }); + }); + }); + } + + if (Object.isExtensible) { + describe('.isExtensible()', function () { + it('works on primitives', function () { + [null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) { + expect(Object.isExtensible(item)).to.equal(false); + }); + }); + }); + } + + describe('.keys()', function () { + it('works on strings', function () { + expect(Object.keys('foo')).to.eql(['0', '1', '2']); + }); + + it('throws on null or undefined', function () { + expect(function () { Object.keys(); }).to['throw'](TypeError); + expect(function () { Object.keys(undefined); }).to['throw'](TypeError); + expect(function () { Object.keys(null); }).to['throw'](TypeError); + }); + + it('works on other primitives', function () { + [true, false, NaN, 42, /a/g].forEach(function (item) { + expect(Object.keys(item)).to.eql([]); + }); + }); + }); + + describe('.is()', function () { + if (!Object.prototype.hasOwnProperty.call(Object, 'is')) { + return it('exists', function () { + expect(Object).to.have.property('is'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Object.is).to.have.property('name', 'is'); + }); + + it('should have the right arity', function () { + expect(Object.is).to.have.property('length', 2); + }); + + it('should compare regular objects correctly', function () { + [null, undefined, [0], 5, 'str', { a: null }].map(function (item) { + return Object.is(item, item); + }).forEach(function (result) { + expect(result).to.equal(true); + }); + }); + + it('should compare 0 and -0 correctly', function () { + expect(Object.is(0, -0)).to.equal(false); + }); + + it('should compare NaNs correctly', function () { + expect(Object.is(NaN, NaN)).to.equal(true); + }); + }); + + describe('.assign()', function () { + if (!Object.prototype.hasOwnProperty.call(Object, 'assign')) { + return it('exists', function () { + expect(Object).to.have.property('assign'); + }); + } + + it('has the correct length', function () { + expect(Object.assign.length).to.eql(2); + }); + + it('returns the modified target object', function () { + var target = {}; + var returned = Object.assign(target, { a: 1 }); + expect(returned).to.equal(target); + }); + + it('should merge two objects', function () { + var target = { a: 1 }; + var returned = Object.assign(target, { b: 2 }); + expect(returned).to.eql({ a: 1, b: 2 }); + }); + + it('should merge three objects', function () { + var target = { a: 1 }; + var source1 = { b: 2 }; + var source2 = { c: 3 }; + var returned = Object.assign(target, source1, source2); + expect(returned).to.eql({ a: 1, b: 2, c: 3 }); + }); + + it('only iterates over own keys', function () { + var Foo = function () {}; + Foo.prototype.bar = true; + var foo = new Foo(); + foo.baz = true; + var target = { a: 1 }; + var returned = Object.assign(target, foo); + expect(returned).to.equal(target); + expect(target).to.eql({ baz: true, a: 1 }); + }); + + it('throws when target is null or undefined', function () { + expect(function () { Object.assign(null); }).to['throw'](TypeError); + expect(function () { Object.assign(undefined); }).to['throw'](TypeError); + }); + + it('coerces lone target to an object', function () { + var result = { + bool: Object.assign(true), + number: Object.assign(1), + string: Object.assign('1') + }; + + expect(typeof result.bool).to.equal('object'); + expect(Boolean.prototype.valueOf.call(result.bool)).to.equal(true); + + expect(typeof result.number).to.equal('object'); + expect(Number.prototype.valueOf.call(result.number)).to.equal(1); + + expect(typeof result.string).to.equal('object'); + expect(String.prototype.valueOf.call(result.string)).to.equal('1'); + }); + + it('coerces target to an object, assigns from sources', function () { + var sourceA = { a: 1 }; + var sourceB = { b: 1 }; + + var result = { + bool: Object.assign(true, sourceA, sourceB), + number: Object.assign(1, sourceA, sourceB), + string: Object.assign('1', sourceA, sourceB) + }; + + expect(typeof result.bool).to.equal('object'); + expect(Boolean.prototype.valueOf.call(result.bool)).to.equal(true); + expect(result.bool).to.eql({ a: 1, b: 1 }); + + expect(typeof result.number).to.equal('object'); + expect(Number.prototype.valueOf.call(result.number)).to.equal(1); + + expect(typeof result.string).to.equal('object'); + expect(String.prototype.valueOf.call(result.string)).to.equal('1'); + expect(result.string).to.eql({ 0: '1', a: 1, b: 1 }); + }); + + it('ignores non-object sources', function () { + expect(Object.assign({ a: 1 }, null, { b: 2 })).to.eql({ a: 1, b: 2 }); + expect(Object.assign({ a: 1 }, undefined, { b: 2 })).to.eql({ a: 1, b: 2 }); + expect(Object.assign({ a: 1 }, { b: 2 }, null)).to.eql({ a: 1, b: 2 }); + }); + + ifExtensionsPreventable('does not have pending exceptions', function () { + 'use strict'; + + // Firefox 37 still has "pending exception" logic in its Object.assign implementation, + // which is 72% slower than our shim, and Firefox 40's native implementation. + var thrower = { 1: 2, 2: 3, 3: 4 }; + Object.defineProperty(thrower, 2, { + get: function () { return 3; }, + set: function (v) { throw new RangeError('IE 9 does not throw on preventExtensions: ' + v); } + }); + Object.preventExtensions(thrower); + expect(thrower).to.have.property(2, 3); + var error; + try { + Object.assign(thrower, 'wxyz'); + } catch (e) { + error = e; + } + expect(thrower).not.to.have.property(0); + if (thrower[1] === 'x') { + // IE 9 doesn't throw in strict mode with preventExtensions + expect(error).to.be.an.instanceOf(RangeError); + } else { + expect(error).to.be.an.instanceOf(TypeError); + expect(thrower).to.have.property(1, 2); + } + expect(thrower).to.have.property(2, 3); + expect(thrower).to.have.property(3, 4); + }); + + ifSymbolsIt('includes enumerable symbols, after keys', function () { + /* eslint max-statements-per-line: 1 */ + var visited = []; + var obj = {}; + Object.defineProperty(obj, 'a', { get: function () { visited.push('a'); return 42; }, enumerable: true }); + var symbol = Symbol('enumerable'); + Object.defineProperty(obj, symbol, { + get: function () { visited.push(symbol); return Infinity; }, + enumerable: true + }); + var nonEnumSymbol = Symbol('non-enumerable'); + Object.defineProperty(obj, nonEnumSymbol, { + get: function () { visited.push(nonEnumSymbol); return -Infinity; }, + enumerable: false + }); + var target = Object.assign({}, obj); + expect(visited).to.eql(['a', symbol]); + expect(target.a).to.equal(42); + expect(target[symbol]).to.equal(Infinity); + expect(target[nonEnumSymbol]).not.to.equal(-Infinity); + }); + }); + + describe('Object.setPrototypeOf()', function () { + if (!Object.setPrototypeOf) { + return; // IE < 11 + } + + describe('argument checking', function () { + it('should throw TypeError if first arg is not object', function () { + var nonObjects = [null, undefined, true, false, 1, 3, 'foo']; + nonObjects.forEach(function (value) { + expect(function () { Object.setPrototypeOf(value); }).to['throw'](TypeError); + }); + }); + + it('should throw TypeError if second arg is not object or null', function () { + expect(function () { Object.setPrototypeOf({}, null); }).not.to['throw'](TypeError); + var invalidPrototypes = [true, false, 1, 3, 'foo']; + invalidPrototypes.forEach(function (proto) { + expect(function () { Object.setPrototypeOf({}, proto); }).to['throw'](TypeError); + }); + }); + }); + + describe('set prototype', function () { + it('should work', function () { + var Foo = function () {}; + var Bar = {}; + var foo = new Foo(); + expect(Object.getPrototypeOf(foo)).to.equal(Foo.prototype); + + var fooBar = Object.setPrototypeOf(foo, Bar); + expect(fooBar).to.equal(foo); + expect(Object.getPrototypeOf(foo)).to.equal(Bar); + }); + it('should be able to set to null', function () { + var Foo = function () {}; + var foo = new Foo(); + + var fooNull = Object.setPrototypeOf(foo, null); + expect(fooNull).to.equal(foo); + expect(Object.getPrototypeOf(foo)).to.equal(null); + }); + }); + }); + + describe('.getPrototypeOf()', function () { + ifObjectGetPrototypeOfIt('does not throw for a primitive', function () { + expect(Object.getPrototypeOf(3)).to.equal(Number.prototype); + }); + }); +}); diff --git a/node_modules/es6-shim/test/promise.js b/node_modules/es6-shim/test/promise.js new file mode 100644 index 0000000..213bbd8 --- /dev/null +++ b/node_modules/es6-shim/test/promise.js @@ -0,0 +1,43 @@ +/* This file is for testing implementation regressions of Promises. */ + +describe('Promise', function () { + if (typeof Promise === 'undefined') { + return it('exists', function () { + expect(typeof Promise).to.be('function'); + }); + } + + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Promise).to.equal(Promise); + }); + + it('ignores non-function .then arguments', function () { + expect(function () { + Promise.reject(42).then(null, 5).then(null, function () {}); + }).not.to['throw'](); + }); + + describe('extra methods (bad Chrome!)', function () { + it('does not have accept', function () { + expect(Promise).not.to.have.property('accept'); + }); + + it('does not have defer', function () { + expect(Promise).not.to.have.property('defer'); + }); + + it('does not have chain', function () { + expect(Promise.prototype).not.to.have.property('chain'); + }); + }); + + it('requires an object context', function () { + // this fails in Safari 7.1 - 9 + expect(function promiseDotCallThree() { + Promise.call(3, function () {}); + }).to['throw'](); + }); +}); diff --git a/node_modules/es6-shim/test/promise/all.js b/node_modules/es6-shim/test/promise/all.js new file mode 100644 index 0000000..f7717ff --- /dev/null +++ b/node_modules/es6-shim/test/promise/all.js @@ -0,0 +1,197 @@ +/* global it, describe, expect, assert, Promise */ + +var failIfThrows = function (done) { + 'use strict'; + + return function (e) { + done(e || new Error()); + }; +}; + +describe('Promise.all', function () { + 'use strict'; + + it('should not be enumerable', function () { + expect(Promise).ownPropertyDescriptor('all').to.have.property('enumerable', false); + }); + + it('fulfills if passed an empty array', function (done) { + var iterable = []; + + Promise.all(iterable).then(function (value) { + assert(Array.isArray(value)); + assert.deepEqual(value, []); + }).then(done, failIfThrows(done)); + }); + + it('fulfills if passed an empty array-like', function (done) { + var f = function () { + Promise.all(arguments).then(function (value) { + assert(Array.isArray(value)); + assert.deepEqual(value, []); + }).then(done, failIfThrows(done)); + }; + f(); + }); + + it('fulfills if passed an array of mixed fulfilled promises and values', function (done) { + var iterable = [0, Promise.resolve(1), 2, Promise.resolve(3)]; + + Promise.all(iterable).then(function (value) { + assert(Array.isArray(value)); + assert.deepEqual(value, [0, 1, 2, 3]); + }).then(done, failIfThrows(done)); + }); + + it('rejects if any passed promise is rejected', function (done) { + var foreverPending = new Promise(function () { }); + var error = new Error('Rejected'); + var rejected = Promise.reject(error); + + var iterable = [foreverPending, rejected]; + + Promise.all(iterable).then( + function () { + assert(false, 'should never get here'); + }, + function (reason) { + assert.strictEqual(reason, error); + } + ).then(done, failIfThrows(done)); + }); + + it('resolves foreign thenables', function (done) { + var normal = Promise.resolve(1); + var foreign = { then: function (f) { f(2); } }; + + var iterable = [normal, foreign]; + + Promise.all(iterable).then(function (value) { + assert.deepEqual(value, [1, 2]); + }).then(done, failIfThrows(done)); + }); + + it('fulfills when passed an sparse array, giving `undefined` for the omitted values', function (done) { + /* eslint-disable no-sparse-arrays */ + var iterable = [Promise.resolve(0), , , Promise.resolve(1)]; + /* eslint-enable no-sparse-arrays */ + + Promise.all(iterable).then(function (value) { + assert.deepEqual(value, [0, undefined, undefined, 1]); + }).then(done, failIfThrows(done)); + }); + + it('does not modify the input array', function (done) { + var input = [0, 1]; + var iterable = input; + + Promise.all(iterable).then(function (value) { + assert.notStrictEqual(input, value); + }).then(done, failIfThrows(done)); + }); + + it('should reject with a TypeError if given a non-iterable', function (done) { + var notIterable = {}; + + Promise.all(notIterable).then( + function () { + assert(false, 'should never get here'); + }, + function (reason) { + assert(reason instanceof TypeError); + } + ).then(done, failIfThrows(done)); + }); + + // test cases from + // https://github.com/domenic/promises-unwrapping/issues/89#issuecomment-33110203 + var tamper = function (p) { + p.then = function (fulfill, reject) { + fulfill('tampered'); + return Promise.prototype.then.call(this, fulfill, reject); + }; + return p; + }; + + it('should be robust against tampering (1)', function (done) { + var g = [tamper(Promise.resolve(0))]; + // Prevent countdownHolder.[[Countdown]] from ever reaching zero + Promise.all(g).then( + function () { done(); }, + failIfThrows(done) + ); + }); + + it('should be robust against tampering (2)', function (done) { + // Promise from Promise.all resolved before arguments + var fulfillCalled = false; + + var g = [ + Promise.resolve(0), + tamper(Promise.resolve(1)), + Promise.resolve(2).then(function () { + assert(!fulfillCalled, 'should be resolved before all()'); + }).then(function () { + assert(!fulfillCalled, 'should be resolved before all()'); + })['catch'](failIfThrows(done)) + ]; + Promise.all(g).then(function () { + assert(!fulfillCalled, 'should be resolved last'); + fulfillCalled = true; + }).then(done, failIfThrows(done)); + }); + + it('should be robust against tampering (3)', function (done) { + var g = [ + Promise.resolve(0), + tamper(Promise.resolve(1)), + Promise.reject(2) + ]; + // Promise from Promise.all resolved despite rejected promise in arguments + Promise.all(g).then(function () { + throw new Error('should not reach here!'); + }, function (e) { + assert.strictEqual(e, 2); + }).then(done, failIfThrows(done)); + }); + + it('should be robust against tampering (4)', function (done) { + var hijack = true; + var actualArguments = []; + var P = function (resolver) { + var self; + if (hijack) { + hijack = false; + self = new Promise(function (resolve, reject) { + return resolver(function (values) { + // record arguments & # of times resolve function is called + actualArguments.push(values.slice()); + return resolve(values); + }, reject); + }); + } else { + self = new Promise(resolver); + } + Object.setPrototypeOf(self, P.prototype); + return self; + }; + if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11 + Object.setPrototypeOf(P, Promise); + P.prototype = Object.create(Promise.prototype, { + constructor: { value: P } + }); + P.resolve = function (p) { return p; }; + + var g = [ + Promise.resolve(0), + tamper(Promise.resolve(1)), + Promise.resolve(2) + ]; + + // Promise.all calls resolver twice + P.all(g)['catch'](failIfThrows(done)); + Promise.resolve().then(function () { + assert.deepEqual(actualArguments, [[0, 'tampered', 2]]); + }).then(done, failIfThrows(done)); + }); +}); diff --git a/node_modules/es6-shim/test/promise/evil-promises.js b/node_modules/es6-shim/test/promise/evil-promises.js new file mode 100644 index 0000000..f2c3b07 --- /dev/null +++ b/node_modules/es6-shim/test/promise/evil-promises.js @@ -0,0 +1,36 @@ +describe('Evil promises should not be able to break invariants', function () { + 'use strict'; + + specify('resolving to a promise that calls onFulfilled twice', function (done) { + // note that we have to create a trivial subclass, as otherwise the + // Promise.resolve(evilPromise) is just the identity function. + // (And in fact, most native Promise implementations use a private + // [[PromiseConstructor]] field in `Promise.resolve` which can't be + // easily patched in an ES5 engine, so instead of + // `Promise.resolve(evilPromise)` we'll use + // `new Promise(function(r){r(evilPromise);})` below.) + var EvilPromise = function (executor) { + var self = new Promise(executor); + Object.setPrototypeOf(self, EvilPromise.prototype); + return self; + }; + if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11 + Object.setPrototypeOf(EvilPromise, Promise); + EvilPromise.prototype = Object.create(Promise.prototype, { + constructor: { value: EvilPromise } + }); + + var evilPromise = EvilPromise.resolve(); + evilPromise.then = function (f) { + f(1); + f(2); + }; + + var calledAlready = false; + new Promise(function (r) { r(evilPromise); }).then(function (value) { + assert.strictEqual(calledAlready, false); + calledAlready = true; + assert.strictEqual(value, 1); + }).then(done, done); + }); +}); diff --git a/node_modules/es6-shim/test/promise/promises-aplus.js b/node_modules/es6-shim/test/promise/promises-aplus.js new file mode 100644 index 0000000..b7ab4f3 --- /dev/null +++ b/node_modules/es6-shim/test/promise/promises-aplus.js @@ -0,0 +1,23 @@ +// tests from promises-aplus-tests + +describe('Promises/A+ Tests', function () { + 'use strict'; + + if (typeof Promise === 'undefined') { + return; + } + + require('promises-aplus-tests').mocha({ + // an adapter from es6 spec to Promises/A+ + deferred: function () { + var result = {}; + result.promise = new Promise(function (resolve, reject) { + result.resolve = resolve; + result.reject = reject; + }); + return result; + }, + resolved: Promise.resolve.bind(Promise), + rejected: Promise.reject.bind(Promise) + }); +}); diff --git a/node_modules/es6-shim/test/promise/promises-es6.js b/node_modules/es6-shim/test/promise/promises-es6.js new file mode 100644 index 0000000..d5b307a --- /dev/null +++ b/node_modules/es6-shim/test/promise/promises-es6.js @@ -0,0 +1,22 @@ +// tests from promises-es6-tests +(function () { + 'use strict'; + + if (typeof Promise === 'undefined') { + return; + } + + describe('Promises/ES6 Tests', function () { + + // an adapter that sets up global.Promise + // since it's already set up, empty functions will suffice + var adapter = { + defineGlobalPromise: function () { + }, + removeGlobalPromise: function () { + } + }; + + require('promises-es6-tests').mocha(adapter); + }); +}()); diff --git a/node_modules/es6-shim/test/promise/race.js b/node_modules/es6-shim/test/promise/race.js new file mode 100644 index 0000000..d18309a --- /dev/null +++ b/node_modules/es6-shim/test/promise/race.js @@ -0,0 +1,88 @@ +var failIfThrows = function (done) { + 'use strict'; + + return function (e) { + done(e || new Error()); + }; +}; + +var delayPromise = function (value, ms) { + 'use strict'; + + return new Promise(function (resolve) { + setTimeout(function () { + resolve(value); + }, ms); + }); +}; + +describe('Promise.race', function () { + 'use strict'; + + it('should not be enumerable', function () { + expect(Promise).ownPropertyDescriptor('race').to.have.property('enumerable', false); + }); + + it('should fulfill if all promises are settled and the ordinally-first is fulfilled', function (done) { + var iterable = [Promise.resolve(1), Promise.reject(2), Promise.resolve(3)]; + + Promise.race(iterable).then(function (value) { + assert.strictEqual(value, 1); + }).then(done, failIfThrows(done)); + }); + + it('should reject if all promises are settled and the ordinally-first is rejected', function (done) { + var iterable = [Promise.reject(1), Promise.reject(2), Promise.resolve(3)]; + + Promise.race(iterable).then( + function () { + assert(false, 'should never get here'); + }, + function (reason) { + assert.strictEqual(reason, 1); + } + ).then(done, failIfThrows(done)); + }); + + it('should settle in the same way as the first promise to settle', function (done) { + // ensure that even if timeouts are delayed an all execute together, + // p2 will settle first. + var p2 = delayPromise(2, 200); + var p1 = delayPromise(1, 1000); + var p3 = delayPromise(3, 500); + var iterable = [p1, p2, p3]; + + Promise.race(iterable).then(function (value) { + assert.strictEqual(value, 2); + }).then(done, failIfThrows(done)); + }); + + // see https://github.com/domenic/promises-unwrapping/issues/75 + it('should never settle when given an empty iterable', function (done) { + var iterable = []; + var settled = false; + + Promise.race(iterable).then( + function () { settled = true; }, + function () { settled = true; } + ); + + setTimeout(function () { + assert.strictEqual(settled, false); + done(); + }, 300); + }); + + it('should reject with a TypeError if given a non-iterable', function (done) { + var notIterable = {}; + + Promise.race(notIterable).then( + function () { + assert(false, 'should never get here'); + }, + function (reason) { + assert(reason instanceof TypeError); + } + ).then(done, failIfThrows(done)); + }); +}); diff --git a/node_modules/es6-shim/test/promise/reject.js b/node_modules/es6-shim/test/promise/reject.js new file mode 100644 index 0000000..c1c94f9 --- /dev/null +++ b/node_modules/es6-shim/test/promise/reject.js @@ -0,0 +1,34 @@ +var failIfThrows = function (done) { + 'use strict'; + + return function (e) { + done(e || new Error()); + }; +}; + +describe('Promise.reject', function () { + 'use strict'; + + it('should not be enumerable', function () { + expect(Promise).ownPropertyDescriptor('reject').to.have.property('enumerable', false); + }); + + it('should return a rejected promise', function (done) { + var value = {}; + Promise.reject(value).then(failIfThrows(done), function (result) { + expect(result).to.equal(value); + done(); + }); + }); + + it('throws when receiver is a primitive', function () { + var promise = Promise.reject(); + expect(function () { Promise.reject.call(undefined, promise); }).to['throw'](); + expect(function () { Promise.reject.call(null, promise); }).to['throw'](); + expect(function () { Promise.reject.call('', promise); }).to['throw'](); + expect(function () { Promise.reject.call(42, promise); }).to['throw'](); + expect(function () { Promise.reject.call(false, promise); }).to['throw'](); + expect(function () { Promise.reject.call(true, promise); }).to['throw'](); + promise.then(null, function () {}); // silence unhandled rejection errors in Chrome + }); +}); diff --git a/node_modules/es6-shim/test/promise/resolve.js b/node_modules/es6-shim/test/promise/resolve.js new file mode 100644 index 0000000..23bad8d --- /dev/null +++ b/node_modules/es6-shim/test/promise/resolve.js @@ -0,0 +1,33 @@ +var failIfThrows = function (done) { + 'use strict'; + + return function (e) { + done(e || new Error()); + }; +}; + +describe('Promise.resolve', function () { + 'use strict'; + + it('should not be enumerable', function () { + expect(Promise).ownPropertyDescriptor('resolve').to.have.property('enumerable', false); + }); + + it('should return a resolved promise', function (done) { + var value = {}; + Promise.resolve(value).then(function (result) { + expect(result).to.equal(value); + done(); + }, failIfThrows(done)); + }); + + it('throws when receiver is a primitive', function () { + var promise = Promise.resolve(); + expect(function () { Promise.resolve.call(undefined, promise); }).to['throw'](); + expect(function () { Promise.resolve.call(null, promise); }).to['throw'](); + expect(function () { Promise.resolve.call('', promise); }).to['throw'](); + expect(function () { Promise.resolve.call(42, promise); }).to['throw'](); + expect(function () { Promise.resolve.call(false, promise); }).to['throw'](); + expect(function () { Promise.resolve.call(true, promise); }).to['throw'](); + }); +}); diff --git a/node_modules/es6-shim/test/promise/simple.js b/node_modules/es6-shim/test/promise/simple.js new file mode 100644 index 0000000..1feb665 --- /dev/null +++ b/node_modules/es6-shim/test/promise/simple.js @@ -0,0 +1,96 @@ +var failIfThrows = function (done) { + 'use strict'; + + return function (e) { + done(e || new Error()); + }; +}; + +describe('Promise', function () { + 'use strict'; + + specify('sanity check: a fulfilled promise calls its fulfillment handler', function (done) { + Promise.resolve(5).then(function (value) { + assert.strictEqual(value, 5); + }).then(done, failIfThrows(done)); + }); + + specify('directly resolving the promise with itself', function (done) { + var resolvePromise; + var promise = new Promise(function (resolve) { resolvePromise = resolve; }); + + resolvePromise(promise); + + promise.then( + function () { + assert(false, 'Should not be fulfilled'); + }, + function (err) { + assert(err instanceof TypeError); + } + ).then(done, failIfThrows(done)); + }); + + specify('Stealing a resolver and using it to trigger possible reentrancy bug (#83)', function () { + var stolenResolver; + var StealingPromiseConstructor = function StealingPromiseConstructor(resolver) { + stolenResolver = resolver; + resolver(function () { }, function () { }); + }; + + var iterable = {}; + var atAtIterator = '@@iterator'; // on firefox, at least. + iterable[atAtIterator] = function () { + stolenResolver(null, null); + throw new Error(0); + }; + + assert.doesNotThrow(function () { + Promise.all.call(StealingPromiseConstructor, iterable); + }); + }); + + specify('resolve with a thenable calls it once', function () { + var resolve; + var p = new Promise(function (r) { resolve = r; }); + var count = 0; + resolve({ + then: function () { + count += 1; + throw new RangeError('reject the promise'); + } + }); + var a = p.then(function () {})['catch'](function (err) { + assert.equal(count, 1); + assert.ok(err instanceof RangeError); + }); + var b = p.then(function () {})['catch'](function (err) { + assert.equal(count, 1); + assert.ok(err instanceof RangeError); + }); + return Promise.all([a, b]); + }); + + specify('resolve with a thenable that throws on .then, rejects the promise synchronously', function () { + var resolve; + var p = new Promise(function (r) { resolve = r; }); + var count = 0; + var thenable = Object.defineProperty({}, 'then', { + get: function () { + count += 1; + throw new RangeError('no then for you'); + } + }); + resolve(thenable); + assert.equal(count, 1); + var a = p.then(function () {})['catch'](function (err) { + assert.equal(count, 1); + assert.ok(err instanceof RangeError); + }); + var b = p.then(function () {})['catch'](function (err) { + assert.equal(count, 1); + assert.ok(err instanceof RangeError); + }); + return Promise.all([a, b]); + }); +}); diff --git a/node_modules/es6-shim/test/promise/subclass.js b/node_modules/es6-shim/test/promise/subclass.js new file mode 100644 index 0000000..8ff3bed --- /dev/null +++ b/node_modules/es6-shim/test/promise/subclass.js @@ -0,0 +1,47 @@ +/* global it, describe, assert, Promise */ + +describe('Support user subclassing of Promise', function () { + 'use strict'; + + it('should work if you do it right', function (done) { + // This is the "correct" es6-compatible way. + // (Thanks, @domenic and @zloirock!) + var MyPromise = function (executor) { + var self = new Promise(executor); + Object.setPrototypeOf(self, MyPromise.prototype); + self.mine = 'yeah'; + return self; + }; + if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11 + Object.setPrototypeOf(MyPromise, Promise); + MyPromise.prototype = Object.create(Promise.prototype, { + constructor: { value: MyPromise } + }); + + // let's try it! + var p1 = MyPromise.resolve(5); + assert.strictEqual(p1.mine, 'yeah'); + p1 = p1.then(function (x) { + assert.strictEqual(x, 5); + }); + assert.strictEqual(p1.mine, 'yeah'); + + var p2 = new MyPromise(function (r) { r(6); }); + assert.strictEqual(p2.mine, 'yeah'); + p2 = p2.then(function (x) { + assert.strictEqual(x, 6); + }); + assert.strictEqual(p2.mine, 'yeah'); + + var p3 = MyPromise.all([p1, p2]); + assert.strictEqual(p3.mine, 'yeah'); + p3.then(function () { done(); }, done); + }); + + it("should throw if you don't inherit at all", function () { + var MyPromise = function () {}; + assert['throws'](function () { + Promise.all.call(MyPromise, []); + }, TypeError); + }); +}); diff --git a/node_modules/es6-shim/test/reflect.js b/node_modules/es6-shim/test/reflect.js new file mode 100644 index 0000000..7ea8419 --- /dev/null +++ b/node_modules/es6-shim/test/reflect.js @@ -0,0 +1,679 @@ +var arePropertyDescriptorsSupported = function () { + try { + Object.defineProperty({}, 'x', {}); + return true; + } catch (e) { /* this is IE 8. */ + return false; + } +}; +var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); +var functionsHaveNames = function f() {}.name === 'f'; + +var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; +var ifSymbolsIt = hasSymbols ? it : xit; +var describeIfGetProto = Object.getPrototypeOf ? describe : xdescribe; +var describeIfSetProto = Object.setPrototypeOf ? describe : xdescribe; +var describeIfES5 = supportsDescriptors ? describe : xdescribe; +var describeIfExtensionsPreventible = Object.preventExtensions ? describe : xdescribe; +var describeIfGetOwnPropertyNames = Object.getOwnPropertyNames ? describe : xdescribe; +var ifExtensionsPreventibleIt = Object.preventExtensions ? it : xit; +var ifES5It = supportsDescriptors ? it : xit; +var ifFreezeIt = typeof Object.freeze === 'function' ? it : xit; +var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; +var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + +describe('Reflect', function () { + if (typeof Reflect === 'undefined') { + return it('exists', function () { + expect(this).to.have.property('Reflect'); + }); + } + + var object = { + something: 1, + _value: 0 + }; + + if (supportsDescriptors) { + /* eslint-disable accessor-pairs */ + Object.defineProperties(object, { + value: { + get: function () { + return this._value; + } + }, + + setter: { + set: function (val) { + this._value = val; + } + }, + + bool: { + value: true + } + }); + /* eslint-enable accessor-pairs */ + } + + var testXThrow = function (values, func) { + var checker = function checker(item) { + try { + func(item); + return false; + } catch (e) { + return e instanceof TypeError; + } + }; + + values.forEach(function (item) { + expect(item).to.satisfy(checker); + }); + }; + + var testCallableThrow = testXThrow.bind(null, [null, undefined, 1, 'string', true, [], {}]); + + var testPrimitiveThrow = testXThrow.bind(null, [null, undefined, 1, 'string', true]); + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Reflect).to.equal(Reflect); + }); + + describe('.apply()', function () { + if (typeof Reflect.apply === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('apply'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.apply).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.apply.name).to.equal('apply'); + }); + + it('throws if target isn’t callable', function () { + testCallableThrow(function (item) { + return Reflect.apply(item, null, []); + }); + }); + + it('works also with redefined apply', function () { + expect(Reflect.apply(Array.prototype.push, [1, 2], [3, 4, 5])).to.equal(5); + + var F = function F(a, b, c) { + return a + b + c; + }; + + F.apply = false; + + expect(Reflect.apply(F, null, [1, 2, 3])).to.equal(6); + + var G = function G(last) { + return this.x + 'lo' + last; + }; + + G.apply = function nop() {}; + + expect(Reflect.apply(G, { x: 'yel' }, ['!'])).to.equal('yello!'); + }); + }); + + describe('.construct()', function () { + if (typeof Reflect.construct === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('construct'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.construct).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.construct.name).to.equal('construct'); + }); + + it('throws if target isn’t callable', function () { + testCallableThrow(function (item) { + return Reflect.apply(item, null, []); + }); + }); + + it('works also with redefined apply', function () { + var C = function C(a, b, c) { + this.qux = [a, b, c].join('|'); + }; + + C.apply = undefined; + + expect(Reflect.construct(C, ['foo', 'bar', 'baz']).qux).to.equal('foo|bar|baz'); + }); + + it('correctly handles newTarget param', function () { + var F = function F() {}; + expect(Reflect.construct(function () {}, [], F) instanceof F).to.equal(true); + }); + }); + + describeIfES5('.defineProperty()', function () { + if (typeof Reflect.defineProperty === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('defineProperty'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.defineProperty).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.defineProperty.name).to.equal('defineProperty'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.defineProperty(item, 'prop', { value: true }); + }); + }); + + ifExtensionsPreventibleIt('returns false for non-extensible objects', function () { + var o = Object.preventExtensions({}); + + expect(Reflect.defineProperty(o, 'prop', {})).to.equal(false); + }); + + it('can return true, even for non-configurable, non-writable properties', function () { + var o = {}; + var desc = { + value: 13, + enumerable: false, + writable: false, + configurable: false + }; + + expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(true); + + // Defined as non-configurable, but descriptor is identical. + expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(true); + + desc.value = 37; // Change + + expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(false); + }); + + it('can change from one property type to another, if configurable', function () { + var o = {}; + + var desc1 = { + set: function () {}, + configurable: true + }; + + var desc2 = { + value: 13, + configurable: false + }; + + var desc3 = { + get: function () {} + }; + + expect(Reflect.defineProperty(o, 'prop', desc1)).to.equal(true); + + expect(Reflect.defineProperty(o, 'prop', desc2)).to.equal(true); + + expect(Reflect.defineProperty(o, 'prop', desc3)).to.equal(false); + }); + }); + + describe('.deleteProperty()', function () { + if (typeof Reflect.deleteProperty === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('deleteProperty'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.deleteProperty).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.deleteProperty.name).to.equal('deleteProperty'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.deleteProperty(item, 'prop'); + }); + }); + + ifES5It('returns true for success and false for failure', function () { + var o = { a: 1 }; + + Object.defineProperty(o, 'b', { value: 2 }); + + expect(o).to.have.property('a'); + expect(o).to.have.property('b'); + expect(o.a).to.equal(1); + expect(o.b).to.equal(2); + + expect(Reflect.deleteProperty(o, 'a')).to.equal(true); + + expect(o).not.to.have.property('a'); + expect(o.b).to.equal(2); + + expect(Reflect.deleteProperty(o, 'b')).to.equal(false); + + expect(o).to.have.property('b'); + expect(o.b).to.equal(2); + + expect(Reflect.deleteProperty(o, 'a')).to.equal(true); + }); + + it('cannot delete an array’s length property', function () { + expect(Reflect.deleteProperty([], 'length')).to.equal(false); + }); + }); + + describeIfES5('.get()', function () { + if (typeof Reflect.get === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('get'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.get).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.get.name).to.equal('get'); + }); + + it('throws on null and undefined', function () { + [null, undefined].forEach(function (item) { + expect(function () { + return Reflect.get(item, 'property'); + }).to['throw'](TypeError); + }); + }); + + it('can retrieve a simple value, from the target', function () { + var p = { something: 2, bool: false }; + + expect(Reflect.get(object, 'something')).to.equal(1); + // p has no effect + expect(Reflect.get(object, 'something', p)).to.equal(1); + + // Value-defined properties take the target's value, + // and ignore that of the receiver. + expect(Reflect.get(object, 'bool', p)).to.equal(true); + + // Undefined values + expect(Reflect.get(object, 'undefined_property')).to.equal(undefined); + }); + + it('will invoke getters on the receiver rather than target', function () { + var other = { _value: 1337 }; + + expect(Reflect.get(object, 'value', other)).to.equal(1337); + + // No getter for setter property + expect(Reflect.get(object, 'setter', other)).to.equal(undefined); + }); + + it('will search the prototype chain', function () { + var other = Object.create(object); + other._value = 17; + + var yetAnother = { _value: 4711 }; + + expect(Reflect.get(other, 'value', yetAnother)).to.equal(4711); + + expect(Reflect.get(other, 'bool', yetAnother)).to.equal(true); + }); + }); + + describeIfES5('.set()', function () { + if (typeof Reflect.set === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('set'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.set).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.set.name).to.equal('set'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.set(item, 'prop', 'value'); + }); + }); + + it('sets values on receiver', function () { + var target = {}; + var receiver = {}; + + expect(Reflect.set(target, 'foo', 1, receiver)).to.equal(true); + + expect('foo' in target).to.equal(false); + expect(receiver.foo).to.equal(1); + + expect(Reflect.defineProperty(receiver, 'bar', { + value: 0, + writable: true, + enumerable: false, + configurable: true + })).to.equal(true); + + expect(Reflect.set(target, 'bar', 1, receiver)).to.equal(true); + expect(receiver.bar).to.equal(1); + expect(Reflect.getOwnPropertyDescriptor(receiver, 'bar').enumerable).to.equal(false); + + var out; + /* eslint-disable accessor-pairs */ + target = Object.create({}, { + o: { + set: function () { out = this; } + } + }); + /* eslint-enable accessor-pairs */ + + expect(Reflect.set(target, 'o', 17, receiver)).to.equal(true); + expect(out).to.equal(receiver); + }); + }); + + describeIfES5('.getOwnPropertyDescriptor()', function () { + if (typeof Reflect.getOwnPropertyDescriptor === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('getOwnPropertyDescriptor'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.getOwnPropertyDescriptor).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.getOwnPropertyDescriptor.name).to.equal('getOwnPropertyDescriptor'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.getOwnPropertyDescriptor(item, 'prop'); + }); + }); + + it('retrieves property descriptors', function () { + var obj = { a: 4711 }; + + var desc = Reflect.getOwnPropertyDescriptor(obj, 'a'); + + expect(desc).to.deep.equal({ + value: 4711, + configurable: true, + writable: true, + enumerable: true + }); + }); + }); + + describeIfGetProto('.getPrototypeOf()', function () { + if (typeof Reflect.getPrototypeOf === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('getPrototypeOf'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.getPrototypeOf).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.getPrototypeOf.name).to.equal('getPrototypeOf'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.getPrototypeOf(item); + }); + }); + + it('retrieves prototypes', function () { + expect(Reflect.getPrototypeOf(Object.create(null))).to.equal(null); + + expect(Reflect.getPrototypeOf([])).to.equal(Array.prototype); + }); + }); + + describe('.has()', function () { + if (typeof Reflect.has === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('has'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.has).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.has.name).to.equal('has'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.has(item, 'prop'); + }); + }); + + it('will detect own properties', function () { + var target = Object.create ? Object.create(null) : {}; + + expect(Reflect.has(target, 'prop')).to.equal(false); + + target.prop = undefined; + expect(Reflect.has(target, 'prop')).to.equal(true); + + delete target.prop; + expect(Reflect.has(target, 'prop')).to.equal(false); + + expect(Reflect.has(Reflect.has, 'length')).to.equal(true); + }); + + ifES5It('will detect an own accessor property', function () { + var target = Object.create(null); + /* eslint-disable accessor-pairs */ + Object.defineProperty(target, 'accessor', { + set: function () {} + }); + /* eslint-enable accessor-pairs */ + + expect(Reflect.has(target, 'accessor')).to.equal(true); + }); + + it('will search the prototype chain', function () { + var Parent = function () {}; + Parent.prototype.someProperty = undefined; + + var Child = function () {}; + Child.prototype = new Parent(); + + var target = new Child(); + target.bool = true; + + expect(Reflect.has(target, 'bool')).to.equal(true); + expect(Reflect.has(target, 'someProperty')).to.equal(true); + expect(Reflect.has(target, 'undefinedProperty')).to.equal(false); + }); + }); + + describeIfExtensionsPreventible('.isExtensible()', function () { + if (typeof Reflect.isExtensible === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('isExtensible'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.isExtensible).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.isExtensible.name).to.equal('isExtensible'); + }); + + it('returns true for plain objects', function () { + expect(Reflect.isExtensible({})).to.equal(true); + expect(Reflect.isExtensible(Object.preventExtensions({}))).to.equal(false); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.isExtensible(item); + }); + }); + }); + + describeIfGetOwnPropertyNames('.ownKeys()', function () { + if (typeof Reflect.ownKeys === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('ownKeys'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.ownKeys).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.ownKeys.name).to.equal('ownKeys'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.ownKeys(item); + }); + }); + + it('should return the same result as Object.getOwnPropertyNames if there are no Symbols', function () { + var obj = { foo: 1, bar: 2 }; + + obj[1] = 'first'; + + var result = Object.getOwnPropertyNames(obj); + + // Reflect.ownKeys depends on the implementation of + // Object.getOwnPropertyNames, at least for non-symbol keys. + expect(Reflect.ownKeys(obj)).to.deep.equal(result); + + // We can only be sure of which keys should exist. + expect(result.sort()).to.deep.equal(['1', 'bar', 'foo']); + }); + + ifSymbolsIt('symbols come last', function () { + var s = Symbol(); + + var o = { + 'non-symbol': true + }; + + o[s] = true; + + expect(Reflect.ownKeys(o)).to.deep.equal(['non-symbol', s]); + }); + }); + + describeIfExtensionsPreventible('.preventExtensions()', function () { + if (typeof Reflect.preventExtensions === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('preventExtensions'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.preventExtensions).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.preventExtensions.name).to.equal('preventExtensions'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.preventExtensions(item); + }); + }); + + it('prevents extensions on objects', function () { + var obj = {}; + Reflect.preventExtensions(obj); + expect(Object.isExtensible(obj)).to.equal(false); + }); + }); + + describeIfSetProto('.setPrototypeOf()', function () { + if (typeof Reflect.setPrototypeOf === 'undefined') { + return it('exists', function () { + expect(Reflect).to.have.property('setPrototypeOf'); + }); + } + + it('is a function', function () { + expect(typeof Reflect.setPrototypeOf).to.equal('function'); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Reflect.setPrototypeOf.name).to.equal('setPrototypeOf'); + }); + + it('throws if the target isn’t an object', function () { + testPrimitiveThrow(function (item) { + return Reflect.setPrototypeOf(item, null); + }); + }); + + it('throws if the prototype is neither object nor null', function () { + var o = {}; + + [undefined, 1, 'string', true].forEach(function (item) { + expect(function () { + return Reflect.setPrototypeOf(o, item); + }).to['throw'](TypeError); + }); + }); + + it('can set prototypes, and returns true on success', function () { + var obj = {}; + + expect(Reflect.setPrototypeOf(obj, Array.prototype)).to.equal(true); + expect(obj).to.be.an.instanceOf(Array); + + expect(obj.toString).not.to.equal(undefined); + expect(Reflect.setPrototypeOf(obj, null)).to.equal(true); + expect(obj.toString).to.equal(undefined); + }); + + ifFreezeIt('is returns false on failure', function () { + var obj = Object.freeze({}); + + expect(Reflect.setPrototypeOf(obj, null)).to.equal(false); + }); + + it('fails when attempting to create a circular prototype chain', function () { + var o = {}; + + expect(Reflect.setPrototypeOf(o, o)).to.equal(false); + }); + }); +}); diff --git a/node_modules/es6-shim/test/regexp.js b/node_modules/es6-shim/test/regexp.js new file mode 100644 index 0000000..15843f5 --- /dev/null +++ b/node_modules/es6-shim/test/regexp.js @@ -0,0 +1,413 @@ +var getRegexLiteral = function (stringRegex) { + try { + /* eslint-disable no-new-func */ + return Function('return ' + stringRegex + ';')(); + /* eslint-enable no-new-func */ + } catch (e) { /**/ } +}; +var describeIfSupportsDescriptors = Object.getOwnPropertyDescriptor ? describe : describe.skip; +var callAllowsPrimitives = (function () { return this === 3; }.call(3)); +var ifCallAllowsPrimitivesIt = callAllowsPrimitives ? it : it.skip; +var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; +var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && typeof Symbol('') === 'symbol'; +var ifSymbolsDescribe = hasSymbols ? describe : describe.skip; +var defaultRegex = (function () { + // Chrome Canary 51 has an undefined RegExp#toSource, and + // RegExp#toString produces `/undefined/` + try { + return RegExp.prototype.source ? String(RegExp.prototype) : '/(?:)/'; + } catch (e) { + return '/(?:)/'; + } +}()); + +describe('RegExp', function () { + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.RegExp).to.equal(RegExp); + }); + + it('can be called with no arguments', function () { + var regex = RegExp(); + expect(String(regex)).to.equal(defaultRegex); + expect(regex).to.be.an.instanceOf(RegExp); + }); + + it('can be called with null/undefined', function () { + expect(String(RegExp(null))).to.equal('/null/'); + expect(String(RegExp(undefined))).to.equal(defaultRegex); + }); + + describe('constructor', function () { + it('allows a regex as the pattern', function () { + var a = /a/g; + var b = new RegExp(a); + if (typeof a !== 'function') { + // in browsers like Safari 5, new RegExp with a regex returns the same instance. + expect(a).not.to.equal(b); + } + expect(a).to.eql(b); + }); + + it('allows a string with flags', function () { + expect(new RegExp('a', 'mgi')).to.eql(/a/gim); + expect(String(new RegExp('a', 'mgi'))).to.equal('/a/gim'); + }); + + it('allows a regex with flags', function () { + var a = /a/g; + var makeRegex = function () { return new RegExp(a, 'mi'); }; + expect(makeRegex).not.to['throw'](TypeError); + expect(makeRegex()).to.eql(/a/mi); + expect(String(makeRegex())).to.equal('/a/im'); + }); + + it('works with instanceof', function () { + expect(/a/g).to.be.an.instanceOf(RegExp); + expect(new RegExp('a', 'im')).to.be.an.instanceOf(RegExp); + expect(new RegExp(/a/g, 'im')).to.be.an.instanceOf(RegExp); + }); + + it('has the right constructor', function () { + expect(/a/g).to.have.property('constructor', RegExp); + expect(new RegExp('a', 'im')).to.have.property('constructor', RegExp); + expect(new RegExp(/a/g, 'im')).to.have.property('constructor', RegExp); + }); + + it('toStrings properly', function () { + expect(Object.prototype.toString.call(/a/g)).to.equal('[object RegExp]'); + expect(Object.prototype.toString.call(new RegExp('a', 'g'))).to.equal('[object RegExp]'); + expect(Object.prototype.toString.call(new RegExp(/a/g, 'im'))).to.equal('[object RegExp]'); + }); + + it('functions as a boxed primitive wrapper', function () { + var regex = /a/g; + expect(RegExp(regex)).to.equal(regex); + }); + + ifSymbolsDescribe('Symbol.replace', function () { + if (!hasSymbols || typeof Symbol.replace === 'undefined') { + return; + } + + it('is a function', function () { + expect(RegExp.prototype).to.have.property(Symbol.replace); + expect(typeof RegExp.prototype[Symbol.replace]).to.equal('function'); + }); + + it('is the same as String#replace', function () { + var regex = /a/g; + var str = 'abc'; + var symbolReplace = regex[Symbol.replace](str); + var stringReplace = str.replace(regex); + expect(Object.keys(symbolReplace)).to.eql(Object.keys(stringReplace)); + expect(symbolReplace).to.eql(stringReplace); + }); + }); + + ifSymbolsDescribe('Symbol.search', function () { + if (!hasSymbols || typeof Symbol.search === 'undefined') { + return; + } + + it('is a function', function () { + expect(RegExp.prototype).to.have.property(Symbol.search); + expect(typeof RegExp.prototype[Symbol.search]).to.equal('function'); + }); + + it('is the same as String#search', function () { + var regex = /a/g; + var str = 'abc'; + var symbolSearch = regex[Symbol.search](str); + var stringSearch = str.search(regex); + expect(Object.keys(symbolSearch)).to.eql(Object.keys(stringSearch)); + expect(symbolSearch).to.eql(stringSearch); + }); + }); + + ifSymbolsDescribe('Symbol.split', function () { + if (!hasSymbols || typeof Symbol.split === 'undefined') { + return; + } + + it('is a function', function () { + expect(RegExp.prototype).to.have.property(Symbol.split); + expect(typeof RegExp.prototype[Symbol.split]).to.equal('function'); + }); + + it('is the same as String#split', function () { + var regex = /a/g; + var str = 'abcabc'; + var symbolSplit = regex[Symbol.split](str, 1); + var stringSplit = str.split(regex, 1); + expect(Object.keys(symbolSplit)).to.eql(Object.keys(stringSplit)); + expect(symbolSplit).to.eql(stringSplit); + }); + }); + + ifSymbolsDescribe('Symbol.match', function () { + if (!hasSymbols || typeof Symbol.match === 'undefined') { + return; + } + + var regexFalsyMatch; + var nonregexTruthyMatch; + + beforeEach(function () { + regexFalsyMatch = /./; + regexFalsyMatch[Symbol.match] = false; + nonregexTruthyMatch = { constructor: RegExp }; + nonregexTruthyMatch[Symbol.match] = true; + }); + + it('is a function', function () { + expect(RegExp.prototype).to.have.property(Symbol.match); + expect(typeof RegExp.prototype[Symbol.match]).to.equal('function'); + }); + + it('is the same as String#match', function () { + var regex = /a/g; + var str = 'abc'; + var symbolMatch = regex[Symbol.match](str); + var stringMatch = str.match(regex); + expect(Object.keys(symbolMatch)).to.eql(Object.keys(stringMatch)); + expect(symbolMatch).to.eql(stringMatch); + }); + + it('function does not passthrough regexes with a falsy Symbol.match', function () { + expect(RegExp(regexFalsyMatch)).not.to.equal(regexFalsyMatch); + }); + + it('constructor does not passthrough regexes with a falsy Symbol.match', function () { + expect(new RegExp(regexFalsyMatch)).not.to.equal(regexFalsyMatch); + }); + + it('function passes through non-regexes with a truthy Symbol.match', function () { + expect(RegExp(nonregexTruthyMatch)).to.equal(nonregexTruthyMatch); + }); + + it('constructor does not pass through non-regexes with a truthy Symbol.match', function () { + expect(new RegExp(nonregexTruthyMatch)).not.to.equal(nonregexTruthyMatch); + }); + }); + }); + + describeIfSupportsDescriptors('#flags', function () { + if (!Object.prototype.hasOwnProperty.call(RegExp.prototype, 'flags')) { + return it('exists', function () { + expect(RegExp.prototype).to.have.property('flags'); + }); + } + + var regexpFlagsDescriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags'); + var testGenericRegExpFlags = function (object) { + return regexpFlagsDescriptor.get.call(object); + }; + + it('has the correct descriptor', function () { + expect(regexpFlagsDescriptor.configurable).to.equal(true); + expect(regexpFlagsDescriptor.enumerable).to.equal(false); + expect(regexpFlagsDescriptor.get instanceof Function).to.equal(true); + expect(regexpFlagsDescriptor.set).to.equal(undefined); + }); + + ifCallAllowsPrimitivesIt('throws when not called on an object', function () { + var nonObjects = ['', false, true, 42, NaN, null, undefined]; + nonObjects.forEach(function (nonObject) { + expect(function () { testGenericRegExpFlags(nonObject); }).to['throw'](TypeError); + }); + }); + + it('has the correct flags on a literal', function () { + expect((/a/g).flags).to.equal('g'); + expect((/a/i).flags).to.equal('i'); + expect((/a/m).flags).to.equal('m'); + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) { + expect(getRegexLiteral('/a/y').flags).to.equal('y'); + } + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) { + expect(getRegexLiteral('/a/u').flags).to.equal('u'); + } + }); + + it('has the correct flags on a constructed RegExp', function () { + expect(new RegExp('a', 'g').flags).to.equal('g'); + expect(new RegExp('a', 'i').flags).to.equal('i'); + expect(new RegExp('a', 'm').flags).to.equal('m'); + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) { + expect(new RegExp('a', 'y').flags).to.equal('y'); + } + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) { + expect(new RegExp('a', 'u').flags).to.equal('u'); + } + }); + + it('returns flags sorted on a literal', function () { + expect((/a/gim).flags).to.equal('gim'); + expect((/a/mig).flags).to.equal('gim'); + expect((/a/mgi).flags).to.equal('gim'); + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) { + expect(getRegexLiteral('/a/gyim').flags).to.equal('gimy'); + } + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) { + expect(getRegexLiteral('/a/ugmi').flags).to.equal('gimu'); + } + }); + + it('returns flags sorted on a constructed RegExp', function () { + expect(new RegExp('a', 'gim').flags).to.equal('gim'); + expect(new RegExp('a', 'mig').flags).to.equal('gim'); + expect(new RegExp('a', 'mgi').flags).to.equal('gim'); + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) { + expect(new RegExp('a', 'mygi').flags).to.equal('gimy'); + } + if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) { + expect(new RegExp('a', 'mugi').flags).to.equal('gimu'); + } + }); + }); + + describe('#toString()', function () { + it('throws on null/undefined', function () { + expect(function () { RegExp.prototype.toString.call(null); }).to['throw'](TypeError); + expect(function () { RegExp.prototype.toString.call(undefined); }).to['throw'](TypeError); + }); + + it('works on regexes', function () { + expect(RegExp.prototype.toString.call(/a/g)).to.equal('/a/g'); + expect(RegExp.prototype.toString.call(new RegExp('a', 'g'))).to.equal('/a/g'); + }); + + it('works on non-regexes', function () { + expect(RegExp.prototype.toString.call({ source: 'abc', flags: '' })).to.equal('/abc/'); + expect(RegExp.prototype.toString.call({ source: 'abc', flags: 'xyz' })).to.equal('/abc/xyz'); + }); + + ifSymbolsDescribe('Symbol.match', function () { + if (!hasSymbols || typeof Symbol.match === 'undefined') { + return; + } + + it('accepts a non-regex with Symbol.match', function () { + var obj = { source: 'abc', flags: 'def' }; + obj[Symbol.match] = RegExp.prototype[Symbol.match]; + expect(RegExp.prototype.toString.call(obj)).to.equal('/abc/def'); + }); + }); + }); + + describe('Object properties', function () { + it('does not have the nonstandard $input property', function () { + expect(RegExp).not.to.have.property('$input'); // Chrome < 39, Opera < 26 have this + }); + + it('has "input" property', function () { + expect(RegExp).to.have.ownProperty('input'); + expect(RegExp).to.have.ownProperty('$_'); + }); + + it('has "last match" property', function () { + expect(RegExp).to.have.ownProperty('lastMatch'); + expect(RegExp).to.have.ownProperty('$+'); + }); + + it('has "last paren" property', function () { + expect(RegExp).to.have.ownProperty('lastParen'); + expect(RegExp).to.have.ownProperty('$&'); + }); + + it('has "leftContext" property', function () { + expect(RegExp).to.have.ownProperty('leftContext'); + expect(RegExp).to.have.ownProperty('$`'); + }); + + it('has "rightContext" property', function () { + expect(RegExp).to.have.ownProperty('rightContext'); + expect(RegExp).to.have.ownProperty("$'"); + }); + + it.skip('has "multiline" property', function () { + // fails in IE 9, 10, 11 + expect(RegExp).to.have.ownProperty('multiline'); + expect(RegExp).to.have.ownProperty('$*'); + }); + + it('has the right globals', function () { + var matchVars = [ + '$1', + '$2', + '$3', + '$4', + '$5', + '$6', + '$7', + '$8', + '$9' + ]; + matchVars.forEach(function (match) { + expect(RegExp).to.have.property(match); + }); + }); + + describe('updates RegExp globals', function () { + var str = 'abcdefghijklmnopq'; + var re; + beforeEach(function () { + re = /(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)/; + re.exec(str); + }); + + it('has "input"', function () { + expect(RegExp.input).to.equal(str); + expect(RegExp.$_).to.equal(str); + }); + + it('has "multiline"', function () { + if (Object.prototype.hasOwnProperty.call(RegExp, 'multiline')) { + expect(RegExp.multiline).to.equal(false); + } + if (Object.prototype.hasOwnProperty.call(RegExp, '$*')) { + expect(RegExp['$*']).to.equal(false); + } + }); + + it('has "lastMatch"', function () { + expect(RegExp.lastMatch).to.equal('bcdefghijklmnop'); + expect(RegExp['$&']).to.equal('bcdefghijklmnop'); + }); + + // in all but IE, this works. IE lastParen breaks after 11 tokens. + it.skip('has "lastParen"', function () { + expect(RegExp.lastParen).to.equal('p'); + expect(RegExp['$+']).to.equal('p'); + }); + it('has "lastParen" for less than 11 tokens', function () { + (/(b)(c)(d)/).exec('abcdef'); + expect(RegExp.lastParen).to.equal('d'); + expect(RegExp['$+']).to.equal('d'); + }); + + it('has "leftContext"', function () { + expect(RegExp.leftContext).to.equal('a'); + expect(RegExp['$`']).to.equal('a'); + }); + + it('has "rightContext"', function () { + expect(RegExp.rightContext).to.equal('q'); + expect(RegExp["$'"]).to.equal('q'); + }); + + it('has $1 - $9', function () { + expect(RegExp.$1).to.equal('b'); + expect(RegExp.$2).to.equal('c'); + expect(RegExp.$3).to.equal('d'); + expect(RegExp.$4).to.equal('e'); + expect(RegExp.$5).to.equal('f'); + expect(RegExp.$6).to.equal('g'); + expect(RegExp.$7).to.equal('h'); + expect(RegExp.$8).to.equal('i'); + expect(RegExp.$9).to.equal('j'); + }); + }); + }); +}); diff --git a/node_modules/es6-shim/test/set.js b/node_modules/es6-shim/test/set.js new file mode 100644 index 0000000..97debc9 --- /dev/null +++ b/node_modules/es6-shim/test/set.js @@ -0,0 +1,656 @@ +// Big thanks to V8 folks for test ideas. +// v8/test/mjsunit/harmony/collections.js + +var Assertion = expect().constructor; +Assertion.addMethod('theSameSet', function (otherArray) { + var array = this._obj; + + expect(Array.isArray(array)).to.equal(true); + expect(Array.isArray(otherArray)).to.equal(true); + + var diff = array.filter(function (value) { + return otherArray.every(function (otherValue) { + var areBothNaN = typeof value === 'number' && typeof otherValue === 'number' && value !== value && otherValue !== otherValue; + return !areBothNaN && value !== otherValue; + }); + }); + + this.assert( + diff.length === 0, + 'expected #{this} to be equal to #{exp} (as sets, i.e. no order)', + array, + otherArray + ); +}); + +var $iterator$ = typeof Symbol === 'function' ? Symbol.iterator : '_es6-shim iterator_'; +if (typeof Set === 'function' && typeof Set.prototype['@@iterator'] === 'function') { + $iterator$ = '@@iterator'; +} + +Assertion.addMethod('iterations', function (expected) { + var iterator = this._obj[$iterator$](); + + expect(Array.isArray(expected)).to.equal(true); + var expectedValues = expected.slice(); + + var result; + do { + result = iterator.next(); + expect(result.value).to.eql(expectedValues.shift()); + } while (!result.done); +}); + +describe('Set', function () { + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + var ifGetPrototypeOfIt = Object.getPrototypeOf ? it : xit; + + var range = function (from, to) { + var result = []; + for (var value = from; value < to; value++) { + result.push(value); + } + return result; + }; + + var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype'); + var expectNotEnumerable = function (object) { + if (prototypePropIsEnumerable && typeof object === 'function') { + expect(Object.keys(object)).to.eql(['prototype']); + } else { + expect(Object.keys(object)).to.eql([]); + } + }; + + var Sym = typeof Symbol === 'undefined' ? {} : Symbol; + var isSymbol = function (sym) { + return typeof Sym === 'function' && typeof sym === 'symbol'; + }; + var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit; + + var testSet = function (set, key) { + expect(set.has(key)).to.equal(false); + expect(set['delete'](key)).to.equal(false); + expect(set.add(key)).to.equal(set); + expect(set.has(key)).to.equal(true); + expect(set['delete'](key)).to.equal(true); + expect(set.has(key)).to.equal(false); + expect(set.add(key)).to.equal(set); // add it back + }; + + if (typeof Set === 'undefined') { + return it('exists', function () { + expect(typeof Set).to.equal('function'); + }); + } + + var set; + beforeEach(function () { + set = new Set(); + }); + + afterEach(function () { + set = null; + }); + + it('set iteration', function () { + expect(set.add('a')).to.equal(set); + expect(set.add('b')).to.equal(set); + expect(set.add('c')).to.equal(set); + expect(set.add('d')).to.equal(set); + + var keys = []; + var iterator = set.keys(); + keys.push(iterator.next().value); + expect(set['delete']('a')).to.equal(true); + expect(set['delete']('b')).to.equal(true); + expect(set['delete']('c')).to.equal(true); + expect(set.add('e')).to.equal(set); + keys.push(iterator.next().value); + keys.push(iterator.next().value); + + expect(iterator.next().done).to.equal(true); + expect(set.add('f')).to.equal(set); + expect(iterator.next().done).to.equal(true); + expect(keys).to.eql(['a', 'd', 'e']); + }); + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.Set).to.equal(Set); + }); + + it('should exist in global namespace', function () { + expect(typeof Set).to.equal('function'); + }); + + it('has the right arity', function () { + expect(Set).to.have.property('length', 0); + }); + + it('returns the set from #add() for chaining', function () { + expect(set.add({})).to.equal(set); + }); + + it('should return false when deleting an item not in the set', function () { + expect(set.has('a')).to.equal(false); + expect(set['delete']('a')).to.equal(false); + }); + + it('should accept an iterable as argument', function () { + testSet(set, 'a'); + testSet(set, 'b'); + var set2 = new Set(set); + expect(set2.has('a')).to.equal(true); + expect(set2.has('b')).to.equal(true); + expect(set2).to.have.iterations(['a', 'b']); + }); + + it('accepts an array as an argument', function () { + var arr = ['a', 'b', 'c']; + var setFromArray = new Set(arr); + expect(setFromArray).to.have.iterations(['a', 'b', 'c']); + }); + + it('should not be callable without "new"', function () { + expect(Set).to['throw'](TypeError); + }); + + it('should be subclassable', function () { + if (!Object.setPrototypeOf) { return; } // skip test if on IE < 11 + var MySet = function MySet() { + var actualSet = new Set(['a', 'b']); + Object.setPrototypeOf(actualSet, MySet.prototype); + return actualSet; + }; + Object.setPrototypeOf(MySet, Set); + MySet.prototype = Object.create(Set.prototype, { + constructor: { value: MySet } + }); + + var mySet = new MySet(); + testSet(mySet, 'c'); + testSet(mySet, 'd'); + expect(mySet).to.have.iterations(['a', 'b', 'c', 'd']); + }); + + it('should has valid getter and setter calls', function () { + ['add', 'has', 'delete'].forEach(function (method) { + expect(function () { + set[method]({}); + }).to.not['throw'](); + }); + }); + + it('uses SameValueZero even on a Set of size > 4', function () { + var firstFour = [1, 2, 3, 4]; + var fourSet = new Set(firstFour); + expect(fourSet.size).to.equal(4); + expect(fourSet.has(-0)).to.equal(false); + expect(fourSet.has(0)).to.equal(false); + + fourSet.add(-0); + + expect(fourSet.size).to.equal(5); + expect(fourSet.has(0)).to.equal(true); + expect(fourSet.has(-0)).to.equal(true); + }); + + it('should work as expected', function () { + // Run this test twice, one with the "fast" implementation (which only + // allows string and numeric keys) and once with the "slow" impl. + [true, false].forEach(function (slowkeys) { + set = new Set(); + + range(1, 20).forEach(function (number) { + if (slowkeys) { testSet(set, {}); } + testSet(set, number); + testSet(set, number / 100); + testSet(set, 'key-' + number); + testSet(set, String(number)); + if (slowkeys) { testSet(set, Object(String(number))); } + }); + + var testkeys = [+0, Infinity, -Infinity, NaN]; + if (slowkeys) { + testkeys.push(true, false, null, undefined); + } + testkeys.forEach(function (number) { + testSet(set, number); + testSet(set, String(number)); + }); + testSet(set, ''); + + // -0 and +0 should be the same key (Set uses SameValueZero) + expect(set.has(-0)).to.equal(true); + expect(set['delete'](+0)).to.equal(true); + testSet(set, -0); + expect(set.has(+0)).to.equal(true); + + // verify that properties of Object don't peek through. + [ + 'hasOwnProperty', + 'constructor', + 'toString', + 'isPrototypeOf', + '__proto__', + '__parent__', + '__count__' + ].forEach(function (prop) { testSet(set, prop); }); + }); + }); + + describe('#size', function () { + it('returns the expected size', function () { + expect(set.add(1)).to.equal(set); + expect(set.add(5)).to.equal(set); + expect(set.size).to.equal(2); + }); + }); + + describe('#clear()', function () { + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Set.prototype.clear).to.have.property('name', 'clear'); + }); + + it('is not enumerable', function () { + expect(Set.prototype).ownPropertyDescriptor('clear').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Set.prototype.clear).to.have.property('length', 0); + }); + + it('clears a Set with only primitives', function () { + expect(set.add(1)).to.equal(set); + expect(set.size).to.equal(1); + expect(set.add(5)).to.equal(set); + expect(set.size).to.equal(2); + expect(set.has(5)).to.equal(true); + set.clear(); + expect(set.size).to.equal(0); + expect(set.has(5)).to.equal(false); + }); + + it('clears a Set with primitives and objects', function () { + expect(set.add(1)).to.equal(set); + expect(set.size).to.equal(1); + var obj = {}; + expect(set.add(obj)).to.equal(set); + expect(set.size).to.equal(2); + expect(set.has(obj)).to.equal(true); + set.clear(); + expect(set.size).to.equal(0); + expect(set.has(obj)).to.equal(false); + }); + }); + + describe('#keys()', function () { + if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'keys')) { + return it('exists', function () { + expect(Set.prototype).to.have.property('keys'); + }); + } + + it('is the same object as #values()', function () { + expect(Set.prototype.keys).to.equal(Set.prototype.values); + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Set.prototype.keys).to.have.property('name', 'values'); + }); + + it('is not enumerable', function () { + expect(Set.prototype).ownPropertyDescriptor('keys').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Set.prototype.keys).to.have.property('length', 0); + }); + }); + + describe('#values()', function () { + if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'values')) { + return it('exists', function () { + expect(Set.prototype).to.have.property('values'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Set.prototype.values).to.have.property('name', 'values'); + }); + + it('is not enumerable', function () { + expect(Set.prototype).ownPropertyDescriptor('values').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Set.prototype.values).to.have.property('length', 0); + }); + + it('throws when called on a non-Set', function () { + var expectedMessage = /^(Method )?Set.prototype.values called on incompatible receiver |^values method called on incompatible |^Cannot create a Set value iterator for a non-Set object.$|^Set.prototype.values: 'this' is not a Set object$|^std_Set_iterator method called on incompatible \w+$/; + var nonSets = [true, false, 'abc', NaN, new Map([[1, 2]]), { a: true }, [1], Object('abc'), Object(NaN)]; + nonSets.forEach(function (nonSet) { + expect(function () { return Set.prototype.values.call(nonSet); }).to['throw'](TypeError, expectedMessage); + }); + }); + }); + + describe('#entries()', function () { + if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'entries')) { + return it('exists', function () { + expect(Set.prototype).to.have.property('entries'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Set.prototype.entries).to.have.property('name', 'entries'); + }); + + it('is not enumerable', function () { + expect(Set.prototype).ownPropertyDescriptor('entries').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Set.prototype.entries).to.have.property('length', 0); + }); + }); + + describe('#has()', function () { + if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'has')) { + return it('exists', function () { + expect(Set.prototype).to.have.property('has'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Set.prototype.has).to.have.property('name', 'has'); + }); + + it('is not enumerable', function () { + expect(Set.prototype).ownPropertyDescriptor('has').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Set.prototype.has).to.have.property('length', 1); + }); + }); + + it('should allow NaN values as keys', function () { + expect(set.has(NaN)).to.equal(false); + expect(set.has(NaN + 1)).to.equal(false); + expect(set.has(23)).to.equal(false); + expect(set.add(NaN)).to.equal(set); + expect(set.has(NaN)).to.equal(true); + expect(set.has(NaN + 1)).to.equal(true); + expect(set.has(23)).to.equal(false); + }); + + it('should not have [[Enumerable]] props', function () { + expectNotEnumerable(Set); + expectNotEnumerable(Set.prototype); + expectNotEnumerable(new Set()); + }); + + it('should not have an own constructor', function () { + var s = new Set(); + expect(s).not.to.haveOwnPropertyDescriptor('constructor'); + expect(s.constructor).to.equal(Set); + }); + + it('should allow common ecmascript idioms', function () { + expect(set instanceof Set).to.equal(true); + expect(typeof Set.prototype.add).to.equal('function'); + expect(typeof Set.prototype.has).to.equal('function'); + expect(typeof Set.prototype['delete']).to.equal('function'); + }); + + it('should have a unique constructor', function () { + expect(Set.prototype).to.not.equal(Object.prototype); + }); + + describe('has an iterator that works with Array.from', function () { + if (!Object.prototype.hasOwnProperty.call(Array, 'from')) { + return it('requires Array.from to exist', function () { + expect(Array).to.have.property('from'); + }); + } + + var values = [1, NaN, false, true, null, undefined, 'a']; + + it('works with the full set', function () { + expect(new Set(values)).to.have.iterations(values); + }); + + it('works with Set#keys()', function () { + expect(new Set(values).keys()).to.have.iterations(values); + }); + + it('works with Set#values()', function () { + expect(new Set(values).values()).to.have.iterations(values); + }); + + it('works with Set#entries()', function () { + expect(new Set(values).entries()).to.have.iterations([ + [1, 1], + [NaN, NaN], + [false, false], + [true, true], + [null, null], + [undefined, undefined], + ['a', 'a'] + ]); + }); + }); + + ifSymbolIteratorIt('has the right default iteration function', function () { + // fixed in Webkit https://bugs.webkit.org/show_bug.cgi?id=143838 + expect(Set.prototype).to.have.property(Sym.iterator, Set.prototype.values); + }); + + it('should preserve insertion order', function () { + var arr1 = ['d', 'a', 'b']; + var arr2 = [3, 2, 'z', 'a', 1]; + var arr3 = [3, 2, 'z', {}, 'a', 1]; + + [arr1, arr2, arr3].forEach(function (array) { + expect(new Set(array)).to.have.iterations(array); + }); + }); + + describe('#forEach', function () { + var setToIterate; + beforeEach(function () { + setToIterate = new Set(); + expect(setToIterate.add('a')).to.equal(setToIterate); + expect(setToIterate.add('b')).to.equal(setToIterate); + expect(setToIterate.add('c')).to.equal(setToIterate); + }); + + afterEach(function () { + setToIterate = null; + }); + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(Set.prototype.forEach).to.have.property('name', 'forEach'); + }); + + it('is not enumerable', function () { + expect(Set.prototype).ownPropertyDescriptor('forEach').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(Set.prototype.forEach).to.have.property('length', 1); + }); + + it('should be iterable via forEach', function () { + var expectedSet = ['a', 'b', 'c']; + var foundSet = []; + setToIterate.forEach(function (value, alsoValue, entireSet) { + expect(entireSet).to.equal(setToIterate); + expect(value).to.equal(alsoValue); + foundSet.push(value); + }); + expect(foundSet).to.eql(expectedSet); + }); + + it('should iterate over empty keys', function () { + var setWithEmptyKeys = new Set(); + var expectedKeys = [{}, null, undefined, '', NaN, 0]; + expectedKeys.forEach(function (key) { + expect(setWithEmptyKeys.add(key)).to.equal(setWithEmptyKeys); + }); + var foundKeys = []; + setWithEmptyKeys.forEach(function (value, key, entireSet) { + expect([key]).to.be.theSameSet([value]); // handles NaN correctly + expect(entireSet.has(key)).to.equal(true); + foundKeys.push(key); + }); + expect(foundKeys).to.be.theSameSet(expectedKeys); + }); + + it('should support the thisArg', function () { + var context = function () {}; + setToIterate.forEach(function () { + expect(this).to.equal(context); + }, context); + }); + + it('should have a length of 1', function () { + expect(Set.prototype.forEach.length).to.equal(1); + }); + + it('should not revisit modified keys', function () { + var hasModifiedA = false; + setToIterate.forEach(function (value, key) { + if (!hasModifiedA && key === 'a') { + expect(setToIterate.add('a')).to.equal(setToIterate); + hasModifiedA = true; + } else { + expect(key).not.to.equal('a'); + } + }); + }); + + it('visits keys added in the iterator', function () { + var hasAdded = false; + var hasFoundD = false; + setToIterate.forEach(function (value, key) { + if (!hasAdded) { + expect(setToIterate.add('d')).to.equal(setToIterate); + hasAdded = true; + } else if (key === 'd') { + hasFoundD = true; + } + }); + expect(hasFoundD).to.equal(true); + }); + + it('visits keys added in the iterator when there is a deletion (slow path)', function () { + var hasSeenFour = false; + var setToMutate = new Set(); + expect(setToMutate.add({})).to.equal(setToMutate); // force use of the slow O(N) implementation + expect(setToMutate.add('0')).to.equal(setToMutate); + setToMutate.forEach(function (value, key) { + if (key === '0') { + expect(setToMutate['delete']('0')).to.equal(true); + expect(setToMutate.add('4')).to.equal(setToMutate); + } else if (key === '4') { + hasSeenFour = true; + } + }); + expect(hasSeenFour).to.equal(true); + }); + + it('visits keys added in the iterator when there is a deletion (fast path)', function () { + var hasSeenFour = false; + var setToMutate = new Set(); + expect(setToMutate.add('0')).to.equal(setToMutate); + setToMutate.forEach(function (value, key) { + if (key === '0') { + expect(setToMutate['delete']('0')).to.equal(true); + expect(setToMutate.add('4')).to.equal(setToMutate); + } else if (key === '4') { + hasSeenFour = true; + } + }); + expect(hasSeenFour).to.equal(true); + }); + + it('does not visit keys deleted before a visit', function () { + var hasVisitedC = false; + var hasDeletedC = false; + setToIterate.forEach(function (value, key) { + if (key === 'c') { + hasVisitedC = true; + } + if (!hasVisitedC && !hasDeletedC) { + hasDeletedC = setToIterate['delete']('c'); + expect(hasDeletedC).to.equal(true); + } + }); + expect(hasVisitedC).to.equal(false); + }); + + it('should work after deletion of the current key', function () { + var expectedSet = { + a: 'a', + b: 'b', + c: 'c' + }; + var foundSet = {}; + setToIterate.forEach(function (value, key) { + foundSet[key] = value; + expect(setToIterate['delete'](key)).to.equal(true); + }); + expect(foundSet).to.eql(expectedSet); + }); + + it('should convert key -0 to +0', function () { + var zeroSet = new Set(); + var result = []; + expect(zeroSet.add(-0)).to.equal(zeroSet); + zeroSet.forEach(function (key) { + result.push(String(1 / key)); + }); + expect(zeroSet.add(1)).to.equal(zeroSet); + expect(zeroSet.add(0)).to.equal(zeroSet); // shouldn't cause reordering + zeroSet.forEach(function (key) { + result.push(String(1 / key)); + }); + expect(result.join(', ')).to.equal('Infinity, Infinity, 1'); + }); + }); + + it('Set.prototype.size should throw TypeError', function () { + // see https://github.com/paulmillr/es6-shim/issues/176 + expect(function () { return Set.prototype.size; }).to['throw'](TypeError); + expect(function () { return Set.prototype.size; }).to['throw'](TypeError); + }); + + it.skip('should throw proper errors when user invokes methods with wrong types of receiver', function () { + }); + + ifGetPrototypeOfIt('SetIterator identification test prototype inequality', function () { + var mapEntriesProto = Object.getPrototypeOf(new Map().entries()); + var setEntriesProto = Object.getPrototypeOf(new Set().entries()); + expect(mapEntriesProto).to.not.equal(setEntriesProto); + }); + + it('SetIterator identification', function () { + var fnSetValues = Set.prototype.values; + var setSentinel = new Set(['SetSentinel']); + var testSet1 = new Set(); + var testSetValues = testSet1.values(); + expect(testSetValues.next.call(fnSetValues.call(setSentinel)).value).to.equal('SetSentinel'); + + var testMap = new Map(); + var testMapValues = testMap.values(); + expect(function () { + return testMapValues.next.call(fnSetValues.call(setSentinel)).value; + }).to['throw'](TypeError); + }); +}); diff --git a/node_modules/es6-shim/test/string.js b/node_modules/es6-shim/test/string.js new file mode 100644 index 0000000..721da32 --- /dev/null +++ b/node_modules/es6-shim/test/string.js @@ -0,0 +1,927 @@ +var runStringTests = function (it) { + 'use strict'; + + var functionsHaveNames = (function foo() {}).name === 'foo'; + var ifFunctionsHaveNamesIt = functionsHaveNames ? it : it.skip; + var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; + var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && typeof Symbol.iterator === 'symbol'; + var ifSymbolsDescribe = hasSymbols ? describe : describe.skip; + + describe('String', function () { + var hasStrictMode = (function () { return this === null; }.call(null)); + var testObjectCoercible = function (methodName) { + var fn = String.prototype[methodName]; + if (!hasStrictMode) { return; } // skip these tests on IE <= 10 + expect(function () { return fn.call(undefined); }).to['throw'](TypeError); + expect(function () { return fn.call(null); }).to['throw'](TypeError); + expect(function () { return fn.apply(undefined); }).to['throw'](TypeError); + expect(function () { return fn.apply(null); }).to['throw'](TypeError); + }; + + ifShimIt('is on the exported object', function () { + var exported = require('../'); + expect(exported.String).to.equal(String); + }); + + describe('#repeat()', function () { + if (!Object.prototype.hasOwnProperty.call(String.prototype, 'repeat')) { + return it('exists', function () { + expect(String.prototype).to.have.property('repeat'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.prototype.repeat).to.have.property('name', 'repeat'); + }); + + it('is not enumerable', function () { + expect(String.prototype).ownPropertyDescriptor('repeat').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(String.prototype.repeat).to.have.property('length', 1); + }); + + it('should throw a TypeError when called on null or undefined', function () { + testObjectCoercible('repeat'); + }); + + it('should throw a RangeError when negative or infinite', function () { + expect(function negativeOne() { return 'test'.repeat(-1); }).to['throw'](RangeError); + expect(function infinite() { return 'test'.repeat(Infinity); }).to['throw'](RangeError); + }); + + it('should coerce to an integer', function () { + expect('test'.repeat(null)).to.eql(''); + expect('test'.repeat(false)).to.eql(''); + expect('test'.repeat('')).to.eql(''); + expect('test'.repeat(NaN)).to.eql(''); + expect('test'.repeat({})).to.eql(''); + expect('test'.repeat([])).to.eql(''); + expect('test'.repeat({ + valueOf: function () { return 2; } + })).to.eql('testtest'); + }); + it('should work', function () { + expect('test'.repeat(3)).to.eql('testtesttest'); + }); + it('should work on integers', function () { + expect(String.prototype.repeat.call(2, 3)).to.eql('222'); + }); + it('should work on booleans', function () { + expect(String.prototype.repeat.call(true, 3)).to.eql('truetruetrue'); + }); + it('should work on dates', function () { + var d = new Date(); + expect(String.prototype.repeat.call(d, 3)).to.eql([d, d, d].join('')); + }); + }); + + describe('#startsWith()', function () { + if (!Object.prototype.hasOwnProperty.call(String.prototype, 'startsWith')) { + return it('exists', function () { + expect(String.prototype).to.have.property('startsWith'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.prototype.startsWith).to.have.property('name', 'startsWith'); + }); + + it('is not enumerable', function () { + expect(String.prototype).ownPropertyDescriptor('startsWith').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + // WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659 + expect(String.prototype.startsWith).to.have.property('length', 1); + }); + + it('should throw a TypeError when called on null or undefined', function () { + testObjectCoercible('startsWith'); + }); + + it('should throw a TypeError when called on null or undefined', function () { + testObjectCoercible('startsWith'); + }); + + it('should be truthy on correct results', function () { + expect('test'.startsWith('te')).to.equal(true); + expect('test'.startsWith('st')).to.equal(false); + expect(''.startsWith('/')).to.equal(false); + expect('#'.startsWith('/')).to.equal(false); + expect('##'.startsWith('///')).to.equal(false); + + expect('abc'.startsWith('abc')).to.equal(true); + expect('abcd'.startsWith('abc')).to.equal(true); + expect('abc'.startsWith('a')).to.equal(true); + expect('abc'.startsWith('abcd')).to.equal(false); + expect('abc'.startsWith('bcde')).to.equal(false); + expect('abc'.startsWith('b')).to.equal(false); + expect('abc'.startsWith('abc', 0)).to.equal(true); + expect('abc'.startsWith('bc', 0)).to.equal(false); + expect('abc'.startsWith('bc', 1)).to.equal(true); + expect('abc'.startsWith('c', 1)).to.equal(false); + expect('abc'.startsWith('abc', 1)).to.equal(false); + expect('abc'.startsWith('c', 2)).to.equal(true); + expect('abc'.startsWith('d', 2)).to.equal(false); + expect('abc'.startsWith('dcd', 2)).to.equal(false); + expect('abc'.startsWith('a', NaN)).to.equal(true); + expect('abc'.startsWith('b', NaN)).to.equal(false); + expect('abc'.startsWith('ab', -43)).to.equal(true); + expect('abc'.startsWith('ab', -Infinity)).to.equal(true); + expect('abc'.startsWith('bc', -42)).to.equal(false); + expect('abc'.startsWith('bc', -Infinity)).to.equal(false); + if (hasStrictMode) { + expect(function () { + return ''.startsWith.call(null, 'nu'); + }).to['throw'](TypeError); + expect(function () { + return ''.startsWith.call(undefined, 'un'); + }).to['throw'](TypeError); + } + var myobj = { + toString: function () { return 'abc'; }, + startsWith: String.prototype.startsWith + }; + expect(myobj.startsWith('abc')).to.equal(true); + expect(myobj.startsWith('bc')).to.equal(false); + + var gotStr = false; + var gotPos = false; + + myobj = { + toString: function () { + expect(gotPos).to.equal(false); + gotStr = true; + return 'xyz'; + }, + startsWith: String.prototype.startsWith + }; + var idx = { + valueOf: function () { + expect(gotStr).to.equal(true); + gotPos = true; + return 42; + } + }; + myobj.startsWith('elephant', idx); + expect(gotPos).to.equal(true); + }); + + it('should handle large positions', function () { + expect('abc'.startsWith('a', 42)).to.equal(false); + expect('abc'.startsWith('a', Infinity)).to.equal(false); + }); + + it('should coerce to a string', function () { + expect('abcd'.startsWith({ toString: function () { return 'ab'; } })).to.equal(true); + expect('abcd'.startsWith({ toString: function () { return 'foo'; } })).to.equal(false); + }); + + it('should not allow a regex', function () { + expect(function () { return 'abcd'.startsWith(/abc/); }).to['throw'](TypeError); + expect(function () { return 'abcd'.startsWith(new RegExp('abc')); }).to['throw'](TypeError); + }); + + ifSymbolsDescribe('Symbol.match', function () { + if (!hasSymbols || !Symbol.match) { + return it('exists', function () { + expect(Symbol).to.have.property('match'); + }); + } + + it('allows a regex with Symbol.match set to a falsy value', function () { + var re = /a/g; + re[Symbol.match] = false; + expect(function () { return 'abcd'.startsWith(re); }).not.to['throw'](); + expect('abcd'.startsWith(re)).to.equal('abcd'.startsWith(String(re))); + }); + }); + }); + + describe('#endsWith()', function () { + if (!Object.prototype.hasOwnProperty.call(String.prototype, 'endsWith')) { + return it('exists', function () { + expect(String.prototype).to.have.property('endsWith'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.prototype.endsWith).to.have.property('name', 'endsWith'); + }); + + it('is not enumerable', function () { + expect(String.prototype).ownPropertyDescriptor('endsWith').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + // WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659 + expect(String.prototype.endsWith).to.have.property('length', 1); + }); + + it('should throw a TypeError when called on null or undefined', function () { + testObjectCoercible('endsWith'); + }); + + it('should be truthy on correct results', function () { + expect('test'.endsWith('st')).to.equal(true); + expect('test'.endsWith('te')).to.equal(false); + expect(''.endsWith('/')).to.equal(false); + expect('#'.endsWith('/')).to.equal(false); + expect('##'.endsWith('///')).to.equal(false); + + expect('abc'.endsWith('abc')).to.equal(true); + expect('abcd'.endsWith('bcd')).to.equal(true); + expect('abc'.endsWith('c')).to.equal(true); + expect('abc'.endsWith('abcd')).to.equal(false); + expect('abc'.endsWith('bbc')).to.equal(false); + expect('abc'.endsWith('b')).to.equal(false); + expect('abc'.endsWith('abc', 3)).to.equal(true); + expect('abc'.endsWith('bc', 3)).to.equal(true); + expect('abc'.endsWith('a', 3)).to.equal(false); + expect('abc'.endsWith('bc', 3)).to.equal(true); + expect('abc'.endsWith('a', 1)).to.equal(true); + expect('abc'.endsWith('abc', 1)).to.equal(false); + expect('abc'.endsWith('b', 2)).to.equal(true); + expect('abc'.endsWith('d', 2)).to.equal(false); + expect('abc'.endsWith('dcd', 2)).to.equal(false); + expect('abc'.endsWith('bc', undefined)).to.equal(true); + expect('abc'.endsWith('bc', NaN)).to.equal(false); + if (hasStrictMode) { + expect(function () { + return ''.endsWith.call(null, 'ull'); + }).to['throw'](TypeError); + expect(function () { + return ''.endsWith.call(undefined, 'ned'); + }).to['throw'](TypeError); + } + + var myobj = { + toString: function () { return 'abc'; }, + endsWith: String.prototype.endsWith + }; + expect(myobj.endsWith('abc')).to.equal(true); + expect(myobj.endsWith('ab')).to.equal(false); + var gotStr = false; + var gotPos = false; + + myobj = { + toString: function () { + expect(gotPos).to.equal(false); + gotStr = true; + return 'xyz'; + }, + endsWith: String.prototype.endsWith + }; + var idx = { + valueOf: function () { + expect(gotStr).to.equal(true); + gotPos = true; + return 42; + } + }; + myobj.endsWith('elephant', idx); + expect(gotPos).to.equal(true); + }); + + it('should coerce to a string', function () { + expect('abcd'.endsWith({ toString: function () { return 'cd'; } })).to.equal(true); + expect('abcd'.endsWith({ toString: function () { return 'foo'; } })).to.equal(false); + }); + + it('should not allow a regex', function () { + expect(function () { return 'abcd'.endsWith(/abc/); }).to['throw'](TypeError); + expect(function () { return 'abcd'.endsWith(new RegExp('abc')); }).to['throw'](TypeError); + }); + + it('should handle negative and zero endPositions properly', function () { + expect('abcd'.endsWith('bcd', 0)).to.equal(false); + expect('abcd'.endsWith('bcd', -2)).to.equal(false); + expect('abcd'.endsWith('b', -2)).to.equal(false); + expect('abcd'.endsWith('ab', -2)).to.equal(false); + expect('abc'.endsWith('bc', -43)).to.equal(false); + expect('abc'.endsWith('bc', -Infinity)).to.equal(false); + }); + + it('should handle large endPositions properly', function () { + expect('abc'.endsWith('a', 42)).to.equal(false); + expect('abc'.endsWith('bc', Infinity)).to.equal(true); + expect('abc'.endsWith('a', Infinity)).to.equal(false); + }); + + ifSymbolsDescribe('Symbol.match', function () { + if (!hasSymbols || !Symbol.match) { + return it('exists', function () { + expect(Symbol).to.have.property('match'); + }); + } + + it('allows a regex with Symbol.match set to a falsy value', function () { + var re = /a/g; + re[Symbol.match] = false; + expect(function () { return 'abcd'.startsWith(re); }).not.to['throw'](); + expect('abcd'.endsWith(re)).to.equal('abcd'.endsWith(String(re))); + }); + }); + }); + + describe('#includes()', function () { + if (!Object.prototype.hasOwnProperty.call(String.prototype, 'includes')) { + return it('exists', function () { + expect(String.prototype).to.have.property('includes'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.prototype.includes).to.have.property('name', 'includes'); + }); + + it('is not enumerable', function () { + expect(String.prototype).ownPropertyDescriptor('includes').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + // WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659 + expect(String.prototype.includes).to.have.property('length', 1); + }); + + it('should throw a TypeError when called on null or undefined', function () { + testObjectCoercible('includes'); + }); + + it('throws a TypeError when given a regex', function () { + expect(function () { 'foo'.includes(/a/g); }).to['throw'](TypeError); + }); + + it('should be truthy on correct results', function () { + expect('test'.includes('es')).to.equal(true); + expect('abc'.includes('a')).to.equal(true); + expect('abc'.includes('b')).to.equal(true); + expect('abc'.includes('abc')).to.equal(true); + expect('abc'.includes('bc')).to.equal(true); + expect('abc'.includes('d')).to.equal(false); + expect('abc'.includes('abcd')).to.equal(false); + expect('abc'.includes('ac')).to.equal(false); + expect('abc'.includes('abc', 0)).to.equal(true); + expect('abc'.includes('bc', 0)).to.equal(true); + expect('abc'.includes('de', 0)).to.equal(false); + expect('abc'.includes('bc', 1)).to.equal(true); + expect('abc'.includes('c', 1)).to.equal(true); + expect('abc'.includes('a', 1)).to.equal(false); + expect('abc'.includes('abc', 1)).to.equal(false); + expect('abc'.includes('c', 2)).to.equal(true); + expect('abc'.includes('d', 2)).to.equal(false); + expect('abc'.includes('dcd', 2)).to.equal(false); + expect('abc'.includes('ab', NaN)).to.equal(true); + expect('abc'.includes('cd', NaN)).to.equal(false); + + var myobj = { + toString: function () { return 'abc'; }, + includes: String.prototype.includes + }; + + expect(myobj.includes('abc')).to.equal(true); + expect(myobj.includes('cd')).to.equal(false); + + var gotStr = false; + var gotPos = false; + + myobj = { + toString: function () { + expect(gotPos).to.equal(false); + gotStr = true; + return 'xyz'; + }, + + includes: String.prototype.includes + }; + + var idx = { + valueOf: function () { + expect(gotStr).to.equal(true); + gotPos = true; + return 42; + } + }; + + myobj.includes('elephant', idx); + expect(gotPos).to.equal(true); + }); + + it('should handle large positions', function () { + expect('abc'.includes('a', 42)).to.equal(false); + expect('abc'.includes('a', Infinity)).to.equal(false); + }); + + it('should handle negative positions', function () { + expect('abc'.includes('ab', -43)).to.equal(true); + expect('abc'.includes('cd', -42)).to.equal(false); + expect('abc'.includes('ab', -Infinity)).to.equal(true); + expect('abc'.includes('cd', -Infinity)).to.equal(false); + }); + + it('should be falsy on incorrect results', function () { + expect('test'.includes('1290')).to.equal(false); + }); + + ifSymbolsDescribe('Symbol.match', function () { + if (!hasSymbols || !Symbol.match) { + return it('exists', function () { + expect(Symbol).to.have.property('match'); + }); + } + + it('allows a regex with Symbol.match set to a falsy value', function () { + var re = /a/g; + re[Symbol.match] = false; + expect(function () { return 'abcd'.includes(re); }).not.to['throw'](); + expect('abcd'.includes(re)).to.equal('abcd'.includes(String(re))); + }); + }); + }); + + describe('.fromCodePoint()', function () { + if (!Object.prototype.hasOwnProperty.call(String, 'fromCodePoint')) { + return it('exists', function () { + expect(String).to.have.property('fromCodePoint'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.fromCodePoint).to.have.property('name', 'fromCodePoint'); + }); + + it('is not enumerable', function () { + expect(String).ownPropertyDescriptor('fromCodePoint').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(String.fromCodePoint).to.have.property('length', 1); + }); + + it('throws a RangeError', function () { + var invalidValues = [ + 'abc', + {}, + -1, + 0x10FFFF + 1 + ]; + invalidValues.forEach(function (value) { + expect(function () { return String.fromCodePoint(value); }).to['throw'](RangeError); + }); + }); + + it('returns the empty string with no args', function () { + expect(String.fromCodePoint()).to.equal(''); + }); + + it('works', function () { + var codePoints = []; + var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789…?!'; + for (var i = 0; i < chars.length; ++i) { + codePoints.push(chars.charCodeAt(i)); + expect(String.fromCodePoint(chars.charCodeAt(i))).to.equal(chars[i]); + } + expect(String.fromCodePoint.apply(String, codePoints)).to.equal(chars); + }); + + it('works with unicode', function () { + expect(String.fromCodePoint(0x2500)).to.equal('\u2500'); + expect(String.fromCodePoint(0x010000)).to.equal('\ud800\udc00'); + expect(String.fromCodePoint(0x10FFFF)).to.equal('\udbff\udfff'); + }); + }); + + describe('#codePointAt()', function () { + if (!Object.prototype.hasOwnProperty.call(String.prototype, 'codePointAt')) { + return it('exists', function () { + expect(String.prototype).to.have.property('codePointAt'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.prototype.codePointAt).to.have.property('name', 'codePointAt'); + }); + + it('is not enumerable', function () { + expect(String.prototype).ownPropertyDescriptor('codePointAt').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(String.prototype.codePointAt).to.have.property('length', 1); + }); + + it('should throw a TypeError when called on null or undefined', function () { + testObjectCoercible('codePointAt'); + }); + + it('should work', function () { + var str = 'abc'; + expect(str.codePointAt(0)).to.equal(97); + expect(str.codePointAt(1)).to.equal(98); + expect(str.codePointAt(2)).to.equal(99); + }); + + it('should work with unicode', function () { + expect('\u2500'.codePointAt(0)).to.equal(0x2500); + expect('\ud800\udc00'.codePointAt(0)).to.equal(0x10000); + expect('\udbff\udfff'.codePointAt(0)).to.equal(0x10ffff); + expect('\ud800\udc00\udbff\udfff'.codePointAt(0)).to.equal(0x10000); + expect('\ud800\udc00\udbff\udfff'.codePointAt(1)).to.equal(0xdc00); + expect('\ud800\udc00\udbff\udfff'.codePointAt(2)).to.equal(0x10ffff); + expect('\ud800\udc00\udbff\udfff'.codePointAt(3)).to.equal(0xdfff); + }); + + it('should return undefined when pos is negative or too large', function () { + var str = 'abc'; + expect(str.codePointAt(-1)).to.equal(undefined); + expect(str.codePointAt(str.length)).to.equal(undefined); + }); + }); + + describe('#[Symbol.iterator]()', function () { + if (!Object.prototype.hasOwnProperty.call(Array, 'from')) { + return it('requires Array.from to test', function () { + expect(Array).to.have.property('from'); + }); + } + + it('should work with plain strings', function () { + var str = 'abc'; + expect(Array.from(str)).to.eql(['a', 'b', 'c']); + }); + + it('should work with surrogate characters', function () { + var str = '\u2500\ud800\udc00\udbff\udfff\ud800'; + expect(Array.from(str)).to.eql(['\u2500', '\ud800\udc00', '\udbff\udfff', '\ud800']); + }); + }); + + describe('.raw()', function () { + if (!Object.prototype.hasOwnProperty.call(String, 'raw')) { + return it('exists', function () { + expect(String).to.have.property('raw'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.raw).to.have.property('name', 'raw'); + }); + + it('is not enumerable', function () { + expect(String).ownPropertyDescriptor('raw').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(String.raw).to.have.property('length', 1); + }); + + it('works with callSite.raw: Array', function () { + var callSite = {}; + + var str = 'The total is 10 ($11 with tax)'; + callSite.raw = ['The total is ', ' ($', ' with tax)']; + expect(String.raw(callSite, 10, 11)).to.eql(str); + + // eslint-disable-next-line no-template-curly-in-string + str = 'The total is {total} (${total * 1.01} with tax)'; + callSite.raw = ['The total is ', ' ($', ' with tax)']; + expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql(str); + }); + + it('works with callSite.raw: array-like object', function () { + var callSite = {}; + + var str = 'The total is 10 ($11 with tax)'; + callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 }; + expect(String.raw(callSite, 10, 11)).to.eql(str); + + // eslint-disable-next-line no-template-curly-in-string + str = 'The total is {total} (${total * 1.01} with tax)'; + callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 }; + expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql(str); + }); + + it('works with callSite.raw: empty Objects', function () { + var callSite = { raw: {} }; + expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql(''); + expect(String.raw(callSite)).to.equal(''); + }); + + it('ReturnIfAbrupt - Less Substitutions', function () { + var callSite = { + raw: { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 } + }; + var str = 'The total is 10 ($ with tax)'; + expect(String.raw(callSite, 10)).to.equal(str); + }); + }); + + describe('#trim()', function () { + if (!Object.prototype.hasOwnProperty.call(String.prototype, 'trim')) { + return it('exists', function () { + expect(String.prototype).to.have.property('trim'); + }); + } + + ifFunctionsHaveNamesIt('has the right name', function () { + expect(String.prototype.trim).to.have.property('name', 'trim'); + }); + + it('is not enumerable', function () { + expect(String.prototype).ownPropertyDescriptor('trim').to.have.property('enumerable', false); + }); + + it('has the right arity', function () { + expect(String.prototype.trim).to.have.property('length', 0); + }); + + it('should trim the correct characters', function () { + var whitespace = [ + '\u0009', + '\u000b', + '\u000c', + '\u0020', + '\u00a0', + '\u1680', + '\u2000', + '\u2001', + '\u2002', + '\u2003', + '\u2004', + '\u2005', + '\u2006', + '\u2007', + '\u2008', + '\u2009', + '\u200A', + '\u202f', + '\u205f', + '\u3000' + ].join(''); + + var lineTerminators = [ + '\u000a', + '\u000d', + '\u2028', + '\u2029' + ].join(''); + + var trimmed = (whitespace + lineTerminators).trim(); + expect(trimmed).to.have.property('length', 0); + expect(trimmed).to.equal(''); + }); + + it('should not trim U+0085', function () { + var trimmed = '\u0085'.trim(); + expect(trimmed).to.have.property('length', 1); + expect(trimmed).to.equal('\u0085'); + }); + + it('should trim on both sides', function () { + var trimmed = ' a '.trim(); + expect(trimmed).to.have.property('length', 1); + expect(trimmed).to.equal('a'); + }); + }); + + describe('#search()', function () { + it('works with strings', function () { + expect('abc'.search('a')).to.equal(0); + expect('abc'.search('b')).to.equal(1); + expect('abc'.search('c')).to.equal(2); + expect('abc'.search('d')).to.equal(-1); + }); + + it('works with regexes', function () { + expect('abc'.search(/a/)).to.equal(0); + expect('abc'.search(/b/)).to.equal(1); + expect('abc'.search(/c/)).to.equal(2); + expect('abc'.search(/d/)).to.equal(-1); + }); + + ifSymbolsDescribe('Symbol.search', function () { + it('is a symbol', function () { + expect(typeof Symbol.search).to.equal('symbol'); + }); + + if (!hasSymbols || typeof Symbol.search !== 'symbol') { + return; + } + + it('is nonconfigurable', function () { + expect(Symbol).ownPropertyDescriptor('search').to.have.property('configurable', false); + }); + + it('is nonenumerable', function () { + expect(Symbol).ownPropertyDescriptor('search').to.have.property('enumerable', false); + }); + + it('is nonwritable', function () { + expect(Symbol).ownPropertyDescriptor('search').to.have.property('writable', false); + }); + + it('is respected', function () { + var str = Object('a'); + var obj = {}; + obj[Symbol.search] = function (string) { return string === str && this === obj; }; + expect(str.search(obj)).to.equal(true); + }); + }); + }); + + describe('#replace()', function () { + it('works', function () { + expect('abcabc'.replace('c', 'd')).to.equal('abdabc'); + expect('abcabc'.replace(/c/, 'd')).to.equal('abdabc'); + expect('abcabc'.replace(/c/g, 'd')).to.equal('abdabd'); + expect('abcabc'.replace(/C/ig, 'd')).to.equal('abdabd'); + }); + + ifSymbolsDescribe('Symbol.replace', function () { + it('is a symbol', function () { + expect(typeof Symbol.replace).to.equal('symbol'); + }); + + if (!hasSymbols || typeof Symbol.replace !== 'symbol') { + return; + } + + it('is nonconfigurable', function () { + expect(Symbol).ownPropertyDescriptor('replace').to.have.property('configurable', false); + }); + + it('is nonenumerable', function () { + expect(Symbol).ownPropertyDescriptor('replace').to.have.property('enumerable', false); + }); + + it('is nonwritable', function () { + expect(Symbol).ownPropertyDescriptor('replace').to.have.property('writable', false); + }); + + it('respects Symbol.replace', function () { + var str = Object('a'); + var replaceVal = Object('replaceValue'); + var obj = {}; + obj[Symbol.replace] = function (string, replaceValue) { + return string === str && replaceValue === replaceVal && this === obj; + }; + expect(str.replace(obj, replaceVal)).to.equal(true); + }); + }); + }); + + describe('#split()', function () { + it('works', function () { + expect('abcabc'.split('b')).to.eql(['a', 'ca', 'c']); + expect('abcabc'.split('b', 2)).to.eql(['a', 'ca']); + expect('abcabc'.split(/b.?/)).to.eql(['a', 'a', '']); + expect('abcabc'.split(/b.?/, 2)).to.eql(['a', 'a']); + expect('abcabc'.split(/b/)).to.eql(['a', 'ca', 'c']); + expect('abcabc'.split(/b/, 2)).to.eql(['a', 'ca']); + expect('abcabc'.split(/b/g)).to.eql(['a', 'ca', 'c']); + expect('abcabc'.split(/b/g, 2)).to.eql(['a', 'ca']); + expect('abcabc'.split(/B/i)).to.eql(['a', 'ca', 'c']); + expect('abcabc'.split(/B/i, 2)).to.eql(['a', 'ca']); + expect('abcabc'.split(/B/gi)).to.eql(['a', 'ca', 'c']); + expect('abcabc'.split(/B/gi, 2)).to.eql(['a', 'ca']); + }); + + ifSymbolsDescribe('Symbol.split', function () { + it('is a symbol', function () { + expect(typeof Symbol.split).to.equal('symbol'); + }); + + if (!hasSymbols || typeof Symbol.split !== 'symbol') { + return; + } + + it('is nonconfigurable', function () { + expect(Symbol).ownPropertyDescriptor('split').to.have.property('configurable', false); + }); + + it('is nonenumerable', function () { + expect(Symbol).ownPropertyDescriptor('split').to.have.property('enumerable', false); + }); + + it('is nonwritable', function () { + expect(Symbol).ownPropertyDescriptor('split').to.have.property('writable', false); + }); + + it('respects Symbol.split', function () { + var str = Object('a'); + var limitVal = Object(42); + var obj = {}; + obj[Symbol.split] = function (string, limit) { return string === str && limit === limitVal && this === obj; }; + expect(str.split(obj, limitVal)).to.equal(true); + }); + }); + }); + + describe('#match()', function () { + it('works with a string', function () { + var str = 'abca'; + var match = str.match('a'); + expect(match.index).to.equal(0); + expect(match.input).to.equal(str); + expect(Array.prototype.slice.call(match)).to.eql(['a']); + }); + + it('works with a regex', function () { + var str = 'abca'; + var match = str.match(/a/); + expect(match.index).to.equal(0); + expect(match.input).to.equal(str); + expect(Array.prototype.slice.call(match)).to.eql(['a']); + }); + + ifSymbolsDescribe('Symbol.match', function () { + it('is a symbol', function () { + expect(typeof Symbol.match).to.equal('symbol'); + }); + + if (!hasSymbols || typeof Symbol.match !== 'symbol') { + return; + } + + it('is nonconfigurable', function () { + expect(Symbol).ownPropertyDescriptor('match').to.have.property('configurable', false); + }); + + it('is nonenumerable', function () { + expect(Symbol).ownPropertyDescriptor('match').to.have.property('enumerable', false); + }); + + it('is nonwritable', function () { + expect(Symbol).ownPropertyDescriptor('match').to.have.property('writable', false); + }); + + it('respects Symbol.match', function () { + var str = Object('a'); + var obj = {}; + obj[Symbol.match] = function (string) { return string === str && this === obj; }; + expect(str.match(obj)).to.equal(true); + }); + }); + }); + }); + + describe('Annex B', function () { + it('has #anchor', function () { + expect('foo'.anchor('bar"baz"')).to.equal('foo'); + }); + it('has #big', function () { + expect('foo'.big()).to.equal('foo'); + }); + it('has #blink', function () { + expect('foo'.blink()).to.equal('foo'); + }); + it('has #bold', function () { + expect('foo'.bold()).to.equal('foo'); + }); + it('has #fixed', function () { + expect('foo'.fixed()).to.equal('foo'); + }); + it('has #fontcolor', function () { + expect('foo'.fontcolor('blue"red"green')).to.equal('foo'); + }); + it('has #fontsize', function () { + expect('foo'.fontsize('10"large"small')).to.equal('foo'); + }); + it('has #italics', function () { + expect('foo'.italics()).to.equal('foo'); + }); + it('has #link', function () { + expect('foo'.link('url"http://"')).to.equal('foo'); + }); + it('has #small', function () { + expect('foo'.small()).to.equal('foo'); + }); + it('has #strike', function () { + expect('foo'.strike()).to.equal('foo'); + }); + it('has #sub', function () { + expect('foo'.sub()).to.equal('foo'); + }); + it('has #sup', function () { + expect('foo'.sup()).to.equal('foo'); + }); + }); +}; + +describe('clean Object.prototype', function () { + return runStringTests.call(this, it); +}); + +describe('polluted Object.prototype', function () { + var shimmedIt = function () { + /* eslint-disable no-extend-native */ + Object.prototype[1] = 42; + /* eslint-enable no-extend-native */ + it.apply(this, arguments); + delete Object.prototype[1]; + }; + shimmedIt.skip = it.skip; + return runStringTests.call(this, shimmedIt); +}); diff --git a/node_modules/es6-shim/test/test_helpers.js b/node_modules/es6-shim/test/test_helpers.js new file mode 100644 index 0000000..0030701 --- /dev/null +++ b/node_modules/es6-shim/test/test_helpers.js @@ -0,0 +1,17 @@ +/* global expect: true, assert: true, require, process */ + +expect = (function () { + var chai = require('chai'); + chai.config.includeStack = true; + return chai.expect; +}()); + +assert = (function () { + var chai = require('chai'); + chai.config.includeStack = true; + return chai.assert; +}()); + +if (typeof process === 'undefined' || !process.env.NO_ES6_SHIM) { + require('../'); +} diff --git a/node_modules/es6-shim/test/worker-runner.workerjs b/node_modules/es6-shim/test/worker-runner.workerjs new file mode 100644 index 0000000..f443995 --- /dev/null +++ b/node_modules/es6-shim/test/worker-runner.workerjs @@ -0,0 +1,7 @@ +importScripts( + '../node_modules/es5-shim/es5-shim.js', + '../node_modules/es5-shim/es5-sham.js', + '../es6-shim.js' +); + +postMessage('ready'); diff --git a/node_modules/es6-shim/test/worker-test.js b/node_modules/es6-shim/test/worker-test.js new file mode 100644 index 0000000..cf914ca --- /dev/null +++ b/node_modules/es6-shim/test/worker-test.js @@ -0,0 +1,39 @@ +/* globals Worker, location */ + +describe('Worker', function () { + var workerErrorEventToError = function (errorEvent) { + var errorText = 'Error in Worker'; + if (errorEvent.filename !== undefined) { + errorText += ' ' + errorEvent.filename; + } + if (errorEvent.lineno !== undefined) { + errorText += '(' + errorEvent.lineno + ')'; + } + if (errorEvent.message !== undefined) { + errorText += ': ' + errorEvent.message; + } + return new Error(errorText); + }; + var canRunWorkerTestInCurrentContext = function () { + var workerConstructorExists = typeof Worker !== 'undefined'; + var locationPropertyExists = typeof location !== 'undefined'; + var runningOnFileUriScheme = locationPropertyExists && location.protocol === 'file:'; + + // The Worker constructor doesn't exist in some older browsers nor does it exist in non-browser contexts like Node. + // Additionally some browsers (at least Chrome) don't allow Workers over file URIs. + // To prevent false negative test failures in the cases where Workers are unavailable for either of those reasons + // we skip this test. + return workerConstructorExists && !runningOnFileUriScheme; + }; + + if (canRunWorkerTestInCurrentContext()) { + it('can import es6-shim', function (done) { + var worker = new Worker('worker-runner.workerjs'); + worker.addEventListener('error', function (errorEvent) { throw workerErrorEventToError(errorEvent); }); + worker.addEventListener('message', function (messageEvent) { + expect(messageEvent.data).to.eql('ready'); + done(); + }); + }); + } +}); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..240c7f0 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,18 @@ +{ + "name": "welsonjs", + "version": "0.1.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "es5-shim": { + "version": "4.5.14", + "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.14.tgz", + "integrity": "sha512-7SwlpL+2JpymWTt8sNLuC2zdhhc+wrfe5cMPI2j0o6WsPdfAiPwmFy2f0AocPB4RQVBOZ9kNTgi5YF7TdhkvEg==" + }, + "es6-shim": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.5.tgz", + "integrity": "sha512-E9kK/bjtCQRpN1K28Xh4BlmP8egvZBGJJ+9GtnzOwt7mdqtrjHFuVGr7QJfdjBIKqrlU5duPf3pCBoDrkjVYFg==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b354023 --- /dev/null +++ b/package.json @@ -0,0 +1,41 @@ +{ + "name": "welsonjs", + "version": "0.1.0", + "description": "Build a windows desktop apps ultra-fastly with WSH.js and HTA", + "main": "app.js", + "directories": { + "lib": "lib" + }, + "scripts": { + "test": "cscript app.js helloworld" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/gnh1201/welsonjs.git" + }, + "keywords": [ + "wsh", + "javascript", + "windows", + "desktop", + "alternative", + "hta", + "uri", + "jscript", + "electronjs", + "js", + "ie", + "mshta", + "mshtml" + ], + "author": "Go Namhyeon", + "license": "LGPL-2.1", + "bugs": { + "url": "https://github.com/gnh1201/welsonjs/issues" + }, + "homepage": "https://github.com/gnh1201/welsonjs#readme", + "dependencies": { + "es5-shim": "^4.5.14", + "es6-shim": "^0.35.5" + } +}