es6-shim-0.34.1/000077500000000000000000000000001264300104700132275ustar00rootroot00000000000000es6-shim-0.34.1/.eslintignore000066400000000000000000000000261264300104700157300ustar00rootroot00000000000000Gruntfile.js *.min.js es6-shim-0.34.1/.eslintrc000066400000000000000000000032141264300104700150530ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "ecmaFeatures": { "regexYFlag": true, "regexUFlag": true }, "rules": { "callback-return": [0], "complexity": [1], "consistent-return": [1], "dot-notation": [2, { "allowKeywords": false }], "eqeqeq": [2, "allow-null"], "global-require": [0], "id-length": [2, { "min": 1, "max": 40 }], "max-depth": [2, 5], "max-params": [2, 4], "max-nested-callbacks": [2, 5], "max-statements": [1, 25], "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": [0], "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": ["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], "operator-linebreak": [2, "after"], "spaced-comment": [0], "strict": [0] } } es6-shim-0.34.1/.gitignore000066400000000000000000000000301264300104700152100ustar00rootroot00000000000000.DS_Store node_modules/ es6-shim-0.34.1/.jscs.json000066400000000000000000000067071264300104700151540ustar00rootroot00000000000000{ "es3": true, "additionalRules": [], "requireSemicolons": true, "disallowMultipleSpaces": true, "disallowIdentifierNames": [], "requireCurlyBraces": { "allExcept": [], "keywords": ["if", "else", "for", "while", "do", "try", "catch"] }, "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], "disallowSpaceAfterKeywords": [], "disallowSpaceBeforeComma": true, "disallowSpaceAfterComma": false, "disallowSpaceBeforeSemicolon": true, "disallowNodeTypes": [ "DebuggerStatement", "LabeledStatement", "SwitchCase", "SwitchStatement", "WithStatement" ], "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, "requireSpaceBetweenArguments": true, "disallowSpacesInsideParentheses": true, "disallowSpacesInsideArrayBrackets": true, "disallowQuotedKeysInObjects": "allButReserved", "disallowSpaceAfterObjectKeys": true, "requireCommaBeforeLineBreak": true, "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], "requireSpaceAfterPrefixUnaryOperators": [], "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], "requireSpaceBeforePostfixUnaryOperators": [], "disallowSpaceBeforeBinaryOperators": [], "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "disallowSpaceAfterBinaryOperators": [], "disallowImplicitTypeConversion": ["binary", "string"], "disallowKeywords": ["with", "eval"], "requireKeywordsOnNewLine": [], "disallowKeywordsOnNewLine": ["else"], "requireLineFeedAtFileEnd": true, "disallowTrailingWhitespace": true, "disallowTrailingComma": true, "excludeFiles": ["node_modules/**", "vendor/**"], "disallowMultipleLineStrings": true, "requireDotNotation": { "allExcept": ["keywords"] }, "requireParenthesesAroundIIFE": true, "validateLineBreaks": "LF", "validateQuoteMarks": { "escape": true, "mark": "'" }, "disallowOperatorBeforeLineBreak": [], "requireSpaceBeforeKeywords": [ "do", "for", "if", "else", "switch", "case", "try", "catch", "finally", "while", "with", "return" ], "validateAlignedFunctionParameters": { "lineBreakAfterOpeningBraces": true, "lineBreakBeforeClosingBraces": true }, "requirePaddingNewLinesBeforeExport": true, "validateNewlineAfterArrayElements": { "maximum": 10 }, "requirePaddingNewLinesAfterUseStrict": true, "disallowArrowFunctions": true, "disallowMultiLineTernary": true, "validateOrderInObjectKeys": false, "disallowIdenticalDestructuringNames": true, "disallowNestedTernaries": { "maxLevel": 1 }, "requireSpaceAfterComma": { "allExcept": ["trailing"] }, "requireAlignedMultilineParams": false, "requireSpacesInGenerator": { "afterStar": true }, "disallowSpacesInGenerator": { "beforeStar": true }, "disallowVar": false, "requireArrayDestructuring": false, "requireEnhancedObjectLiterals": false, "requireObjectDestructuring": false, "requireEarlyReturn": false } es6-shim-0.34.1/.jshintrc000066400000000000000000000001251264300104700150520ustar00rootroot00000000000000{ "es3": true, "esnext": true, "sub": true, "newcap": false, "notypeof": true } es6-shim-0.34.1/.npmignore000066400000000000000000000000621264300104700152240ustar00rootroot00000000000000.DS_Store node_modules/ .travis.yml testling.html es6-shim-0.34.1/.travis.yml000066400000000000000000000051471264300104700153470ustar00rootroot00000000000000language: node_js node_js: - "5.3" - "5.2" - "5.1" - "5.0" - "4.2" - "4.1" - "4.0" - "iojs-v3.3" - "iojs-v3.2" - "iojs-v3.1" - "iojs-v3.0" - "iojs-v2.5" - "iojs-v2.4" - "iojs-v2.3" - "iojs-v2.2" - "iojs-v2.1" - "iojs-v2.0" - "iojs-v1.8" - "iojs-v1.7" - "iojs-v1.6" - "iojs-v1.5" - "iojs-v1.4" - "iojs-v1.3" - "iojs-v1.2" - "iojs-v1.1" - "iojs-v1.0" - "0.11" - "0.10" - "0.9" - "0.8" - "0.6" - "0.4" before_install: - 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' - 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' - '[ "${TRAVIS_RUN_SAUCE}" != "true" ] || npm install -g grunt-cli' script: - 'if [ "${TRAVIS_RUN_SAUCE}" == "true" ]; then npm run sauce ; elif [ "${TRAVIS_NODE_VERSION}" != "0.11" ] && [ "${TRAVIS_RUN_LINT_ONLY}" != "true" ]; then npm run tests-only ; else npm test ; fi' # NOTE: sauce_connect is disabled, because it applies to every test and we only need it on one of them. # It's available inside `npm run sauce` # addons: # sauce_connect: true sudo: false matrix: fast_finish: true include: - node_js: "0.12" env: TRAVIS_RUN_SAUCE=false TRAVIS_RUN_LINT_ONLY=true - node_js: "0.12" env: TRAVIS_RUN_SAUCE=true TRAVIS_RUN_LINT_ONLY=false - node_js: "0.12" env: TRAVIS_RUN_SAUCE=false TRAVIS_RUN_LINT_ONLY=false allow_failures: - node_js: "5.2" - node_js: "5.1" - node_js: "5.0" - node_js: "4.1" - node_js: "4.0" - node_js: "iojs-v3.2" - node_js: "iojs-v3.1" - node_js: "iojs-v3.0" - node_js: "iojs-v2.4" - node_js: "iojs-v2.3" - node_js: "iojs-v2.2" - node_js: "iojs-v2.1" - node_js: "iojs-v2.0" - node_js: "iojs-v1.7" - node_js: "iojs-v1.6" - node_js: "iojs-v1.5" - node_js: "iojs-v1.4" - node_js: "iojs-v1.3" - node_js: "iojs-v1.2" - node_js: "iojs-v1.1" - node_js: "iojs-v1.0" - node_js: "0.11" - node_js: "0.9" - node_js: "0.8" - node_js: "0.6" - node_js: "0.4" - node_js: "0.12" env: TRAVIS_RUN_SAUCE=true TRAVIS_RUN_LINT_ONLY=false env: global: - secure: YD4HLTE93NhSxa+64MYHhnbJ2ZkREp/HGiFGE4q+AWShqAiehtqE/K3hQUe7p0+1/2/34avhm2bz31j508ayCobm6SSUhpleJH58IK3v4LI2o9qtM+2N/MPJFOIvbziHqOM6fPluowU0k3OSdEAp4U+6S23wKSuXzcUSK8upAiM= - secure: k7+PgLcGJL1zyMMxZ8DSRxRrmLr5sb9i4M1kCdUvw2kRGacqoI3UhdvO2AyrAD0TAjIQoRM4dL37WsgJijhTNOu1gTb5lMUXWSQU47T7tFTvpM6OlGvQ54I7iAgv5NABZ/0gDGlQDrVdb9hQPLG1FDrMxsxcdXfgXqzqbhNsv7I= - SAUCE_HAS_TUNNEL=true es6-shim-0.34.1/CHANGELOG.md000066400000000000000000000636431264300104700150540ustar00rootroot00000000000000# es6-shim x.x.x (not yet released) # 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 es6-shim-0.34.1/Gruntfile.js000066400000000000000000000074001264300104700155250ustar00rootroot00000000000000'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']); }; es6-shim-0.34.1/LICENSE000066400000000000000000000025451264300104700142420ustar00rootroot00000000000000The 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-2015 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. es6-shim-0.34.1/README.md000066400000000000000000000235241264300104700145140ustar00rootroot00000000000000# 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. 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) * `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()` * `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) * `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()` * `enumerate()` * `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 es6-shim-0.34.1/bower.json000066400000000000000000000007621264300104700152450ustar00rootroot00000000000000{ "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" ] } es6-shim-0.34.1/component.json000066400000000000000000000006701264300104700161270ustar00rootroot00000000000000{ "name": "es6-shim", "version": "0.34.1", "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": {} } es6-shim-0.34.1/es6-sham.js000066400000000000000000000104371264300104700152150ustar00rootroot00000000000000 /*! * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License * es6-sham: v0.34.1 * see https://github.com/paulmillr/es6-shim/blob/0.34.1/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'; /*jshint evil: true */ /* eslint-disable no-new-func */ var getGlobal = new Function('return this;'); /* eslint-enable no-new-func */ /*jshint evil: false */ var globals = getGlobal(); var Object = globals.Object; // 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; } /*jshint proto: true */ // @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; }()); })); es6-shim-0.34.1/es6-sham.map000066400000000000000000000026341264300104700153560ustar00rootroot00000000000000{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","defineProperty","getPrototypeOf","objProto","prototype","copyDescriptors","target","source","forEach","key","createAndCopy","origin","proto","set","call","e","__proto__"],"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,YAIA,IAAIC,GAAY,GAAIC,UAAS,eAI7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,QAWpB,WACC,GAAIA,EAAOC,eAAgB,CAAE,OAK7B,GAAIC,GAAsBF,EAAOE,mBACjC,IAAIC,GAA2BH,EAAOG,wBACtC,IAAIC,GAASJ,EAAOI,MACpB,IAAIC,GAAiBL,EAAOK,cAC5B,IAAIC,GAAiBN,EAAOM,cAC5B,IAAIC,GAAWP,EAAOQ,SAEtB,IAAIC,GAAkB,SAAUC,EAAQC,GAEtCT,EAAoBS,GAAQC,QAAQ,SAAUC,GAC5CR,EACEK,EACAG,EACAV,EAAyBQ,EAAQE,KAGrC,OAAOH,GAGT,IAAII,GAAgB,SAAUC,EAAQC,GACpC,MAAOP,GAAgBL,EAAOY,GAAQD,GAExC,IAAIE,GAAKhB,CACT,KAGEgB,EAAMd,EAAyBI,EAAU,aAAaU,GACtDA,GAAIC,QAAS,KAGbjB,GAAiB,SAAUc,EAAQC,GACjCC,EAAIC,KAAKH,EAAQC,EACjB,OAAOD,IAET,MAAOI,GAEPF,GAAQG,UAAW,KAGnB,IAAIH,YAAejB,GAAQ,CACzBC,EAAiBa,MACZ,CAGLG,EAAIG,UAAYb,CAIhB,IAAIU,YAAejB,GAAQ,CACzBC,EAAiB,SAAUc,EAAQC,GAGjCD,EAAOK,UAAYJ,CAEnB,OAAOD,QAEJ,CAGLd,EAAiB,SAAUc,EAAQC,GAEjC,GAAIV,EAAeS,GAAS,CAG1BA,EAAOK,UAAYJ,CAEnB,OAAOD,OACF,CAEL,MAAOD,GAAcC,EAAQC,OAMvChB,EAAOC,eAAiBA"}es6-shim-0.34.1/es6-sham.min.js000066400000000000000000000022741264300104700157770ustar00rootroot00000000000000/*! * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License * es6-sham: v0.34.1 * see https://github.com/paulmillr/es6-shim/blob/0.34.1/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;(function(){if(r.setPrototypeOf){return}var t=r.getOwnPropertyNames;var e=r.getOwnPropertyDescriptor;var n=r.create;var o=r.defineProperty;var f=r.getPrototypeOf;var i=r.prototype;var u=function(r,n){t(n).forEach(function(t){o(r,t,e(n,t))});return r};var c=function(t,e){return u(n(e),t)};var a,_;try{a=e(i,"__proto__").set;a.call({},null);_=function(t,e){a.call(t,e);return t}}catch(p){a={__proto__:null};if(a instanceof r){_=c}else{a.__proto__=i;if(a instanceof r){_=function(t,e){t.__proto__=e;return t}}else{_=function(t,e){if(f(t)){t.__proto__=e;return t}else{return c(t,e)}}}}}r.setPrototypeOf=_})()}); //# sourceMappingURL=es6-sham.map es6-shim-0.34.1/es6-shim.js000066400000000000000000004040431264300104700152250ustar00rootroot00000000000000 /*! * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License * es6-shim: v0.34.1 * see https://github.com/paulmillr/es6-shim/blob/0.34.1/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 () { Object.defineProperty({}, 'x', { get: function () {} }); }); }; var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); var functionsHaveNames = (function foo() {}).name === 'foo'; 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 _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 _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 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); }; // 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'); }, object: function (x) { return x !== null && 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); }; 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', {}); } var Reflect = globals.Reflect; var $String = String; var ES = { // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-call-f-v-args 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) { /* jshint eqnull:true */ if (x == null) { 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'; }, 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 (func === void 0 || func === null) { 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 (S === void 0 || S === null) { 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]; } 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 (regexp !== null && typeof regexp !== 'undefined') { 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 (searchValue !== null && typeof searchValue !== 'undefined') { 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 (separator !== null && typeof separator !== 'undefined') { 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 (regexp !== null && typeof regexp !== 'undefined') { 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 */ '/a/'.startsWith(/a/); }); var startsWithHandlesInfinity = '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); // see https://people.mozilla.org/~jorendorff/es6-draft.html#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, i = this._i; if (typeof s === 'undefined' || i >= s.length) { this._s = void 0; return { value: void 0, done: true }; } var first = s.charCodeAt(i), 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 { value: s.substr(i, len), done: false }; }; 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); } 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); // 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 }; }; // 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, 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 { value: retval, done: false }; } } this.array = void 0; return { value: void 0, done: true }; } }); 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); }; var ObjectIterator = function (object, kind) { defineProperties(this, { object: object, array: getAllKeys(object), kind: kind }); }; defineProperties(ObjectIterator.prototype, { next: function next() { var key; var array = this.array; if (!(this instanceof ObjectIterator)) { throw new TypeError('Not an ObjectIterator'); } // Find next key in the object while (array.length > 0) { key = _shift(array); // The candidate key isn't defined on object. // Must have been deleted, or object[[Prototype]] // has been modified. if (!(key in this.object)) { continue; } if (this.kind === 'key') { return iteratorResult(key); } else if (this.kind === 'value') { return iteratorResult(this.object[key]); } else { return iteratorResult([key, this.object[key]]); } } return iteratorResult(); } }); addIterator(ObjectIterator.prototype); // 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 (_hasOwnProperty(o, from)) { o[to] = o[from]; } else { delete o[from]; } 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); 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); } /* jshint newcap: false */ return OrigNumber(primValue); /* jshint newcap: true */ }; return NumberShim; }()); wrapConstructor(OrigNumber, NumberShim, {}); /*globals Number: true */ /* eslint-disable no-undef */ Number = NumberShim; Value.redefine(globals, 'Number', NumberShim); /* eslint-enable no-undef */ /*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.) /*jshint elision: true */ /* eslint-disable no-sparse-arrays */ if (![, 1].find(function (item, idx) { return idx === 0; })) { overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find); } if ([, 1].findIndex(function (item, idx) { return idx === 0; }) !== 0) { overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex); } /* eslint-enable no-sparse-arrays */ /*jshint elision: false */ 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, 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 () { Object.keys('foo'); }); if (!objectKeysAcceptsPrimitives) { var originalObjectKeys = Object.keys; overrideNative(Object, 'keys', function keys(value) { return originalObjectKeys(ES.ToObject(value)); }); keys = Object.keys; } if (Object.getOwnPropertyNames) { var objectGOPNAcceptsPrimitives = !throwsError(function () { 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 () { 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 () { Object.seal('foo'); }); if (!objectSealAcceptsPrimitives) { var originalObjectSeal = Object.seal; overrideNative(Object, 'seal', function seal(value) { if (!Type.object(value)) { return value; } return originalObjectSeal(value); }); } } if (Object.isSealed) { var objectIsSealedAcceptsPrimitives = !throwsError(function () { Object.isSealed('foo'); }); if (!objectIsSealedAcceptsPrimitives) { var originalObjectIsSealed = Object.isSealed; overrideNative(Object, 'isSealed', function isSealed(value) { if (!Type.object(value)) { return true; } return originalObjectIsSealed(value); }); } } if (Object.freeze) { var objectFreezeAcceptsPrimitives = !throwsError(function () { Object.freeze('foo'); }); if (!objectFreezeAcceptsPrimitives) { var originalObjectFreeze = Object.freeze; overrideNative(Object, 'freeze', function freeze(value) { if (!Type.object(value)) { return value; } return originalObjectFreeze(value); }); } } if (Object.isFrozen) { var objectIsFrozenAcceptsPrimitives = !throwsError(function () { Object.isFrozen('foo'); }); if (!objectIsFrozenAcceptsPrimitives) { var originalObjectIsFrozen = Object.isFrozen; overrideNative(Object, 'isFrozen', function isFrozen(value) { if (!Type.object(value)) { return true; } return originalObjectIsFrozen(value); }); } } if (Object.preventExtensions) { var objectPreventExtensionsAcceptsPrimitives = !throwsError(function () { Object.preventExtensions('foo'); }); if (!objectPreventExtensionsAcceptsPrimitives) { var originalObjectPreventExtensions = Object.preventExtensions; overrideNative(Object, 'preventExtensions', function preventExtensions(value) { if (!Type.object(value)) { return value; } return originalObjectPreventExtensions(value); }); } } if (Object.isExtensible) { var objectIsExtensibleAcceptsPrimitives = !throwsError(function () { Object.isExtensible('foo'); }); if (!objectIsExtensibleAcceptsPrimitives) { var originalObjectIsExtensible = Object.isExtensible; overrideNative(Object, 'isExtensible', function isExtensible(value) { if (!Type.object(value)) { return false; } return originalObjectIsExtensible(value); }); } } if (Object.getPrototypeOf) { var objectGetProtoAcceptsPrimitives = !throwsError(function () { 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; }()); if (supportsDescriptors && (!regExpSupportsFlagsWithRegex || regExpNeedsToSupportSymbolMatch)) { var flagsGetter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get; var sourceDesc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source') || {}; var legacySourceGetter = function () { return this.source; }; // prior to it being a getter, it's own + nonconfigurable 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 */ RegExp = RegExpShim; Value.redefine(globals, 'RegExp', RegExpShim); /* eslint-enable no-undef */ /*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 numberCLZ = Number.prototype.clz; delete Number.prototype.clz; // Safari 8 has Number#clz var MathShims = { acosh: function acosh(value) { var x = Number(value); if (Number.isNaN(x) || value < 1) { return NaN; } if (x === 1) { return 0; } if (x === Infinity) { return x; } return _log(x / Math.E + _sqrt(x + 1) * _sqrt(x - 1) / Math.E) + 1; }, asinh: function asinh(value) { var x = Number(value); if (x === 0 || !globalIsFinite(x)) { return x; } return x < 0 ? -Math.asinh(-x) : _log(x + _sqrt(x * x + 1)); }, atanh: function atanh(value) { var x = Number(value); if (Number.isNaN(x) || x < -1 || x > 1) { return NaN; } if (x === -1) { return -Infinity; } if (x === 1) { return Infinity; } if (x === 0) { return x; } return 0.5 * _log((1 + x) / (1 - x)); }, cbrt: function cbrt(value) { var x = Number(value); if (x === 0) { return x; } var negate = x < 0, result; if (negate) { x = -x; } if (x === Infinity) { result = Infinity; } else { result = Math.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) * Math.LOG2E); }, cosh: function cosh(value) { var x = Number(value); if (x === 0) { return 1; } // +0 or -0 if (Number.isNaN(x)) { return NaN; } if (!globalIsFinite(x)) { return Infinity; } if (x < 0) { x = -x; } if (x > 21) { return Math.exp(x) / 2; } return (Math.exp(x) + Math.exp(-x)) / 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 Math.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) * Math.LOG2E; }, log10: function log10(value) { return _log(value) * Math.LOG10E; }, log1p: function log1p(value) { var x = Number(value); if (x < -1 || Number.isNaN(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)); }, sign: function sign(value) { var number = Number(value); if (number === 0) { return number; } if (Number.isNaN(number)) { return number; } return number < 0 ? -1 : 1; }, sinh: function sinh(value) { var x = Number(value); if (!globalIsFinite(x) || x === 0) { return x; } if (_abs(x) < 1) { return (Math.expm1(x) - Math.expm1(-x)) / 2; } return (Math.exp(x - 1) - Math.exp(-x - 1)) * Math.E / 2; }, tanh: function tanh(value) { var x = Number(value); if (Number.isNaN(x) || x === 0) { return x; } if (x === Infinity) { return 1; } if (x === -Infinity) { return -1; } var a = Math.expm1(x); var b = Math.expm1(-x); if (a === Infinity) { return 1; } if (b === Infinity) { return -1; } return (a - b) / (Math.exp(x) + Math.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 = Math.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; } }; defineProperties(Math, MathShims); // 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 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); // Firefox 38 on Windows defineProperty(Math, 'cbrt', MathShims.cbrt, Math.abs(1 - Math.cbrt(1e-300) / 1e-100) / Number.EPSILON > 8); // 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 https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-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 */ /* jscs:disable disallowMultiLineTernary */ 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 /* jscs:enable disallowMultiLineTernary */ // 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 = [], remaining = { count: 1 }, 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, 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 () { globals.Promise.reject(42).then(null, 5).then(null, noop); }); var promiseRequiresObjectContext = throwsError(function () { 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); 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; 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 */ Promise = PromiseShim; /* eslint-enable no-undef */ /*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) { if (!preservesInsertionOrder) { return null; } var type = typeof key; if (type === 'undefined' || key === null) { return '^' + ES.ToString(key); } else if (type === 'string') { return '$' + key; } else if (type === 'number') { // note that -0 will get coerced to "0" when used as a property key if (!preservesNumericInsertionOrder) { return 'n' + key; } return key; } else if (type === '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 (iterable !== null && typeof iterable !== 'undefined') { 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 (iterable !== null && typeof iterable !== 'undefined') { 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 = { next: function next() { var i = this.i, kind = this.kind, head = this.head, result; if (typeof this.i === 'undefined') { return { value: void 0, done: true }; } while (i.isRemoved() && i !== head) { // back up off of removed entries i = i.prev; } // advance to next unreturned element. 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 { value: result, done: false }; } } // once the iterator is done, it is done forever. this.i = void 0; return { value: void 0, done: true }; } }; 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, _storage: emptyObject(), _size: 0 }); var head = new MapEntry(null, null); // circular doubly-linked list. 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 fkey = fastkey(key); if (fkey !== null) { // fast O(1) path var entry = this._storage[fkey]; if (entry) { return entry.value; } else { return; } } var head = this._head, 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); if (fkey !== null) { // fast O(1) path return typeof this._storage[fkey] !== 'undefined'; } var head = this._head, 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, i = head, entry; var fkey = fastkey(key); 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); 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, i = head; var fkey = fastkey(key); 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 } while ((i = i.next) !== head) { if (ES.SameValueZero(i.key, key)) { i.key = i.value = empty; i.prev.next = i.next; i.next.prev = i.prev; this._size -= 1; return true; } } return false; }, clear: function clear() { requireMapSlot(this, 'clear'); this._size = 0; this._storage = emptyObject(); var head = this._head, i = head, p = i.next; while ((i = p) !== head) { i.key = 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 = set['[[SetData]]'] = new collectionShims.Map(); _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 this['[[SetData]]'].values(); }, entries: function entries() { requireSetSlot(this, 'entries'); ensureMap(this); return 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); return SetShim; }()) }; 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) { var OrigMapNoArgs = globals.Map; globals.Map = function Map() { if (!(this instanceof Map)) { throw new TypeError('Constructor Map requires "new"'); } var m = new OrigMapNoArgs(); if (arguments.length > 0) { addIterableToMap(Map, m, arguments[0]); } delete m.constructor; Object.setPrototypeOf(m, globals.Map.prototype); return m; }; globals.Map.prototype = create(OrigMapNoArgs.prototype); defineProperty(globals.Map.prototype, 'constructor', globals.Map, true); Value.preserveToString(globals.Map, OrigMapNoArgs); } 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) { var origMapSet = Map.prototype.set; overrideNative(Map.prototype, 'set', function set(k, v) { _call(origMapSet, this, k === 0 ? 0 : k, v); return this; }); } if (!mapUsesSameValueZero) { var origMapGet = Map.prototype.get; var origMapHas = Map.prototype.has; 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 = (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; }); var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible var mapRequiresNew = (function () { try { return !(globals.Map() instanceof globals.Map); } catch (e) { return e instanceof TypeError; } }()); if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) { var OrigMap = globals.Map; 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; }); var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing; // without Object.setPrototypeOf, subclassing is not possible 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 mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () { return (new Map()).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 || new globals.Map().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 (new globals.Map().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]; }, enumerate: function enumerate(target) { throwUnlessTargetIsObject(target); return new ObjectIterator(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 () { 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 () { 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]); }); if (functionsHaveNames && globals.Reflect.getPrototypeOf.name !== 'getPrototypeOf') { var originalReflectGetProto = globals.Reflect.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 // https://people.mozilla.org/~jorendorff/es6-draft.html#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 = replacer ? _call(replacer, 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; })); es6-shim-0.34.1/es6-shim.map000066400000000000000000002327511264300104700153730ustar00rootroot00000000000000{"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","_concat","concat","_sort","sort","_strSlice","slice","_push","push","_pushApply","_shift","shift","_max","Math","max","_min","min","_floor","floor","_abs","abs","_log","log","_sqrt","sqrt","_hasOwnProperty","hasOwnProperty","ArrayIterator","noop","Symbol","symbolSpecies","species","numberIsNaN","Number","isNaN","numberIsFinite","isStandardArguments","isArguments","isLegacyArguments","length","callee","Type","primitive","string","regex","symbol","overrideNative","replacement","original","hasSymbols","$iterator$","iterator","Set","Reflect","$String","ES","Call","F","V","args","IsCallable","RequireObjectCoercible","optMessage","TypeIsObject","ToObject","IsConstructor","ToInt32","ToNumber","ToUint32","ToInteger","number","ToLength","len","MAX_SAFE_INTEGER","SameValue","a","b","SameValueZero","IsIterable","GetIterator","itFn","GetMethod","it","p","IteratorComplete","iterResult","IteratorClose","completionIsThrow","returnMethod","innerResult","innerException","IteratorNext","result","next","IteratorStep","done","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","Infinity","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","StringIterator","_s","_i","substr","ArrayShims","from","items","mapFn","mapping","T","usingIterator","nextValue","arrayLike","of","A","k","iteratorResult","array","kind","retval","orderKeys","aNumeric","bNumeric","localeCompare","getAllKeys","ownKeys","ObjectIterator","arrayOfSupportsSubclassing","Foo","fooArr","ArrayPrototypeShims","copyWithin","relativeTarget","relativeStart","to","relativeEnd","finalItem","count","direction","fill","find","predicate","list","thisArg","findIndex","values","entries","unscopables","originalArrayPrototypeValues","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","NaN","receiver","valueOfSucceeds","maxSafeInteger","MIN_SAFE_INTEGER","EPSILON","parseFloat","isInteger","isSafeInteger","item","idx","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","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","flagsGetter","sourceDesc","legacySourceGetter","sourceGetter","OrigRegExp","RegExpShim","pattern","patternIsRegExp","calledWithNew","P","$input","regexGlobals","input","lastMatch","lastParen","leftContext","rightContext","inverseEpsilon","roundTiesToEven","n","BINARY_32_EPSILON","BINARY_32_MAX_VALUE","BINARY_32_MIN_VALUE","numberCLZ","clz","MathShims","acosh","E","asinh","atanh","cbrt","negate","exp","clz32","LOG2E","cosh","expm1","t","sum","hypot","y","largest","log2","log10","LOG10E","log1p","sign","sinh","tanh","trunc","imul","ah","al","bh","bl","fround","v","MAX_VALUE","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","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","all","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","type","emptyObject","addIterableToMap","MapConstructor","entry","iter","adder","nextItem","addIterableToSet","SetConstructor","add","collectionShims","Map","empty","MapEntry","prev","isRemoved","isMap","_es6map","requireMapSlot","MapIterator","head","_head","Map$prototype","MapShim","_storage","_size","fkey","has","delete","clear","callback","context","isSet","_es6set","requireSetSlot","Set$prototype","SetShim","[[SetData]]","decodeKey","charAt","ensureMap","m","size","hasFKey","entireSet","mapAcceptsArguments","OrigMapNoArgs","testMap","mapUsesSameValueZero","mapSupportsChaining","origMapSet","origMapGet","origMapHas","testSet","setUsesSameValueZero","setSupportsChaining","origSetAdd","origSetHas","origSetDel","SetDelete","mapSupportsSubclassing","M","mapFailsToSupportSubclassing","mapRequiresNew","OrigMap","setSupportsSubclassing","setFailsToSupportSubclassing","setRequiresNew","OrigSet","mapIterationThrowsStopIterator","anonymousSetHas","throwUnlessTargetIsObject","ReflectShims","deleteProperty","enumerate","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,YAAa,OAAQb,EAAOY,EAAMb,KAAMe,YAE1D,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,WAAcN,OAAOW,kBAAmB,KAAOC,IAAK,iBAE1E,IAAIC,KAAwBb,OAAOW,gBAAkBD,GACrD,IAAII,GAAqB,QAAUC,SAAUC,OAAS,KAEtD,IAAIC,GAAWzB,SAASC,KAAKC,KAAKI,MAAMoB,UAAUC,QAClD,IAAIC,GAAU5B,SAASC,KAAKC,KAAKI,MAAMoB,UAAUG,OACjD,IAAIC,GAAU9B,SAASC,KAAKC,KAAKI,MAAMoB,UAAUK,OACjD,IAAIC,GAAQhC,SAASC,KAAKC,KAAKI,MAAMoB,UAAUO,KAE/C,IAAId,GAAiB,SAAUe,EAAQV,EA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AAaC,KAAKD,UAAY,IACpG,KAAKA,EAAW,CAAE,MAAO,OACzB,SAAWA,GAAUjoB,OAAc,YAAa,CAAE,MAAO,MACzD,GAAIioB,GAAWjoB,QAAe,SAAU,CAAE,MAAO,MACjD,GAAIwE,IAAQ1B,EAAG9C,IACfwE,GAAIxE,KAAY,IAChB,IAAIioB,EAAUzjB,KAAS,KAAM,CAAE,MAAO,MACtC,MAAO,SAET,IAAI2jB,IAAmC5uB,EAAqB,WAE1D,IAAK6H,EAAY,CAAE,MAAO,MAC1B,MAAO8mB,MAAKD,UAAUlvB,OAAOiH,QAAe,MAAQkoB,KAAKD,WAAWlvB,OAAOiH,SAAgB,QAE7F,IAAIgoB,KAA2BG,GAAkC,CAC/D,GAAIC,IAAgBF,KAAKD,SACzBhnB,GAAeinB,KAAM,YAAa,QAASD,WAAUvtB,GACnD,SAAWA,KAAU,SAAU,CAAE,OACjC,GAAI8L,EACJ,IAAIpN,UAAUsH,OAAS,EAAG,CACxB8F,EAAWpN,UAAU,GAEvB,GAAI0I,IAAQpH,EACZ,KAAK9B,EAAQ4N,GAAW,CACtB,GAAI6hB,GAAY3mB,GAAGK,WAAWyE,GAAYA,EAAW,IACrD,IAAI8hB,GAAkB,SAAUxsB,EAAKiY,GACnC,GAAIwU,GAAc/hB,EAAW7N,EAAM6N,EAAUnO,KAAMyD,EAAKiY,GAAOA,CAC/D,UAAWwU,KAAgB,SAAU,CACnC,GAAI3nB,EAAKI,OAAOunB,GAAc,CAC5B,MAAOhW,QAAagW,OACf,CACL,MAAOA,KAIbzmB,GAAKnD,KAAK2pB,OACL,CAELxmB,EAAKnD,KAAK6H,GAEZ,GAAIpN,UAAUsH,OAAS,EAAG,CACxBoB,EAAKnD,KAAKvF,UAAU,IAEtB,MAAOgvB,IAAc1vB,MAAML,KAAMyJ,KAIrC,MAAOhE"}es6-shim-0.34.1/es6-shim.min.js000066400000000000000000001552421264300104700160130ustar00rootroot00000000000000/*! * https://github.com/paulmillr/es6-shim * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) * and contributors, MIT License * es6-shim: v0.34.1 * see https://github.com/paulmillr/es6-shim/blob/0.34.1/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(){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 g=function(e,t,r){l(n(t),function(n){var o=t[n];h(e,n,o,!!r)})};var b=Function.call.bind(Object.prototype.toString);var d=typeof/abc/==="function"?function IsCallableSlow(e){return typeof e==="function"&&b(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.call.bind(Array.prototype.concat);var P=Function.call.bind(Array.prototype.sort);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 F=Math.log;var L=Math.sqrt;var D=Function.call.bind(Object.prototype.hasOwnProperty);var z;var q=function(){};var W=S.Symbol||{};var G=W.species||"@@species";var H=Number.isNaN||function isNaN(e){return e!==e};var B=Number.isFinite||function isFinite(e){return typeof e==="number"&&T(e)};var $=function isArguments(e){return b(e)==="[object Arguments]"};var V=function isArguments(e){return e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&b(e)!=="[object Array]"&&b(e.callee)==="[object Function]"};var J=$(arguments)?$:V;var K={primitive:function(e){return e===null||typeof e!=="function"&&typeof e!=="object"},object:function(e){return e!==null&&typeof e==="object"},string:function(e){return b(e)==="[object String]"},regex:function(e){return b(e)==="[object RegExp]"},symbol:function(e){return typeof S.Symbol==="function"&&typeof e==="symbol"}};var U=function overrideNative(e,t,r){var n=e[t];h(e,t,r,true);m.preserveToString(e[t],n)};var X=typeof W==="function"&&typeof W["for"]==="function"&&K.symbol(W());var Z=K.symbol(W.iterator)?W.iterator:"_es6-shim iterator_";if(S.Set&&typeof(new S.Set)["@@iterator"]==="function"){Z="@@iterator"}if(!S.Reflect){h(S,"Reflect",{})}var Q=S.Reflect;var Y=String;var ee={Call:function Call(t,r){var n=arguments.length>2?arguments[2]:[];if(!ee.IsCallable(t)){throw new TypeError(t+" is not a function")}return e(t,r,n)},RequireObjectCoercible:function(e,t){if(e==null){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"},ToObject:function(e,t){return Object(ee.RequireObjectCoercible(e,t))},IsCallable:d,IsConstructor:function(e){return ee.IsCallable(e)},ToInt32:function(e){return ee.ToNumber(e)>>0},ToUint32:function(e){return ee.ToNumber(e)>>>0},ToNumber:function(e){if(b(e)==="[object Symbol]"){throw new TypeError("Cannot convert a Symbol value to a number")}return+e},ToInteger:function(e){var t=ee.ToNumber(e);if(H(t)){return 0}if(t===0||!B(t)){return t}return(t>0?1:-1)*_(k(t))},ToLength:function(e){var t=ee.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 H(e)&&H(t)},SameValueZero:function(e,t){return e===t||H(e)&&H(t)},IsIterable:function(e){return ee.TypeIsObject(e)&&(typeof e[Z]!=="undefined"||J(e))},GetIterator:function(e){if(J(e)){return new z(e,"value")}var t=ee.GetMethod(e,Z);if(!ee.IsCallable(t)){throw new TypeError("value is not an iterable")}var r=ee.Call(t,e);if(!ee.TypeIsObject(r)){throw new TypeError("bad iterator")}return r},GetMethod:function(e,t){var r=ee.ToObject(e)[t];if(r===void 0||r===null){return void 0}if(!ee.IsCallable(r)){throw new TypeError("Method not callable: "+t)}return r},IteratorComplete:function(e){return!!e.done},IteratorClose:function(e,t){var r=ee.GetMethod(e,"return");if(r===void 0){return}var n,o;try{n=ee.Call(r,e)}catch(i){o=i}if(t){return}if(o){throw o}if(!ee.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(!ee.TypeIsObject(t)){throw new TypeError("bad iterator")}return t},IteratorStep:function(e){var t=ee.IteratorNext(e);var r=ee.IteratorComplete(t);return r?false:t},Construct:function(e,t,r,n){var o=typeof r==="undefined"?e:r;if(!n&&Q.construct){return Q.construct(e,t,o)}var i=o.prototype;if(!ee.TypeIsObject(i)){i=Object.prototype}var a=O(i);var u=ee.Call(e,a,t);return ee.TypeIsObject(u)?u:a},SpeciesConstructor:function(e,t){var r=e.constructor;if(r===void 0){return t}if(!ee.TypeIsObject(r)){throw new TypeError("Bad constructor")}var n=r[G];if(n===void 0||n===null){return t}if(!ee.IsConstructor(n)){throw new TypeError("Bad @@species")}return n},CreateHTML:function(e,t,r,n){var o=ee.ToString(e);var i="<"+t;if(r!==""){var a=ee.ToString(n);var u=a.replace(/"/g,""");i+=" "+r+'="'+u+'"'}var f=i+">";var s=f+o;return s+""},IsRegExp:function IsRegExp(e){if(!ee.TypeIsObject(e)){return false}var t=e[W.match];if(typeof t!=="undefined"){return!!t}return K.regex(e)},ToString:function ToString(e){return Y(e)}};if(s&&X){var te=function defineWellKnownSymbol(e){if(K.symbol(W[e])){return W[e]}var t=W["for"]("Symbol."+e);Object.defineProperty(W,e,{configurable:false,enumerable:false,writable:false,value:t});return t};if(!K.symbol(W.search)){var re=te("search");var ne=String.prototype.search;h(RegExp.prototype,re,function search(e){return ee.Call(ne,e,[this])});var oe=function search(e){var t=ee.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var r=ee.GetMethod(e,re);if(typeof r!=="undefined"){return ee.Call(r,e,[t])}}return ee.Call(ne,t,[ee.ToString(e)])};U(String.prototype,"search",oe)}if(!K.symbol(W.replace)){var ie=te("replace");var ae=String.prototype.replace;h(RegExp.prototype,ie,function replace(e,t){return ee.Call(ae,e,[this,t])});var ue=function replace(e,t){var r=ee.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var n=ee.GetMethod(e,ie);if(typeof n!=="undefined"){return ee.Call(n,e,[r,t])}}return ee.Call(ae,r,[ee.ToString(e),t])};U(String.prototype,"replace",ue)}if(!K.symbol(W.split)){var fe=te("split");var se=String.prototype.split;h(RegExp.prototype,fe,function split(e,t){return ee.Call(se,e,[this,t])});var ce=function split(e,t){var r=ee.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var n=ee.GetMethod(e,fe);if(typeof n!=="undefined"){return ee.Call(n,e,[r,t])}}return ee.Call(se,r,[ee.ToString(e),t])};U(String.prototype,"split",ce)}var le=K.symbol(W.match);var pe=le&&function(){var e={};e[W.match]=function(){return 42};return"a".match(e)!==42}();if(!le||pe){var ve=te("match");var ye=String.prototype.match;h(RegExp.prototype,ve,function match(e){return ee.Call(ye,e,[this])});var he=function match(e){var t=ee.RequireObjectCoercible(this);if(e!==null&&typeof e!=="undefined"){var r=ee.GetMethod(e,ve);if(typeof r!=="undefined"){return ee.Call(r,e,[t])}}return ee.Call(ye,t,[ee.ToString(e)])};U(String.prototype,"match",he)}}var ge=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 q||r[n]){return}m.proxy(e,n,t)})}else{l(Object.keys(e),function(n){if(n in q||r[n]){return}t[n]=e[n]})}t.prototype=e.prototype;m.redefine(e.prototype,"constructor",t)};var be=function(){return this};var de=function(e){if(s&&!D(e,G)){m.getter(e,G,be)}};var me=function(e,t){var r=t||function iterator(){return this};h(e,Z,r);if(!e[Z]&&K.symbol(Z)){e[Z]=r}};var Oe=function createDataProperty(e,t,r){if(s){Object.defineProperty(e,t,{configurable:true,enumerable:true,writable:true,value:r})}else{e[t]=r}};var we=function createDataPropertyOrThrow(e,t,r){Oe(e,t,r);if(!ee.SameValue(e[t],r)){throw new TypeError("property is nonconfigurable")}};var je=function(e,t,r,n){if(!ee.TypeIsObject(e)){throw new TypeError("Constructor requires `new`: "+t.name)}var o=t.prototype;if(!ee.TypeIsObject(o)){o=r}var i=O(o);for(var a in n){if(D(n,a)){var u=n[a];h(i,a,u,true)}}return i};if(String.fromCodePoint&&String.fromCodePoint.length!==1){var Se=String.fromCodePoint;U(String,"fromCodePoint",function fromCodePoint(e){return ee.Call(Se,this,arguments)})}var Te={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=ee.ToObject(e,"bad callSite");var r=ee.ToObject(t.raw,"bad raw value");var n=r.length;var o=ee.ToLength(n);if(o<=0){return""}var i=[];var a=0;var u,f,s,c;while(a=o){break}f=a+1=Ee){throw new RangeError("repeat count must be less than infinity and not overflow maximum string size")}return Ie(t,r)},startsWith:function startsWith(e){var t=ee.ToString(ee.RequireObjectCoercible(this));if(ee.IsRegExp(e)){throw new TypeError('Cannot call method "startsWith" with a regex')}var r=ee.ToString(e);var n;if(arguments.length>1){n=arguments[1]}var o=A(ee.ToInteger(n),0);return C(t,o,o+r.length)===r},endsWith:function endsWith(e){var t=ee.ToString(ee.RequireObjectCoercible(this));if(ee.IsRegExp(e)){throw new TypeError('Cannot call method "endsWith" with a regex')}var r=ee.ToString(e);var n=t.length;var o;if(arguments.length>1){o=arguments[1]}var i=typeof o==="undefined"?n:ee.ToInteger(o);var a=R(A(i,0),n);return C(t,a-r.length,a)===r},includes:function includes(e){if(ee.IsRegExp(e)){throw new TypeError('"includes" does not accept a RegExp')}var t=ee.ToString(e);var r;if(arguments.length>1){r=arguments[1]}return I(this,t,r)!==-1},codePointAt:function codePointAt(e){var t=ee.ToString(ee.RequireObjectCoercible(this));var r=ee.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){U(String.prototype,"includes",Pe.includes)}if(String.prototype.startsWith&&String.prototype.endsWith){var Ce=i(function(){"/a/".startsWith(/a/)});var Me="abc".startsWith("a",Infinity)===false;if(!Ce||!Me){U(String.prototype,"startsWith",Pe.startsWith);U(String.prototype,"endsWith",Pe.endsWith)}}if(X){var xe=a(function(){var e=/a/;e[W.match]=false;return"/a/".startsWith(e)});if(!xe){U(String.prototype,"startsWith",Pe.startsWith)}var Ne=a(function(){var e=/a/;e[W.match]=false;return"/a/".endsWith(e)});if(!Ne){U(String.prototype,"endsWith",Pe.endsWith)}var Ae=a(function(){var e=/a/;e[W.match]=false;return"/a/".includes(e)});if(!Ae){U(String.prototype,"includes",Pe.includes)}}g(String.prototype,Pe);var Re=[" \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 _e=new RegExp("(^["+Re+"]+)|(["+Re+"]+$)","g");var ke=function trim(){return ee.ToString(ee.RequireObjectCoercible(this)).replace(_e,"")};var Fe=["\x85","\u200b","\ufffe"].join("");var Le=new RegExp("["+Fe+"]","g");var De=/^[\-+]0x[0-9a-f]+$/i;var ze=Fe.trim().length!==Fe.length;h(String.prototype,"trim",ke,ze);var qe=function(e){ee.RequireObjectCoercible(e);this._s=ee.ToString(e);this._i=0};qe.prototype.next=function(){var e=this._s,t=this._i;if(typeof e==="undefined"||t>=e.length){this._s=void 0;return{value:void 0,done:true}}var r=e.charCodeAt(t),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{value:e.substr(t,o),done:false}};me(qe.prototype);me(String.prototype,function(){return new qe(this)});var We={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(!ee.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(J(e)||ee.GetMethod(e,Z))!=="undefined";var u,f,s;if(a){f=ee.IsConstructor(r)?Object(new r):[];var c=ee.GetIterator(e);var l,p;s=0;while(true){l=ee.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){ee.IteratorClose(c,true);throw v}s+=1}u=s}else{var y=ee.ToObject(e);u=ee.ToLength(y.length);f=ee.IsConstructor(r)?Object(new r(u)):new Array(u);var h;for(s=0;s0){e=N(t);if(!(e in this.object)){continue}if(this.kind==="key"){return Ge(e)}else if(this.kind==="value"){return Ge(this.object[e])}else{return Ge([e,this.object[e]])}}return Ge()}});me($e.prototype);var Ve=Array.of===We.of||function(){var e=function Foo(e){this.length=e};e.prototype=[];var t=Array.of.apply(e,[1,2]);return t instanceof e&&t.length===2}();if(!Ve){U(Array,"of",We.of)}var Je={copyWithin:function copyWithin(e,t){var r=ee.ToObject(this);var n=ee.ToLength(r.length);var o=ee.ToInteger(e);var i=ee.ToInteger(t);var a=o<0?A(n+o,0):R(o,n);var u=i<0?A(n+i,0):R(i,n);var f;if(arguments.length>2){f=arguments[2]}var s=typeof f==="undefined"?n:ee.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(D(r,u)){r[a]=r[u]}else{delete r[u]}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=ee.ToObject(this);var o=ee.ToLength(n.length);t=ee.ToInteger(typeof t==="undefined"?0:t);r=ee.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 ee.Call(Qe,this,arguments)}else{return t(Qe,this,e)}})}var Ye=-(Math.pow(2,32)-1);var et=function(e,r){var n={length:Ye};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(!et(Array.prototype.forEach)){var tt=Array.prototype.forEach;U(Array.prototype,"forEach",function forEach(e){return ee.Call(tt,this.length>=0?this:[],arguments)},true)}if(!et(Array.prototype.map)){var rt=Array.prototype.map;U(Array.prototype,"map",function map(e){return ee.Call(rt,this.length>=0?this:[],arguments)},true)}if(!et(Array.prototype.filter)){var nt=Array.prototype.filter;U(Array.prototype,"filter",function filter(e){return ee.Call(nt,this.length>=0?this:[],arguments)},true)}if(!et(Array.prototype.some)){var ot=Array.prototype.some;U(Array.prototype,"some",function some(e){return ee.Call(ot,this.length>=0?this:[],arguments)},true)}if(!et(Array.prototype.every)){var it=Array.prototype.every;U(Array.prototype,"every",function every(e){return ee.Call(it,this.length>=0?this:[],arguments)},true)}if(!et(Array.prototype.reduce)){var at=Array.prototype.reduce;U(Array.prototype,"reduce",function reduce(e){return ee.Call(at,this.length>=0?this:[],arguments)},true)}if(!et(Array.prototype.reduceRight,true)){var ut=Array.prototype.reduceRight;U(Array.prototype,"reduceRight",function reduceRight(e){return ee.Call(ut,this.length>=0?this:[],arguments)},true)}var ft=Number("0o10")!==8;var st=Number("0b10")!==2;var ct=y(Fe,function(e){return Number(e+0+e)===0});if(ft||st||ct){var lt=Number;var pt=/^0b[01]+$/i;var vt=/^0o[0-7]+$/i;var yt=pt.test.bind(pt);var ht=vt.test.bind(vt);var gt=function(e){var t;if(typeof e.valueOf==="function"){t=e.valueOf();if(K.primitive(t)){return t}}if(typeof e.toString==="function"){t=e.toString();if(K.primitive(t)){return t}}throw new TypeError("No default value")};var bt=Le.test.bind(Le);var dt=De.test.bind(De);var mt=function(){var e=function Number(t){var r;if(arguments.length>0){r=K.primitive(t)?t:gt(t,"number")}else{r=0}if(typeof r==="string"){r=ee.Call(ke,r);if(yt(r)){r=parseInt(C(r,2),2)}else if(ht(r)){r=parseInt(C(r,2),8)}else if(bt(r)||dt(r)){r=NaN}}var n=this;var o=a(function(){lt.prototype.valueOf.call(n);return true});if(n instanceof e&&!o){return new lt(r)}return lt(r)};return e}();ge(lt,mt,{});Number=mt;m.redefine(S,"Number",mt)}var Ot=Math.pow(2,53)-1;g(Number,{MAX_SAFE_INTEGER:Ot,MIN_SAFE_INTEGER:-Ot,EPSILON:2.220446049250313e-16,parseInt:S.parseInt,parseFloat:S.parseFloat,isFinite:B,isInteger:function isInteger(e){return B(e)&&ee.ToInteger(e)===e},isSafeInteger:function isSafeInteger(e){return Number.isInteger(e)&&k(e)<=Number.MAX_SAFE_INTEGER},isNaN:H});h(Number,"parseInt",S.parseInt,Number.parseInt!==S.parseInt);if(![,1].find(function(e,t){return t===0})){U(Array.prototype,"find",Je.find)}if([,1].findIndex(function(e,t){return t===0})!==0){U(Array.prototype,"findIndex",Je.findIndex)}var wt=Function.bind.call(Function.bind,Object.prototype.propertyIsEnumerable);var jt=function ensureEnumerable(e,t){if(s&&wt(e,t)){Object.defineProperty(e,t,{enumerable:false})}};var St=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}if(t===-1){return-Infinity}if(t===1){return Infinity}if(t===0){return t}return.5*F((1+t)/(1-t))},cbrt:function cbrt(e){var t=Number(e);if(t===0){return t}var r=t<0,n;if(r){t=-t}if(t===Infinity){n=Infinity}else{n=Math.exp(F(t)/3);n=(t/(n*n)+2*n)/3}return r?-n:n},clz32:function clz32(e){var t=Number(e);var r=ee.ToUint32(t);if(r===0){return 32}return pr?ee.Call(pr,r):31-_(F(r+.5)*Math.LOG2E)},cosh:function cosh(e){var t=Number(e);if(t===0){return 1}if(Number.isNaN(t)){return NaN}if(!T(t)){return Infinity}if(t<0){t=-t}if(t>21){return Math.exp(t)/2}return(Math.exp(t)+Math.exp(-t))/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 Math.exp(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*L(r)},log2:function log2(e){return F(e)*Math.LOG2E},log10:function log10(e){return F(e)*Math.LOG10E},log1p:function log1p(e){var t=Number(e);if(t<-1||Number.isNaN(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))},sign:function sign(e){var t=Number(e);if(t===0){return t}if(Number.isNaN(t)){return t}return t<0?-1:1},sinh:function sinh(e){var t=Number(e);if(!T(t)||t===0){return t}if(k(t)<1){return(Math.expm1(t)-Math.expm1(-t))/2}return(Math.exp(t-1)-Math.exp(-t-1))*Math.E/2},tanh:function tanh(e){var t=Number(e);if(Number.isNaN(t)||t===0){return t}if(t===Infinity){return 1}if(t===-Infinity){return-1}var r=Math.expm1(t);var n=Math.expm1(-t);if(r===Infinity){return 1}if(n===Infinity){return-1}return(r-n)/(Math.exp(t)+Math.exp(-t))},trunc:function trunc(e){var t=Number(e);return t<0?-_(-t):_(t)},imul:function imul(e,t){var r=ee.ToUint32(e);var n=ee.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||H(t)){return t}var r=Math.sign(t);var n=k(t);if(ncr||H(i)){return r*Infinity}return r*i}};g(Math,vr);h(Math,"log1p",vr.log1p,Math.log1p(-1e-17)!==-1e-17);h(Math,"asinh",vr.asinh,Math.asinh(-1e7)!==-Math.asinh(1e7));h(Math,"tanh",vr.tanh,Math.tanh(-2e-17)!==-2e-17);h(Math,"acosh",vr.acosh,Math.acosh(Number.MAX_VALUE)===Infinity);h(Math,"cbrt",vr.cbrt,Math.abs(1-Math.cbrt(1e-300)/1e-100)/Number.EPSILON>8);h(Math,"sinh",vr.sinh,Math.sinh(-2e-17)!==-2e-17);var yr=Math.expm1(10);h(Math,"expm1",vr.expm1,yr>22025.465794806718||yr<22025.465794806718);var hr=Math.round;var gr=Math.round(.5-Number.EPSILON/4)===0&&Math.round(-.5+Number.EPSILON/3.99)===1;var br=ur+1;var dr=2*ur-1;var mr=[br,dr].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},!gr||!mr);m.preserveToString(Math.round,hr);var Or=Math.imul;if(Math.imul(4294967295,5)!==-5){Math.imul=vr.imul;m.preserveToString(Math.imul,Or)}if(Math.imul.length!==2){U(Math,"imul",function imul(e,t){return ee.Call(Or,Math,arguments)})}var wr=function(){var e=S.setTimeout; if(typeof e!=="function"&&typeof e!=="object"){return}ee.IsPromise=function(e){if(!ee.TypeIsObject(e)){return false}if(typeof e._promise==="undefined"){return false}return true};var r=function(e){if(!ee.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(!(ee.IsCallable(t.resolve)&&ee.IsCallable(t.reject))){throw new TypeError("Bad promise constructor")}};var n;if(typeof window!=="undefined"&&ee.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=ee.IsCallable(S.setImmediate)?S.setImmediate:typeof process==="object"&&process.nextTick?process.nextTick:o()||(ee.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(){b(e,t,r)})};var b=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(g&&o===E){i=y}else{i=new r(o)}var b=ee.IsCallable(e)?e:a;var d=ee.IsCallable(t)?t:u;var m=n._promise;var O;if(m.state===f){if(m.reactionLength===0){m.fulfillReactionHandler0=b;m.rejectReactionHandler0=d;m.reactionCapability0=i}else{var w=3*(m.reactionLength-1);m[w+l]=b;m[w+p]=d;m[w+v]=i}m.reactionLength+=1}else if(m.state===s){O=m.result;h(b,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 wr==="function"){g(S,{Promise:wr});var jr=w(S.Promise,function(e){return e.resolve(42).then(function(){})instanceof e});var Sr=!i(function(){S.Promise.reject(42).then(null,5).then(null,q)});var Tr=i(function(){S.Promise.call(3,q)});var Ir=function(e){var t=e.resolve(5);t.constructor={};var r=e.resolve(t);return t===r}(S.Promise);var Er=s&&function(){var e=0;var t=Object.defineProperty({},"then",{get:function(){e+=1}});Promise.resolve(t);return e===1}();var Pr=function BadResolverPromise(e){var t=new Promise(e);e(3,function(){});this.then=t.then;this.constructor=BadResolverPromise};Pr.prototype=Promise.prototype;Pr.all=Promise.all;var Cr=a(function(){return!!Pr.all([1,2])});if(!jr||!Sr||!Tr||Ir||!Er||Cr){Promise=wr;U(S,"Promise",wr)}if(Promise.all.length!==1){var Mr=Promise.all;U(Promise,"all",function all(e){return ee.Call(Mr,this,arguments)})}if(Promise.race.length!==1){var xr=Promise.race;U(Promise,"race",function race(e){return ee.Call(xr,this,arguments)})}if(Promise.resolve.length!==1){var Nr=Promise.resolve;U(Promise,"resolve",function resolve(e){return ee.Call(Nr,this,arguments)})}if(Promise.reject.length!==1){var Ar=Promise.reject;U(Promise,"reject",function reject(e){return ee.Call(Ar,this,arguments)})}jt(Promise,"all");jt(Promise,"race");jt(Promise,"resolve");jt(Promise,"reject");de(Promise)}var Rr=function(e){var t=n(p(e,function(e,t){e[t]=true;return e},{}));return e.join(":")===t.join(":")};var _r=Rr(["z","a","bb"]);var kr=Rr(["z",1,"a","3",2]);if(s){var Fr=function fastkey(e){if(!_r){return null}var t=typeof e;if(t==="undefined"||e===null){return"^"+ee.ToString(e)}else if(t==="string"){return"$"+e}else if(t==="number"){if(!kr){return"n"+e}return e}else if(t==="boolean"){return"b"+e}return null};var Lr=function emptyObject(){return Object.create?Object.create(null):{}};var Dr=function addIterableToMap(e,n,o){if(r(o)||K.string(o)){l(o,function(e){if(!ee.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(o!==null&&typeof o!=="undefined"){a=n.set;if(!ee.IsCallable(a)){throw new TypeError("bad map")}i=ee.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=ee.IteratorStep(i);if(u===false){break}var f=u.value;try{if(!ee.TypeIsObject(f)){throw new TypeError("Iterator value "+f+" is not an entry object")}t(a,n,f[0],f[1])}catch(s){ee.IteratorClose(i,true);throw s}}}}};var zr=function addIterableToSet(e,n,o){if(r(o)||K.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(o!==null&&typeof o!=="undefined"){a=n.add;if(!ee.IsCallable(a)){throw new TypeError("bad set")}i=ee.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=ee.IteratorStep(i);if(u===false){break}var f=u.value;try{t(a,n,f)}catch(s){ee.IteratorClose(i,true);throw s}}}}};var qr={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(!ee.TypeIsObject(e)||!n(e)){throw new TypeError("Method Map.prototype."+t+" called on incompatible receiver "+ee.ToString(e))}};var i=function MapIterator(e,t){o(e,"[[MapIterator]]");this.head=e._head;this.i=this.head;this.kind=t};i.prototype={next:function next(){var e=this.i,t=this.kind,r=this.head,n;if(typeof this.i==="undefined"){return{value:void 0,done:true}}while(e.isRemoved()&&e!==r){e=e.prev}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{value:n,done:false}}}this.i=void 0;return{value:void 0,done:true}}};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=je(this,Map,a,{_es6map:true,_head:null,_storage:Lr(),_size:0});var t=new r(null,null);t.next=t.prev=t;e._head=t;if(arguments.length>0){Dr(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});g(a,{get:function get(e){o(this,"get");var t=Fr(e);if(t!==null){var r=this._storage[t];if(r){return r.value}else{return}}var n=this._head,i=n;while((i=i.next)!==n){if(ee.SameValueZero(i.key,e)){return i.value}}},has:function has(e){o(this,"has");var t=Fr(e);if(t!==null){return typeof this._storage[t]!=="undefined"}var r=this._head,n=r;while((n=n.next)!==r){if(ee.SameValueZero(n.key,e)){return true}}return false},set:function set(e,t){o(this,"set");var n=this._head,i=n,a;var u=Fr(e);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}}while((i=i.next)!==n){if(ee.SameValueZero(i.key,e)){i.value=t;return this}}a=a||new r(e,t);if(ee.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,n=r;var i=Fr(t);if(i!==null){if(typeof this._storage[i]==="undefined"){return false}n=this._storage[i].prev;delete this._storage[i]}while((n=n.next)!==r){if(ee.SameValueZero(n.key,t)){n.key=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._size=0;this._storage=Lr();var t=this._head,r=t,n=r.next;while((r=n)!==t){r.key=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(!ee.TypeIsObject(t)||!e(t)){throw new TypeError("Set.prototype."+r+" called on incompatible receiver "+ee.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=je(this,Set,o,{_es6set:true,"[[SetData]]":null,_storage:Lr()});if(!e._es6set){throw new TypeError("bad set")}if(arguments.length>0){zr(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=e["[[SetData]]"]=new qr.Map;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});g(i.prototype,{has:function has(e){r(this,"has");var t;if(this._storage&&(t=Fr(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=Fr(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=Fr(e))!==null){var n=D(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=Lr()}if(this["[[SetData]]"]){this["[[SetData]]"].clear()}},values:function values(){r(this,"values");u(this);return this["[[SetData]]"].values()},entries:function entries(){r(this,"entries");u(this);return 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);return i}()};if(S.Map||S.Set){var Wr=a(function(){return new Map([[1,2]]).get(1)===2});if(!Wr){var Gr=S.Map;S.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new Gr;if(arguments.length>0){Dr(Map,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,S.Map.prototype);return e};S.Map.prototype=O(Gr.prototype);h(S.Map.prototype,"constructor",S.Map,true);m.preserveToString(S.Map,Gr)}var Hr=new Map;var Br=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 $r=Hr.set(1,2)===Hr;if(!Br||!$r){var Vr=Map.prototype.set;U(Map.prototype,"set",function set(e,r){t(Vr,this,e===0?0:e,r);return this})}if(!Br){var Jr=Map.prototype.get;var Kr=Map.prototype.has;g(Map.prototype,{get:function get(e){return t(Jr,this,e===0?0:e)},has:function has(e){return t(Kr,this,e===0?0:e)}},true);m.preserveToString(Map.prototype.get,Jr);m.preserveToString(Map.prototype.has,Kr)}var Ur=new Set;var Xr=function(e){e["delete"](0);e.add(-0);return!e.has(0)}(Ur);var Zr=Ur.add(1)===Ur;if(!Xr||!Zr){var Qr=Set.prototype.add;Set.prototype.add=function add(e){t(Qr,this,e===0?0:e);return this};m.preserveToString(Set.prototype.add,Qr)}if(!Xr){var Yr=Set.prototype.has;Set.prototype.has=function has(e){return t(Yr,this,e===0?0:e)};m.preserveToString(Set.prototype.has,Yr);var en=Set.prototype["delete"];Set.prototype["delete"]=function SetDelete(e){return t(en,this,e===0?0:e)};m.preserveToString(Set.prototype["delete"],en)}var tn=w(S.Map,function(e){var t=new e([]);t.set(42,42);return t instanceof e});var rn=Object.setPrototypeOf&&!tn;var nn=function(){try{return!(S.Map()instanceof S.Map)}catch(e){return e instanceof TypeError}}();if(S.Map.length!==0||rn||!nn){var on=S.Map;S.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new on;if(arguments.length>0){Dr(Map,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,Map.prototype);return e};S.Map.prototype=on.prototype;h(S.Map.prototype,"constructor",S.Map,true);m.preserveToString(S.Map,on)}var an=w(S.Set,function(e){var t=new e([]);t.add(42,42);return t instanceof e});var un=Object.setPrototypeOf&&!an;var fn=function(){try{return!(S.Set()instanceof S.Set)}catch(e){return e instanceof TypeError}}();if(S.Set.length!==0||un||!fn){var sn=S.Set;S.Set=function Set(){if(!(this instanceof Set)){throw new TypeError('Constructor Set requires "new"')}var e=new sn;if(arguments.length>0){zr(Set,e,arguments[0])}delete e.constructor;Object.setPrototypeOf(e,Set.prototype);return e};S.Set.prototype=sn.prototype;h(S.Set.prototype,"constructor",S.Set,true);m.preserveToString(S.Set,sn)}var cn=!a(function(){return(new Map).keys().next().done});if(typeof S.Map.prototype.clear!=="function"||(new S.Set).size!==0||(new S.Map).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(new S.Map).keys().next!=="function"||cn||!tn){g(S,{Map:qr.Map,Set:qr.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 ln=S.Set.prototype.has;U(S.Set.prototype,"has",function has(e){return t(ln,this,e)})}}g(S,qr);de(S.Map);de(S.Set)}var pn=function throwUnlessTargetIsObject(e){if(!ee.TypeIsObject(e)){throw new TypeError("target must be an object")}};var vn={apply:function apply(){return ee.Call(ee.Call,null,arguments)},construct:function construct(e,t){if(!ee.IsConstructor(e)){throw new TypeError("First argument must be a constructor.")}var r=arguments.length>2?arguments[2]:e;if(!ee.IsConstructor(r)){throw new TypeError("new.target must be a constructor.")}return ee.Construct(e,t,r,"internal")},deleteProperty:function deleteProperty(e,t){pn(e);if(s){var r=Object.getOwnPropertyDescriptor(e,t);if(r&&!r.configurable){return false}}return delete e[t]},enumerate:function enumerate(e){pn(e);return new $e(e,"key")},has:function has(e,t){pn(e);return t in e}};if(Object.getOwnPropertyNames){Object.assign(vn,{ownKeys:function ownKeys(e){pn(e);var t=Object.getOwnPropertyNames(e);if(ee.IsCallable(Object.getOwnPropertySymbols)){x(t,Object.getOwnPropertySymbols(e))}return t}})}var yn=function ConvertExceptionToBoolean(e){return!i(e)};if(Object.preventExtensions){Object.assign(vn,{isExtensible:function isExtensible(e){pn(e);return Object.isExtensible(e)},preventExtensions:function preventExtensions(e){pn(e);return yn(function(){Object.preventExtensions(e)})}})}if(s){var hn=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 hn(o,t,r)}if("value"in n){return n.value}if(n.get){return ee.Call(n.get,r)}return void 0};var gn=function set(e,r,n,o){var i=Object.getOwnPropertyDescriptor(e,r);if(!i){var a=Object.getPrototypeOf(e);if(a!==null){return gn(a,r,n,o)}i={value:void 0,writable:true,enumerable:true,configurable:true}}if("value"in i){if(!i.writable){return false}if(!ee.TypeIsObject(o)){return false}var u=Object.getOwnPropertyDescriptor(o,r);if(u){return Q.defineProperty(o,r,{value:n})}else{return Q.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(vn,{defineProperty:function defineProperty(e,t,r){pn(e);return yn(function(){Object.defineProperty(e,t,r)})},getOwnPropertyDescriptor:function getOwnPropertyDescriptor(e,t){pn(e);return Object.getOwnPropertyDescriptor(e,t)},get:function get(e,t){pn(e);var r=arguments.length>2?arguments[2]:e;return hn(e,t,r)},set:function set(e,t,r){pn(e);var n=arguments.length>3?arguments[3]:e;return gn(e,t,r,n)}})}if(Object.getPrototypeOf){var bn=Object.getPrototypeOf;vn.getPrototypeOf=function getPrototypeOf(e){pn(e);return bn(e)}}if(Object.setPrototypeOf&&vn.getPrototypeOf){var dn=function(e,t){var r=t;while(r){if(e===r){return true}r=vn.getPrototypeOf(r)}return false};Object.assign(vn,{setPrototypeOf:function setPrototypeOf(e,t){pn(e);if(t!==null&&!ee.TypeIsObject(t)){throw new TypeError("proto must be an object or null")}if(t===Q.getPrototypeOf(e)){return true}if(Q.isExtensible&&!Q.isExtensible(e)){return false}if(dn(e,t)){return false}Object.setPrototypeOf(e,t);return true}})}var mn=function(e,t){if(!ee.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){U(S.Reflect,e,t)}}};Object.keys(vn).forEach(function(e){mn(e,vn[e])});if(c&&S.Reflect.getPrototypeOf.name!=="getPrototypeOf"){var On=S.Reflect.getPrototypeOf;U(S.Reflect,"getPrototypeOf",function getPrototypeOf(e){return t(On,S.Reflect,e)})}if(S.Reflect.setPrototypeOf){if(a(function(){S.Reflect.setPrototypeOf(1,{});return true})){U(S.Reflect,"setPrototypeOf",vn.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})){U(S.Reflect,"defineProperty",vn.defineProperty)}}if(S.Reflect.construct){if(!a(function(){var e=function F(){};return S.Reflect.construct(function(){},[],e)instanceof e})){U(S.Reflect,"construct",vn.construct)}}if(String(new Date(NaN))!=="Invalid Date"){var wn=Date.prototype.toString;var jn=function toString(){var e=+this;if(e!==e){return"Invalid Date"}return ee.Call(wn,this)};U(Date.prototype,"toString",jn)}var Sn={anchor:function anchor(e){return ee.CreateHTML(this,"a","name",e)},big:function big(){return ee.CreateHTML(this,"big","","")},blink:function blink(){return ee.CreateHTML(this,"blink","","")},bold:function bold(){return ee.CreateHTML(this,"b","","")},fixed:function fixed(){return ee.CreateHTML(this,"tt","","")},fontcolor:function fontcolor(e){return ee.CreateHTML(this,"font","color",e)},fontsize:function fontsize(e){return ee.CreateHTML(this,"font","size",e)},italics:function italics(){return ee.CreateHTML(this,"i","","")},link:function link(e){return ee.CreateHTML(this,"a","href",e)},small:function small(){return ee.CreateHTML(this,"small","","")},strike:function strike(){return ee.CreateHTML(this,"strike","","")},sub:function sub(){return ee.CreateHTML(this,"sub","","")},sup:function sub(){return ee.CreateHTML(this,"sup","","")}};l(Object.keys(Sn),function(e){var r=String.prototype[e];var n=false;if(ee.IsCallable(r)){var o=t(r,"",' " ');var i=E([],o.match(/"/g)).length;n=o!==o.toLowerCase()||i>2}else{n=true}if(n){U(String.prototype,e,Sn[e])}});var Tn=function(){if(!X){return false}var e=typeof JSON==="object"&&typeof JSON.stringify==="function"?JSON.stringify:null;if(!e){return false}if(typeof e(W())!=="undefined"){return true}if(e([W()])!=="[null]"){return true}var t={a:W()};t[W()]=true;if(e(t)!=="{}"){return true}return false}();var In=a(function(){if(!X){return true}return JSON.stringify(Object(W()))==="{}"&&JSON.stringify([Object(W())])==="[{}]"});if(Tn||!In){var En=JSON.stringify;U(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=ee.IsCallable(n)?n:null;var a=function(e,r){var o=n?t(n,this,e,r):r;if(typeof o!=="symbol"){if(K.symbol(o)){return Tt({})(o)}else{return o}}};o.push(a)}else{o.push(n)}if(arguments.length>2){o.push(arguments[2])}return En.apply(this,o)})}return S}); //# sourceMappingURL=es6-shim.map es6-shim-0.34.1/package.json000066400000000000000000000060171264300104700155210ustar00rootroot00000000000000{ "name": "es6-shim", "version": "0.34.1", "author": "Paul Miller (http://paulmillr.com)", "description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines", "keywords": [ "ecmascript", "harmony", "es6", "shim", "promise", "promises", "setPrototypeOf", "map", "set", "__proto__" ], "homepage": "https://github.com/paulmillr/es6-shim/", "license": "MIT", "repository": { "type": "git", "url": "git://github.com/paulmillr/es6-shim.git" }, "main": "es6-shim", "scripts": { "test": "npm run lint && evalmd *.md && npm run tests-only", "tests-only": "npm run test:shim && npm run test:sham", "test:shim": "mocha test/*.js test/*/*.js", "test:sham": "mocha test-sham/*.js", "test:native": "NO_ES6_SHIM=1 npm run tests-only", "lint": "npm run lint:shim && npm run lint:sham", "lint:shim": "npm run jshint:shim && npm run jscs:shim && npm run eslint:shim", "lint:sham": "npm run jshint:sham && npm run jscs:sham && npm run eslint:sham", "eslint": "npm run eslint:shim && npm run eslint:sham", "eslint:shim": "eslint es6-shim.js test/*.js test/*/*.js", "eslint:sham": "eslint es6-sham.js test-sham/*.js", "jshint": "npm run jshint:shim && npm run jshint:sham", "jshint:shim": "jshint es6-shim.js test/*.js test/*/*.js", "jshint:sham": "jshint es6-sham.js test-sham/*.js", "jscs": "npm run jscs:shim && npm run jscs:sham", "jscs:shim": "jscs es6-shim.js test/*.js test/*/*.js", "jscs:sham": "jscs es6-sham.js test-sham/*.js", "minify": "npm run minify:shim && npm run minify:sham", "minify:shim": "uglifyjs es6-shim.js --keep-fnames --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js", "minify:sham": "uglifyjs es6-sham.js --keep-fnames --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js", "sauce-connect": "curl -L https://gist.githubusercontent.com/henrikhodne/9322897/raw/sauce-connect.sh | bash && export TRAVIS_SAUCE_CONNECT=true", "sauce": "npm run sauce-connect && grunt sauce" }, "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" ] }, "dependencies": {}, "devDependencies": { "chai": "^3.4.1", "es5-shim": "^4.4.1", "eslint": "^1.10.3", "@ljharb/eslint-config": "^1.6.1", "grunt": "^0.4.5", "grunt-contrib-connect": "^0.11.2", "grunt-contrib-watch": "^0.6.1", "grunt-saucelabs": "^8.6.2", "jscs": "^2.7.0", "jshint": "^2.8.0", "mocha": "^2.3.4", "promises-aplus-tests": "^2.1.1", "promises-es6-tests": "^0.5.0", "uglify-js": "^2.6.1", "evalmd": "^0.0.16" } } es6-shim-0.34.1/test-sham/000077500000000000000000000000001264300104700151345ustar00rootroot00000000000000es6-shim-0.34.1/test-sham/index.html000066400000000000000000000014771264300104700171420ustar00rootroot00000000000000 es6-shim tests
es6-shim-0.34.1/test-sham/set-prototype-of.js000066400000000000000000000014361264300104700207360ustar00rootroot00000000000000/* 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).to.be.an.instanceOf(Object); // sham requires assignment to work cross browser obj = Object.setPrototypeOf(obj, null); expect(obj).not.to.be.an.instanceOf(Object); expect(obj.a).to.equal(123); }); it('changes prototype to null objects', function () { var obj = Object.create(null); obj.a = 456; expect(obj).not.to.be.an.instanceOf(Object); expect(obj.a).to.equal(456); // sham requires assignment to work cross browser obj = Object.setPrototypeOf(obj, {}); expect(obj).to.be.an.instanceOf(Object); expect(obj.a).to.equal(456); }); }); es6-shim-0.34.1/test/000077500000000000000000000000001264300104700142065ustar00rootroot00000000000000es6-shim-0.34.1/test/array.js000066400000000000000000001050231264300104700156630ustar00rootroot00000000000000/* global describe, it, xit, expect, require, beforeEach, afterEach */ 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 : xit; var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit; var ifSymbolIteratorAndArrayValuesIt = isSymbol(Sym.iterator) && Array.prototype.values ? it : xit; var ifSymbolUnscopablesIt = isSymbol(Sym.unscopables) ? it : xit; var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it; 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 = {}, 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 (!Array.hasOwnProperty('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 () { /*jshint elision: true */ /* jscs:disable disallowSpaceBeforeComma */ /* eslint-disable no-sparse-arrays */ var input = [0, , 2]; var result = Array.from([0, , 2]); /* eslint-enable no-sparse-arrays */ /* jscs:enable disallowSpaceBeforeComma */ /*jshint elision: false */ 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]); }); }); describe('.of()', function () { if (!Array.hasOwnProperty('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 (!Array.prototype.hasOwnProperty('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); }); }); describe('#find()', function () { if (!Array.prototype.hasOwnProperty('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 () { /*jshint elision: true */ /* jscs:disable disallowSpaceBeforeComma */ /* eslint-disable no-sparse-arrays */ var obj = [1, , undefined]; /* eslint-enable no-sparse-arrays */ /* jscs:enable disallowSpaceBeforeComma */ /*jshint elision: false */ 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 (!Array.prototype.hasOwnProperty('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 () { /*jshint elision: true */ /* jscs:disable disallowSpaceBeforeComma */ /* eslint-disable no-sparse-arrays */ var obj = [1, , undefined]; /* eslint-enable no-sparse-arrays */ /* jscs:enable disallowSpaceBeforeComma */ /*jshint elision: false */ 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 (!Array.prototype.hasOwnProperty('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 (!Array.prototype.hasOwnProperty('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 (!Array.prototype.hasOwnProperty('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 (!Array.prototype.hasOwnProperty('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 (!Array.prototype.hasOwnProperty('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('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); }); es6-shim-0.34.1/test/browser-onload.js000066400000000000000000000024441264300104700175050ustar00rootroot00000000000000/* 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()); }; } es6-shim-0.34.1/test/browser-setup.js000066400000000000000000000003711264300104700173660ustar00rootroot00000000000000/* 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; }; } es6-shim-0.34.1/test/date.js000066400000000000000000000003351264300104700154620ustar00rootroot00000000000000/* global describe, it, expect, require */ describe('Date', function () { it('when invalid, dates should toString to "Invalid Date"', function () { expect(String(new Date(NaN))).to.equal('Invalid Date'); }); }); es6-shim-0.34.1/test/index.html000066400000000000000000000027261264300104700162120ustar00rootroot00000000000000 es6-shim tests
es6-shim-0.34.1/test/json.js000066400000000000000000000055521264300104700155240ustar00rootroot00000000000000/* global describe, it, xit, expect, require */ 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}'); }); }); }); }); es6-shim-0.34.1/test/map.js000066400000000000000000000466561264300104700153420ustar00rootroot00000000000000/* global describe, it, xit, expect, require, beforeEach, afterEach */ // 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 range = function range(from, to) { var result = []; for (var value = from; value < to; value++) { result.push(value); } return result; }; var prototypePropIsEnumerable = (function () {}).propertyIsEnumerable('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 (!Map.prototype.hasOwnProperty('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 (!Map.prototype.hasOwnProperty('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 (!Map.prototype.hasOwnProperty('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$/; 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']); }); }); es6-shim-0.34.1/test/math.js000066400000000000000000000733131264300104700155040ustar00rootroot00000000000000/* global describe, it, xit, expect, require */ var Assertion = expect().constructor; Assertion.prototype.almostEqual = function (obj, precision) { 'use strict'; var allowedDiff = precision || 1e-11; return this.within(obj - allowedDiff, obj + allowedDiff); }; 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; } }; var EPSILON = Number.EPSILON || 2.2204460492503130808472633361816e-16; ifShimIt('is on the exported object', function () { var exported = require('../'); expect(exported.Math).to.equal(Math); }); describe('.acosh()', function () { if (!Math.hasOwnProperty('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); }); }); describe('.asinh()', function () { if (!Math.hasOwnProperty('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); }); }); describe('.atanh()', function () { if (!Math.hasOwnProperty('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); }); }); describe('.cbrt()', function () { if (!Math.hasOwnProperty('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); 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); expect(Math.cbrt(1e+300)).to.almostEqual(1e+100); }); }); describe('.clz32()', function () { if (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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); }); }); describe('.expm1()', function () { if (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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); }); }); describe('.tanh()', function () { if (!Math.hasOwnProperty('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(90)).to.almostEqual(1); expect(Math.tanh(10)).to.almostEqual(0.9999999958776927); expect(Math.tanh(-2e-17)).to.equal(-2e-17); }); }); describe('.trunc()', function () { if (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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 (!Math.hasOwnProperty('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); expect(Math.fround(maxFloat32 + Math.pow(2, Math.pow(2, 8 - 1) - 1 - 23 - 2))).to.equal(maxFloat32); // round-nearest rounds down to 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); }); }); }); es6-shim-0.34.1/test/mocha.opts000066400000000000000000000000401264300104700161760ustar00rootroot00000000000000--require test/test_helpers.js es6-shim-0.34.1/test/native.html000066400000000000000000000024241264300104700163640ustar00rootroot00000000000000 es6-shim tests
es6-shim-0.34.1/test/number.js000066400000000000000000000407321264300104700160420ustar00rootroot00000000000000/* global describe, it, xit, expect, require */ 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(Number.propertyIsEnumerable('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(Number.propertyIsEnumerable('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(Number.propertyIsEnumerable('EPSILON')).to.equal(false); expect(Number.EPSILON).to.equal(2.2204460492503130808472633361816e-16); }); }); describe('.parseInt()', function () { if (!Number.hasOwnProperty('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 (!Number.hasOwnProperty('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 (!Number.hasOwnProperty('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 (!Number.hasOwnProperty('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 (!Number.hasOwnProperty('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 (!Number.hasOwnProperty('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 () { /* jshint -W053 */ /* eslint-disable no-new-wrappers */ var one = new Number('1'); var a = new Number('0xA'); /* eslint-enable no-new-wrappers */ /* jshint +W053 */ 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 () { 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'; // 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'); expect(String(Number(whitespace + '3' + whitespace))).to.equal('3'); }); }); }); es6-shim-0.34.1/test/object.js000066400000000000000000000311341264300104700160140ustar00rootroot00000000000000/* global describe, it, xit, expect, require, Symbol */ 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.hasOwnProperty('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.hasOwnProperty('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 () { 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); }); }); }); es6-shim-0.34.1/test/promise.js000066400000000000000000000024401264300104700162220ustar00rootroot00000000000000/* global describe, it, expect, require, Promise */ /* 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'](); }); }); es6-shim-0.34.1/test/promise/000077500000000000000000000000001264300104700156645ustar00rootroot00000000000000es6-shim-0.34.1/test/promise/all.js000066400000000000000000000137651264300104700170060ustar00rootroot00000000000000/* 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) { /* jshint elision: true */ /* jscs:disable disallowSpaceBeforeComma */ /* eslint-disable no-sparse-arrays */ var iterable = [Promise.resolve(0), , , Promise.resolve(1)]; /* eslint-enable no-sparse-arrays */ /* jscs:enable disallowSpaceBeforeComma */ /* jshint elision: false */ 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)); }); }); es6-shim-0.34.1/test/promise/evil-promises.js000066400000000000000000000026471264300104700210310ustar00rootroot00000000000000/* global describe, specify, assert, Promise */ 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); }); }); es6-shim-0.34.1/test/promise/promises-aplus.js000066400000000000000000000011311264300104700212010ustar00rootroot00000000000000/* global describe, require, Promise */ // 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) }); }); es6-shim-0.34.1/test/promise/promises-es6.js000066400000000000000000000010551264300104700205570ustar00rootroot00000000000000/* global describe, require */ // 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); }); }()); es6-shim-0.34.1/test/promise/race.js000066400000000000000000000047051264300104700171420ustar00rootroot00000000000000/* global describe, it, expect, setTimeout, assert, Promise */ 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)); }); }); es6-shim-0.34.1/test/promise/reject.js000066400000000000000000000022151264300104700174760ustar00rootroot00000000000000/* global describe, it, expect, setTimeout, Promise */ 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'](); }); }); es6-shim-0.34.1/test/promise/resolve.js000066400000000000000000000022271264300104700177040ustar00rootroot00000000000000/* global describe, it, expect, setTimeout, Promise */ 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'](); }); }); es6-shim-0.34.1/test/promise/simple.js000066400000000000000000000054071264300104700175210ustar00rootroot00000000000000/* global describe, specify, assert, Promise */ 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]); }); }); es6-shim-0.34.1/test/promise/subclass.js000066400000000000000000000026521264300104700200460ustar00rootroot00000000000000/* 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 = 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); }); }); es6-shim-0.34.1/test/reflect.js000066400000000000000000000561461264300104700162040ustar00rootroot00000000000000/* global describe, xdescribe, it, xit, expect, require, Reflect */ 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 = {}, 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); }); }); describe('.enumerate()', function () { if (typeof Reflect.enumerate === 'undefined') { return it('exists', function () { expect(Reflect).to.have.property('enumerate'); }); } it('is a function', function () { expect(typeof Reflect.enumerate).to.equal('function'); }); ifFunctionsHaveNamesIt('has the right name', function () { expect(Reflect.enumerate.name).to.equal('enumerate'); }); ifES5It('only includes enumerable properties', function () { var a = Object.create(null, { // Non-enumerable per default. a: { value: 1 } }); a.b = 2; var iter = Reflect.enumerate(a); if (hasSymbols && typeof Symbol.iterator === 'symbol') { expect(Symbol.iterator in iter).to.equal(true); } expect(Array.from(iter)).to.deep.equal(['b']); }); it('includes all enumerable properties of prototypes', function () { var Parent = function () {}; Parent.prototype.prop = true; var Child = function () {}; Child.prototype = new Parent(); Child.prototype.childProp = true; var child = new Child(); expect(Array.from(Reflect.enumerate(child)).sort()).to.deep.equal(['prop', 'childProp'].sort()); }); describe('keys determined at first next() call', function () { it('likely does not yield a key added after next()', function () { var obj = { a: 1, b: 2 }, iter = Reflect.enumerate(obj); expect(iter.next()).to.deep.equal({ value: 'a', done: false }); obj.c = 3; expect(iter.next()).to.deep.equal({ value: 'b', done: false }); expect(iter.next()).to.deep.equal({ value: undefined, done: true }); }); it('may not yield a key added after enumerate(), before next()', function () { var obj = { a: 1, b: 2 }; var iter = Reflect.enumerate(obj); obj.c = 3; expect(iter.next()).to.deep.equal({ value: 'a', done: false }); expect(iter.next()).to.deep.equal({ value: 'b', done: false }); var thirdResult = iter.next(); // Webkit's implementation of Reflect.enumerate locks the keys at iterator creation if (thirdResult.done) { expect(iter.next()).to.deep.equal({ value: undefined, done: true }); } else { expect(iter.next()).to.deep.equal({ value: 'c', done: false }); expect(iter.next()).to.deep.equal({ value: undefined, done: true }); } }); it('does not yield an unyielded key deleted after first next()', function () { var obj = { a: 1, b: 2 }; var iter = Reflect.enumerate(obj); expect(iter.next()).to.deep.equal({ value: 'a', done: false }); delete obj.b; expect(iter.next()).to.deep.equal({ value: undefined, done: true }); }); }); describe('enumeration order', function () { it('enumerates own keys before prototype keys', function () { var Foo = function Foo(arg) { this.b = arg; this[2] = arg; }; Foo.prototype.a = 'bar'; Foo.prototype.c = 'bar'; Foo.prototype[1] = 'bar'; var foo = new Foo(42); var iter = Reflect.enumerate(foo); expect(iter.next()).to.deep.equal({ value: '2', done: false }); expect(iter.next()).to.deep.equal({ value: 'b', done: false }); expect(iter.next()).to.deep.equal({ value: '1', done: false }); expect(iter.next()).to.deep.equal({ value: 'a', done: false }); expect(iter.next()).to.deep.equal({ value: 'c', done: false }); expect(iter.next()).to.deep.equal({ value: undefined, done: true }); }); }); }); 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); }); }); }); es6-shim-0.34.1/test/regexp.js000066400000000000000000000323301264300104700160370ustar00rootroot00000000000000/* global beforeEach, describe, it, expect, require */ var getRegexLiteral = function (stringRegex) { try { /* jshint evil: true */ /* eslint-disable no-new-func */ return Function('return ' + stringRegex + ';')(); /* eslint-enable no-new-func */ /* jshint evil: false */ } 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 () { try { return 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 (!RegExp.prototype.hasOwnProperty('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 (RegExp.prototype.hasOwnProperty('sticky')) { expect(getRegexLiteral('/a/y').flags).to.equal('y'); } if (RegExp.prototype.hasOwnProperty('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 (RegExp.prototype.hasOwnProperty('sticky')) { expect(new RegExp('a', 'y').flags).to.equal('y'); } if (RegExp.prototype.hasOwnProperty('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 (RegExp.prototype.hasOwnProperty('sticky')) { expect(getRegexLiteral('/a/gyim').flags).to.equal('gimy'); } if (RegExp.prototype.hasOwnProperty('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 (RegExp.prototype.hasOwnProperty('sticky')) { expect(new RegExp('a', 'mygi').flags).to.equal('gimy'); } if (RegExp.prototype.hasOwnProperty('unicode')) { expect(new RegExp('a', 'mugi').flags).to.equal('gimu'); } }); }); 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 re, str = 'abcdefghijklmnopq'; 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 (RegExp.hasOwnProperty('multiline')) { expect(RegExp.multiline).to.equal(false); } if (RegExp.hasOwnProperty('$*')) { 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'); }); }); }); }); es6-shim-0.34.1/test/set.js000066400000000000000000000500501264300104700153370ustar00rootroot00000000000000/* global describe, it, xit, expect, require, beforeEach, afterEach */ // 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 : void 0; if (!$iterator$ && typeof Set === 'function') { $iterator$ = typeof Set['@@iterator'] === 'function' ? '@@iterator' : '_es6-shim 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 range = function (from, to) { var result = []; for (var value = from; value < to; value++) { result.push(value); } return result; }; var prototypePropIsEnumerable = (function () {}).propertyIsEnumerable('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 (!Set.prototype.hasOwnProperty('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 (!Set.prototype.hasOwnProperty('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$/; 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 (!Set.prototype.hasOwnProperty('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 (!Set.prototype.hasOwnProperty('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 (!Array.hasOwnProperty('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 () { }); }); es6-shim-0.34.1/test/string.js000066400000000000000000001025211264300104700160530ustar00rootroot00000000000000/* global describe, it, expect, require */ 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 (!String.prototype.hasOwnProperty('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 (!String.prototype.hasOwnProperty('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, 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 (!String.prototype.hasOwnProperty('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, 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 (!String.prototype.hasOwnProperty('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, 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 (!String.hasOwnProperty('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 (!String.prototype.hasOwnProperty('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 (!Array.hasOwnProperty('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 (!String.hasOwnProperty('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); 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); 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 (!String.prototype.hasOwnProperty('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); }); es6-shim-0.34.1/test/test_helpers.js000066400000000000000000000005751264300104700172540ustar00rootroot00000000000000/* 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('../'); } es6-shim-0.34.1/test/worker-runner.workerjs000066400000000000000000000002201264300104700206100ustar00rootroot00000000000000importScripts( '../node_modules/es5-shim/es5-shim.js', '../node_modules/es5-shim/es5-sham.js', '../es6-shim.js' ); postMessage('ready'); es6-shim-0.34.1/test/worker-test.js000066400000000000000000000031341264300104700170330ustar00rootroot00000000000000/* global describe, it, expect, 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(); }); }); } }); es6-shim-0.34.1/testling.html000066400000000000000000000026211264300104700157470ustar00rootroot00000000000000 es6-shim tests