rebuild with package manager

rebuild with package manager
This commit is contained in:
Namhyeon Go 2020-07-20 07:01:03 +09:00
parent 49eb70f989
commit 2922cd66ec
89 changed files with 22932 additions and 4 deletions

5
helloworld.js Normal file
View File

@ -0,0 +1,5 @@
return {
main: function() {
console.log("Hello world");
}
};

View File

@ -33,12 +33,12 @@ if (!Function.prototype.GetResource) {
} }
// ECMAScript 5 compatibility shims for legacy (and modern) JavaScript engines // ECMAScript 5 compatibility shims for legacy (and modern) JavaScript engines
require("app/assets/js/es5-shim-4.5.14.min"); require("node_modules/es5-shim/es5-shim");
require("app/assets/js/es5-sham-4.5.14.min"); require("node_modules/es5-shim/es5-sham");
// ECMAScript 6 compatibility shims for legacy JS engines // ECMAScript 6 compatibility shims for legacy JS engines
require("app/assets/js/es6-shim-0.35.5.min"); require("node_modules/es6-shim/es6-shim");
require("app/assets/js/es6-shim-0.35.5.min"); require("node_modules/es6-shim/es6-sham");
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Global APIs // Global APIs

2
node_modules/es5-shim/.eslintignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
*.min.js
tests/lib/*

68
node_modules/es5-shim/.eslintrc generated vendored Normal file
View File

@ -0,0 +1,68 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"array-bracket-newline": 0,
"object-curly-newline": 0,
"camelcase": [0],
"complexity": [0],
"eqeqeq": [2, "allow-null"],
"func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 40 }],
"indent": [2, 4],
"max-len": [2, 120, 4, {
"ignoreUrls": true,
"ignoreComments": true,
"ignoreRegExpLiterals": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}],
"max-lines": 0,
"max-lines-per-function": 0,
"max-nested-callbacks": [2, 5],
"max-params": [2, 7],
"max-statements": [1, 30],
"new-cap": [2, { "capIsNewExceptions": ["ToInteger", "ToObject", "ToPrimitive", "ToUint32"] }],
"no-constant-condition": [1],
"no-extend-native": [2, {"exceptions": ["Date", "Error", "RegExp"]}],
"no-extra-parens": [0],
"no-extra-semi": [1],
"no-func-assign": [1],
"no-implicit-coercion": [2, {
"boolean": false,
"number": false,
"string": true
}],
"no-invalid-this": [0],
"no-magic-numbers": [0],
"no-native-reassign": [2, {"exceptions": ["Date", "parseInt"]}],
"no-new-func": [1],
"no-plusplus": [1],
"no-restricted-syntax": [2, "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"],
"no-shadow": [1],
"no-unused-vars": [1, { "vars": "all", "args": "after-used" }],
"operator-linebreak": [2, "before"],
"quote-props": [1, "as-needed", { "keywords": true }],
"sort-keys": [0],
"spaced-comment": [0],
"strict": [0],
"multiline-comment-style": 1,
},
"overrides": [
{
"files": "tests/**",
"rules": {
"max-len": 0,
"max-lines": 0,
"max-statements-per-line": [2, { "max": 2 }],
},
"env": {
"jasmine": true
},
},
],
}

15
node_modules/es5-shim/.github/workflows/rebase.yml generated vendored Normal file
View File

@ -0,0 +1,15 @@
name: Automatic Rebase
on: [pull_request]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

7
node_modules/es5-shim/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,7 @@
version: ~> 1.0
language: node_js
os:
- linux
import:
- ljharb/travis-ci:node/all.yml
- ljharb/travis-ci:node/pretest.yml

442
node_modules/es5-shim/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,442 @@
4.5.14
- [Fix] handle no `deleteCount` to `splice()` in Opera (#465)
- [Refactor] remove unnecessary comparison
- [meta] remove unused Makefile and associated utilities
- [meta] add `funding` field
- [meta] Rename CHANGES to CHANGELOG.md
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `replace`, `semver`; add `safe-publish-latest`
- [Tests] fix negative Date tests to handle TZData
- [Tests] use shared travis-ci configs
- [Tests] remove `jscs`
- [Tests] clarify toPrecision's range increased in ES2018
- [actions] add automatic rebasing / merge commit blocking
4.5.13
- [Fix] exclude deprecated Firefox keys (#460)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jasmine-node`, `replace`, `semver`
4.5.12
- [meta] republish broken 4.5.11
4.5.11
- [Fix] sync Object.keys excluded list from object-keys (#456)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jasmine-node`, `replace`, `semver`
- [Tests] pin jasmine-node to ~1.13
4.5.10
- [Fix] Safari 11 throws on `.sort({})`, but not on `.sort(null)`
- [Fix] ensure the shimmed parseInt throws with Symbols (#450)
- [Fix] skip over `localStorage`, which cant be accessed on file://
- [Fix] Accessing window.top.{constructor|prototype} throws error in iOS (#445)
- [Fix] avoid `width` and `height` on `window`, to prevent reflow (https://github.com/ljharb/object-keys/issues/31)
- [Fix] ensure minified literal of `1000000000000000128` stays as that literal (#441)
- [Robustness] always prefer `String(x)` over `x.toString()`
- [Tests] up to `node` `v9.3`, `v8.9`, `v7.10`, `v6.12`, `v5.12`, `v4.8`; improve test matrix; use `nvm install-latest-npm`; comment out OS X builds; pin included builds to LTS
- [Tests] `parseInt`: add another test for NaN parsing (#433)
- [Dev Deps] `uglify-js`: add `--support-ie8` and peg to v2.7.x since it doesnt follow semver
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `semver`; remove `concurrently` (#421)
4.5.9
- [Fix] parseInt and parseFloat should both accept null/undefined (#402)
- [Tests] up to `node` `v6.2`
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `concurrently`
4.5.8
- [Fix] Check if property descriptor is configurable before re-defining it (#394, #373)
- [Dev Deps] update `eslint`, `jscs`, `@ljharb/eslint-config`
- [Tests] up to `node` `v5.10`, `v4.4`
- [Tests] Use `concurrently` instead of `parallelshell`
- [Tests] use `pretest` to run the linter
4.5.7
- [Fix] `bind` in IE 8: Update `is-callable` implementation to v1.1.3 (#390)
4.5.6
- [Fix] `new Date(new Date())` should work in IE 8 (#389)
- [Tests] on `node` `v5.7`
- [Dev Deps] update `uglify-js`
4.5.5
- [Fix] Adobe Photoshops JS engine bizarrely can have `+date !== date.getTime()` (#365)
- [Dev Deps] update `eslint`
- [Refactor] Update `is-callable` implementation to match latest
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
4.5.4
- [Fix] careless error from 5cf99aca49e59bae03b5d542381424bb1b13ec42
4.5.3
- [Fix] Saturday is a day in the week (#386)
- [Robustness] improve Function#bind (#381)
- [Tests] on `node` `v5.6`, `v4.3`
- [Tests] use json3 (#382)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`
- [Docs] add note about script order (#379)
4.5.2
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.5.1
- [Fix] Make sure preexisting + broken `Array#` methods that throw dont break the runtime (#377)
- [Dev Deps] update `jscs`
4.5.0
- [New] `parseFloat('-0')` should return -0 in Opera 12 (#371)
- [New] Provide and replace Date UTC methods (#360)
- [Robustness] cache `Date` getUTC* methods so that `Date#toISOString` doesnt observably look them up on the receiver
- [Robustness] use a cached and shimmed `String#trim`
- [Tests] up to `node` `v5.5`
- [Tests] add `parallelshell` and use it in a few tasks
- [Refactor] rename cached methods to avoid linter warnings
- [Dev Deps] update `eslint`, `jscs`, '@ljharb/eslint-config'
- [Docs] Update license year to 2016 (#374)
4.4.2
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.4.1
- [Fix] ensure that IE 11 in compatibility mode doesn't throw (#370)
- [Docs] add missing shimmed things
4.4.0
- [New] Detect and patch `RegExp#toString` in IE 8, which returns flags in the wrong order (#364)
- [Fix] Patch `Array#sort` on {Chrome, Safari, IE < 9, FF 4} that throws improperly, per ES5 (#354)
- [Fix] In IE 6, `window.external` makes `Object.keys` throw
- [Fix] `Array#slice`: boxed string access on IE <= 8 (#349)
- [Fix] `Array#join`: fix IE 6-8 join called on string literal (#352)
- [Fix] Ensure that `Error#message` and `Error#name` are non-enumerable (#358)
- [Fix: sham] `Object.getOwnPropertyDescriptor`: In Opera 11.6, `propertyIsEnumerable` is a nonshadowable global, like `toString`
- [Robustness] Use a bound form of `Array#slice.call`
- [Tests] Properly check for descriptor support in IE <= 8
- [Tests] on `node` `v5.1`
- [Tests] Add `Array#slice` tests (#346)
- [Dev Deps] update `uglify-js`, `eslint`, `jscs`, `uglify-js`, `semver`
- [Docs] Fix broken UMD links (#344)
4.3.2
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.3.1
- [Fix] `String#split`: revert part of dcce96ae21185a69d2d40e67416e7496b73e8e47 which broke in older browsers (#342)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
- [Tests] Firefox allows `Number#toPrecision` values of [1,100], which the spec permits
4.3.0
- [New] `Array#push`: in IE <= 7, `Array#push` was not generic (#336)
- [New] `Array#push` in Opera `10.6` has a super weird bug when pushing `undefined`
- [New] `Array#join`: In IE <= 7, passing `undefined` didn't use the default separator (#333)
- [New] `Error#toString`: prints out the proper message in IE 7 and below (#334)
- [New] `Number#toPrecision`: IE 7 and below incorrectly throw when an explicit `undefined` precision is passed (#340)
- [Fix] `String#lastIndexOf`: ensure the correct length in IE 8
- [Fix] ensure `parseInt` accepts negative and plus-prefixed hex values (#332)
- [Robustness] Use a bound `Array#push` instead of relying on `Function#call`
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
- [Tests] Add some conditionals to avoid impossible-to-fix test failures in IE 6-8, due to it being unable to distinguish between `undefined` and an absent index (#114)
- [Tests] Fix false negatives in IE 6-8 with jasmine comparing arrays to arraylikes (#114)
- [Tests] add additional `Array#shift` tests (#337)
- [Tests] Add additional `Array#splice` tests (#339)
- [Tests] Add `Array#pop` tests, just in case (#338)
- [Tests] include `global` tests in HTML test files
- [Tests] Make sure the HTML tests run with the right charset
- [Tests] ensure `node` `v0.8` tests stay passing.
- [Tests] Prevent nondeterminism in the tests - this sometime produced values that are one ms off
- [Tests] on `node` `v5.0`
- [Tests] fix npm upgrades for older nodes
4.2.1
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.2.0
- [shim: new] Overwrite `String#lastIndexOf` in IE 9, 10, 11, and Edge, so it has proper unicode support.
- [Dev Deps] update `eslint`, `jscs`
4.1.16
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.1.15
- [shim: fix] new Date + Date.parse: Fix a Safari 8 & 9 bug where the `ms` arg is treated as a signed instead of unsigned int (#329)
- [shim: fix] add 'frame' to blacklisted keys (#330)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`
- [Tests] on `node` `v4.2`
- [Tests] Date: prevent nondeterminism in the tests - this sometime produced values that are one ms off
4.1.14
- [shim: fix] Wrap more things in a try/catch, because IE sucks and sometimes throws on [[Get]] of window.localStorage (#327)
- [Refactor] Use `ES.ToUint32` instead of inline `>>>`
- [Tests] up to `node` `v4.1`
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver`, `jscs`
4.1.13
- [shim: fix] Fix a bug where `Date(x)` threw instead of equalling `String(Date(x))` (#326)
4.1.12
- [fix] Make sure uglify doesn't remove function names
- [shim: fix] Use `is-arguments` implementation; don't call down legacy code path in modern engines (#325)
- [Tests] up to `io.js` `v3.3`
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`
4.1.11
- [shim: fix] Object.keys in Safari 9 has some bugs. (Already fixed in Webkit Nightly)
- [shim: fix] Omit !Date.parse check in the if statement (#323)
- [sham: fix] Fix Object.create sham to not set __proto__ (#301)
- [sham: fix] Add a typeof check to Object.getPrototypeOf (#319, #320)
- [Tests] up to `io.js` `v3.1`
- [Tests] Make sure `Object.getPrototypeOf` tests don't fail when engines implement ES6 semantics
- [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG (#318)
- [Dev Deps] Update `eslint`, `uglify-js`, `jscs`; use my personal shared `eslint` config
4.1.10
- [Fix] Fix IE 8 issue with `window.frameElement` access in a child iframe (#322)
- [Tests] Consolidating `Date.parse` extended year tests
- [Tests] Account for a `Date.parse` precision variance in Safari 8
- [Tests] DRY up some Date.parse tests
- [Tests] Don't create globals in Date tests
- [Tests] Better failure output when an invalid date's toJSON throws
- [Tests] Also compare lengths of array-likes
- [Tests] Extra check on Object.keys(arguments)
- [Tests] Skip appropriate tests when objects aren't extensible/freezeable/sealable
4.1.9
- [Fix] Remove "extended", add "unicode" in `String#split` shim, to match ES6
- [Fix] Object.keys: Preserve the IE 8 dontEnum bugfix, and the automation equality bugfix.
- [Fix] Object.keys: Prevent a deprecation message from showing up in Chrome.
- [Performance] Speed up blacklisted key check for Object.keys automation equality bug.
- [Tests] Test on `io.js` `v2.4`
- [Dev Deps] Update `eslint`, `semver`
4.1.8
- [Fix] Fix an `Object.keys` IE 8 bug where `localStorage.prototype.constructor === localStorage` would throw (#275)
- [Fix] Shimmed `Object.defineProperty` should not throw for an empty descriptor (#315)
- [Fix] Fix `Date#toISOString` in Safari 5.1 (#243)
- [Fix] Use `Object#propertyIsEnumerable` to default the initial "enumerable" value in `Object.getOwnPropertyDescriptor` sham (#289)
- [Fix] Fix `Array#splice` with large sparse arrays in Safari 7/8, and Opera 12.15 (#295)
- [Robustness] Safely use and reference many builtins internally (also see #313)
- [Tests] Add `Date#{getUTCDate,getUTCMonth}` tests to expose Opera 10.6/11.61/12 `Date` bugs
- [Dev Deps] Update `eslint`
4.1.7
- Make sure `Date.parse` is not enumerable (#310)
4.1.6
- Support IE 8 when `document.domain` is set (#306, #150)
- Remove version from `bower.json` (#307)
4.1.5
- Add a failing runtime check for Safari 8 `Date.parse`
- Update `eslint`, `semver`
- Test on `io.js` `v2.2`
4.1.4
- Make sure copied `Date` properties remain non-enumerable.
- Using a more reliable check for supported property descriptors in non-IE ES3
- Fix 'constructor' in Object.defineProperties sham in ES3 (#252, #305)
- Use a reference to `Array#concat` rather than relying on the runtime environment's `concat`.
- Test on `io.js` `v2.1`
- Clean up `Array.prototype` iteration methods
4.1.3
- Update `license` in `package.json` per https://docs.npmjs.com/files/package.json#license
- Update `uglify-js`, `eslint`
4.1.2
- In IE 6-8, `Date` inside the function expression does not reference `DateShim` (#303)
- Date: Ensure all code paths have the correct `constructor` property
- Date: Don't copy non-own properties from original `Date`
- Test up to `io.js` `v2.0.0`
- Simplify `isPrimitive` check.
- Adding sanity check tests for ES5 `Number` constants.
- Update `uglify-js`, `eslint`, `semver`
4.1.1
- Fix name of `parseInt` replacement.
- Update copyright year
- Update `eslint`, `jscs`
- Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change.
- All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`.
- Run `travis-ci` tests on latest `node` and `iojs`; speed up builds; allow 0.8 failures.
- Ensure some Object tests don't fail in ES6
- Make sure `Date` instances don't have an enumerable `constructor` property, when possible.
4.1.0
- Update `eslint`
- Improve type checks: `Array.isArray`, `isRegex`
- Replace `isRegex`/`isString`/`isCallable` checks with inlined versions from npm modules
- Note which ES abstract methods are replaceable via `es-abstract`
- Run `travis-ci` tests on `iojs`!
4.0.6
- Update `jscs`, `uglify-js`, add `eslint`
- es5-sham: fix Object.defineProperty to not check for own properties (#211)
- Fix Array#splice bug in Safari 5 (#284)
- Fix `Object.keys` issue with boxed primitives with extra properties in older browsers. (#242, #285)
4.0.5
- Update `jscs` so tests pass
4.0.4
- Style/indentation/whitespace cleanups.
- README tweaks
4.0.3
- Fix keywords (#268)
- add some Date tests
- Note in README that the es5-sham requires the es5-shim (https://github.com/es-shims/es5-shim/issues/256#issuecomment-52875710)
4.0.2
- Start including version numbers in minified files (#267)
4.0.1
- Fix legacy arguments object detection in Object.keys (#260)
4.0.0
- No longer shim the ES5-spec behavior of splice when `deleteCount` is omitted - since no engines implement it, and ES6 changes it. (#255)
- Use Object.defineProperty where available, so that polyfills are non-enumerable when possible (#250)
- lots of internal refactoring
- Fixed a bug referencing String#indexOf and String#lastIndexOf before polyfilling it (#253, #254)
3.4.0
- Removed nonstandard SpiderMonkey extension to Array#splice - when `deleteCount` is omitted, it's now treated as 0. (#192, #239)
- Fix Object.keys with Arguments objects in Safari 5.0
- Now shimming String#split in Opera 10.6
- Avoid using "toString" as a variable name, since that breaks Opera
- Internal implementation and test cleanups
3.3.2
- Remove an internal "bind" call, which should make the shim a bit faster
- Fix a bug with object boxing in Array#reduceRight that was failing a test in IE 6
3.3.1
- Fixing an Array#splice bug in IE 6/7
- cleaning up Array#splice tests
3.3.0
- Fix Array#reduceRight in node 0.6 and older browsers (#238)
3.2.0
- Fix es5-sham UMD definition to work properly with AMD (#237)
- Ensure that Array methods do not autobox context in strict mode (#233)
3.1.1
- Update minified files (#231)
3.1.0
- Fix String#replace in Firefox up through 29 (#228)
3.0.2
- Fix `Function#bind` in IE 7 and 8 (#224, #225, #226)
3.0.1
- Version bump to ensure npm has newest minified assets
3.0.0
- es5-sham: fix `Object.getPrototypeOf` and `Object.getOwnPropertyDescriptor` for Opera Mini
- Better override noncompliant native ES5 methods: `Array#forEach`, `Array#map`, `Array#filter`, `Array#every`, `Array#some`, `Array#reduce`, `Date.parse`, `String#trim`
- Added spec-compliant shim for `parseInt`
- Ensure `Object.keys` handles more edge cases with `arguments` objects and boxed primitives
- Improve minification of builds
2.3.0
- parseInt is now properly shimmed in ES3 browsers to default the radix
- update URLs to point to the new organization
2.2.0
- Function.prototype.bind shim now reports correct length on a bound function
- fix node 0.6.x v8 bug in Array#forEach
- test improvements
2.1.0
- Object.create fixes
- tweaks to the Object.defineProperties shim
2.0.0
- Separate reliable shims from dubious shims (shams).
1.2.10
- Group-effort Style Cleanup
- Took a stab at fixing Object.defineProperty on IE8 without
bad side-effects. (@hax)
- Object.isExtensible no longer fakes it. (@xavierm)
- Date.prototype.toISOString no longer deals with partial
ISO dates, per spec (@kitcambridge)
- More (mostly from @bryanforbes)
1.2.9
- Corrections to toISOString by @kitcambridge
- Fixed three bugs in array methods revealed by Jasmine tests.
- Cleaned up Function.prototype.bind with more fixes and tests from
@bryanforbes.
1.2.8
- Actually fixed problems with Function.prototype.bind, and regressions
from 1.2.7 (@bryanforbes, @jdalton #36)
1.2.7 - REGRESSED
- Fixed problems with Function.prototype.bind when called as a constructor.
(@jdalton #36)
1.2.6
- Revised Date.parse to match ES 5.1 (kitcambridge)
1.2.5
- Fixed a bug for padding it Date..toISOString (tadfisher issue #33)
1.2.4
- Fixed a descriptor bug in Object.defineProperty (raynos)
1.2.3
- Cleaned up RequireJS and <script> boilerplate
1.2.2
- Changed reduce to follow the letter of the spec with regard to having and
owning properties.
- Fixed a bug where RegExps pass as Functions in some engines in reduce.
1.2.1
- Adding few fixes to make jshint happy.
- Fix for issue #12, function expressions can cause scoping issues in IE.
- NPM will minify on install or when `npm run-script install` is executed.
- Adding .gitignore to avoid publishing dev dependencies.
1.2.0
- Making script loadable as AMD module.
- Adding `indexOf` to the list of safe shims.
1.1.0
- Added support for accessor properties where possible (which is all browsers
except IE).
- Stop exposing bound function's (that are returned by
`Function.prototype.bind`) internal properties (`bound, boundTo, boundArgs`)
as in some cases (when using facade objects for example) capabilities of the
enclosed functions will be leaked.
- `Object.create` now explicitly sets `__proto__` property to guarantee
correct behavior of `Object.getPrototypeOf`'s on all objects created using
`Object.create`.
- Switched to `===` from `==` where possible as it's slightly faster on older
browsers that are target of this lib.
- Added names to all anonymous functions to have a better stack traces.
1.0.0
- fixed Date.toISODate, using UTC accessors, as in
http://code.google.com/p/v8/source/browse/trunk/src/date.js?r=6120#986
(arian)
0.0.4
- Revised Object.getPrototypeOf to work in more cases
in response to http://ejohn.org/blog/objectgetprototypeof/
[issue #2] (fschaefer)
0.0.3
- Fixed typos in Object.keys (samsonjs)
0.0.2
Per kangax's recommendations:
- faster Object.create(null)
- fixed a function-scope function declaration statement in Object.create
0.0.1
- fixed Object.create(null), in so far as that's possible
- reworked Rhino Object.freeze(Function) bug detector and patcher
0.0.0
- forked from narwhal-lib

27
node_modules/es5-shim/CONTRIBUTORS.md generated vendored Normal file
View File

@ -0,0 +1,27 @@
- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal
Project)
- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
- kossnocorp Sasha Koss XXX TODO License or CLA
- bryanforbes Bryan Forbes XXX TODO License or CLA
- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD
License
- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain)
- iwyg XXX TODO License or CLA
- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License
- xavierm02 Montillet Xavier Copyright (C) 2011 MIT License
- Raynos Jake Verbaten Copyright (C) 2011 MIT Licence
- samsonjs Sami Samhuri Copyright (C) 2010 MIT License
- rwldrn Rick Waldron Copyright (C) 2011 MIT License
- lexer Alexey Zakharov XXX TODO License or CLA
- 280 North Inc. (Now Motorola LLC, a subsidiary of Google Inc.)
Copyright (C) 2009 MIT License
- Steven Levithan Copyright (C) 2012 MIT License
- Jordan Harband (C) 2013 MIT License

22
node_modules/es5-shim/LICENSE generated vendored Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (C) 2009-2016 Kristopher Michael Kowal 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.

188
node_modules/es5-shim/README.md generated vendored Normal file
View File

@ -0,0 +1,188 @@
# es5-shim <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>
[![npm badge][npm-badge-png]][npm-url]
[![Build Status][travis-svg]][travis-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
`es5-shim.js` and `es5-shim.min.js` monkey-patch a JavaScript context to
contain all EcmaScript 5 methods that can be faithfully emulated with a
legacy JavaScript engine.
**Note:** As `es5-shim.js` is designed to patch the native Javascript
engine, it should be the library that is loaded first.
`es5-sham.js` and `es5-sham.min.js` monkey-patch other ES5 methods as
closely as possible. For these methods, as closely as possible to ES5
is not very close. Many of these shams are intended only to allow code
to be written to ES5 without causing run-time errors in older engines.
In many cases, this means that these shams cause many ES5 methods to
silently fail. Decide carefully whether this is what you want.
**Note:** `es5-sham.js` requires `es5-shim.js` to be able to work properly.
## Tests
The tests are written with the Jasmine BDD test framework.
To run the tests, navigate to <root-folder>/tests/ , or,
simply `npm install` and `npm test`.
## Shims
### Complete tests ###
* Array.prototype.every
* Array.prototype.filter
* Array.prototype.forEach
* Array.prototype.indexOf
* Array.prototype.lastIndexOf
* Array.prototype.map
* Array.prototype.slice
* Array.prototype.some
* Array.prototype.sort
* Array.prototype.reduce
* Array.prototype.reduceRight
* Array.prototype.push
* Array.prototype.join
* Array.isArray
* Date.now
* Date.prototype.toJSON
* Function.prototype.bind
* :warning: Caveat: the bound function has a prototype property.
* :warning: Caveat: bound functions do not try too hard to keep you
from manipulating their ``arguments`` and ``caller`` properties.
* :warning: Caveat: bound functions don't have checks in ``call`` and
``apply`` to avoid executing as a constructor.
* Number.prototype.toFixed
* Number.prototype.toPrecision
* Object.keys
* String.prototype.split
* String.prototype.trim
* String.prototype.lastIndexOf
* String.prototype.replace
* Firefox (through v29) natively handles capturing groups incorrectly.
* Date.parse (for ISO parsing)
* Date.prototype.toISOString
* parseInt
* parseFloat
* Error.prototype.toString
* Error.prototype.name
* Error.prototype.message
* RegExp.prototype.toString
## Shams
* :warning: Object.create
For the case of simply "begetting" an object that inherits
prototypically from another, this should work fine across legacy
engines.
:warning: The second argument is passed to Object.defineProperties
which will probably fail either silently or with extreme prejudice.
* :warning: Object.getPrototypeOf
This will return "undefined" in some cases. It uses `__proto__` if
it's available. Failing that, it uses constructor.prototype, which
depends on the constructor property of the object's prototype having
not been replaced. If your object was created like this, it won't
work:
function Foo() {
}
Foo.prototype = {};
Because the prototype reassignment destroys the constructor
property.
This will work for all objects that were created using
`Object.create` implemented with this library.
* :warning: Object.getOwnPropertyNames
This method uses Object.keys, so it will not be accurate on legacy
engines.
* Object.isSealed
Returns "false" in all legacy engines for all objects, which is
conveniently guaranteed to be accurate.
* Object.isFrozen
Returns "false" in all legacy engines for all objects, which is
conveniently guaranteed to be accurate.
* Object.isExtensible
Works like a charm, by trying very hard to extend the object then
redacting the extension.
### May fail
* :warning: Object.getOwnPropertyDescriptor
The behavior of this shim does not conform to ES5. It should
probably not be used at this time, until its behavior has been
reviewed and been confirmed to be useful in legacy engines.
* :warning: Object.defineProperty
In the worst of circumstances, IE 8 provides a version of this
method that only works on DOM objects. This sham will not be
installed. The given version of `defineProperty` will throw an
exception if used on non-DOM objects.
In slightly better circumstances, this method will silently fail to
set "writable", "enumerable", and "configurable" properties.
Providing a getter or setter with "get" or "set" on a descriptor
will silently fail on engines that lack "__defineGetter__" and
"__defineSetter__", which include all versions of IE.
https://github.com/es-shims/es5-shim/issues#issue/5
* :warning: Object.defineProperties
This uses the Object.defineProperty shim.
* Object.seal
Silently fails on all legacy engines. This should be
fine unless you are depending on the safety and security
provisions of this method, which you cannot possibly
obtain in legacy engines.
* Object.freeze
Silently fails on all legacy engines. This should be
fine unless you are depending on the safety and security
provisions of this method, which you cannot possibly
obtain in legacy engines.
* Object.preventExtensions
Silently fails on all legacy engines. This should be
fine unless you are depending on the safety and security
provisions of this method, which you cannot possibly
obtain in legacy engines.
### Example of applying ES compatibility shims in a browser project
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.14/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.14/es5-sham.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.5/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.5/es6-sham.min.js"></script>
<script src="other-libs.js"></script>
```
[npm-url]: https://npmjs.org/package/es5-shim
[npm-version-svg]: http://versionbadg.es/es-shims/es5-shim.svg
[travis-svg]: https://travis-ci.org/es-shims/es5-shim.svg
[travis-url]: https://travis-ci.org/es-shims/es5-shim
[deps-svg]: https://david-dm.org/es-shims/es5-shim.svg
[deps-url]: https://david-dm.org/es-shims/es5-shim
[dev-deps-svg]: https://david-dm.org/es-shims/es5-shim/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/es5-shim#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/es5-shim.png?downloads=true&stars=true

33
node_modules/es5-shim/bower.json generated vendored Normal file
View File

@ -0,0 +1,33 @@
{
"name": "es5-shim",
"main": "es5-shim.js",
"repository": {
"type": "git",
"url": "git://github.com/es-shims/es5-shim"
},
"homepage": "https://github.com/es-shims/es5-shim",
"authors": [
"Kris Kowal <kris@cixar.com> (http://github.com/kriskowal/)",
"Sami Samhuri <sami.samhuri@gmail.com> (http://samhuri.net/)",
"Florian Schäfer <florian.schaefer@gmail.com> (http://github.com/fschaefer)",
"Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)",
"Kit Cambridge <kitcambridge@gmail.com> (http://kitcambridge.github.com)",
"Jordan Harband <ljharb@gmail.com> (https://github.com/ljharb/)"
],
"description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
"keywords": [
"shim",
"es5",
"es5 shim",
"javascript",
"ecmascript",
"polyfill"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"tests"
]
}

19
node_modules/es5-shim/component.json generated vendored Normal file
View File

@ -0,0 +1,19 @@
{
"name": "es5-shim",
"repo": "es-shims/es5-shim",
"description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
"version": "v4.5.1",
"keywords": [
"shim",
"es5",
"es5 shim",
"javascript",
"ecmascript",
"polyfill"
],
"license": "MIT",
"main": "es5-shim.js",
"scripts": [
"es5-shim.js"
]
}

558
node_modules/es5-shim/es5-sham.js generated vendored Normal file
View File

@ -0,0 +1,558 @@
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2020 by contributors, MIT License
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
*/
// vim: ts=4 sts=4 sw=4 expandtab
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
;
// UMD (Universal Module Definition)
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function (root, factory) {
'use strict';
/* global define */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory(); // eslint-disable-line no-param-reassign
}
}(this, function () {
var call = Function.call;
var prototypeOfObject = Object.prototype;
var owns = call.bind(prototypeOfObject.hasOwnProperty);
var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);
var toStr = call.bind(prototypeOfObject.toString);
// If JS engine supports accessors creating shortcuts.
var defineGetter;
var defineSetter;
var lookupGetter;
var lookupSetter;
var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
if (supportsAccessors) {
/* eslint-disable no-underscore-dangle, no-restricted-properties */
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
/* eslint-enable no-underscore-dangle, no-restricted-properties */
}
var isPrimitive = function isPrimitive(o) {
return o == null || (typeof o !== 'object' && typeof o !== 'function');
};
// ES5 15.2.3.2
// http://es5.github.com/#x15.2.3.2
if (!Object.getPrototypeOf) {
// https://github.com/es-shims/es5-shim/issues#issue/2
// http://ejohn.org/blog/objectgetprototypeof/
// recommended by fschaefer on github
//
// sure, and webreflection says ^_^
// ... this will nerever possibly return null
// ... Opera Mini breaks here with infinite loops
Object.getPrototypeOf = function getPrototypeOf(object) {
// eslint-disable-next-line no-proto
var proto = object.__proto__;
if (proto || proto === null) {
return proto;
} else if (toStr(object.constructor) === '[object Function]') {
return object.constructor.prototype;
} else if (object instanceof Object) {
return prototypeOfObject;
} else {
// Correctly return null for Objects created with `Object.create(null)`
// (shammed or native) or `{ __proto__: null}`. Also returns null for
// cross-realm objects on browsers that lack `__proto__` support (like
// IE <11), but that's the best we can do.
return null;
}
};
}
// ES5 15.2.3.3
// http://es5.github.com/#x15.2.3.3
// check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
if (Object.defineProperty) {
var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
try {
object.sentinel = 0; // eslint-disable-line no-param-reassign
return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
} catch (exception) {
return false;
}
};
var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined'
|| doesGetOwnPropertyDescriptorWork(document.createElement('div'));
if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
}
}
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
/* eslint-disable no-proto */
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
if (isPrimitive(object)) {
throw new TypeError(ERR_NON_OBJECT + object);
}
// make a valiant attempt to use the real getOwnPropertyDescriptor
// for I8's DOM elements.
if (getOwnPropertyDescriptorFallback) {
try {
return getOwnPropertyDescriptorFallback.call(Object, object, property);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
var descriptor;
// If object does not owns property return undefined immediately.
if (!owns(object, property)) {
return descriptor;
}
// If object has a property then it's for sure `configurable`, and
// probably `enumerable`. Detect enumerability though.
descriptor = {
enumerable: isEnumerable(object, property),
configurable: true
};
// If JS engine supports accessor properties then property may be a
// getter or setter.
if (supportsAccessors) {
// Unfortunately `__lookupGetter__` will return a getter even
// if object has own non getter property along with a same named
// inherited getter. To avoid misbehavior we temporary remove
// `__proto__` so that `__lookupGetter__` will return getter only
// if it's owned by an object.
var prototype = object.__proto__;
var notPrototypeOfObject = object !== prototypeOfObject;
// avoid recursion problem, breaking in Opera Mini when
// Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
// or any other Object.prototype accessor
if (notPrototypeOfObject) {
object.__proto__ = prototypeOfObject; // eslint-disable-line no-param-reassign
}
var getter = lookupGetter(object, property);
var setter = lookupSetter(object, property);
if (notPrototypeOfObject) {
// Once we have getter and setter we can put values back.
object.__proto__ = prototype; // eslint-disable-line no-param-reassign
}
if (getter || setter) {
if (getter) {
descriptor.get = getter;
}
if (setter) {
descriptor.set = setter;
}
// If it was accessor property we're done and return here
// in order to avoid adding `value` to the descriptor.
return descriptor;
}
}
// If we got this far we know that object has an own property that is
// not an accessor so we set it as a value and return descriptor.
descriptor.value = object[property];
descriptor.writable = true;
return descriptor;
};
/* eslint-enable no-proto */
}
// ES5 15.2.3.4
// http://es5.github.com/#x15.2.3.4
if (!Object.getOwnPropertyNames) {
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
return Object.keys(object);
};
}
// ES5 15.2.3.5
// http://es5.github.com/#x15.2.3.5
if (!Object.create) {
// Contributed by Brandon Benvie, October, 2012
var createEmpty;
var supportsProto = !({ __proto__: null } instanceof Object);
// the following produces false positives
// in Opera Mini => not a reliable check
// Object.prototype.__proto__ === null
// Check for document.domain and active x support
// No need to use active x approach when document.domain is not set
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
/* global ActiveXObject */
var shouldUseActiveX = function shouldUseActiveX() {
// return early if document.domain not set
if (!document.domain) {
return false;
}
try {
return !!new ActiveXObject('htmlfile');
} catch (exception) {
return false;
}
};
// This supports IE8 when document.domain is used
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
var getEmptyViaActiveX = function getEmptyViaActiveX() {
var empty;
var xDoc;
xDoc = new ActiveXObject('htmlfile');
var script = 'script';
xDoc.write('<' + script + '></' + script + '>');
xDoc.close();
empty = xDoc.parentWindow.Object.prototype;
xDoc = null;
return empty;
};
// The original implementation using an iframe
// before the activex approach was added
// see https://github.com/es-shims/es5-shim/issues/150
var getEmptyViaIFrame = function getEmptyViaIFrame() {
var iframe = document.createElement('iframe');
var parent = document.body || document.documentElement;
var empty;
iframe.style.display = 'none';
parent.appendChild(iframe);
// eslint-disable-next-line no-script-url
iframe.src = 'javascript:';
empty = iframe.contentWindow.Object.prototype;
parent.removeChild(iframe);
iframe = null;
return empty;
};
/* global document */
if (supportsProto || typeof document === 'undefined') {
createEmpty = function () {
return { __proto__: null };
};
} else {
// In old IE __proto__ can't be used to manually set `null`, nor does
// any other method exist to make an object that inherits from nothing,
// aside from Object.prototype itself. Instead, create a new global
// object and *steal* its Object.prototype and strip it bare. This is
// used as the prototype to create nullary objects.
createEmpty = function () {
// Determine which approach to use
// see https://github.com/es-shims/es5-shim/issues/150
var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
delete empty.constructor;
delete empty.hasOwnProperty;
delete empty.propertyIsEnumerable;
delete empty.isPrototypeOf;
delete empty.toLocaleString;
delete empty.toString;
delete empty.valueOf;
var Empty = function Empty() {};
Empty.prototype = empty;
// short-circuit future calls
createEmpty = function () {
return new Empty();
};
return new Empty();
};
}
Object.create = function create(prototype, properties) {
var object;
var Type = function Type() {}; // An empty constructor.
if (prototype === null) {
object = createEmpty();
} else if (isPrimitive(prototype)) {
// In the native implementation `parent` can be `null`
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
// like they are in modern browsers. Using `Object.create` on DOM elements
// is...err...probably inappropriate, but the native version allows for it.
throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
} else {
Type.prototype = prototype;
object = new Type();
// IE has no built-in implementation of `Object.getPrototypeOf`
// neither `__proto__`, but this manually setting `__proto__` will
// guarantee that `Object.getPrototypeOf` will work as expected with
// objects created using `Object.create`
// eslint-disable-next-line no-proto
object.__proto__ = prototype;
}
if (properties !== void 0) {
Object.defineProperties(object, properties);
}
return object;
};
}
// ES5 15.2.3.6
// http://es5.github.com/#x15.2.3.6
// Patch for WebKit and IE8 standard mode
// Designed by hax <hax.github.com>
// related issue: https://github.com/es-shims/es5-shim/issues#issue/5
// IE8 Reference:
// http://msdn.microsoft.com/en-us/library/dd282900.aspx
// http://msdn.microsoft.com/en-us/library/dd229916.aspx
// WebKit Bugs:
// https://bugs.webkit.org/show_bug.cgi?id=36423
var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
try {
Object.defineProperty(object, 'sentinel', {});
return 'sentinel' in object;
} catch (exception) {
return false;
}
};
// check whether defineProperty works if it's given. Otherwise,
// shim partially.
if (Object.defineProperty) {
var definePropertyWorksOnObject = doesDefinePropertyWork({});
var definePropertyWorksOnDom = typeof document === 'undefined'
|| doesDefinePropertyWork(document.createElement('div'));
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
var definePropertyFallback = Object.defineProperty,
definePropertiesFallback = Object.defineProperties;
}
}
if (!Object.defineProperty || definePropertyFallback) {
var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
Object.defineProperty = function defineProperty(object, property, descriptor) {
if (isPrimitive(object)) {
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
}
if (isPrimitive(descriptor)) {
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
}
// make a valiant attempt to use the real defineProperty
// for I8's DOM elements.
if (definePropertyFallback) {
try {
return definePropertyFallback.call(Object, object, property, descriptor);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
// If it's a data property.
if ('value' in descriptor) {
// fail silently if 'writable', 'enumerable', or 'configurable'
// are requested but not supported
/*
// alternate approach:
if ( // can't implement these features; allow false but not true
('writable' in descriptor && !descriptor.writable) ||
('enumerable' in descriptor && !descriptor.enumerable) ||
('configurable' in descriptor && !descriptor.configurable)
))
throw new RangeError(
'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
);
*/
if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
// As accessors are supported only on engines implementing
// `__proto__` we can safely override `__proto__` while defining
// a property to make sure that we don't hit an inherited
// accessor.
/* eslint-disable no-proto, no-param-reassign */
var prototype = object.__proto__;
object.__proto__ = prototypeOfObject;
// Deleting a property anyway since getter / setter may be
// defined on object itself.
delete object[property];
object[property] = descriptor.value;
// Setting original `__proto__` back now.
object.__proto__ = prototype;
/* eslint-enable no-proto, no-param-reassign */
} else {
object[property] = descriptor.value; // eslint-disable-line no-param-reassign
}
} else {
var hasGetter = 'get' in descriptor;
var hasSetter = 'set' in descriptor;
if (!supportsAccessors && (hasGetter || hasSetter)) {
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
// If we got that far then getters and setters can be defined !!
if (hasGetter) {
defineGetter(object, property, descriptor.get);
}
if (hasSetter) {
defineSetter(object, property, descriptor.set);
}
}
return object;
};
}
// ES5 15.2.3.7
// http://es5.github.com/#x15.2.3.7
if (!Object.defineProperties || definePropertiesFallback) {
Object.defineProperties = function defineProperties(object, properties) {
// make a valiant attempt to use the real defineProperties
if (definePropertiesFallback) {
try {
return definePropertiesFallback.call(Object, object, properties);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
Object.keys(properties).forEach(function (property) {
if (property !== '__proto__') {
Object.defineProperty(object, property, properties[property]);
}
});
return object;
};
}
// ES5 15.2.3.8
// http://es5.github.com/#x15.2.3.8
if (!Object.seal) {
Object.seal = function seal(object) {
if (Object(object) !== object) {
throw new TypeError('Object.seal can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
return object;
};
}
// ES5 15.2.3.9
// http://es5.github.com/#x15.2.3.9
if (!Object.freeze) {
Object.freeze = function freeze(object) {
if (Object(object) !== object) {
throw new TypeError('Object.freeze can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
return object;
};
}
// detect a Rhino bug and patch it
try {
Object.freeze(function () {});
} catch (exception) {
Object.freeze = (function (freezeObject) {
return function freeze(object) {
if (typeof object === 'function') {
return object;
} else {
return freezeObject(object);
}
};
}(Object.freeze));
}
// ES5 15.2.3.10
// http://es5.github.com/#x15.2.3.10
if (!Object.preventExtensions) {
Object.preventExtensions = function preventExtensions(object) {
if (Object(object) !== object) {
throw new TypeError('Object.preventExtensions can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
return object;
};
}
// ES5 15.2.3.11
// http://es5.github.com/#x15.2.3.11
if (!Object.isSealed) {
Object.isSealed = function isSealed(object) {
if (Object(object) !== object) {
throw new TypeError('Object.isSealed can only be called on Objects.');
}
return false;
};
}
// ES5 15.2.3.12
// http://es5.github.com/#x15.2.3.12
if (!Object.isFrozen) {
Object.isFrozen = function isFrozen(object) {
if (Object(object) !== object) {
throw new TypeError('Object.isFrozen can only be called on Objects.');
}
return false;
};
}
// ES5 15.2.3.13
// http://es5.github.com/#x15.2.3.13
if (!Object.isExtensible) {
Object.isExtensible = function isExtensible(object) {
// 1. If Type(O) is not Object throw a TypeError exception.
if (Object(object) !== object) {
throw new TypeError('Object.isExtensible can only be called on Objects.');
}
// 2. Return the Boolean value of the [[Extensible]] internal property of O.
var name = '';
while (owns(object, name)) {
name += '?';
}
object[name] = true; // eslint-disable-line no-param-reassign
var returnValue = owns(object, name);
delete object[name]; // eslint-disable-line no-param-reassign
return returnValue;
};
}
}));

1
node_modules/es5-shim/es5-sham.map generated vendored Normal file

File diff suppressed because one or more lines are too long

7
node_modules/es5-shim/es5-sham.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

2113
node_modules/es5-shim/es5-shim.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/es5-shim/es5-shim.map generated vendored Normal file

File diff suppressed because one or more lines are too long

7
node_modules/es5-shim/es5-shim.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

124
node_modules/es5-shim/package.json generated vendored Normal file
View File

@ -0,0 +1,124 @@
{
"_from": "es5-shim",
"_id": "es5-shim@4.5.14",
"_inBundle": false,
"_integrity": "sha512-7SwlpL+2JpymWTt8sNLuC2zdhhc+wrfe5cMPI2j0o6WsPdfAiPwmFy2f0AocPB4RQVBOZ9kNTgi5YF7TdhkvEg==",
"_location": "/es5-shim",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "es5-shim",
"name": "es5-shim",
"escapedName": "es5-shim",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.14.tgz",
"_shasum": "90009e1019d0ea327447cb523deaff8fe45697ef",
"_spec": "es5-shim",
"_where": "C:\\Users\\knh94\\Documents\\GitHub\\welsonjs",
"bugs": {
"url": "http://github.com/es-shims/es5-shim/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Kris Kowal",
"email": "kris@cixar.com",
"url": "http://github.com/kriskowal/"
},
{
"name": "Sami Samhuri",
"email": "sami.samhuri@gmail.com",
"url": "http://samhuri.net/"
},
{
"name": "Florian Schäfer",
"email": "florian.schaefer@gmail.com",
"url": "http://github.com/fschaefer"
},
{
"name": "Irakli Gozalishvili",
"email": "rfobic@gmail.com",
"url": "http://jeditoolkit.com"
},
{
"name": "Kit Cambridge",
"email": "kitcambridge@gmail.com",
"url": "http://kitcambridge.github.com"
},
{
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "https://github.com/ljharb/"
}
],
"deprecated": false,
"description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
"devDependencies": {
"@ljharb/eslint-config": "^16.0.0",
"eslint": "^6.8.0",
"jasmine-node": "^1.16.2",
"safe-publish-latest": "^1.1.4",
"uglify-js": "2.7.3"
},
"engines": {
"node": ">=0.4.0"
},
"greenkeeper": {
"ignore": [
"uglify-js"
]
},
"homepage": "http://github.com/es-shims/es5-shim/",
"keywords": [
"shim",
"es5",
"es5 shim",
"javascript",
"ecmascript",
"polyfill"
],
"license": "MIT",
"main": "es5-shim.js",
"name": "es5-shim",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/es-shims/es5-shim.git"
},
"scripts": {
"lint": "eslint .",
"minify": "npm run --silent minify-shim && npm run --silent minify-sham",
"minify-sham": "uglifyjs es5-sham.js --support-ie8 --keep-fnames --comments --source-map=es5-sham.map -m -b ascii_only=true,beautify=false > es5-sham.min.js",
"minify-shim": "uglifyjs es5-shim.js --support-ie8 --keep-fnames --comments --source-map=es5-shim.map -m -b ascii_only=true,beautify=false | sed 's/0xde0b6b3a7640080/1000000000000000128/' > es5-shim.min.js",
"prepublish": "safe-publish-latest && npm run minify",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"test-native": "jasmine-node --matchall tests/spec/",
"tests-only": "jasmine-node --matchall ./ tests/spec/"
},
"testling": {
"browsers": [
"iexplore/6.0..latest",
"firefox/3.0..6.0",
"firefox/18.0..latest",
"firefox/nightly",
"chrome/4.0..10.0",
"chrome/25.0..latest",
"chrome/canary",
"opera/10.0..latest",
"opera/next",
"safari/4.0..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2"
]
},
"version": "4.5.14"
}

7
node_modules/es5-shim/shims.json generated vendored Normal file
View File

@ -0,0 +1,7 @@
{
"Object": {
"prototype": {},
"keys": "object-keys"
}
}

39
node_modules/es5-shim/tests/helpers/h-matchers.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
var has = Object.prototype.hasOwnProperty;
var getKeys = function (o) {
'use strict';
var key;
var a = [];
for (key in o) {
if (has.call(o, key)) {
a.push(key);
}
}
return a;
};
beforeEach(function () {
'use strict';
this.addMatchers({
toExactlyMatch: function (expected) {
var a1, a2, l, i, key;
var actual = this.actual;
a1 = getKeys(actual);
a2 = getKeys(expected);
l = a1.length;
if (l !== a2.length) {
return false;
}
for (i = 0; i < l; i++) {
key = a1[i];
expect(key).toEqual(a2[i]);
expect(actual[key]).toEqual(expected[key]);
}
return true;
}
});
});

66
node_modules/es5-shim/tests/index.html generated vendored Normal file
View File

@ -0,0 +1,66 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine.css">
<script type="text/javascript" src="lib/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-html.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<!-- include helper files here... -->
<script src="helpers/h-matchers.js"></script>
<!-- include source files here... -->
<script src="../es5-shim.js"></script>
<script src="../es5-sham.js"></script>
<!-- include spec files here... -->
<script src="spec/s-array.js"></script>
<script src="spec/s-date.js"></script>
<script src="spec/s-error.js"></script>
<script src="spec/s-function.js"></script>
<script src="spec/s-global.js"></script>
<script src="spec/s-number.js"></script>
<script src="spec/s-object.js"></script>
<script src="spec/s-string.js"></script>
<script src="spec/s-regexp.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv.addReporter(trivialReporter);
jasmineEnv.specFilter = function(spec) {
return trivialReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
</body>
</html>

64
node_modules/es5-shim/tests/index.min.html generated vendored Normal file
View File

@ -0,0 +1,64 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine.css">
<script type="text/javascript" src="lib/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-html.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<!-- include helper files here... -->
<script src="helpers/h-matchers.js"></script>
<!-- include source files here... -->
<script src="../es5-shim.min.js"></script>
<!-- include spec files here... -->
<script src="spec/s-array.js"></script>
<script src="spec/s-date.js"></script>
<script src="spec/s-error.js"></script>
<script src="spec/s-function.js"></script>
<script src="spec/s-global.js"></script>
<script src="spec/s-number.js"></script>
<script src="spec/s-object.js"></script>
<script src="spec/s-string.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv.addReporter(trivialReporter);
jasmineEnv.specFilter = function(spec) {
return trivialReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
</body>
</html>

190
node_modules/es5-shim/tests/lib/jasmine-html.js generated vendored Normal file
View File

@ -0,0 +1,190 @@
jasmine.TrivialReporter = function(doc) {
this.document = doc || document;
this.suiteDivs = {};
this.logRunningSpecs = false;
};
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
var el = document.createElement(type);
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child === 'string') {
el.appendChild(document.createTextNode(child));
} else {
if (child) { el.appendChild(child); }
}
}
for (var attr in attrs) {
if (attr == "className") {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
}
return el;
};
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
var showPassed, showSkipped;
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
this.createDom('div', { className: 'banner' },
this.createDom('div', { className: 'logo' },
this.createDom('span', { className: 'title' }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),
this.createDom('div', { className: 'options' },
"Show ",
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
)
),
this.runnerDiv = this.createDom('div', { className: 'runner running' },
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
);
this.document.body.appendChild(this.outerDiv);
var suites = runner.suites();
for (var i = 0; i < suites.length; i++) {
var suite = suites[i];
var suiteDiv = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
this.suiteDivs[suite.id] = suiteDiv;
var parentDiv = this.outerDiv;
if (suite.parentSuite) {
parentDiv = this.suiteDivs[suite.parentSuite.id];
}
parentDiv.appendChild(suiteDiv);
}
this.startedAt = new Date();
var self = this;
showPassed.onclick = function(evt) {
if (showPassed.checked) {
self.outerDiv.className += ' show-passed';
} else {
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
}
};
showSkipped.onclick = function(evt) {
if (showSkipped.checked) {
self.outerDiv.className += ' show-skipped';
} else {
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
}
};
};
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
var results = runner.results();
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
this.runnerDiv.setAttribute("class", className);
//do it twice for IE
this.runnerDiv.setAttribute("className", className);
var specs = runner.specs();
var specCount = 0;
for (var i = 0; i < specs.length; i++) {
if (this.specFilter(specs[i])) {
specCount++;
}
}
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
};
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
var results = suite.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.totalCount === 0) { // todo: change this to check results.skipped
status = 'skipped';
}
this.suiteDivs[suite.id].className += " " + status;
};
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
if (this.logRunningSpecs) {
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
}
};
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
var results = spec.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.skipped) {
status = 'skipped';
}
var specDiv = this.createDom('div', { className: 'spec ' + status },
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
this.createDom('a', {
className: 'description',
href: '?spec=' + encodeURIComponent(spec.getFullName()),
title: spec.getFullName()
}, spec.description));
var resultItems = results.getItems();
var messagesDiv = this.createDom('div', { className: 'messages' });
for (var i = 0; i < resultItems.length; i++) {
var result = resultItems[i];
if (result.type == 'log') {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
} else if (result.type == 'expect' && result.passed && !result.passed()) {
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
if (result.trace.stack) {
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
}
}
}
if (messagesDiv.childNodes.length > 0) {
specDiv.appendChild(messagesDiv);
}
this.suiteDivs[spec.suite.id].appendChild(specDiv);
};
jasmine.TrivialReporter.prototype.log = function() {
var console = jasmine.getGlobal().console;
if (console && console.log) {
if (console.log.apply) {
console.log.apply(console, arguments);
} else {
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
}
}
};
jasmine.TrivialReporter.prototype.getLocation = function() {
return this.document.location;
};
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
var paramMap = {};
var params = this.getLocation().search.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
if (!paramMap.spec) {
return true;
}
return spec.getFullName().indexOf(paramMap.spec) === 0;
};

166
node_modules/es5-shim/tests/lib/jasmine.css generated vendored Normal file
View File

@ -0,0 +1,166 @@
body {
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
}
.jasmine_reporter a:visited, .jasmine_reporter a {
color: #303;
}
.jasmine_reporter a:hover, .jasmine_reporter a:active {
color: blue;
}
.run_spec {
float:right;
padding-right: 5px;
font-size: .8em;
text-decoration: none;
}
.jasmine_reporter {
margin: 0 5px;
}
.banner {
color: #303;
background-color: #fef;
padding: 5px;
}
.logo {
float: left;
font-size: 1.1em;
padding-left: 5px;
}
.logo .version {
font-size: .6em;
padding-left: 1em;
}
.runner.running {
background-color: yellow;
}
.options {
text-align: right;
font-size: .8em;
}
.suite {
border: 1px outset gray;
margin: 5px 0;
padding-left: 1em;
}
.suite .suite {
margin: 5px;
}
.suite.passed {
background-color: #dfd;
}
.suite.failed {
background-color: #fdd;
}
.spec {
margin: 5px;
padding-left: 1em;
clear: both;
}
.spec.failed, .spec.passed, .spec.skipped {
padding-bottom: 5px;
border: 1px solid gray;
}
.spec.failed {
background-color: #fbb;
border-color: red;
}
.spec.passed {
background-color: #bfb;
border-color: green;
}
.spec.skipped {
background-color: #bbb;
}
.messages {
border-left: 1px dashed gray;
padding-left: 1em;
padding-right: 1em;
}
.passed {
background-color: #cfc;
display: none;
}
.failed {
background-color: #fbb;
}
.skipped {
color: #777;
background-color: #eee;
display: none;
}
/*.resultMessage {*/
/*white-space: pre;*/
/*}*/
.resultMessage span.result {
display: block;
line-height: 2em;
color: black;
}
.resultMessage .mismatch {
color: black;
}
.stackTrace {
white-space: pre;
font-size: .8em;
margin-left: 10px;
max-height: 5em;
overflow: auto;
border: 1px inset red;
padding: 1em;
background: #eef;
}
.finished-at {
padding-left: 1em;
font-size: .6em;
}
.show-passed .passed,
.show-skipped .skipped {
display: block;
}
#jasmine_content {
position:fixed;
right: 100%;
}
.runner {
border: 1px solid gray;
display: block;
margin: 5px 0;
padding: 2px 0 2px 10px;
}

2601
node_modules/es5-shim/tests/lib/jasmine.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

62
node_modules/es5-shim/tests/native.html generated vendored Normal file
View File

@ -0,0 +1,62 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine.css">
<script type="text/javascript" src="lib/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-html.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<!-- include helper files here... -->
<script src="helpers/h-matchers.js"></script>
<!-- include spec files here... -->
<script src="spec/s-array.js"></script>
<script src="spec/s-date.js"></script>
<script src="spec/s-error.js"></script>
<script src="spec/s-function.js"></script>
<script src="spec/s-global.js"></script>
<script src="spec/s-number.js"></script>
<script src="spec/s-object.js"></script>
<script src="spec/s-string.js"></script>
<script src="spec/s-regexp.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv.addReporter(trivialReporter);
jasmineEnv.specFilter = function(spec) {
return trivialReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
</body>
</html>

1978
node_modules/es5-shim/tests/spec/s-array.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

558
node_modules/es5-shim/tests/spec/s-date.js generated vendored Normal file
View File

@ -0,0 +1,558 @@
describe('Date', function () {
'use strict';
var supportsDescriptors = Object.defineProperty && (function () {
try {
var obj = {};
Object.defineProperty(obj, 'x', {
enumerable: false,
value: obj
});
for (var _ in obj) { // jscs:ignore disallowUnusedVariables
return false;
}
return obj.x === obj;
} catch (e) { /* this is ES3 */
return false;
}
}());
var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit;
var has = Object.prototype.hasOwnProperty;
var negativeDate;
beforeEach(function () {
var negativeCanned = [
{
getTime: -3509827329600292,
getUTCDay: 4,
getDay: 4,
dim: 31
},
{
getTime: -3509824651200292,
getUTCDay: 0,
getDay: 0,
dim: 29
},
{
getTime: -3509822145600292,
getUTCDay: 1,
getDay: 1,
dim: 31
},
{
getTime: -3509819467200292,
getUTCDay: 4,
getDay: 4,
dim: 30
},
{
getTime: -3509816875200292,
getUTCDay: 6,
getDay: 6,
dim: 31
},
{
getTime: -3509814196800292,
getUTCDay: 2,
getDay: 2,
dim: 30
},
{
getTime: -3509811604800292,
getUTCDay: 4,
getDay: 4,
dim: 31
},
{
getTime: -3509808926400292,
getUTCDay: 0,
getDay: 0,
dim: 31
},
{
getTime: -3509806248000292,
getUTCDay: 3,
getDay: 3,
dim: 30
},
{
getTime: -3509803656000292,
getUTCDay: 5,
getDay: 5,
dim: 31
},
{
getTime: -3509800977600292,
getUTCDay: 1,
getDay: 1,
dim: 30
},
{
getTime: -3509798385600292,
getUTCDay: 3,
getDay: 3,
dim: 31
}
];
negativeDate = negativeCanned.map(function (item) {
var dateFirst = new Date(item.getTime);
var dateLast = new Date(item.getTime + ((item.dim - 1) * 86400000));
return {
dates: [dateFirst, dateLast],
days: [1, item.dim],
getUTCDay: [item.getUTCDay, (item.getUTCDay + item.dim - 1) % 7],
getDay: [item.getDay, (item.getDay + item.dim - 1) % 7]
};
});
});
describe('.now()', function () {
it('should be the current time', function () {
var before = (new Date()).getTime();
var middle = Date.now();
var after = (new Date()).getTime();
expect(middle).not.toBeLessThan(before);
expect(middle).not.toBeGreaterThan(after);
});
});
describe('constructor', function () {
it('works with standard formats', function () {
// Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
expect(+new Date('2012-12-31T23:59:59.000Z')).toBe(1356998399000); // 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000
expect(+new Date('2012-04-04T05:02:02.170Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(+new Date('2012-04-04T05:02:02.170999Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(+new Date('2012-04-04T05:02:02.17Z')).toBe(1333515722170); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(+new Date('2012-04-04T05:02:02.1Z')).toBe(1333515722100); // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(+new Date('2012-04-04T24:00:00.000Z')).toBe(1333584000000); // NaN 1333584000000 1333584000000 1333584000000 1333584000000
expect(+new Date('2012-02-29T12:00:00.000Z')).toBe(1330516800000); // 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000
expect(+new Date('2011-03-01T12:00:00.000Z')).toBe(1298980800000); // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
// https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
expect(new Date('2034-03-01T00:00:00.000Z')
- new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
});
ifSupportsDescriptorsIt('is not enumerable', function () {
expect(Object.keys(new Date())).not.toContain('constructor');
});
it('works as a function', function () {
var zeroDate = Date(0);
expect(zeroDate).toBe(String(zeroDate));
var value = Date(1441705534578);
expect(value).toBe(String(value));
});
it('fixes this Safari 8/9 bug', function () {
var offset = new Date(1970).getTimezoneOffset() * 60e3;
var timestamp = 2147483647; // Math.pow(2, 31) - 1
var date = new Date(1970, 0, 1, 0, 0, 0, timestamp);
var expectedTimestamp = timestamp + offset;
expect(date.getTime()).toBe(expectedTimestamp);
var brokenTimestamp = 2147483648; // Math.pow(2, 31)
var brokenDate = new Date(1970, 0, 1, 0, 0, 0, brokenTimestamp);
var expectedBrokenTimestamp = brokenTimestamp + offset;
expect(brokenDate.getTime()).toBe(expectedBrokenTimestamp); // NaN in Safari 8/9
var veryBrokenTS = 1435734000000;
var veryBrokenDate = new Date(1970, 0, 1, 0, 0, 0, veryBrokenTS);
var largeDate = new Date('Wed Jul 01 2015 07:00:00 GMT-0700 (PDT)');
var expectedVeryBrokenTS = veryBrokenTS + (largeDate.getTimezoneOffset() * 60e3);
expect(veryBrokenDate.getTime()).toBe(expectedVeryBrokenTS); // NaN in Safari 8/9
});
it('works with a Date object', function () {
var date = new Date(1456297712984);
var copiedDate = new Date(date);
expect(date).not.toBe(copiedDate);
expect(copiedDate.getTime()).toBe(date.getTime());
expect(+copiedDate).toBe(+date);
expect(String(copiedDate)).toBe(String(date));
});
});
describe('.parse()', function () {
// TODO: Write the rest of the test.
ifSupportsDescriptorsIt('is not enumerable', function () {
expect(Object.getOwnPropertyDescriptor(Date, 'parse').enumerable).toBe(false);
});
it('should be an invalid date', function () {
// Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
expect(Date.parse('2012-11-31T23:59:59.000Z')).toBeFalsy(); // 1354406399000 NaN NaN 1354406399000 NaN
expect(Date.parse('2012-12-31T23:59:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356998400000
expect(Date.parse('2012-04-04T24:00:00.500Z')).toBeFalsy(); // NaN NaN 1333584000500 1333584000500 NaN
expect(Date.parse('2012-12-31T10:08:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356948540000
expect(Date.parse('2012-13-01T12:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('2012-12-32T12:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('2012-12-31T25:00:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('2012-12-31T24:01:00.000Z')).toBeFalsy(); // NaN NaN NaN 1356998460000 NaN
expect(Date.parse('2012-12-31T12:60:00.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('2012-12-31T12:00:60.000Z')).toBeFalsy(); // NaN NaN NaN NaN 1356955260000
expect(Date.parse('2012-00-31T23:59:59.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('2012-12-00T23:59:59.000Z')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('2011-02-29T12:00:00.000Z')).toBeFalsy(); // 1298980800000 NaN NaN 1298980800000 NaN
});
it('should work', function () {
var dates = {
// Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1 Safari 8
'2012-12-31T23:59:59.000Z': 1356998399000, // 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000 1356998399000
'2012-04-04T05:02:02.170Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
'2012-04-04T05:02:02.170999Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170.999
'2012-04-04T05:02:02.17Z': 1333515722170, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
'2012-04-04T05:02:02.1Z': 1333515722100, // 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
'2012-04-04T24:00:00.000Z': 1333584000000, // NaN 1333584000000 1333584000000 1333584000000 1333584000000 1333584000000
'2012-02-29T12:00:00.000Z': 1330516800000, // 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000 1330516800000
'2011-03-01T12:00:00.000Z': 1298980800000 // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
};
for (var str in dates) {
if (has.call(dates, str)) {
expect(Math.floor(Date.parse(str))).toBe(dates[str]);
}
}
// https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
expect(Date.parse('2034-03-01T00:00:00.000Z')
- Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
});
it('fixes a Safari 8/9 bug with parsing in UTC instead of local time', function () {
var offset = new Date('2015-07-01').getTimezoneOffset() * 60e3;
expect(Date.parse('2015-07-01T00:00:00')).toBe(1435708800000 + offset); // Safari 8/9 give NaN
});
it('should support extended years', function () {
// Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
expect(Date.parse('0000-01-01T00:00:00.000Z')).toBe(-621672192e5); // -621672192e5 -621672192e5 -621672192e5 -621672192e5 -621672192e5
expect(Date.parse('0001-01-01T00:00:00Z')).toBe(-621355968e5); // -621355968e5 -621355968e5 -621355968e5 8.64e15 -621355968e5
expect(Date.parse('+275760-09-13T00:00:00.000Z')).toBe(8.64e15); // 8.64e15 NaN 8.64e15 8.64e15 8.64e15
expect(Date.parse('-271821-04-20T00:00:00.000Z')).toBe(-8.64e15); // -8.64e15 NaN -8.64e15 -8.64e15 -8.6400000864e15
expect(Date.parse('+275760-09-13T00:00:00.001Z')).toBeFalsy(); // NaN NaN NaN 8.64e15 + 1 8.64e15 + 1
expect(Date.parse('-271821-04-19T23:59:59.999Z')).toBeFalsy(); // NaN NaN NaN -8.64e15 - 1 -8.6400000864e15 - 1
expect(Date.parse('+033658-09-27T01:46:40.000Z')).toBe(1e15); // 1e15 NaN 1e15 1e15 9999999136e5
expect(Date.parse('-000001-01-01T00:00:00Z')).toBe(-621987552e5); // -621987552e5 NaN -621987552e5 -621987552e5 -621987552e5
expect(Date.parse('+002009-12-15T00:00:00Z')).toBe(12608352e5); // 12608352e5 NaN 12608352e5 12608352e5 12608352e5
});
it('works with timezone offsets', function () {
// Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
expect(Date.parse('2012-01-29T12:00:00.000+01:00')).toBe(132783480e4); // 132783480e4 132783480e4 132783480e4 132783480e4 132783480e4
expect(Date.parse('2012-01-29T12:00:00.000-00:00')).toBe(132783840e4); // 132783840e4 132783840e4 132783840e4 132783840e4 132783840e4
expect(Date.parse('2012-01-29T12:00:00.000+00:00')).toBe(132783840e4); // 132783840e4 132783840e4 132783840e4 132783840e4 132783840e4
expect(Date.parse('2012-01-29T12:00:00.000+23:59')).toBe(132775206e4); // 132775206e4 132775206e4 132775206e4 132775206e4 132775206e4
expect(Date.parse('2012-01-29T12:00:00.000-23:59')).toBe(132792474e4); // 132792474e4 132792474e4 132792474e4 132792474e4 132792474e4
expect(Date.parse('2012-01-29T12:00:00.000+24:00')).toBeFalsy(); // NaN 1327752e6 NaN 1327752000000 1327752000000
expect(Date.parse('2012-01-29T12:00:00.000+24:01')).toBeFalsy(); // NaN NaN NaN 1327751940000 1327751940000
expect(Date.parse('2012-01-29T12:00:00.000+24:59')).toBeFalsy(); // NaN NaN NaN 1327748460000 1327748460000
expect(Date.parse('2012-01-29T12:00:00.000+25:00')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('2012-01-29T12:00:00.000+00:60')).toBeFalsy(); // NaN NaN NaN NaN NaN
expect(Date.parse('-271821-04-20T00:00:00.000+00:01')).toBeFalsy(); // NaN NaN NaN -864000000006e4 -864000008646e4
expect(Date.parse('-271821-04-20T00:01:00.000+00:01')).toBe(-8.64e15); // -8.64e15 NaN -8.64e15 -8.64e15 -864000008640e4
// When time zone is missed, local offset should be used (ES 5.1 bug)
// see https://bugs.ecmascript.org/show_bug.cgi?id=112
var tzOffset = Number(new Date(1970, 0));
// same as (new Date().getTimezoneOffset() * 60000)
expect(Date.parse('1970-01-01T00:00:00')).toBe(tzOffset); // tzOffset 0 0 0 NaN
});
it('should be able to coerce to a number', function () {
var actual = Number(new Date(1970, 0));
var expected = parseInt(actual, 10);
expect(actual).toBeDefined();
expect(actual).toBe(expected);
expect(isNaN(actual)).toBeFalsy();
});
});
describe('#toString()', function () {
var actual;
beforeEach(function () {
actual = (new Date(1970, 0)).toString();
});
it('should show correct date info for ' + actual, function () {
expect(actual).toMatch(/1970/);
expect(actual).toMatch(/jan/i);
expect(actual).toMatch(/thu/i);
expect(actual).toMatch(/00:00:00/);
});
});
describe('#valueOf()', function () {
// Note that new Date(1970, 0).valueOf() is 0 in UTC timezone.
// Check check that it's a number (and an int), not that it's "truthy".
var actual;
beforeEach(function () {
actual = (new Date(1970, 0)).valueOf();
});
it('should give a numeric value', function () {
expect(typeof actual).toBe('number');
});
it('should not be NaN', function () {
expect(isNaN(actual)).toBe(false);
});
it('should give an int value', function () {
expect(actual).toBe(Math.floor(actual));
});
});
describe('#getUTCDate()', function () {
it('should return the right value for negative dates', function () {
// Opera 10.6/11.61/Opera 12 bug
negativeDate.forEach(function (item) {
item.dates.forEach(function (date, index) {
expect(date.getUTCDate()).toBe(item.days[index], date);
});
});
});
});
describe('#getUTCDay()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date, index) {
expect(date.getUTCDay()).toBe(item.getUTCDay[index]);
});
});
});
});
describe('#getUTCFullYear()', function () {
it('should return the right value for negative dates', function () {
// Opera 10.6/11.61/Opera 12 bug
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getUTCFullYear()).toBe(-109252);
});
});
});
});
describe('#getUTCMonth()', function () {
it('should return the right value for negative dates', function () {
// Opera 10.6/11.61/Opera 12 bug
negativeDate.forEach(function (item, index) {
item.dates.forEach(function (date) {
expect(date.getUTCMonth()).toBe(index);
});
});
});
it('should return correct values', function () {
expect(new Date(8.64e15).getUTCMonth()).toBe(8);
expect(new Date(0).getUTCMonth()).toBe(0);
});
});
describe('#getUTCHours()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getUTCHours()).toBe(11);
});
});
});
});
describe('#getUTCMinutes()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getUTCMinutes()).toBe(59);
});
});
});
});
describe('#getUTCSeconds()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getUTCSeconds()).toBe(59);
});
});
});
});
describe('#getUTCMilliseconds()', function () {
it('should return the right value for negative dates', function () {
// Opera 10.6/11.61/Opera 12 bug
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getUTCMilliseconds()).toBe(708);
});
});
});
});
describe('#getDate()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date, index) {
expect(date.getDate()).toBe(item.days[index]);
});
});
});
});
describe('#getDay()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date, index) {
expect(date.getDay()).toBe(item.getDay[index]);
});
});
});
});
describe('#getFullYear()', function () {
it('should return the right value for negative dates', function () {
// Opera 10.6/11.61/Opera 12 bug
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getFullYear()).toBe(-109252);
});
});
});
});
describe('#getMonth()', function () {
it('should return the right value for negative dates', function () {
// Opera 10.6/11.61/Opera 12 bug
negativeDate.forEach(function (item, index) {
item.dates.forEach(function (date) {
expect(date.getMonth()).toBe(index);
});
});
});
});
describe('#getHours()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getHours() + Math.floor(date.getTimezoneOffset() / 60)).toBe(11);
});
});
});
});
describe('#getMinutes()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
var off = date.getTimezoneOffset();
var offHours = Math.floor(off / 60);
var offMins = off - (offHours * 60);
expect(date.getMinutes() + offMins).toBe(59);
});
});
});
});
describe('#getSeconds()', function () {
it('should return the right value for negative dates', function () {
negativeDate.forEach(function (item) {
item.dates.forEach(function (date, i) {
// the regex here is because in UTC, it's 59, but with TZData applied,
// which can have fractional hour offsets, it'll be 1.
expect(i + ':' + date.getSeconds()).toMatch(new RegExp(i + ':(?:' + 59 + '|' + 1 + ')'));
});
});
});
});
describe('#getMilliseconds()', function () {
it('should return the right value for negative dates', function () {
// Opera 10.6/11.61/Opera 12 bug
negativeDate.forEach(function (item) {
item.dates.forEach(function (date) {
expect(date.getMilliseconds()).toBe(708);
});
});
});
});
describe('#toISOString()', function () {
// TODO: write the rest of the test.
it('should support extended years', function () {
expect(new Date(-62198755200000).toISOString().indexOf('-000001-01-01')).toBe(0);
expect(new Date(8.64e15).toISOString().indexOf('+275760-09-13')).toBe(0);
});
it('should return correct dates', function () {
expect(new Date(-1).toISOString()).toBe('1969-12-31T23:59:59.999Z'); // Safari 5.1.5 "1969-12-31T23:59:59.-01Z"
negativeDate.forEach(function (item, index) {
var m = index + 1;
item.dates.forEach(function (date, idx) {
var d = item.days[idx];
expect(date.toISOString()).toBe('-109252-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + 'T11:59:59.708Z'); // Opera 11.61/Opera 12 bug with Date#getUTCMonth
});
});
});
});
describe('#toUTCString()', function () {
it('should return correct dates', function () {
expect(new Date(-1509842289600292).toUTCString()).toBe('Mon, 01 Jan -45875 11:59:59 GMT');
});
});
describe('#toDateString()', function () {
it('should return correct dates', function () {
expect(new Date(-1509842289600292).toDateString()).toBe('Mon Jan 01 -45875');
});
});
describe('#toString()', function () {
it('should return correct dates', function () {
var actual = new Date(1449662400000).toString();
var re = /^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/;
expect(re.test(actual)).toBe(true, actual);
});
});
describe('#toJSON()', function () {
// Opera 11.6x/12 bug
it('should call toISOString', function () {
var date = new Date(0);
date.toISOString = function () {
return 1;
};
expect(date.toJSON()).toBe(1);
});
it('should return null for not finite dates', function () {
var date = new Date(NaN),
json;
try {
json = date.toJSON();
} catch (e) {
/* invalid json */
expect(e).not.toEqual(jasmine.any(Error));
}
expect(json).toBe(null);
});
it('should return the isoString when stringified', function () {
var date = new Date();
expect(JSON.stringify(date.toISOString())).toBe(JSON.stringify(date));
});
});
});

48
node_modules/es5-shim/tests/spec/s-error.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
describe('Error', function () {
'use strict';
var supportsDescriptors = Object.defineProperty && (function () {
try {
var obj = {};
Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables
return obj.x === obj;
} catch (e) { /* this is ES3 */
return false;
}
}());
var ifSupportsDescriptorsIt = supportsDescriptors ? it : xit;
describe('#toString()', function () {
it('stringifies a newed error properly', function () {
var msg = 'test';
var error = new RangeError(msg);
expect(error.name).toBe('RangeError');
expect(error.message).toBe(msg);
expect(String(error)).toBe(error.name + ': ' + msg);
});
it('stringifies a thrown error properly', function () {
var msg = 'test';
var error;
try {
throw new RangeError(msg);
} catch (e) {
error = e;
}
expect(error.name).toBe('RangeError');
expect(error.message).toBe(msg);
expect(String(error)).toBe(error.name + ': ' + msg);
});
});
describe('enumerability of prototype properties', function () {
ifSupportsDescriptorsIt('#message', function () {
expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'message')).toBe(false);
});
ifSupportsDescriptorsIt('#name', function () {
expect(Object.prototype.propertyIsEnumerable.call(Error.prototype, 'name')).toBe(false);
});
});
});

174
node_modules/es5-shim/tests/spec/s-function.js generated vendored Normal file
View File

@ -0,0 +1,174 @@
describe('Function', function () {
'use strict';
describe('#apply()', function () {
it('works with arraylike objects', function () {
var arrayLike = { length: 4, 0: 1, 2: 4, 3: true };
var expectedArray = [1, undefined, 4, true];
var actualArray = (function () {
return Array.prototype.slice.apply(arguments);
}.apply(null, arrayLike));
expect(actualArray).toEqual(expectedArray);
});
});
describe('#bind()', function () {
var actual;
var testSubject = {
push: function (o) {
this.a.push(o);
}
};
var func = function func() {
Array.prototype.forEach.call(arguments, function (a) {
this.push(a);
}, this);
return this;
};
beforeEach(function () {
actual = [];
testSubject.a = [];
});
it('binds properly without a context', function () {
var context;
testSubject.func = function () {
context = this;
}.bind();
testSubject.func();
expect(context).toBe(function () { return this; }.call());
});
it('binds properly without a context, and still supplies bound arguments', function () {
var a, context;
testSubject.func = function () {
a = Array.prototype.slice.call(arguments);
context = this;
}.bind(undefined, 1, 2, 3);
testSubject.func(1, 2, 3);
expect(a).toEqual([1, 2, 3, 1, 2, 3]);
expect(context).toBe(function () { return this; }.call());
});
it('binds a context properly', function () {
testSubject.func = func.bind(actual);
testSubject.func(1, 2, 3);
expect(actual).toEqual([1, 2, 3]);
expect(testSubject.a).toEqual([]);
});
it('binds a context and supplies bound arguments', function () {
testSubject.func = func.bind(actual, 1, 2, 3);
testSubject.func(4, 5, 6);
expect(actual).toEqual([1, 2, 3, 4, 5, 6]);
expect(testSubject.a).toEqual([]);
});
it('returns properly without binding a context', function () {
testSubject.func = function () {
return this;
}.bind();
var context = testSubject.func();
expect(context).toBe(function () { return this; }.call());
});
it('returns properly without binding a context, and still supplies bound arguments', function () {
var context;
testSubject.func = function () {
context = this;
return Array.prototype.slice.call(arguments);
}.bind(undefined, 1, 2, 3);
actual = testSubject.func(1, 2, 3);
expect(context).toBe(function () { return this; }.call());
expect(actual).toEqual([1, 2, 3, 1, 2, 3]);
});
it('returns properly while binding a context properly', function () {
var ret;
testSubject.func = func.bind(actual);
ret = testSubject.func(1, 2, 3);
expect(ret).toBe(actual);
expect(ret).not.toBe(testSubject);
});
it('returns properly while binding a context and supplies bound arguments', function () {
var ret;
testSubject.func = func.bind(actual, 1, 2, 3);
ret = testSubject.func(4, 5, 6);
expect(ret).toBe(actual);
expect(ret).not.toBe(testSubject);
});
it('has the new instance\'s context as a constructor', function () {
var actualContext;
var expectedContext = { foo: 'bar' };
testSubject.Func = function () {
actualContext = this;
}.bind(expectedContext);
var result = new testSubject.Func();
expect(result).toBeTruthy();
expect(actualContext).not.toBe(expectedContext);
});
it('passes the correct arguments as a constructor', function () {
var expected = { name: 'Correct' };
testSubject.Func = function (arg) {
expect(Object.prototype.hasOwnProperty.call(this, 'name')).toBe(false);
return arg;
}.bind({ name: 'Incorrect' });
var ret = new testSubject.Func(expected);
expect(ret).toBe(expected);
});
it('returns the return value of the bound function when called as a constructor', function () {
var oracle = [1, 2, 3];
var Subject = function () {
expect(this).not.toBe(oracle);
return oracle;
}.bind(null);
var result = new Subject();
expect(result).toBe(oracle);
});
it('returns the correct value if constructor returns primitive', function () {
var Subject = function (oracle) {
expect(this).not.toBe(oracle);
return oracle;
}.bind(null);
var primitives = ['asdf', null, true, 1];
for (var i = 0; i < primitives.length; ++i) {
expect(new Subject(primitives[i])).not.toBe(primitives[i]);
}
var objects = [[1, 2, 3], {}, function () {}];
for (var j = 0; j < objects.length; ++j) {
expect(new Subject(objects[j])).toBe(objects[j]);
}
});
it('returns the value that instance of original "class" when called as a constructor', function () {
var ClassA = function (x) {
this.name = x || 'A';
};
var ClassB = ClassA.bind(null, 'B');
var result = new ClassB();
expect(result instanceof ClassA).toBe(true);
expect(result instanceof ClassB).toBe(true);
});
it('sets a correct length without thisArg', function () {
var Subject = function (a, b, c) { return a + b + c; }.bind();
expect(Subject.length).toBe(3);
});
it('sets a correct length with thisArg', function () {
var Subject = function (a, b, c) { return a + b + c + this.d; }.bind({ d: 1 });
expect(Subject.length).toBe(3);
});
it('sets a correct length with thisArg and first argument', function () {
var Subject = function (a, b, c) { return a + b + c + this.d; }.bind({ d: 1 }, 1);
expect(Subject.length).toBe(2);
});
it('sets a correct length without thisArg and first argument', function () {
var Subject = function (a, b, c) { return a + b + c; }.bind(undefined, 1);
expect(Subject.length).toBe(2);
});
it('sets a correct length without thisArg and too many argument', function () {
var Subject = function (a, b, c) { return a + b + c; }.bind(undefined, 1, 2, 3, 4);
expect(Subject.length).toBe(0);
});
});
});

101
node_modules/es5-shim/tests/spec/s-global.js generated vendored Normal file
View File

@ -0,0 +1,101 @@
describe('global methods', function () {
'use strict';
var foo = function foo() {};
var functionsHaveNames = foo.name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
var ifSymbolsIt = hasSymbols ? it : xit;
var is = function (x, y) {
if (x === 0 && y === 0) {
return 1 / x === 1 / y;
}
return x === y;
};
describe('parseInt', function () {
/* eslint-disable radix */
ifFunctionsHaveNamesIt('has the right name', function () {
expect(parseInt.name).toBe('parseInt');
});
it('accepts a radix', function () {
for (var i = 2; i <= 36; ++i) {
expect(parseInt('10', i)).toBe(i);
}
});
it('defaults the radix to 10 when the number does not start with 0x or 0X', function () {
[
'01',
'08',
'10',
'42'
].forEach(function (str) {
expect(parseInt(str)).toBe(parseInt(str, 10));
});
});
it('defaults the radix to 16 when the number starts with 0x or 0X', function () {
expect(parseInt('0x16')).toBe(parseInt('0x16', 16));
expect(parseInt('0X16')).toBe(parseInt('0X16', 16));
});
it('ignores leading whitespace', function () {
expect(parseInt(' 0x16')).toBe(parseInt('0x16', 16));
expect(parseInt(' 42')).toBe(parseInt('42', 10));
expect(parseInt(' 08')).toBe(parseInt('08', 10));
var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003'
+ '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028'
+ '\u2029\uFEFF';
expect(parseInt(ws + '08')).toBe(parseInt('08', 10));
expect(parseInt(ws + '0x16')).toBe(parseInt('0x16', 16));
});
it('defaults the radix properly when not a true number', function () {
var fakeZero = { valueOf: function () { return 0; } };
expect(parseInt('08', fakeZero)).toBe(parseInt('08', 10));
expect(parseInt('0x16', fakeZero)).toBe(parseInt('0x16', 16));
});
it('allows sign-prefixed hex values', function () {
expect(parseInt('-0xF')).toBe(-15);
expect(parseInt('-0xF', 16)).toBe(-15);
expect(parseInt('+0xF')).toBe(15);
expect(parseInt('+0xF', 16)).toBe(15);
});
it('NaN parsing', function () {
expect(parseInt()).toBeNaN();
expect(parseInt(undefined)).toBeNaN();
expect(parseInt(null)).toBeNaN();
expect(parseInt(NaN)).toBeNaN();
});
ifSymbolsIt('throws on symbols', function () {
expect(function () { parseInt(Symbol('')); }).toThrow();
expect(function () { parseInt(Object(Symbol(''))); }).toThrow();
});
/* eslint-enable radix */
});
describe('parseFloat()', function () {
it('works with zeroes', function () {
expect(is(parseFloat('0'), 0) ? '+0' : '-0').toBe('+0');
expect(is(parseFloat(' 0'), 0) ? '+0' : '-0').toBe('+0');
expect(is(parseFloat('+0'), 0) ? '+0' : '-0').toBe('+0');
expect(is(parseFloat(' +0'), 0) ? '+0' : '-0').toBe('+0');
expect(is(parseFloat('-0'), -0) ? '-0' : '+0').toBe('-0');
expect(is(parseFloat(' -0'), -0) ? '-0' : '+0').toBe('-0');
});
it('NaN parsing', function () {
expect(parseFloat(undefined)).toBeNaN();
expect(parseFloat(null)).toBeNaN();
expect(parseFloat(NaN)).toBeNaN();
});
});
});

61
node_modules/es5-shim/tests/spec/s-number.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
describe('Number', function () {
'use strict';
describe('#toFixed()', function () {
it('should convert numbers correctly', function () {
expect((0.00008).toFixed(3)).toBe('0.000');
expect((0.9).toFixed(0)).toBe('1');
expect((1.255).toFixed(2)).toBe('1.25');
expect((1843654265.0774949).toFixed(5)).toBe('1843654265.07749');
expect((1000000000000000128).toFixed(0)).toBe('1000000000000000128');
});
});
describe('#toPrecision()', function () {
// the spec allows for this test to fail.
it('throws a RangeError when < 1 or > 21 (or > 100 in ES2018+)', function () {
expect(function () { return (0.9).toPrecision(0); }).toThrow();
expect(function () {
return [
(0.9).toPrecision(22), // ES2018 increased the limit from 21 to 100
(0.9).toPrecision(101)
];
}).toThrow();
});
it('works as expected', function () {
expect((0.00008).toPrecision(3)).toBe('0.0000800');
expect((1.255).toPrecision(2)).toBe('1.3');
expect((1843654265.0774949).toPrecision(13)).toBe('1843654265.077');
expect(NaN.toPrecision(1)).toBe('NaN');
});
it('works with an undefined precision', function () {
var num = 123.456;
expect(num.toPrecision()).toBe(String(num));
expect(num.toPrecision(undefined)).toBe(String(num));
});
});
describe('constants', function () {
it('should have MAX_VALUE', function () {
expect(Number.MAX_VALUE).toBe(1.7976931348623157e308);
});
it('should have MIN_VALUE', function () {
expect(Number.MIN_VALUE).toBe(5e-324);
});
it('should have NaN', function () {
expect(Number.NaN).not.toBe(Number.NaN);
});
it('should have POSITIVE_INFINITY', function () {
expect(Number.POSITIVE_INFINITY).toBe(Infinity);
});
it('should have NEGATIVE_INFINITY', function () {
expect(Number.NEGATIVE_INFINITY).toBe(-Infinity);
});
});
});

366
node_modules/es5-shim/tests/spec/s-object.js generated vendored Normal file
View File

@ -0,0 +1,366 @@
/* global window */
var has = Object.prototype.hasOwnProperty;
var supportsDescriptors = Object.defineProperty && (function () {
try {
var obj = {};
Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables
return obj.x === obj;
} catch (e) { /* this is ES3 */
return false;
}
}());
var ifWindowIt = typeof window === 'undefined' ? xit : it;
var extensionsPreventible = typeof Object.preventExtensions === 'function' && (function () {
var obj = {};
Object.preventExtensions(obj);
obj.a = 3;
return obj.a !== 3;
}());
var ifExtensionsPreventibleIt = extensionsPreventible ? it : xit;
var canSeal = typeof Object.seal === 'function' && (function () {
var obj = { a: 3 };
Object.seal(obj);
delete obj.a;
return obj.a === 3;
}());
var ifCanSealIt = canSeal ? it : xit;
var canFreeze = typeof Object.freeze === 'function' && (function () {
var obj = {};
Object.freeze(obj);
obj.a = 3;
return obj.a !== 3;
}());
var ifCanFreezeIt = canFreeze ? it : xit;
describe('Object', function () {
'use strict';
describe('.keys()', function () {
var obj = {
str: 'boz',
obj: { },
arr: [],
bool: true,
num: 42,
'null': null,
undefined: undefined
};
var loopedValues = [];
for (var key in obj) {
loopedValues.push(key);
}
var keys = Object.keys(obj);
it('should have correct length', function () {
expect(keys.length).toBe(7);
});
describe('arguments objects', function () {
it('works with an arguments object', function () {
(function () {
expect(arguments.length).toBe(3);
expect(Object.keys(arguments).length).toBe(arguments.length);
expect(Object.keys(arguments)).toEqual(['0', '1', '2']);
}(1, 2, 3));
});
it('works with a legacy arguments object', function () {
var FakeArguments = function (args) {
args.forEach(function (arg, i) {
this[i] = arg;
}.bind(this));
};
FakeArguments.prototype.length = 3;
FakeArguments.prototype.callee = function () {};
var fakeOldArguments = new FakeArguments(['a', 'b', 'c']);
expect(Object.keys(fakeOldArguments)).toEqual(['0', '1', '2']);
});
});
it('should return an Array', function () {
expect(Array.isArray(keys)).toBe(true);
});
it('should return names which are own properties', function () {
keys.forEach(function (name) {
expect(has.call(obj, name)).toBe(true);
});
});
it('should return names which are enumerable', function () {
keys.forEach(function (name) {
expect(loopedValues.indexOf(name)).toNotBe(-1);
});
});
// ES6 Object.keys does not require this throw
xit('should throw error for non object', function () {
var e = {};
expect(function () {
try {
Object.keys(42);
} catch (err) {
throw e;
}
}).toThrow(e);
});
describe('enumerating over non-enumerable properties', function () {
it('has no enumerable keys on a Function', function () {
var Foo = function () {};
expect(Object.keys(Foo.prototype)).toEqual([]);
});
it('has no enumerable keys on a boolean', function () {
expect(Object.keys(Boolean.prototype)).toEqual([]);
});
it('has no enumerable keys on an object', function () {
expect(Object.keys(Object.prototype)).toEqual([]);
});
});
it('works with boxed primitives', function () {
expect(Object.keys(Object('hello'))).toEqual(['0', '1', '2', '3', '4']);
});
it('works with boxed primitives with extra properties', function () {
var x = Object('x');
x.y = 1;
var actual = Object.keys(x);
var expected = ['0', 'y'];
actual.sort();
expected.sort();
expect(actual).toEqual(expected);
});
ifWindowIt('can serialize all objects on the `window`', function () {
var windowItemKeys, exception;
var excludedKeys = ['window', 'console', 'parent', 'self', 'frame', 'frames', 'frameElement', 'external', 'height', 'width', 'top', 'localStorage', 'applicationCache'];
if (supportsDescriptors) {
Object.defineProperty(window, 'thrower', {
configurable: true,
get: function () { throw new RangeError('thrower!'); }
});
}
for (var k in window) {
exception = void 0;
windowItemKeys = exception;
if (excludedKeys.indexOf(k) === -1 && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
try {
windowItemKeys = Object.keys(window[k]);
} catch (e) {
exception = e;
}
expect(Array.isArray(windowItemKeys)).toBe(true);
expect(exception).toBeUndefined();
}
}
if (supportsDescriptors) {
delete window.thrower;
}
});
});
describe('.isExtensible()', function () {
var obj = { };
it('should return true if object is extensible', function () {
expect(Object.isExtensible(obj)).toBe(true);
});
ifExtensionsPreventibleIt('should return false if object is not extensible', function () {
expect(Object.isExtensible(Object.preventExtensions(obj))).toBe(false);
});
ifCanSealIt('should return false if object is sealed', function () {
expect(Object.isExtensible(Object.seal(obj))).toBe(false);
});
ifCanFreezeIt('should return false if object is frozen', function () {
expect(Object.isExtensible(Object.freeze(obj))).toBe(false);
});
it('should throw error for non object', function () {
try {
// note: in ES6, this is expected to return false.
expect(Object.isExtensible(42)).toBe(false);
} catch (err) {
expect(err).toEqual(jasmine.any(TypeError));
}
});
});
describe('.defineProperty()', function () {
var obj;
beforeEach(function () {
obj = {};
Object.defineProperty(obj, 'name', {
value: 'Testing',
configurable: true,
enumerable: true,
writable: true
});
});
it('should return the initial value', function () {
expect(has.call(obj, 'name')).toBeTruthy();
expect(obj.name).toBe('Testing');
});
it('should be setable', function () {
obj.name = 'Other';
expect(obj.name).toBe('Other');
});
it('should return the parent initial value', function () {
var child = Object.create(obj, {});
expect(child.name).toBe('Testing');
expect(has.call(child, 'name')).toBeFalsy();
});
it('should not override the parent value', function () {
var child = Object.create(obj, {});
Object.defineProperty(child, 'name', { value: 'Other' });
expect(obj.name).toBe('Testing');
expect(child.name).toBe('Other');
});
it('should throw error for non object', function () {
expect(function () {
Object.defineProperty(42, 'name', {});
}).toThrow();
});
it('should not throw error for empty descriptor', function () {
expect(function () {
Object.defineProperty({}, 'name', {});
}).not.toThrow();
});
});
describe('.getOwnPropertyDescriptor()', function () {
it('should return undefined because the object does not own the property', function () {
var descr = Object.getOwnPropertyDescriptor({}, 'name');
expect(descr).toBeUndefined();
});
it('should return a data descriptor', function () {
var descr = Object.getOwnPropertyDescriptor({ name: 'Testing' }, 'name');
var expected = {
value: 'Testing',
enumerable: true,
writable: true,
configurable: true
};
expect(descr).toEqual(expected);
});
it('should return undefined because the object does not own the property', function () {
var descr = Object.getOwnPropertyDescriptor(Object.create({ name: 'Testing' }, {}), 'name');
expect(descr).toBeUndefined();
});
it('should return a data descriptor', function () {
var expected = {
value: 'Testing',
configurable: true,
enumerable: true,
writable: true
};
var obj = Object.create({}, { name: expected });
var descr = Object.getOwnPropertyDescriptor(obj, 'name');
expect(descr).toEqual(expected);
});
it('should throw error for non object', function () {
try {
// note: in ES6, we expect this to return undefined.
expect(Object.getOwnPropertyDescriptor(42, 'name')).toBeUndefined();
} catch (err) {
expect(err).toEqual(jasmine.any(TypeError));
}
});
});
describe('.getPrototypeOf()', function () {
it('should return the [[Prototype]] of an object', function () {
var Foo = function () {};
var proto = Object.getPrototypeOf(new Foo());
expect(proto).toBe(Foo.prototype);
});
it('should shamone to the `Object.prototype` if `object.constructor` is not a function', function () {
var Foo = function () {};
Foo.prototype.constructor = 1;
var proto = Object.getPrototypeOf(new Foo()),
fnToString = Function.prototype.toString;
if (fnToString.call(Object.getPrototypeOf).indexOf('[native code]') < 0) {
expect(proto).toBe(Object.prototype);
} else {
expect(proto).toBe(Foo.prototype);
}
});
it('should throw error for non object', function () {
try {
expect(Object.getPrototypeOf(1)).toBe(Number.prototype); // ES6 behavior
} catch (err) {
expect(err).toEqual(jasmine.any(TypeError));
}
});
it('should return null on Object.create(null)', function () {
var obj = Object.create(null);
expect(Object.getPrototypeOf(obj) === null).toBe(true);
});
});
describe('.defineProperties()', function () {
it('should define the constructor property', function () {
var target = {};
var newProperties = { constructor: { value: 'new constructor' } };
Object.defineProperties(target, newProperties);
expect(target.constructor).toBe('new constructor');
});
});
describe('.create()', function () {
it('should create objects with no properties when called as `Object.create(null)`', function () {
var obj = Object.create(null);
expect('hasOwnProperty' in obj).toBe(false);
expect('toString' in obj).toBe(false);
expect('constructor' in obj).toBe(false);
var protoIsEnumerable = false;
for (var k in obj) {
if (k === '__proto__') {
protoIsEnumerable = true;
}
}
expect(protoIsEnumerable).toBe(false);
expect(obj instanceof Object).toBe(false);
});
});
});

26
node_modules/es5-shim/tests/spec/s-regexp.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
describe('RegExp', function () {
'use strict';
describe('#toString()', function () {
describe('literals', function () {
it('should return correct flags and in correct order', function () {
expect(String(/pattern/)).toBe('/pattern/');
expect(String(/pattern/i)).toBe('/pattern/i');
expect(String(/pattern/mi)).toBe('/pattern/im');
expect(String(/pattern/im)).toBe('/pattern/im');
expect(String(/pattern/mgi)).toBe('/pattern/gim');
});
});
describe('objects', function () {
it('should return correct flags and in correct order', function () {
/* eslint prefer-regex-literals: 0 */
expect(String(new RegExp('pattern'))).toBe('/pattern/');
expect(String(new RegExp('pattern', 'i'))).toBe('/pattern/i');
expect(String(new RegExp('pattern', 'mi'))).toBe('/pattern/im');
expect(String(new RegExp('pattern', 'im'))).toBe('/pattern/im');
expect(String(new RegExp('pattern', 'mgi'))).toBe('/pattern/gim');
});
});
});
});

267
node_modules/es5-shim/tests/spec/s-string.js generated vendored Normal file
View File

@ -0,0 +1,267 @@
describe('String', function () {
'use strict';
describe('#trim()', function () {
var test = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
it('trims all ES5 whitespace', function () {
expect(test.trim()).toBe('Hello, World!');
expect(test.trim().length).toBe(13);
});
it('does not trim the zero-width space', function () {
expect('\u200b'.trim()).toBe('\u200b');
expect('\u200b'.trim().length).toBe(1);
});
});
describe('#replace()', function () {
it('returns undefined for non-capturing groups', function () {
var groups = [];
'x'.replace(/x(.)?/g, function (m, group) {
groups.push(group); /* "" in FF, `undefined` in CH/WK/IE */
});
expect(groups.length).toBe(1);
expect(groups[0]).toBeUndefined();
});
it('should not fail in Firefox', function () {
expect(function () {
return '* alef\n* beth \n* gimel~0\n'.replace(
/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
function (match, m1, m2, m3, m4) { return '<li>' + m4 + '</li>\n'; }
);
}).not.toThrow();
});
});
describe('#split()', function () {
var test = 'ab';
it('If "separator" is undefined must return Array with one String - "this" string', function () {
expect(test.split()).toEqual([test]);
expect(test.split(void 0)).toEqual([test]);
});
it('If "separator" is undefined and "limit" set to 0 must return Array[]', function () {
expect(test.split(void 0, 0)).toEqual([]);
});
describe('Tests from Steven Levithan', function () {
it("''.split() results in ['']", function () {
expect(''.split()).toEqual(['']);
});
it("''.split(/./) results in ['']", function () {
expect(''.split(/./)).toEqual(['']);
});
it("''.split(/.?/) results in []", function () {
expect(''.split(/.?/)).toEqual([]);
});
it("''.split(/.??/) results in []", function () {
expect(''.split(/.??/)).toEqual([]);
});
it("'ab'.split(/a*/) results in ['', 'b']", function () {
expect('ab'.split(/a*/)).toEqual(['', 'b']);
});
it("'ab'.split(/a*?/) results in ['a', 'b']", function () {
expect('ab'.split(/a*?/)).toEqual(['a', 'b']);
});
it("'ab'.split(/(?:ab)/) results in ['', '']", function () {
expect('ab'.split(/(?:ab)/)).toEqual(['', '']);
});
it("'ab'.split(/(?:ab)*/) results in ['', '']", function () {
expect('ab'.split(/(?:ab)*/)).toEqual(['', '']);
});
it("'ab'.split(/(?:ab)*?/) results in ['a', 'b']", function () {
expect('ab'.split(/(?:ab)*?/)).toEqual(['a', 'b']);
});
it("'test'.split('') results in ['t', 'e', 's', 't']", function () {
expect('test'.split('')).toEqual(['t', 'e', 's', 't']);
});
it("'test'.split() results in ['test']", function () {
expect('test'.split()).toEqual(['test']);
});
it("'111'.split(1) results in ['', '', '', '']", function () {
expect('111'.split(1)).toEqual(['', '', '', '']);
});
it("'test'.split(/(?:)/, 2) results in ['t', 'e']", function () {
expect('test'.split(/(?:)/, 2)).toEqual(['t', 'e']);
});
it("'test'.split(/(?:)/, -1) results in ['t', 'e', 's', 't']", function () {
expect('test'.split(/(?:)/, -1)).toEqual(['t', 'e', 's', 't']);
});
it("'test'.split(/(?:)/, undefined) results in ['t', 'e', 's', 't']", function () {
expect('test'.split(/(?:)/, undefined)).toEqual(['t', 'e', 's', 't']);
});
it("'test'.split(/(?:)/, null) results in []", function () {
expect('test'.split(/(?:)/, null)).toEqual([]);
});
it("'test'.split(/(?:)/, NaN) results in []", function () {
expect('test'.split(/(?:)/, NaN)).toEqual([]);
});
it("'test'.split(/(?:)/, true) results in ['t']", function () {
expect('test'.split(/(?:)/, true)).toEqual(['t']);
});
it("'test'.split(/(?:)/, '2') results in ['t', 'e']", function () {
expect('test'.split(/(?:)/, '2')).toEqual(['t', 'e']);
});
it("'test'.split(/(?:)/, 'two') results in []", function () {
expect('test'.split(/(?:)/, 'two')).toEqual([]);
});
it("'a'.split(/-/) results in ['a']", function () {
expect('a'.split(/-/)).toEqual(['a']);
});
it("'a'.split(/-?/) results in ['a']", function () {
expect('a'.split(/-?/)).toEqual(['a']);
});
it("'a'.split(/-??/) results in ['a']", function () {
expect('a'.split(/-??/)).toEqual(['a']);
});
it("'a'.split(/a/) results in ['', '']", function () {
expect('a'.split(/a/)).toEqual(['', '']);
});
it("'a'.split(/a?/) results in ['', '']", function () {
expect('a'.split(/a?/)).toEqual(['', '']);
});
it("'a'.split(/a??/) results in ['a']", function () {
expect('a'.split(/a??/)).toEqual(['a']);
});
it("'ab'.split(/-/) results in ['ab']", function () {
expect('ab'.split(/-/)).toEqual(['ab']);
});
it("'ab'.split(/-?/) results in ['a', 'b']", function () {
expect('ab'.split(/-?/)).toEqual(['a', 'b']);
});
it("'ab'.split(/-??/) results in ['a', 'b']", function () {
expect('ab'.split(/-??/)).toEqual(['a', 'b']);
});
it("'a-b'.split(/-/) results in ['a', 'b']", function () {
expect('a-b'.split(/-/)).toEqual(['a', 'b']);
});
it("'a-b'.split(/-?/) results in ['a', 'b']", function () {
expect('a-b'.split(/-?/)).toEqual(['a', 'b']);
});
it("'a-b'.split(/-??/) results in ['a', '-', 'b']", function () {
expect('a-b'.split(/-??/)).toEqual(['a', '-', 'b']);
});
it("'a--b'.split(/-/) results in ['a', '', 'b']", function () {
expect('a--b'.split(/-/)).toEqual(['a', '', 'b']);
});
it("'a--b'.split(/-?/) results in ['a', '', 'b']", function () {
expect('a--b'.split(/-?/)).toEqual(['a', '', 'b']);
});
it("'a--b'.split(/-??/) results in ['a', '-', '-', 'b']", function () {
expect('a--b'.split(/-??/)).toEqual(['a', '-', '-', 'b']);
});
it("''.split(/()()/) results in []", function () {
expect(''.split(/()()/)).toEqual([]);
});
it("'.'.split(/()()/) results in ['.']", function () {
expect('.'.split(/()()/)).toEqual(['.']);
});
it("'.'.split(/(.?)(.?)/) results in ['', '.', '', '']", function () {
expect('.'.split(/(.?)(.?)/)).toEqual(['', '.', '', '']);
});
it("'.'.split(/(.??)(.??)/) results in ['.']", function () {
expect('.'.split(/(.??)(.??)/)).toEqual(['.']);
});
it("'.'.split(/(.)?(.)?/) results in ['', '.', undefined, '']", function () {
expect('.'.split(/(.)?(.)?/)).toEqual(['', '.', undefined, '']);
});
it("'A<B>bold</B>and<CODE>coded</CODE>'.split(/<(\\/)?([^<>]+)>/) results in ['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']", function () {
expect('A<B>bold</B>and<CODE>coded</CODE>'.split(/<(\/)?([^<>]+)>/)).toEqual(['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']);
});
it("'tesst'.split(/(s)*/) results in ['t', undefined, 'e', 's', 't']", function () {
expect('tesst'.split(/(s)*/)).toEqual(['t', undefined, 'e', 's', 't']);
});
it("'tesst'.split(/(s)*?/) results in ['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']", function () {
expect('tesst'.split(/(s)*?/)).toEqual(['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']);
});
it("'tesst'.split(/(s*)/) results in ['t', '', 'e', 'ss', 't']", function () {
expect('tesst'.split(/(s*)/)).toEqual(['t', '', 'e', 'ss', 't']);
});
it("'tesst'.split(/(s*?)/) results in ['t', '', 'e', '', 's', '', 's', '', 't']", function () {
expect('tesst'.split(/(s*?)/)).toEqual(['t', '', 'e', '', 's', '', 's', '', 't']);
});
it("'tesst'.split(/(?:s)*/) results in ['t', 'e', 't']", function () {
expect('tesst'.split(/(?:s)*/)).toEqual(['t', 'e', 't']);
});
it("'tesst'.split(/(?=s+)/) results in ['te', 's', 'st']", function () {
expect('tesst'.split(/(?=s+)/)).toEqual(['te', 's', 'st']);
});
it("'test'.split('t') results in ['', 'es', '']", function () {
expect('test'.split('t')).toEqual(['', 'es', '']);
});
it("'test'.split('es') results in ['t', 't']", function () {
expect('test'.split('es')).toEqual(['t', 't']);
});
it("'test'.split(/t/) results in ['', 'es', '']", function () {
expect('test'.split(/t/)).toEqual(['', 'es', '']);
});
it("'test'.split(/es/) results in ['t', 't']", function () {
expect('test'.split(/es/)).toEqual(['t', 't']);
});
it("'test'.split(/(t)/) results in ['', 't', 'es', 't', '']", function () {
expect('test'.split(/(t)/)).toEqual(['', 't', 'es', 't', '']);
});
it("'test'.split(/(es)/) results in ['t', 'es', 't']", function () {
expect('test'.split(/(es)/)).toEqual(['t', 'es', 't']);
});
it("'test'.split(/(t)(e)(s)(t)/) results in ['', 't', 'e', 's', 't', '']", function () {
expect('test'.split(/(t)(e)(s)(t)/)).toEqual(['', 't', 'e', 's', 't', '']);
});
it("'.'.split(/(((.((.??)))))/) results in ['', '.', '.', '.', '', '', '']", function () {
expect('.'.split(/(((.((.??)))))/)).toEqual(['', '.', '.', '.', '', '', '']);
});
it("'.'.split(/(((((.??)))))/) results in ['.']", function () {
expect('.'.split(/(((((.??)))))/)).toEqual(['.']);
});
it("'a b c d'.split(/ /, -(Math.pow(2, 32) - 1)) results in ['a']", function () {
expect('a b c d'.split(/ /, -(Math.pow(2, 32) - 1))).toEqual(['a']);
});
it("'a b c d'.split(/ /, Math.pow(2, 32) + 1) results in ['a']", function () {
expect('a b c d'.split(/ /, Math.pow(2, 32) + 1)).toEqual(['a']);
});
it("'a b c d'.split(/ /, Infinity) results in []", function () {
expect('a b c d'.split(/ /, Infinity)).toEqual([]);
});
});
it('works with the second argument', function () {
expect('a b'.split(/ /, 1)).toEqual(['a']);
});
});
describe('#indexOf()', function () {
it('has basic support', function () {
expect('abcab'.indexOf('a')).toBe(0);
expect('abcab'.indexOf('a', 1)).toBe(3);
expect('abcab'.indexOf('a', 4)).toBe(-1);
});
it('works with unicode', function () {
expect('あいabcあいabc'.indexOf('あい')).toBe(0);
expect('あいabcあいabc'.indexOf('あい', 0)).toBe(0);
expect('あいabcあいabc'.indexOf('あい', 1)).toBe(5);
expect('あいabcあいabc'.indexOf('あい', 6)).toBe(-1);
});
});
describe('#lastIndexOf()', function () {
it('has the right length', function () {
expect(String.prototype.lastIndexOf.length).toBe(1);
});
it('has basic support', function () {
expect('abcd'.lastIndexOf('d')).toBe(3);
expect('abcd'.lastIndexOf('d', 3)).toBe(3);
expect('abcd'.lastIndexOf('d', 2)).toBe(-1);
});
it('works with unicode', function () {
expect('abcあい'.lastIndexOf('あい')).toBe(3);
expect('abcあい'.lastIndexOf('あい', 3)).toBe(3);
expect('abcあい'.lastIndexOf('あい', 2)).toBe(-1);
});
});
});

20
node_modules/es6-shim/.editorconfig generated vendored Normal file
View File

@ -0,0 +1,20 @@
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 150
[CHANGELOG.md]
indent_style = space
indent_size = 2
[*.json]
max_line_length = off
[Makefile]
max_line_length = off

2
node_modules/es6-shim/.eslintignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
Gruntfile.js
*.min.js

56
node_modules/es6-shim/.eslintrc generated vendored Normal file
View File

@ -0,0 +1,56 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"array-bracket-newline": [0],
"array-element-newline": [0],
"callback-return": [0],
"complexity": [1],
"consistent-return": [1],
"dot-notation": [2, { "allowKeywords": false }],
"eqeqeq": [2, "allow-null"],
"func-name-matching": [0],
"global-require": [0],
"id-length": [2, { "min": 1, "max": 40 }],
"indent": [2, 2],
"max-depth": [2, 5],
"max-len": 0,
"max-lines": [1],
"max-lines-per-function": [0],
"max-params": [2, 4],
"max-nested-callbacks": [2, 5],
"max-statements": [1, 25],
"max-statements-per-line": [2, { "max": 2 }],
"multiline-comment-style": [0],
"new-cap": [2, { "capIsNewExceptions": ["Call", "Construct", "CreateHTML", "GetIterator", "GetMethod", "IsCallable", "IsConstructor", "IsPromise", "IsRegExp", "IteratorClose", "IteratorComplete", "IteratorNext", "IteratorStep", "Map", "OrigNumber", "RequireObjectCoercible", "SameValue", "SameValueZero", "Set", "SpeciesConstructor", "ToInteger", "ToLength", "ToNumber", "ToObject", "ToString", "ToUint32", "TypeIsObject"] }],
"no-constant-condition": [1],
"no-continue": [1],
"no-extend-native": [2, { "exceptions": ["Set"] }],
"no-extra-parens": [1],
"no-func-assign": [1],
"no-implicit-coercion": [2, {
"boolean": false,
"number": false,
"string": true
}],
"no-invalid-this": [0],
"no-invalid-regexp": [2, { "allowConstructorFlags": ["u", "y"] }],
"no-magic-numbers": [0],
"no-native-reassign": [2, { "exceptions": ["Number", "Promise", "RegExp"] }],
"no-negated-condition": [1],
"no-plusplus": [1],
"no-restricted-syntax": [2, "DebuggerStatement", "LabeledStatement", "WithStatement"],
"no-shadow": [1],
"no-underscore-dangle": [0],
"no-unused-vars": [1, { "vars": "all", "args": "after-used" }],
"no-use-before-define": [1],
"no-useless-call": [0],
"object-curly-newline": [1],
"operator-linebreak": [2, "after"],
"sort-keys": [0],
"spaced-comment": [0],
"strict": [0]
}
}

612
node_modules/es6-shim/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,612 @@
# es6-shim 0.35.5 (7 March 2019)
* [Fix] `es6-sham`: `Function.prototype.name`: dont poison the getter when the receiver is `Function.prototype` (#454)
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`
* [Dev Deps] remove `jscs` and `jshint`
# es6-shim 0.35.4 (29 October 2018)
* [Fix] protect against evil build processes by ensuring these feature tests dont look like no-ops that are safe to remove
* [Fix] broken `hasULPDistance` → working `withinULPDistance` helper
* [Fix] `acosh`: fix precision (#338)
* [Fix] `Math.{asinh,atanh,cosh,sinh}` precision (from #338)
* [Fix] Google Translate adds a broken `Set` to the global scope (#438)
* [Fix] Distinguish Set and Map iterators (#387)
* [Docs] Tweaking documentation specifying inclusion order (#435)
# es6-shim 0.35.3 (23 January 2017)
* [Fix] avoid needlessly shimming `Array#{find, findIndex}` (#433)
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `grunt-saucelabs`
* [Tests] up to `node` `v7.4`, `v4.7`; improve test matrix
# es6-shim 0.35.2 (3 December 2016)
* [Fix] ensure `document.all` is not treated as a non-object-coercible (#428)
* [Performance] Use original map for data backing when possible (#429, #422)
* [Dev Deps] update `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`, `jshint`, `mocha`, `promises-plus-tests`, `uglify-js`
* [Tests] up to `node` `v7.2`, `v5.12`, `v4.6`; improve test matrix
* [Tests] avoid function name inference in node 7+
* [Tests] add Firefox Nightly error messages to fix false failure
# es6-shim 0.35.1 (12 May 2016)
* [Fix] Functions are objects (#418)
* [Fix] use `createDataPropertyOrThrow` in `Array.from`, rather than `[[Put]]` (#415)
* [Refactor] Use `iteratorResult` internally for iterator result objects
* [Refactor] Simplify logic for Math.tanh (#412)
* [Robustness] cache `Math` constants
* [Robustness] cache `Math.exp`
* [Robustness] dont rely on a `Math` lookup inside `Math.asinh`
* [Robustness] use cached `Number.isNaN`
* [Robustness] cache `Math.sign`
* [Dev Deps] update `es5-shim`, `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `grunt-contrib-connect`, `grunt-contrib-watch`, `evalmd`, `jshint`
* [Tests] up to `node` `v6.1`, `v5.10`, `v4.4`
* [Tests] `npm run --silent`, use “pretest” for linting
* [Tests] `RegExp#toString`: Chrome Canary 51 produces `/undefined/`
* [Docs] update ES6 draft comment URLs to point to the published spec
# es6-shim 0.35.0 (29 Feb 2016)
* [Breaking] remove `Reflect.enumerate` (#405)
* [New] Add `Array#indexOf` from post-ES6 errata
* [New] Ensure `RegExp#toString` is compliant
* [New] [sham] Add `Function#toString` to `es6-sham`
* [Fix] ensure that a non-object `globals.Reflect` doesnt break the shim (#392)
* [Fix] In ES3 browsers (like Safari 4) `Reflect.getPrototypeOf` is undefined
* [Fix] `Object.keys`: handle regexes in ES3 browsers (#287)
* [Performance] Early exit from tanh for values outside of +-20 at limits of JS precision (#411)
* [Tests] `Function#name` on `new Function`s is empty string in v8
* [Tests] `Function#name` is non-configurable pre-ES6
* [Tests] up to `node` `v5.7`, `v4.3`
* [Docs] correct readme; we sham Function#name, not toString
# es6-shim 0.34.4 (9 Feb 2016)
* [Fix] 'Uncaught (in promise) TypeError' in Chrome 48 (#408, #407)
* [Fix] handle the obscure case where `startsWith` throws on the second parameter (#399)
* [Tests] silence a promise rejection error in Chrome
# es6-shim 0.34.3 (8 Feb 2016)
* [Fix] Suppress “uncaught rejection” warnings in Chrome 50 console (#403)
* [Fix] ensure ES3 `Number` constants dont get lost in ES3 browsers (#402)
* [Dev Deps] update `chai`, `es5-shim`, `jscs`, `mocha`
* [Tests] up to `node` `v5.5`
# es6-shim 0.34.2 (22 Jan 2016)
* [Fix] `JSON.stringify` should ignore a replacer arg unless its an array or function.
* [Fix] `Array#copyWithin`: check for inherited properties as well
* [Fix] `Array#copyWithin`: should delete the target key if the source key is not present
* [Performance] Optimize Map/Set fast key path (#397)
* [Tests] fix `Reflect.enumerate` tests to not call `next` too many times
* [Dev Deps] update `jscs`, `jshint`
* [Docs] update license year to 2016 (#400)
# es6-shim 0.34.1 (5 Jan 2016)
* [Fix] `RegExp#[Symbol.search]` was broken with a regex argument (#394)
* [Fix] ensure that Set#clear works with both primitive and object values
* [Fix] static Promise methods have the wrong length in Firefox
* [Robustness] Cache `Object.keys`
* [Performance] Avoid accessing arguments array without length check
* [Performance] Optimize ES.TypeIsObject (#388)
* [Performance] Promises: lots of improvements (#383)
* [Performance] Only use slow implementation of IsCallable where necessary (old browsers)
* [Performance] Promises: remove unnecessary `.bind` on `setImmediate`
* [Refactor] extract “decode fast Map key” logic
* [Dev Deps] update `s5-shim`, `@ljharb/eslint-config`
* Dont 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 theyre defined before theyre 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 dont 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”, dont 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 dates 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 Firefoxs 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} wont 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 doesnt 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 Chromes 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 dont 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.clzs improper handling of values that coerce to NaN (#269)
* Fix incorrect handling of negative end index on Array#fill (#270)
* Removed Object.getOwnPropertyKeys, which shouldnt 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

98
node_modules/es6-shim/Gruntfile.js generated vendored Normal file
View File

@ -0,0 +1,98 @@
'use strict';
module.exports = function (grunt) {
var browsers = [
{ browserName: 'firefox', version: '19', platform: 'XP' },
{ browserName: 'firefox', platform: 'linux' },
{ browserName: 'firefox', platform: 'OS X 10.10' },
{ browserName: 'chrome', platform: 'linux' },
{ browserName: 'chrome', platform: 'OS X 10.9' },
{ browserName: 'chrome', platform: 'XP' },
{ browserName: 'internet explorer', platform: 'Windows 8.1', version: '11' },
{ browserName: 'internet explorer', platform: 'WIN8', version: '10' },
{ browserName: 'internet explorer', platform: 'VISTA', version: '9' },
{ browserName: 'safari', platform: 'OS X 10.6' },
{ browserName: 'safari', platform: 'OS X 10.8' },
{ browserName: 'safari', platform: 'OS X 10.9' },
{ browserName: 'safari', platform: 'OS X 10.10' },
{ browserName: 'iphone', platform: 'OS X 10.9', version: '7.1' },
{ browserName: 'android', platform: 'Linux', version: '4.4' },
];
var extraBrowsers = [
{ browserName: 'firefox', platform: 'linux', version: '30' },
{ browserName: 'firefox', platform: 'linux', version: '25' },
{ browserName: 'iphone', platform: 'OS X 10.8', version: '6.1' },
{ browserName: 'iphone', platform: 'OS X 10.8', version: '5.1' },
{ browserName: 'android', platform: 'Linux', version: '4.2' },
// XXX haven't investigated these:
// { browserName: 'opera', platform: 'Windows 7', version: '12' },
// { browserName: 'opera', platform: 'Windows 2008', version: '12' }
// { browserName: 'iphone', platform: 'OS X 10.6', version: '4.3' },
// { browserName: 'android', platform: 'Linux', version: '4.0' },
];
if (grunt.option('extra')) {
browsers = browsers.concat(extraBrowsers);
}
grunt.initConfig({
connect: {
server: {
options: {
base: '',
port: 9999,
useAvailablePort: true
}
}
},
'saucelabs-mocha': {
all: {
options: {
urls: (function () {
var urls = ['http://localhost:9999/test/'];
if (grunt.option('extra')) {
urls.push('http://localhost:9999/test-sham/');
}
return urls;
}()),
// tunnelTimeout: 5,
build: process.env.TRAVIS_BUILD_NUMBER,
tunneled: !process.env.SAUCE_HAS_TUNNEL,
identifier: process.env.TRAVIS_JOB_NUMBER,
sauceConfig: {
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
},
// concurrency: 3,
browsers: browsers,
testname: (function () {
var testname = 'mocha';
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
testname += ' (PR ' + process.env.TRAVIS_PULL_REQUEST + ')';
}
if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') {
testname += ' (branch ' + process.env.TRAVIS_BRANCH + ')';
}
return testname;
}()),
tags: (function () {
var tags = [];
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
tags.push('PR-' + process.env.TRAVIS_PULL_REQUEST);
}
if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') {
tags.push(process.env.TRAVIS_BRANCH);
}
return tags;
}())
}
}
},
watch: {}
});
// Loading dependencies
for (var key in grunt.file.readJSON('package.json').devDependencies) {
if (key !== 'grunt' && key.indexOf('grunt') === 0) {
grunt.loadNpmTasks(key);
}
}
grunt.registerTask('dev', ['connect', 'watch']);
grunt.registerTask('sauce', ['connect', 'saucelabs-mocha']);
};

26
node_modules/es6-shim/LICENSE generated vendored Normal file
View File

@ -0,0 +1,26 @@
The project was initially based on [es6-shim by Axel Rauschmayer](https://github.com/rauschma/es6-shim).
Current maintainers are: [Paul Miller](http://paulmillr.com), [Jordan Harband](https://github.com/ljharb), and [C. Scott Ananian](http://cscott.net).
The MIT License (MIT)
Copyright (c) 2013-2016 Paul Miller (http://paulmillr.com) and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

269
node_modules/es6-shim/README.md generated vendored Normal file
View File

@ -0,0 +1,269 @@
# ES6 Shim
Provides compatibility shims so that legacy JavaScript engines behave as
closely as possible to ECMAScript 6 (Harmony).
[![Build Status][1]][2] [![dependency status][3]][4] [![dev dependency status][5]][6]
[![browser support](https://ci.testling.com/paulmillr/es6-shim.png)](https://ci.testling.com/paulmillr/es6-shim)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/es6-shim.svg)](https://saucelabs.com/u/es6-shim)
[HTML version of the final ECMAScript 6 spec][spec-html-url]
## Installation
If you want to use it in browser:
* Just include `es6-shim` before your scripts.
* Include [es5-shim][es5-shim-url] especially if your browser doesn't support ECMAScript 5 - but every JS engine requires the `es5-shim` to correct broken implementations, so it's strongly recommended to always include it. Additionally, `es5-shim` should be loaded before `es6-shim`.
For `node.js`, `io.js`, or any `npm`-managed workflow (this is the recommended method):
npm install es6-shim
Alternative methods:
* `component install paulmillr/es6-shim` if youre using [component(1)](https://github.com/componentjs/component).
* `bower install es6-shim` if youre using [Bower](http://bower.io/).
In both browser and node you may also want to include `unorm`; see the [`String.prototype.normalize`](#stringprototypenormalize) section for details.
## Safe shims
* `Map`, `Set` (requires ES5 property descriptor support)
* `Promise`
* `String`:
* `fromCodePoint()` ([a standalone shim is also available](http://mths.be/fromcodepoint))
* `raw()`
* `String.prototype`:
* `codePointAt()` ([a standalone shim is also available](http://mths.be/codepointat))
* `endsWith()` ([a standalone shim is also available](http://mths.be/endswith))
* `includes()` ([a standalone shim is also available](http://mths.be/includes))
* `repeat()` ([a standalone shim is also available](http://mths.be/repeat))
* `startsWith()` ([a standalone shim is also available](http://mths.be/startswith))
* `RegExp`:
* `new RegExp`, when given a RegExp as the pattern, will no longer throw when given a "flags" string argument. (requires ES5)
* `RegExp.prototype`:
* `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags))
* `[Symbol.match]` (requires native `Symbol`s)
* `[Symbol.replace]` (requires native `Symbol`s)
* `[Symbol.search]` (requires native `Symbol`s)
* `[Symbol.split]` (requires native `Symbol`s)
* `toString`
* `Number`:
* binary and octal literals: `Number('0b1')` and `Number('0o7')`
* `EPSILON`
* `MAX_SAFE_INTEGER`
* `MIN_SAFE_INTEGER`
* `isNaN()`([a standalone shim is also available](https://www.npmjs.com/package/is-nan))
* `isInteger()`
* `isSafeInteger()`
* `isFinite()`
* `parseInt()`
* `parseFloat()`
* `Array`:
* `from()` ([a standalone shim is also available](https://www.npmjs.com/package/array.from))
* `of()` ([a standalone shim is also available](https://www.npmjs.com/package/array.of))
* `Array.prototype`:
* `copyWithin()`
* `entries()`
* `fill()`
* `find()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.find))
* `findIndex()` ([a standalone shim is also available](https://github.com/paulmillr/Array.prototype.findIndex))
* `keys()` (note: keys/values/entries return an `ArrayIterator` object)
* `values()`
* `indexOf()` (ES6 errata)
* `Object`:
* `assign()` ([a standalone shim is also available](https://github.com/ljharb/object.assign))
* `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is))
* `keys()` (in ES5, but no longer throws on non-object non-null/undefined values in ES6)
* `setPrototypeOf()` (IE >= 11)
* `Function.prototype`:
* `name` (es6-sham, covers IE 9-11)
* `Math`:
* `acosh()`
* `asinh()`
* `atanh()`
* `cbrt()`
* `clz32()`
* `cosh()`
* `expm1()`
* `fround()`
* `hypot()`
* `imul()`
* `log10()`
* `log1p()`
* `log2()`
* `sign()`
* `sinh()`
* `tanh()`
* `trunc()`
Math functions accuracy is 1e-11.
* `Reflect`
* `apply()`
* `construct()`
* `defineProperty()`
* `deleteProperty()`
* `get()`
* `getOwnPropertyDescriptor()`
* `getPrototypeOf()`
* `has()`
* `isExtensible()`
* `ownKeys()`
* `preventExtensions()`
* `set()`
* `setPrototypeOf()`
* `Symbol` (only if it already exists)
* `match` (and corresponding `String#match`, `String#startsWith`, `String#endsWith`, `String#includes`, `RegExp` support)
* `replace` (and corresponding `String#replace` support)
* `search` (and corresponding `String#search` support)
* `split` (and corresponding `String#split` support)
Well-known symbols will only be provided if the engine already has `Symbol` support.
* `String.prototype` Annex B HTML methods
* `anchor()`
* `big()`
* `blink()`
* `bold()`
* `fixed()`
* `fontcolor()`
* `fontsize()`
* `italics()`
* `link()`
* `small()`
* `strike()`
* `sub()`
* `sup()`
These methods are part of "Annex B", which means that although they are a defacto standard, you shouldn't use them. None the less, the `es6-shim` provides them and normalizes their behavior across browsers.
## Subclassing
The `Map`, `Set`, and `Promise` implementations are subclassable.
You should use the following pattern to create a subclass in ES5 which will continue to work in ES6:
```javascript
require('es6-shim');
function MyPromise(exec) {
var promise = new Promise(exec);
Object.setPrototypeOf(promise, MyPromise.prototype);
// ...
return promise;
}
Object.setPrototypeOf(MyPromise, Promise);
MyPromise.prototype = Object.create(Promise.prototype, {
constructor: { value: MyPromise }
});
```
## String.prototype.normalize
Including a proper shim for `String.prototype.normalize` would increase the size of this library by a factor of more than 4.
So instead we recommend that you install the [`unorm`](https://github.com/walling/unorm) package alongside `es6-shim` if you need `String.prototype.normalize`.
See https://github.com/paulmillr/es6-shim/issues/134 for more discussion.
## WeakMap shim
It is not possible to implement WeakMap in pure javascript.
The [es6-collections](https://github.com/WebReflection/es6-collections) implementation doesn't hold values strongly, which is critical for the collection. `es6-shim` decided to not include an incorrect shim.
`WeakMap` has very unusual use-cases, so you probably won't need it at all (use simple `Map` instead).
## Getting started
```javascript
require('es6-shim');
var assert = require('assert');
assert.equal(true, 'abc'.startsWith('a'));
assert.equal(false, 'abc'.endsWith('a'));
assert.equal(true, 'john alice'.includes('john'));
assert.equal('123'.repeat(2), '123123');
assert.equal(false, NaN === NaN);
assert.equal(true, Object.is(NaN, NaN));
assert.equal(true, -0 === 0);
assert.equal(false, Object.is(-0, 0));
var result = Object.assign({ a: 1 }, { b: 2 });
assert.deepEqual(result, { a: 1, b: 2 });
assert.equal(true, isNaN('a'));
assert.equal(false, Number.isNaN('a'));
assert.equal(true, Number.isNaN(NaN));
assert.equal(true, isFinite('123'));
assert.equal(false, Number.isFinite('123'));
assert.equal(false, Number.isFinite(Infinity));
// Tests if value is a number, finite,
// >= -9007199254740992 && <= 9007199254740992 and floor(value) === value
assert.equal(false, Number.isInteger(2.4));
assert.equal(1, Math.sign(400));
assert.equal(0, Math.sign(0));
assert.equal(-1, Math.sign(-400));
var found = [5, 10, 15, 10].find(function (item) { return item / 2 === 5; });
assert.equal(10, found);
var foundIndex = [5, 10, 15, 10].findIndex(function (item) { return item / 2 === 5; });
assert.equal(1, foundIndex);
// Replacement for `{}` key-value storage.
// Keys can be anything.
var map = new Map([['Bob', 42], ['Foo', 'bar']]);
map.set('John', 25);
map.set('Alice', 400);
map.set(['meh'], 555);
assert.equal(undefined, map.get(['meh'])); // undefined because you need to use exactly the same object.
map.delete('Alice');
map.keys();
map.values();
assert.equal(4, map.size);
// Useful for storing unique items.
var set = new Set([0, 1]);
set.add(2);
set.add(5);
assert.equal(true, set.has(0));
assert.equal(true, set.has(1));
assert.equal(true, set.has(2));
assert.equal(false, set.has(4));
assert.equal(true, set.has(5));
set.delete(5);
assert.equal(false, set.has(5));
// Promises, see
// http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript
// https://github.com/petkaantonov/bluebird/#what-are-promises-and-why-should-i-use-them
Promise.resolve(5).then(function (value) {
assert.equal(value, 5);
if (value) throw new Error('whoops!');
// do some stuff
return anotherPromise();
}).catch(function (e) {
assert.equal(e.message, 'whoops!');
assert.equal(true, e instanceof Error);
// any errors thrown asynchronously end up here
});
```
## Caveats
- `Object.setPrototypeOf` / `Reflect.setPrototypeOf`
- Note that null objects (`Object.create(null)`, eg, an object with `null` as its `[[Prototype]]`) can not have their `[[Prototype]]` changed except via a native `Object.setPrototypeOf`.
- Well-known `Symbol`s
- In order to make them work cross-realm, these are created with the global `Symbol` registry via `Symbol.for`. This does not violate the spec, but it does mean that `Symbol.for('Symbol.search') === Symbol.search` will be `true`, which it would not by default in a fresh compliant realm.
## [License][license-url]
[1]: https://travis-ci.org/paulmillr/es6-shim.svg
[2]: https://travis-ci.org/paulmillr/es6-shim
[3]: https://david-dm.org/paulmillr/es6-shim.svg
[4]: https://david-dm.org/paulmillr/es6-shim
[5]: https://david-dm.org/paulmillr/es6-shim/dev-status.svg
[6]: https://david-dm.org/paulmillr/es6-shim#info=devDependencies
[license-url]: https://github.com/paulmillr/es6-shim/blob/master/LICENSE
[spec-html-url]: http://www.ecma-international.org/ecma-262/6.0/
[es5-shim-url]: https://github.com/es-shims/es5-shim

28
node_modules/es6-shim/bower.json generated vendored Normal file
View File

@ -0,0 +1,28 @@
{
"name": "es6-shim",
"repo": "paulmillr/es6-shim",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [
"ecmascript",
"harmony",
"es6",
"shim",
"promise",
"promises",
"setPrototypeOf",
"map",
"set",
"__proto__"
],
"main": "es6-shim.js",
"scripts": ["es6-shim.js"],
"dependencies": {},
"development": {},
"ignore": [
"**/.*",
"node_modules",
"components",
"test"
]
}

23
node_modules/es6-shim/component.json generated vendored Normal file
View File

@ -0,0 +1,23 @@
{
"name": "es6-shim",
"version": "0.35.3",
"repo": "paulmillr/es6-shim",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [
"ecmascript",
"harmony",
"es6",
"shim",
"promise",
"promises",
"setPrototypeOf",
"map",
"set",
"__proto__"
],
"main": "es6-shim.js",
"scripts": ["es6-shim.js"],
"dependencies": {},
"development": {}
}

170
node_modules/es6-shim/es6-sham.js generated vendored Normal file
View File

@ -0,0 +1,170 @@
/*!
* https://github.com/paulmillr/es6-shim
* @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com)
* and contributors, MIT License
* es6-sham: v0.35.4
* see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
// UMD (Universal Module Definition)
// see https://github.com/umdjs/umd/blob/master/returnExports.js
(function (root, factory) {
/*global define, exports, module */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
}
}(this, function () {
'use strict';
/* eslint-disable no-new-func */
var getGlobal = new Function('return this;');
/* eslint-enable no-new-func */
var globals = getGlobal();
var Object = globals.Object;
var _call = Function.call.bind(Function.call);
var functionToString = Function.toString;
var _strMatch = String.prototype.match;
var throwsError = function (func) {
try {
func();
return false;
} catch (e) {
return true;
}
};
var arePropertyDescriptorsSupported = function () {
// if Object.defineProperty exists but throws, it's IE 8
return !throwsError(function () {
Object.defineProperty({}, 'x', { get: function () {} }); // eslint-disable-line getter-return
});
};
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
// NOTE: This versions needs object ownership
// because every promoted object needs to be reassigned
// otherwise uncompatible browsers cannot work as expected
//
// NOTE: This might need es5-shim or polyfills upfront
// because it's based on ES5 API.
// (probably just an IE <= 8 problem)
//
// NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
(function () {
if (Object.setPrototypeOf) { return; }
// @author Andrea Giammarchi - @WebReflection
var getOwnPropertyNames = Object.getOwnPropertyNames;
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var create = Object.create;
var defineProperty = Object.defineProperty;
var getPrototypeOf = Object.getPrototypeOf;
var objProto = Object.prototype;
var copyDescriptors = function (target, source) {
// define into target descriptors from source
getOwnPropertyNames(source).forEach(function (key) {
defineProperty(
target,
key,
getOwnPropertyDescriptor(source, key)
);
});
return target;
};
// used as fallback when no promotion is possible
var createAndCopy = function (origin, proto) {
return copyDescriptors(create(proto), origin);
};
var set, setPrototypeOf;
try {
// this might fail for various reasons
// ignore if Chrome cought it at runtime
set = getOwnPropertyDescriptor(objProto, '__proto__').set;
set.call({}, null);
// setter not poisoned, it can promote
// Firefox, Chrome
setPrototypeOf = function (origin, proto) {
set.call(origin, proto);
return origin;
};
} catch (e) {
// do one or more feature detections
set = { __proto__: null };
// if proto does not work, needs to fallback
// some Opera, Rhino, ducktape
if (set instanceof Object) {
setPrototypeOf = createAndCopy;
} else {
// verify if null objects are buggy
/* eslint-disable no-proto */
set.__proto__ = objProto;
/* eslint-enable no-proto */
// if null objects are buggy
// nodejs 0.8 to 0.10
if (set instanceof Object) {
setPrototypeOf = function (origin, proto) {
// use such bug to promote
/* eslint-disable no-proto */
origin.__proto__ = proto;
/* eslint-enable no-proto */
return origin;
};
} else {
// try to use proto or fallback
// Safari, old Firefox, many others
setPrototypeOf = function (origin, proto) {
// if proto is not null
if (getPrototypeOf(origin)) {
// use __proto__ to promote
/* eslint-disable no-proto */
origin.__proto__ = proto;
/* eslint-enable no-proto */
return origin;
} else {
// otherwise unable to promote: fallback
return createAndCopy(origin, proto);
}
};
}
}
}
Object.setPrototypeOf = setPrototypeOf;
}());
if (supportsDescriptors && function foo() {}.name !== 'foo') {
/* eslint no-extend-native: 1 */
Object.defineProperty(Function.prototype, 'name', {
configurable: true,
enumerable: false,
get: function () {
if (this === Function.prototype) {
return '';
}
var str = _call(functionToString, this);
var match = _call(_strMatch, str, /\s*function\s+([^(\s]*)\s*/);
var name = match && match[1];
Object.defineProperty(this, 'name', {
configurable: true,
enumerable: false,
writable: false,
value: name
});
return name;
}
});
}
}));

1
node_modules/es6-shim/es6-sham.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","getGlobal","Function","globals","Object","_call","call","bind","functionToString","toString","_strMatch","String","prototype","match","throwsError","func","e","arePropertyDescriptorsSupported","defineProperty","get","supportsDescriptors","setPrototypeOf","getOwnPropertyNames","getOwnPropertyDescriptor","create","getPrototypeOf","objProto","copyDescriptors","target","source","forEach","key","createAndCopy","origin","proto","set","__proto__","foo","name","configurable","enumerable","str","writable","value"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,WACN,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,MACrB,IAAIC,GAAQH,SAASI,KAAKC,KAAKL,SAASI,KACxC,IAAIE,GAAmBN,SAASO,QAChC,IAAIC,GAAYC,OAAOC,UAAUC,KAEjC,IAAIC,GAAc,SAAUC,GAC1B,IACEA,GACA,OAAO,OACP,MAAOC,GACP,MAAO,OAGX,IAAIC,GAAkC,WAEpC,OAAQH,EAAY,WAClBV,EAAOc,kBAAmB,KAAOC,IAAK,iBAG1C,IAAIC,KAAwBhB,EAAOc,gBAAkBD,KAWpD,WACC,GAAIb,EAAOiB,eAAgB,CAAE,OAI7B,GAAIC,GAAsBlB,EAAOkB,mBACjC,IAAIC,GAA2BnB,EAAOmB,wBACtC,IAAIC,GAASpB,EAAOoB,MACpB,IAAIN,GAAiBd,EAAOc,cAC5B,IAAIO,GAAiBrB,EAAOqB,cAC5B,IAAIC,GAAWtB,EAAOQ,SAEtB,IAAIe,GAAkB,SAAUC,EAAQC,GAEtCP,EAAoBO,GAAQC,QAAQ,SAAUC,GAC5Cb,EACEU,EACAG,EACAR,EAAyBM,EAAQE,KAGrC,OAAOH,GAGT,IAAII,GAAgB,SAAUC,EAAQC,GACpC,MAAOP,GAAgBH,EAAOU,GAAQD,GAExC,IAAIE,GAAKd,CACT,KAGEc,EAAMZ,EAAyBG,EAAU,aAAaS,GACtDA,GAAI7B,QAAS,KAGbe,GAAiB,SAAUY,EAAQC,GACjCC,EAAI7B,KAAK2B,EAAQC,EACjB,OAAOD,IAET,MAAOjB,GAEPmB,GAAQC,UAAW,KAGnB,IAAID,YAAe/B,GAAQ,CACzBiB,EAAiBW,MACZ,CAGLG,EAAIC,UAAYV,CAIhB,IAAIS,YAAe/B,GAAQ,CACzBiB,EAAiB,SAAUY,EAAQC,GAGjCD,EAAOG,UAAYF,CAEnB,OAAOD,QAEJ,CAGLZ,EAAiB,SAAUY,EAAQC,GAEjC,GAAIT,EAAeQ,GAAS,CAG1BA,EAAOG,UAAYF,CAEnB,OAAOD,OACF,CAEL,MAAOD,GAAcC,EAAQC,OAMvC9B,EAAOiB,eAAiBA,KAG1B,IAAID,GAAuB,QAASiB,SAASC,OAAS,MAAO,CAE3DlC,EAAOc,eAAehB,SAASU,UAAW,QACxC2B,aAAc,KACdC,WAAY,MACZrB,IAAK,WACH,GAAInB,OAASE,SAASU,UAAW,CAC/B,MAAO,GAET,GAAI6B,GAAMpC,EAAMG,EAAkBR,KAClC,IAAIa,GAAQR,EAAMK,EAAW+B,EAAK,6BAClC,IAAIH,GAAOzB,GAASA,EAAM,EAC1BT,GAAOc,eAAelB,KAAM,QAC1BuC,aAAc,KACdC,WAAY,MACZE,SAAU,MACVC,MAAOL,GAET,OAAOA"}

11
node_modules/es6-shim/es6-sham.min.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/*!
* https://github.com/paulmillr/es6-shim
* @license es6-shim Copyright 2013-2016 by Paul Miller (http://paulmillr.com)
* and contributors, MIT License
* es6-sham: v0.35.4
* see https://github.com/paulmillr/es6-shim/blob/0.35.3/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
(function(t,e){if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){"use strict";var t=new Function("return this;");var e=t();var r=e.Object;var n=Function.call.bind(Function.call);var o=Function.toString;var i=String.prototype.match;var f=function(t){try{t();return false}catch(e){return true}};var u=function(){return!f(function(){r.defineProperty({},"x",{get:function(){}})})};var a=!!r.defineProperty&&u();(function(){if(r.setPrototypeOf){return}var t=r.getOwnPropertyNames;var e=r.getOwnPropertyDescriptor;var n=r.create;var o=r.defineProperty;var i=r.getPrototypeOf;var f=r.prototype;var u=function(r,n){t(n).forEach(function(t){o(r,t,e(n,t))});return r};var a=function(t,e){return u(n(e),t)};var c,s;try{c=e(f,"__proto__").set;c.call({},null);s=function(t,e){c.call(t,e);return t}}catch(p){c={__proto__:null};if(c instanceof r){s=a}else{c.__proto__=f;if(c instanceof r){s=function(t,e){t.__proto__=e;return t}}else{s=function(t,e){if(i(t)){t.__proto__=e;return t}else{return a(t,e)}}}}}r.setPrototypeOf=s})();if(a&&function foo(){}.name!=="foo"){r.defineProperty(Function.prototype,"name",{configurable:true,enumerable:false,get:function(){if(this===Function.prototype){return""}var t=n(o,this);var e=n(i,t,/\s*function\s+([^(\s]*)\s*/);var f=e&&e[1];r.defineProperty(this,"name",{configurable:true,enumerable:false,writable:false,value:f});return f}})}});
//# sourceMappingURL=es6-sham.map

3890
node_modules/es6-shim/es6-shim.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/es6-shim/es6-shim.map generated vendored Normal file

File diff suppressed because one or more lines are too long

12
node_modules/es6-shim/es6-shim.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

110
node_modules/es6-shim/package.json generated vendored Normal file
View File

@ -0,0 +1,110 @@
{
"_from": "es6-shim",
"_id": "es6-shim@0.35.5",
"_inBundle": false,
"_integrity": "sha512-E9kK/bjtCQRpN1K28Xh4BlmP8egvZBGJJ+9GtnzOwt7mdqtrjHFuVGr7QJfdjBIKqrlU5duPf3pCBoDrkjVYFg==",
"_location": "/es6-shim",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "es6-shim",
"name": "es6-shim",
"escapedName": "es6-shim",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.5.tgz",
"_shasum": "46f59dc0a84a1c5029e8ff1166ca0a902077a9ab",
"_spec": "es6-shim",
"_where": "C:\\Users\\knh94\\Documents\\GitHub\\welsonjs\\node_modules",
"author": {
"name": "Paul Miller",
"url": "http://paulmillr.com"
},
"bugs": {
"url": "https://github.com/paulmillr/es6-shim/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"devDependencies": {
"@ljharb/eslint-config": "^13.1.1",
"chai": "^3.5.0",
"es5-shim": "^4.5.12",
"eslint": "^5.15.1",
"evalmd": "^0.0.17",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-watch": "^1.1.0",
"grunt-saucelabs": "^8.6.3",
"mocha": "^3.5.3",
"promises-aplus-tests": "^2.1.2",
"promises-es6-tests": "^0.5.0",
"safe-publish-latest": "^1.1.2",
"uglify-js": "2.7.3"
},
"homepage": "https://github.com/paulmillr/es6-shim/",
"keywords": [
"ecmascript",
"harmony",
"es6",
"shim",
"promise",
"promises",
"setPrototypeOf",
"map",
"set",
"__proto__"
],
"license": "MIT",
"main": "es6-shim",
"name": "es6-shim",
"repository": {
"type": "git",
"url": "git://github.com/paulmillr/es6-shim.git"
},
"scripts": {
"lint": "npm run lint:shim && npm run lint:sham",
"lint:sham": "eslint es6-sham.js test-sham/*.js",
"lint:shim": "eslint es6-shim.js test/*.js test/*/*.js",
"minify": "npm run minify:shim && npm run minify:sham",
"minify:sham": "uglifyjs es6-sham.js --support-ie8 --keep-fnames --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js",
"minify:shim": "uglifyjs es6-shim.js --support-ie8 --keep-fnames --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js",
"prepublish": "safe-publish-latest && npm run minify",
"pretest": "npm run lint && evalmd *.md",
"sauce": "npm run sauce-connect && grunt sauce",
"sauce-connect": "curl -L https://gist.githubusercontent.com/henrikhodne/9322897/raw/sauce-connect.sh | bash && export TRAVIS_SAUCE_CONNECT=true",
"test": "npm run tests-only",
"test:native": "NO_ES6_SHIM=1 npm run tests-only",
"test:sham": "mocha test-sham/*.js",
"test:shim": "mocha test/*.js test/*/*.js",
"tests-only": "npm run test:shim && npm run test:sham"
},
"testling": {
"html": "testling.html",
"browsers": [
"iexplore/6.0..latest",
"firefox/3.0..6.0",
"firefox/10.0",
"firefox/15.0..latest",
"firefox/nightly",
"chrome/4.0..10.0",
"chrome/20.0..latest",
"chrome/canary",
"opera/10.0..latest",
"opera/next",
"safari/4.0..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
},
"version": "0.35.5"
}

8
node_modules/es6-shim/test-sham/.eslintrc generated vendored Normal file
View File

@ -0,0 +1,8 @@
{
"env": {
"mocha": true
},
"globals": {
"expect": false
}
}

58
node_modules/es6-shim/test-sham/function.js generated vendored Normal file
View File

@ -0,0 +1,58 @@
var identity = function (x) { return x; };
describe('Function', function () {
describe('#name', function () {
it('returns the name for named functions', function () {
var foo = function bar() {};
expect(foo.name).to.equal('bar');
// pre-ES6, this property is nonconfigurable.
var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(foo, 'name').configurable : false;
expect(foo).to.have.ownPropertyDescriptor('name', {
configurable: !!configurable,
enumerable: false,
writable: false,
value: 'bar'
});
});
it('does not poison every name when accessed on Function.prototype', function () {
expect((function foo() {}).name).to.equal('foo');
expect(Function.prototype.name).to.equal('');
expect((function foo() {}).name).to.equal('foo');
});
it('returns empty string for anonymous functions', function () {
var anon = identity(function () {});
expect(anon.name).to.equal('');
// pre-ES6, this property is nonconfigurable.
var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(anon, 'name').configurable : false;
expect(anon).to.have.ownPropertyDescriptor('name', {
configurable: !!configurable,
enumerable: false,
writable: false,
value: ''
});
});
it('returns "anomymous" for Function functions', function () {
// eslint-disable-next-line no-new-func
var func = identity(Function(''));
expect(typeof func.name).to.equal('string');
expect(func.name === 'anonymous' || func.name === '').to.equal(true);
// pre-ES6, this property is nonconfigurable.
var configurable = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(func, 'name').configurable : false;
expect(func).to.have.ownPropertyDescriptor('name', {
configurable: !!configurable,
enumerable: false,
writable: false,
value: func.name
});
});
});
});

23
node_modules/es6-shim/test-sham/index.html generated vendored Normal file
View File

@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>es6-shim tests</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script src="../node_modules/es5-shim/es5-shim.js"></script>
<script src="../node_modules/es5-shim/es5-sham.js"></script>
<script src="../node_modules/mocha/mocha.js"></script>
<!-- note that chai uses Object.create() so needs es5-sham to be loaded -->
<script src="../node_modules/chai/chai.js"></script>
<script src="../es6-sham.js"></script>
<script src="../test/browser-setup.js"></script>
<script src="set-prototype-of.js"></script>
<script src="function.js"></script>
<script src="../test/browser-onload.js"></script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>

26
node_modules/es6-shim/test-sham/set-prototype-of.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
/* global expect, describe, it */
describe('Object.setPrototypeOf(o, p)', function () {
'use strict';
it('changes prototype to regular objects', function () {
var obj = { a: 123 };
expect(obj instanceof Object).to.equal(true);
// sham requires assignment to work cross browser
obj = Object.setPrototypeOf(obj, null);
expect(obj instanceof Object).to.equal(false);
expect(obj.a).to.equal(123);
});
it('changes prototype to null objects', function () {
var obj = Object.create(null);
obj.a = 456;
expect(obj instanceof Object).to.equal(false);
expect(obj.a).to.equal(456);
// sham requires assignment to work cross browser
obj = Object.setPrototypeOf(obj, { b: 789 });
expect(obj instanceof Object).to.equal(true);
expect(obj.a).to.equal(456);
expect(obj.b).to.equal(789);
});
});

21
node_modules/es6-shim/test/.eslintrc generated vendored Normal file
View File

@ -0,0 +1,21 @@
{
"rules": {
"array-callback-return": 0,
"func-name-matching": 0,
"max-lines-per-function": 0,
"max-statements-per-line": [2, { "max": 2 }],
"no-restricted-properties": 1,
"symbol-description": 0,
"prefer-promise-reject-errors": 0,
"consistent-return": 0,
},
"env": {
"mocha": true
},
"globals": {
"Symbol": false,
"Promise": false,
"expect": false,
"assert": false
}
}

1009
node_modules/es6-shim/test/array.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

45
node_modules/es6-shim/test/browser-onload.js generated vendored Normal file
View File

@ -0,0 +1,45 @@
/* global window, mocha */
if (typeof window !== 'undefined') {
window.completedTests = 0;
window.sawFail = false;
window.onload = function () {
window.testsPassed = null;
var handleResults = function (runner) {
var failedTests = [];
if (runner.stats.end) {
window.testsPassed = runner.stats.failures === 0;
}
runner.on('pass', function () {
window.completedTests += 1;
});
runner.on('fail', function (test, err) {
window.sawFail = true;
var flattenTitles = function (testToFlatten) {
var titles = [];
var currentTest = testToFlatten;
while (currentTest.parent.title) {
titles.push(currentTest.parent.title);
currentTest = currentTest.parent;
}
return titles.reverse();
};
failedTests.push({
name: test.title,
result: false,
message: err.message,
stack: err.stack,
titles: flattenTitles(test)
});
});
runner.on('end', function () {
window.testsPassed = !window.sawFail;
// for sauce
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});
return runner;
};
handleResults(mocha.run());
};
}

11
node_modules/es6-shim/test/browser-setup.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/* global window, chai, mocha */
if (typeof window !== 'undefined') {
chai.config.includeStack = true;
window.expect = chai.expect;
window.assert = chai.assert;
mocha.setup('bdd');
window.require = function () {
return window;
};
}

5
node_modules/es6-shim/test/date.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
describe('Date', function () {
it('when invalid, dates should toString to "Invalid Date"', function () {
expect(String(new Date(NaN))).to.equal('Invalid Date');
});
});

46
node_modules/es6-shim/test/google-translate.html generated vendored Normal file
View File

@ -0,0 +1,46 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>es6-shim tests</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script>
window.jstiming = { load: { tick: function () {} } };
</script>
<script src="http://translate.googleusercontent.com/translate/releases/twsfe_w_20170327_RC01/r/js/translate_c.js"></script>
<script src="../node_modules/es5-shim/es5-shim.js"></script>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../es6-shim.js"></script>
<script src="browser-setup.js"></script>
<script src="array.js"></script>
<script src="map.js"></script>
<script src="set.js"></script>
<script src="json.js"></script>
<script src="math.js"></script>
<script src="number.js"></script>
<script src="object.js"></script>
<script src="promise.js"></script>
<script src="regexp.js"></script>
<script src="string.js"></script>
<script src="reflect.js"></script>
<script src="worker-test.js"></script>
<script src="promise/all.js"></script>
<script src="promise/evil-promises.js"></script>
<!--
<script src="promise/promises-aplus.js"></script>
-->
<script src="../node_modules/promises-es6-tests/bundle/promises-es6-tests.js"></script>
<script src="promise/race.js"></script>
<script src="promise/reject.js"></script>
<script src="promise/resolve.js"></script>
<script src="promise/simple.js"></script>
<script src="promise/subclass.js"></script>
<script src="browser-onload.js"></script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>

42
node_modules/es6-shim/test/index.html generated vendored Normal file
View File

@ -0,0 +1,42 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>es6-shim tests</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script src="../node_modules/es5-shim/es5-shim.js"></script>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../es6-shim.js"></script>
<script src="browser-setup.js"></script>
<script src="array.js"></script>
<script src="map.js"></script>
<script src="set.js"></script>
<script src="json.js"></script>
<script src="math.js"></script>
<script src="number.js"></script>
<script src="object.js"></script>
<script src="promise.js"></script>
<script src="regexp.js"></script>
<script src="string.js"></script>
<script src="reflect.js"></script>
<script src="worker-test.js"></script>
<script src="promise/all.js"></script>
<script src="promise/evil-promises.js"></script>
<!--
<script src="promise/promises-aplus.js"></script>
-->
<script src="../node_modules/promises-es6-tests/bundle/promises-es6-tests.js"></script>
<script src="promise/race.js"></script>
<script src="promise/reject.js"></script>
<script src="promise/resolve.js"></script>
<script src="promise/simple.js"></script>
<script src="promise/subclass.js"></script>
<script src="browser-onload.js"></script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>

77
node_modules/es6-shim/test/json.js generated vendored Normal file
View File

@ -0,0 +1,77 @@
describe('JSON', function () {
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
var ifSymbolsIt = hasSymbols ? it : xit;
var ifSymbolsDescribe = hasSymbols ? describe : xit;
describe('.stringify()', function () {
ifFunctionsHaveNamesIt('has the right name', function () {
expect(JSON.stringify.name).to.equal('stringify');
});
ifSymbolsIt('serializes a Symbol to undefined', function () {
expect(JSON.stringify(Symbol())).to.equal(undefined);
});
ifSymbolsIt('serializes a Symbol object to {}', function () {
expect(function stringifyObjectSymbol() { JSON.stringify(Object(Symbol())); }).not.to['throw']();
expect(JSON.stringify(Object(Symbol()))).to.equal('{}');
});
ifSymbolsIt('serializes Symbols in an Array to null', function () {
expect(JSON.stringify([Symbol('foo')])).to.equal('[null]');
});
ifSymbolsIt('serializes Symbol objects in an Array to {}', function () {
expect(function stringifyObjectSymbolInArray() { JSON.stringify([Object(Symbol('foo'))]); }).not.to['throw']();
expect(JSON.stringify([Object(Symbol('foo'))])).to.equal('[{}]');
});
ifSymbolsDescribe('skips symbol properties and values in an object', function () {
var enumSym = Symbol('enumerable');
var nonenum = Symbol('non-enumerable');
var createObject = function () {
var obj = { a: 1 };
obj[enumSym] = true;
obj.sym = enumSym;
Object.defineProperty(obj, nonenum, { enumerable: false, value: true });
expect(Object.getOwnPropertySymbols(obj)).to.eql([enumSym, nonenum]);
return obj;
};
it('works with no replacer', function () {
var obj = createObject();
expect(JSON.stringify(obj)).to.equal('{"a":1}');
expect(JSON.stringify(obj, null, '|')).to.equal('{\n|"a": 1\n}');
});
it('works with a replacer function', function () {
var tuples = [];
var replacer = function (key, value) {
tuples.push([this, key, value]);
return value;
};
var obj = createObject();
expect(JSON.stringify(obj, replacer, '|')).to.equal('{\n|"a": 1\n}'); // populate `tuples` array
expect(tuples).to.eql([
[{ '': obj }, '', obj],
[obj, 'a', 1],
[obj, 'sym', enumSym]
]);
});
it('works with a replacer array', function () {
var obj = createObject();
obj.foo = 'bar';
obj[Symbol.prototype.toString.call(enumSym)] = 'tricksy';
expect(JSON.stringify(obj, ['a', enumSym])).to.equal('{"a":1}');
expect(JSON.stringify(obj, ['a', enumSym], '|')).to.equal('{\n|"a": 1\n}');
});
it('ignores a non-array non-callable replacer object', function () {
expect(JSON.stringify('z', { test: null })).to.equal('"z"');
});
});
});
});

622
node_modules/es6-shim/test/map.js generated vendored Normal file
View File

@ -0,0 +1,622 @@
// Big thanks to V8 folks for test ideas.
// v8/test/mjsunit/harmony/collections.js
var Assertion = expect().constructor;
Assertion.addMethod('theSameSet', function (otherArray) {
var array = this._obj;
expect(Array.isArray(array)).to.equal(true);
expect(Array.isArray(otherArray)).to.equal(true);
var diff = array.filter(function (value) {
return otherArray.every(function (otherValue) {
var areBothNaN = typeof value === 'number' && typeof otherValue === 'number' && value !== value && otherValue !== otherValue;
return !areBothNaN && value !== otherValue;
});
});
this.assert(
diff.length === 0,
'expected #{this} to be equal to #{exp} (as sets, i.e. no order)',
array,
otherArray
);
});
Assertion.addMethod('entries', function (expected) {
var collection = this._obj;
expect(Array.isArray(expected)).to.equal(true);
var expectedEntries = expected.slice();
var iterator = collection.entries();
var result;
do {
result = iterator.next();
expect(result.value).to.be.eql(expectedEntries.shift());
} while (!result.done);
});
describe('Map', function () {
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
var ifGetPrototypeOfIt = Object.getPrototypeOf ? it : xit;
var range = function range(from, to) {
var result = [];
for (var value = from; value < to; value++) {
result.push(value);
}
return result;
};
var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype');
var expectNotEnumerable = function (object) {
if (prototypePropIsEnumerable && typeof object === 'function') {
expect(Object.keys(object)).to.eql(['prototype']);
} else {
expect(Object.keys(object)).to.eql([]);
}
};
var Sym = typeof Symbol === 'undefined' ? {} : Symbol;
var isSymbol = function (sym) {
return typeof Sym === 'function' && typeof sym === 'symbol';
};
var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit;
var testMapping = function (map, key, value) {
expect(map.has(key)).to.equal(false);
expect(map.get(key)).to.equal(undefined);
expect(map.set(key, value)).to.equal(map);
expect(map.get(key)).to.equal(value);
expect(map.has(key)).to.equal(true);
};
if (typeof Map === 'undefined') {
return it('exists', function () {
expect(typeof Map).to.equal('function');
});
}
var map;
beforeEach(function () {
map = new Map();
});
afterEach(function () {
map = null;
});
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.Map).to.equal(Map);
});
it('should exist in global namespace', function () {
expect(typeof Map).to.equal('function');
});
it('should have the right arity', function () {
expect(Map).to.have.property('length', 0);
});
it('should has valid getter and setter calls', function () {
['get', 'set', 'has', 'delete'].forEach(function (method) {
expect(function () {
map[method]({});
}).to.not['throw']();
});
});
it('should accept an iterable as argument', function () {
testMapping(map, 'a', 'b');
testMapping(map, 'c', 'd');
var map2;
expect(function () { map2 = new Map(map); }).not.to['throw'](Error);
expect(map2).to.be.an.instanceOf(Map);
expect(map2.has('a')).to.equal(true);
expect(map2.has('c')).to.equal(true);
expect(map2).to.have.entries([['a', 'b'], ['c', 'd']]);
});
it('should throw with iterables that return primitives', function () {
expect(function () { return new Map('123'); }).to['throw'](TypeError);
expect(function () { return new Map([1, 2, 3]); }).to['throw'](TypeError);
expect(function () { return new Map(['1', '2', '3']); }).to['throw'](TypeError);
expect(function () { return new Map([true]); }).to['throw'](TypeError);
});
it('should not be callable without "new"', function () {
expect(Map).to['throw'](TypeError);
});
it('should be subclassable', function () {
if (!Object.setPrototypeOf) { return; } // skip test if on IE < 11
var MyMap = function MyMap() {
var testMap = new Map([['a', 'b']]);
Object.setPrototypeOf(testMap, MyMap.prototype);
return testMap;
};
Object.setPrototypeOf(MyMap, Map);
MyMap.prototype = Object.create(Map.prototype, {
constructor: { value: MyMap }
});
var myMap = new MyMap();
testMapping(myMap, 'c', 'd');
expect(myMap).to.have.entries([['a', 'b'], ['c', 'd']]);
});
it('uses SameValueZero even on a Map of size > 4', function () {
// Chrome 38-42, node 0.11/0.12, iojs 1/2 have a bug when the Map has a size > 4
var firstFour = [[1, 0], [2, 0], [3, 0], [4, 0]];
var fourMap = new Map(firstFour);
expect(fourMap.size).to.equal(4);
expect(fourMap.has(-0)).to.equal(false);
expect(fourMap.has(0)).to.equal(false);
fourMap.set(-0, fourMap);
expect(fourMap.has(0)).to.equal(true);
expect(fourMap.has(-0)).to.equal(true);
});
it('treats positive and negative zero the same', function () {
var value1 = {};
var value2 = {};
testMapping(map, +0, value1);
expect(map.has(-0)).to.equal(true);
expect(map.get(-0)).to.equal(value1);
expect(map.set(-0, value2)).to.equal(map);
expect(map.get(-0)).to.equal(value2);
expect(map.get(+0)).to.equal(value2);
});
it('should map values correctly', function () {
// Run this test twice, one with the "fast" implementation (which only
// allows string and numeric keys) and once with the "slow" impl.
[true, false].forEach(function (slowkeys) {
map = new Map();
range(1, 20).forEach(function (number) {
if (slowkeys) { testMapping(map, number, {}); }
testMapping(map, number / 100, {});
testMapping(map, 'key-' + number, {});
testMapping(map, String(number), {});
if (slowkeys) { testMapping(map, Object(String(number)), {}); }
});
var testkeys = [Infinity, -Infinity, NaN];
if (slowkeys) {
testkeys.push(true, false, null, undefined);
}
testkeys.forEach(function (key) {
testMapping(map, key, {});
testMapping(map, String(key), {});
});
testMapping(map, '', {});
// verify that properties of Object don't peek through.
[
'hasOwnProperty',
'constructor',
'toString',
'isPrototypeOf',
'__proto__',
'__parent__',
'__count__'
].forEach(function (key) {
testMapping(map, key, {});
});
});
});
it('should map empty values correctly', function () {
testMapping(map, {}, true);
testMapping(map, null, true);
testMapping(map, undefined, true);
testMapping(map, '', true);
testMapping(map, NaN, true);
testMapping(map, 0, true);
});
it('should has correct querying behavior', function () {
var key = {};
testMapping(map, key, 'to-be-present');
expect(map.has(key)).to.equal(true);
expect(map.has({})).to.equal(false);
expect(map.set(key, void 0)).to.equal(map);
expect(map.get(key)).to.equal(undefined);
expect(map.has(key)).to.equal(true);
expect(map.has({})).to.equal(false);
});
it('should allow NaN values as keys', function () {
expect(map.has(NaN)).to.equal(false);
expect(map.has(NaN + 1)).to.equal(false);
expect(map.has(23)).to.equal(false);
expect(map.set(NaN, 'value')).to.equal(map);
expect(map.has(NaN)).to.equal(true);
expect(map.has(NaN + 1)).to.equal(true);
expect(map.has(23)).to.equal(false);
});
it('should not have [[Enumerable]] props', function () {
expectNotEnumerable(Map);
expectNotEnumerable(Map.prototype);
expectNotEnumerable(new Map());
});
it('should not have an own constructor', function () {
var m = new Map();
expect(m).not.to.haveOwnPropertyDescriptor('constructor');
expect(m.constructor).to.equal(Map);
});
it('should allow common ecmascript idioms', function () {
expect(map).to.be.an.instanceOf(Map);
expect(typeof Map.prototype.get).to.equal('function');
expect(typeof Map.prototype.set).to.equal('function');
expect(typeof Map.prototype.has).to.equal('function');
expect(typeof Map.prototype['delete']).to.equal('function');
});
it('should have a unique constructor', function () {
expect(Map.prototype).to.not.equal(Object.prototype);
});
describe('#clear()', function () {
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Map.prototype.clear).to.have.property('name', 'clear');
});
it('is not enumerable', function () {
expect(Map.prototype).ownPropertyDescriptor('clear').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Map.prototype.clear).to.have.property('length', 0);
});
it('should have #clear method', function () {
expect(map.set(1, 2)).to.equal(map);
expect(map.set(5, 2)).to.equal(map);
expect(map.size).to.equal(2);
expect(map.has(5)).to.equal(true);
map.clear();
expect(map.size).to.equal(0);
expect(map.has(5)).to.equal(false);
});
});
describe('#keys()', function () {
if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'keys')) {
return it('exists', function () {
expect(Map.prototype).to.have.property('keys');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Map.prototype.keys).to.have.property('name', 'keys');
});
it('is not enumerable', function () {
expect(Map.prototype).ownPropertyDescriptor('keys').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Map.prototype.keys).to.have.property('length', 0);
});
});
describe('#values()', function () {
if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'values')) {
return it('exists', function () {
expect(Map.prototype).to.have.property('values');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Map.prototype.values).to.have.property('name', 'values');
});
it('is not enumerable', function () {
expect(Map.prototype).ownPropertyDescriptor('values').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Map.prototype.values).to.have.property('length', 0);
});
});
describe('#entries()', function () {
if (!Object.prototype.hasOwnProperty.call(Map.prototype, 'entries')) {
return it('exists', function () {
expect(Map.prototype).to.have.property('entries');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Map.prototype.entries).to.have.property('name', 'entries');
});
it('is not enumerable', function () {
expect(Map.prototype).ownPropertyDescriptor('entries').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Map.prototype.entries).to.have.property('length', 0);
});
it('throws when called on a non-Map', function () {
var expectedMessage = /^(Method )?Map.prototype.entries called on incompatible receiver |^entries method called on incompatible |^Cannot create a Map entry iterator for a non-Map object.|^Map\.prototype\.entries: 'this' is not a Map object$|^std_Map_iterator method called on incompatible \w+$/;
var nonMaps = [true, false, 'abc', NaN, new Set([1, 2]), { a: true }, [1], Object('abc'), Object(NaN)];
nonMaps.forEach(function (nonMap) {
expect(function () { return Map.prototype.entries.call(nonMap); }).to['throw'](TypeError, expectedMessage);
});
});
});
describe('#size', function () {
it('throws TypeError when accessed directly', function () {
// see https://github.com/paulmillr/es6-shim/issues/176
expect(function () { return Map.prototype.size; }).to['throw'](TypeError);
expect(function () { return Map.prototype.size; }).to['throw'](TypeError);
});
it('is an accessor function on the prototype', function () {
expect(Map.prototype).ownPropertyDescriptor('size').to.have.property('get');
expect(typeof Object.getOwnPropertyDescriptor(Map.prototype, 'size').get).to.equal('function');
expect(new Map()).not.to.haveOwnPropertyDescriptor('size');
});
});
it('should return false when deleting a nonexistent key', function () {
expect(map.has('a')).to.equal(false);
expect(map['delete']('a')).to.equal(false);
});
it('should have keys, values and size props', function () {
expect(map.set('a', 1)).to.equal(map);
expect(map.set('b', 2)).to.equal(map);
expect(map.set('c', 3)).to.equal(map);
expect(typeof map.keys).to.equal('function');
expect(typeof map.values).to.equal('function');
expect(map.size).to.equal(3);
expect(map['delete']('a')).to.equal(true);
expect(map.size).to.equal(2);
});
it('should have an iterator that works with Array.from', function () {
expect(Array).to.have.property('from');
expect(map.set('a', 1)).to.equal(map);
expect(map.set('b', NaN)).to.equal(map);
expect(map.set('c', false)).to.equal(map);
expect(Array.from(map)).to.eql([['a', 1], ['b', NaN], ['c', false]]);
expect(Array.from(map.keys())).to.eql(['a', 'b', 'c']);
expect(Array.from(map.values())).to.eql([1, NaN, false]);
expect(map).to.have.entries(Array.from(map.entries()));
});
ifSymbolIteratorIt('has the right default iteration function', function () {
// fixed in Webkit https://bugs.webkit.org/show_bug.cgi?id=143838
expect(Map.prototype).to.have.property(Sym.iterator, Map.prototype.entries);
});
describe('#forEach', function () {
var mapToIterate;
beforeEach(function () {
mapToIterate = new Map();
expect(mapToIterate.set('a', 1)).to.equal(mapToIterate);
expect(mapToIterate.set('b', 2)).to.equal(mapToIterate);
expect(mapToIterate.set('c', 3)).to.equal(mapToIterate);
});
afterEach(function () {
mapToIterate = null;
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Map.prototype.forEach).to.have.property('name', 'forEach');
});
it('is not enumerable', function () {
expect(Map.prototype).ownPropertyDescriptor('forEach').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Map.prototype.forEach).to.have.property('length', 1);
});
it('should be iterable via forEach', function () {
var expectedMap = {
a: 1,
b: 2,
c: 3
};
var foundMap = {};
mapToIterate.forEach(function (value, key, entireMap) {
expect(entireMap).to.equal(mapToIterate);
foundMap[key] = value;
});
expect(foundMap).to.eql(expectedMap);
});
it('should iterate over empty keys', function () {
var mapWithEmptyKeys = new Map();
var expectedKeys = [{}, null, undefined, '', NaN, 0];
expectedKeys.forEach(function (key) {
expect(mapWithEmptyKeys.set(key, true)).to.equal(mapWithEmptyKeys);
});
var foundKeys = [];
mapWithEmptyKeys.forEach(function (value, key, entireMap) {
expect(entireMap.get(key)).to.equal(value);
foundKeys.push(key);
});
expect(foundKeys).to.be.theSameSet(expectedKeys);
});
it('should support the thisArg', function () {
var context = function () {};
mapToIterate.forEach(function () {
expect(this).to.equal(context);
}, context);
});
it('should have a length of 1', function () {
expect(Map.prototype.forEach.length).to.equal(1);
});
it('should not revisit modified keys', function () {
var hasModifiedA = false;
mapToIterate.forEach(function (value, key) {
if (!hasModifiedA && key === 'a') {
expect(mapToIterate.set('a', 4)).to.equal(mapToIterate);
hasModifiedA = true;
} else {
expect(key).not.to.equal('a');
}
});
});
it('returns the map from #set() for chaining', function () {
expect(mapToIterate.set({}, {})).to.equal(mapToIterate);
expect(mapToIterate.set(42, {})).to.equal(mapToIterate);
expect(mapToIterate.set(0, {})).to.equal(mapToIterate);
expect(mapToIterate.set(NaN, {})).to.equal(mapToIterate);
expect(mapToIterate.set(-0, {})).to.equal(mapToIterate);
});
it('visits keys added in the iterator', function () {
var hasAdded = false;
var hasFoundD = false;
mapToIterate.forEach(function (value, key) {
if (!hasAdded) {
mapToIterate.set('d', 5);
hasAdded = true;
} else if (key === 'd') {
hasFoundD = true;
}
});
expect(hasFoundD).to.equal(true);
});
it('visits keys added in the iterator when there is a deletion', function () {
var hasSeenFour = false;
var mapToMutate = new Map();
mapToMutate.set('0', 42);
mapToMutate.forEach(function (value, key) {
if (key === '0') {
expect(mapToMutate['delete']('0')).to.equal(true);
mapToMutate.set('4', 'a value');
} else if (key === '4') {
hasSeenFour = true;
}
});
expect(hasSeenFour).to.equal(true);
});
it('does not visit keys deleted before a visit', function () {
var hasVisitedC = false;
var hasDeletedC = false;
mapToIterate.forEach(function (value, key) {
if (key === 'c') {
hasVisitedC = true;
}
if (!hasVisitedC && !hasDeletedC) {
hasDeletedC = mapToIterate['delete']('c');
expect(hasDeletedC).to.equal(true);
}
});
expect(hasVisitedC).to.equal(false);
});
it('should work after deletion of the current key', function () {
var expectedMap = {
a: 1,
b: 2,
c: 3
};
var foundMap = {};
mapToIterate.forEach(function (value, key) {
foundMap[key] = value;
expect(mapToIterate['delete'](key)).to.equal(true);
});
expect(foundMap).to.eql(expectedMap);
});
it('should convert key -0 to +0', function () {
var zeroMap = new Map();
var result = [];
zeroMap.set(-0, 'a');
zeroMap.forEach(function (value, key) {
result.push(String(1 / key) + ' ' + value);
});
zeroMap.set(1, 'b');
zeroMap.set(0, 'c'); // shouldn't cause reordering
zeroMap.forEach(function (value, key) {
result.push(String(1 / key) + ' ' + value);
});
expect(result.join(', ')).to.equal('Infinity a, Infinity c, 1 b');
});
});
it('should preserve insertion order', function () {
var convertToPairs = function (item) { return [item, true]; };
var arr1 = ['d', 'a', 'b'];
var arr2 = [3, 2, 'z', 'a', 1];
var arr3 = [3, 2, 'z', {}, 'a', 1];
[arr1, arr2, arr3].forEach(function (array) {
var entries = array.map(convertToPairs);
expect(new Map(entries)).to.have.entries(entries);
});
});
it('map iteration', function () {
var map = new Map();
map.set('a', 1);
map.set('b', 2);
map.set('c', 3);
map.set('d', 4);
var keys = [];
var iterator = map.keys();
keys.push(iterator.next().value);
expect(map['delete']('a')).to.equal(true);
expect(map['delete']('b')).to.equal(true);
expect(map['delete']('c')).to.equal(true);
map.set('e');
keys.push(iterator.next().value);
keys.push(iterator.next().value);
expect(iterator.next().done).to.equal(true);
map.set('f');
expect(iterator.next().done).to.equal(true);
expect(keys).to.eql(['a', 'd', 'e']);
});
ifGetPrototypeOfIt('MapIterator identification test prototype inequality', function () {
var mapEntriesProto = Object.getPrototypeOf(new Map().entries());
var setEntriesProto = Object.getPrototypeOf(new Set().entries());
expect(mapEntriesProto).to.not.equal(setEntriesProto);
});
it('MapIterator identification', function () {
var fnMapValues = Map.prototype.values;
var mapSentinel = new Map([[1, 'MapSentinel']]);
var testMap = new Map();
var testMapValues = testMap.values();
expect(testMapValues.next.call(fnMapValues.call(mapSentinel)).value).to.equal('MapSentinel');
var testSet = new Set();
var testSetValues = testSet.values();
expect(function () {
return testSetValues.next.call(fnMapValues.call(mapSentinel)).value;
}).to['throw'](TypeError);
});
});

889
node_modules/es6-shim/test/math.js generated vendored Normal file
View File

@ -0,0 +1,889 @@
var EPSILON = Number.EPSILON || 2.2204460492503130808472633361816e-16;
var Assertion = expect().constructor;
Assertion.prototype.almostEqual = function (obj, precision) {
'use strict';
var allowedDiff = precision || 1e-11;
return this.within(obj - allowedDiff, obj + allowedDiff);
};
Assertion.prototype.haveULPDistance = function (expected, distance) {
var actual = this._obj;
return this.above(Math.abs(1 - (actual / expected)) / EPSILON, distance);
};
describe('Math', function () {
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
var isPositiveZero = function (zero) {
'use strict';
return zero === 0 && 1 / zero === Infinity;
};
var isNegativeZero = function (zero) {
'use strict';
return zero === 0 && 1 / zero === -Infinity;
};
var numberIsNaN = Number.isNaN || function (value) {
return value !== value;
};
var valueOfIsNaN = { valueOf: function () { return NaN; } };
var valueOfIsInfinity = { valueOf: function () { return Infinity; } };
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.Math).to.equal(Math);
});
describe('.acosh()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'acosh')) {
return it('exists', function () {
expect(Math).to.have.property('acosh');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.acosh).to.have.property('name', 'acosh');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('acosh').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.acosh).to.have.property('length', 1);
});
it('should be correct', function () {
expect(numberIsNaN(Math.acosh(NaN))).to.equal(true);
expect(numberIsNaN(Math.acosh(0))).to.equal(true);
expect(numberIsNaN(Math.acosh(0.9999999))).to.equal(true);
expect(numberIsNaN(Math.acosh(-1e300))).to.equal(true);
expect(Math.acosh(1e+99)).to.almostEqual(228.64907138697046);
expect(isPositiveZero(Math.acosh(1))).to.equal(true);
expect(Math.acosh(Infinity)).to.equal(Infinity);
expect(Math.acosh(1234)).to.almostEqual(7.811163220849231);
expect(Math.acosh(8.88)).to.almostEqual(2.8737631531629235);
expect(Math.acosh(1e160)).to.almostEqual(369.10676205960726);
expect(Math.acosh(Number.MAX_VALUE)).to.almostEqual(710.4758600739439);
});
it('works for EPSILON values near 1', function () {
var result = Math.acosh(1 + EPSILON);
var expected = Math.sqrt(2 * EPSILON);
expect(result).to.almostEqual(expected);
expect(result).to.haveULPDistance(expected, 8);
});
});
describe('.asinh()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'asinh')) {
return it('exists', function () {
expect(Math).to.have.property('asinh');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.asinh).to.have.property('name', 'asinh');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('asinh').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.asinh).to.have.property('length', 1);
});
it('should be correct for NaN', function () {
expect(numberIsNaN(Math.asinh(NaN))).to.equal(true);
});
it('should be correct for zeroes', function () {
expect(isPositiveZero(Math.asinh(+0))).to.equal(true);
expect(isNegativeZero(Math.asinh(-0))).to.equal(true);
});
it('should be correct for Infinities', function () {
expect(Math.asinh(Infinity)).to.equal(Infinity);
expect(Math.asinh(-Infinity)).to.equal(-Infinity);
});
it('should be correct', function () {
expect(Math.asinh(1234)).to.almostEqual(7.811163549201245);
expect(Math.asinh(9.99)).to.almostEqual(2.997227420191335);
expect(Math.asinh(1e150)).to.almostEqual(346.0809111296668);
expect(Math.asinh(1e7)).to.almostEqual(16.811242831518268);
expect(Math.asinh(-1e7)).to.almostEqual(-16.811242831518268);
});
it('is correct for extreme non-infinities', function () {
expect(Math.asinh(1e+300)).not.to.equal(Infinity);
expect(Math.asinh(1e+300)).to.almostEqual(691.4686750787736);
});
});
describe('.atanh()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'atanh')) {
return it('exists', function () {
expect(Math).to.have.property('atanh');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.atanh).to.have.property('name', 'atanh');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('atanh').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.atanh).to.have.property('length', 1);
});
it('should be correct', function () {
expect(numberIsNaN(Math.atanh(NaN))).to.equal(true);
expect(numberIsNaN(Math.atanh(-1.00000001))).to.equal(true);
expect(numberIsNaN(Math.atanh(1.00000001))).to.equal(true);
expect(numberIsNaN(Math.atanh(-1e300))).to.equal(true);
expect(numberIsNaN(Math.atanh(1e300))).to.equal(true);
expect(Math.atanh(-1)).to.equal(-Infinity);
expect(Math.atanh(1)).to.equal(Infinity);
expect(isPositiveZero(Math.atanh(+0))).to.equal(true);
expect(isNegativeZero(Math.atanh(-0))).to.equal(true);
expect(Math.atanh(0.5)).to.almostEqual(0.5493061443340549);
expect(Math.atanh(-0.5)).to.almostEqual(-0.5493061443340549);
expect(Math.atanh(-0.5)).to.almostEqual(-0.5493061443340549);
expect(Math.atanh(0.444)).to.almostEqual(0.47720201260109457);
});
it('is correct for extreme non-infinities', function () {
expect(Math.atanh(1e-300)).not.to.equal(0);
expect(Math.atanh(1e-300)).to.almostEqual(1e-300);
});
});
describe('.cbrt()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'cbrt')) {
return it('exists', function () {
expect(Math).to.have.property('cbrt');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.cbrt).to.have.property('name', 'cbrt');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('cbrt').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.cbrt).to.have.property('length', 1);
});
it('should be correct', function () {
expect(isNaN(Math.cbrt(NaN))).to.equal(true);
expect(isPositiveZero(Math.cbrt(+0))).to.equal(true);
expect(isNegativeZero(Math.cbrt(-0))).to.equal(true);
expect(Math.cbrt(Infinity)).to.equal(Infinity);
expect(Math.cbrt(-Infinity)).to.equal(-Infinity);
expect(Math.cbrt(-8)).to.almostEqual(-2);
expect(Math.cbrt(8)).to.almostEqual(2);
expect(Math.cbrt(-1000)).to.almostEqual(-10);
expect(Math.cbrt(1000)).to.almostEqual(10);
});
it('is correct at extremes', function () {
var result = Math.cbrt(1e-300);
var expected = 1e-100;
expect(result).to.almostEqual(expected);
expect(result).to.haveULPDistance(expected, 8);
expect(Math.cbrt(-1e-300)).to.almostEqual(-1e-100);
expect(Math.cbrt(-1e+300)).to.almostEqual(-1e+100);
expect(Math.cbrt(1e+300)).to.almostEqual(1e+100);
});
});
describe('.clz32()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'clz32')) {
return it('exists', function () {
expect(Math).to.have.property('clz32');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.clz32).to.have.property('name', 'clz32');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('clz32').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.clz32).to.have.property('length', 1);
});
it('should have proper uint32 conversion', function () {
var integers = [5295, -5295, -9007199254740991, 9007199254740991, 0, -0];
var nonNumbers = [undefined, true, null, {}, [], 'str'];
var nonIntegers = [-9007199254741992, 9007199254741992, 5.9];
integers.forEach(function (item) {
expect(Math.clz32(item)).to.be.within(0, 32);
});
nonIntegers.forEach(function (item) {
expect(Math.clz32(item)).to.be.within(0, 32);
});
nonNumbers.forEach(function (item) {
expect(Math.clz32(item)).to.equal(item === true ? 31 : 32);
});
expect(Math.clz32(true)).to.equal(Math.clz32(1));
expect(Math.clz32('')).to.equal(Math.clz32(0));
expect(Math.clz32('10')).to.equal(Math.clz32(10));
expect(Math.clz32(0.1)).to.equal(32);
expect(Math.clz32(-1)).to.equal(0);
expect(Math.clz32(1)).to.equal(31);
expect(Math.clz32(0xFFFFFFFF)).to.equal(0);
expect(Math.clz32(0x1FFFFFFFF)).to.equal(0);
expect(Math.clz32(0x111111111)).to.equal(3);
expect(Math.clz32(0x11111111)).to.equal(3);
});
it('returns 32 for numbers that coerce to 0', function () {
var zeroishes = [
0,
-0,
NaN,
Infinity,
-Infinity,
0x100000000,
undefined,
null,
false,
'',
'str',
{},
[],
[1, 2]
];
zeroishes.forEach(function (zeroish) {
expect(Math.clz32(zeroish)).to.equal(32);
});
});
});
describe('.cosh()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'cosh')) {
return it('exists', function () {
expect(Math).to.have.property('cosh');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.cosh).to.have.property('name', 'cosh');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('cosh').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.cosh).to.have.property('length', 1);
});
it('should be correct for NaN', function () {
expect(numberIsNaN(Math.cosh(NaN))).to.equal(true);
});
it('should be correct for Infinities', function () {
expect(Math.cosh(Infinity)).to.equal(Infinity);
expect(Math.cosh(-Infinity)).to.equal(Infinity);
});
it('should be correct for zeroes', function () {
expect(Math.cosh(-0)).to.equal(1);
expect(Math.cosh(+0)).to.equal(1);
});
it('should be correct', function () {
// Overridden precision values here are for Chrome, as of v25.0.1364.172
// Broadened slightly for Firefox 31
expect(Math.cosh(12)).to.almostEqual(81377.39571257407, 9e-11);
expect(Math.cosh(22)).to.almostEqual(1792456423.065795780980053377, 1e-5);
expect(Math.cosh(-10)).to.almostEqual(11013.23292010332313972137);
expect(Math.cosh(-23)).to.almostEqual(4872401723.1244513000, 1e-5);
expect(Math.cosh(-2e-17)).to.equal(1);
});
it('is correct for extreme non-infinities', function () {
expect(Math.cosh(710)).not.to.equal(Infinity);
expect(Math.cosh(710) / 1e+308).to.almostEqual(1.1169973830808557);
});
});
describe('.expm1()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'expm1')) {
return it('exists', function () {
expect(Math).to.have.property('expm1');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.expm1).to.have.property('name', 'expm1');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('expm1').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.expm1).to.have.property('length', 1);
});
it('should be correct for NaN', function () {
expect(numberIsNaN(Math.expm1(NaN))).to.equal(true);
});
it('should be correct for zeroes', function () {
expect(isPositiveZero(Math.expm1(+0))).to.equal(true);
expect(isNegativeZero(Math.expm1(-0))).to.equal(true);
});
it('should be correct for Infinity', function () {
expect(Math.expm1(Infinity)).to.equal(Infinity);
expect(Math.expm1(-Infinity)).to.equal(-1);
});
it('should be correct for arbitrary numbers', function () {
expect(Math.expm1(10)).to.almostEqual(22025.465794806716516957900645284244366353512618556781);
expect(Math.expm1(-10)).to.almostEqual(-0.99995460007023751514846440848443944938976208191113);
expect(Math.expm1(-2e-17)).to.almostEqual(-2e-17);
});
it('works with very negative numbers', function () {
expect(Math.expm1(-38)).to.almostEqual(-1);
expect(Math.expm1(-8675309)).to.almostEqual(-1);
expect(Math.expm1(-4815162342)).to.almostEqual(-1);
});
});
describe('.hypot()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'hypot')) {
return it('exists', function () {
expect(Math).to.have.property('hypot');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.hypot).to.have.property('name', 'hypot');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('hypot').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.hypot).to.have.property('length', 2);
});
it('should be correct', function () {
expect(Math.hypot(Infinity)).to.equal(Infinity);
expect(Math.hypot(-Infinity)).to.equal(Infinity);
expect(Math.hypot(Infinity, NaN)).to.equal(Infinity);
expect(Math.hypot(NaN, Infinity)).to.equal(Infinity);
expect(Math.hypot(-Infinity, 'Hello')).to.equal(Infinity);
expect(Math.hypot(1, 2, Infinity)).to.equal(Infinity);
expect(numberIsNaN(Math.hypot(NaN, 1))).to.equal(true);
expect(isPositiveZero(Math.hypot())).to.equal(true);
expect(isPositiveZero(Math.hypot(0, 0, 0))).to.equal(true);
expect(isPositiveZero(Math.hypot(0, -0, 0))).to.equal(true);
expect(isPositiveZero(Math.hypot(-0, -0, -0))).to.equal(true);
expect(Math.hypot(66, 66)).to.almostEqual(93.33809511662427);
expect(Math.hypot(0.1, 100)).to.almostEqual(100.0000499999875);
});
it('should coerce to a number', function () {
expect(Math.hypot('Infinity', 0)).to.equal(Infinity);
expect(Math.hypot('3', '3', '3', '3')).to.equal(6);
});
it('should take more than 3 arguments', function () {
expect(Math.hypot(66, 66, 66)).to.almostEqual(114.3153532995459);
expect(Math.hypot(66, 66, 66, 66)).to.equal(132);
});
it('should have the right length', function () {
expect(Math.hypot.length).to.equal(2);
});
it('works for very large or small numbers', function () {
expect(Math.hypot(1e+300, 1e+300)).to.almostEqual(1.4142135623730952e+300);
expect(Math.hypot(1e-300, 1e-300)).to.almostEqual(1.4142135623730952e-300);
expect(Math.hypot(1e+300, 1e+300, 2, 3)).to.almostEqual(1.4142135623730952e+300);
});
});
describe('.log2()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'log2')) {
return it('exists', function () {
expect(Math).to.have.property('log2');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.log2).to.have.property('name', 'log2');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('log2').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.log2).to.have.property('length', 1);
});
it('is correct for small numbers', function () {
expect(numberIsNaN(Math.log2(-1e-50))).to.equal(true);
});
it('is correct for edge cases', function () {
expect(numberIsNaN(Math.log2(NaN))).to.equal(true);
expect(Math.log2(+0)).to.equal(-Infinity);
expect(Math.log2(-0)).to.equal(-Infinity);
expect(isPositiveZero(Math.log2(1))).to.equal(true);
expect(Math.log2(Infinity)).to.equal(Infinity);
});
it('should have the right precision', function () {
expect(Math.log2(5)).to.almostEqual(2.321928094887362);
expect(Math.log2(32)).to.almostEqual(5);
});
});
describe('.log10', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'log10')) {
return it('exists', function () {
expect(Math).to.have.property('log10');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.log10).to.have.property('name', 'log10');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('log10').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.log10).to.have.property('length', 1);
});
it('should be correct for edge cases', function () {
expect(numberIsNaN(Math.log10(NaN))).to.equal(true);
expect(numberIsNaN(Math.log10(-1e-50))).to.equal(true);
expect(Math.log10(+0)).to.equal(-Infinity);
expect(Math.log10(-0)).to.equal(-Infinity);
expect(isPositiveZero(Math.log10(1))).to.equal(true);
expect(Math.log10(Infinity)).to.equal(Infinity);
});
it('should have the right precision', function () {
expect(Math.log10(5)).to.almostEqual(0.698970004336018);
expect(Math.log10(50)).to.almostEqual(1.6989700043360187);
});
});
describe('.log1p', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'log1p')) {
return it('exists', function () {
expect(Math).to.have.property('log1p');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.log1p).to.have.property('name', 'log1p');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('log1p').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.log1p).to.have.property('length', 1);
});
it('should be correct', function () {
expect(numberIsNaN(Math.log1p(NaN))).to.equal(true);
expect(numberIsNaN(Math.log1p(-1.000000001))).to.equal(true);
expect(Math.log1p(-1)).to.equal(-Infinity);
expect(isPositiveZero(Math.log1p(+0))).to.equal(true);
expect(isNegativeZero(Math.log1p(-0))).to.equal(true);
expect(Math.log1p(Infinity)).to.equal(Infinity);
expect(Math.log1p(5)).to.almostEqual(1.791759469228055);
expect(Math.log1p(50)).to.almostEqual(3.9318256327243257);
expect(Math.log1p(-1e-17)).to.equal(-1e-17);
expect(Math.log1p(-2e-17)).to.equal(-2e-17);
});
});
describe('.sign()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'sign')) {
return it('exists', function () {
expect(Math).to.have.property('sign');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.sign).to.have.property('name', 'sign');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('sign').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.sign).to.have.property('length', 1);
});
it('should be correct', function () {
// we also verify that [[ToNumber]] is being called
[Infinity, 1].forEach(function (value) {
expect(Math.sign(value)).to.equal(1);
expect(Math.sign(String(value))).to.equal(1);
});
expect(Math.sign(true)).to.equal(1);
[-Infinity, -1].forEach(function (value) {
expect(Math.sign(value)).to.equal(-1);
expect(Math.sign(String(value))).to.equal(-1);
});
expect(isPositiveZero(Math.sign(+0))).to.equal(true);
expect(isPositiveZero(Math.sign('0'))).to.equal(true);
expect(isPositiveZero(Math.sign('+0'))).to.equal(true);
expect(isPositiveZero(Math.sign(''))).to.equal(true);
expect(isPositiveZero(Math.sign(' '))).to.equal(true);
expect(isPositiveZero(Math.sign(null))).to.equal(true);
expect(isPositiveZero(Math.sign(false))).to.equal(true);
expect(isNegativeZero(Math.sign(-0))).to.equal(true);
expect(isNegativeZero(Math.sign('-0'))).to.equal(true);
expect(numberIsNaN(Math.sign(NaN))).to.equal(true);
expect(numberIsNaN(Math.sign('NaN'))).to.equal(true);
expect(numberIsNaN(Math.sign(undefined))).to.equal(true);
});
});
describe('.sinh()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'sinh')) {
return it('exists', function () {
expect(Math).to.have.property('sinh');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.sinh).to.have.property('name', 'sinh');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('sinh').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.sinh).to.have.property('length', 1);
});
it('should be correct', function () {
expect(numberIsNaN(Math.sinh(NaN))).to.equal(true);
expect(isPositiveZero(Math.sinh(+0))).to.equal(true);
expect(isNegativeZero(Math.sinh(-0))).to.equal(true);
expect(Math.sinh(Infinity)).to.equal(Infinity);
expect(Math.sinh(-Infinity)).to.equal(-Infinity);
expect(Math.sinh(-5)).to.almostEqual(-74.20321057778875);
expect(Math.sinh(2)).to.almostEqual(3.6268604078470186);
expect(Math.sinh(-2e-17)).to.equal(-2e-17);
});
it('is correct for extreme non-infinities', function () {
expect(Math.sinh(710)).not.to.equal(Infinity);
expect(Math.sinh(710) / 1e+308).to.almostEqual(1.1169973830808557);
});
});
describe('.tanh()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'tanh')) {
return it('exists', function () {
expect(Math).to.have.property('tanh');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.tanh).to.have.property('name', 'tanh');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('tanh').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.tanh).to.have.property('length', 1);
});
it('should be correct', function () {
expect(numberIsNaN(Math.tanh(NaN))).to.equal(true);
expect(isPositiveZero(Math.tanh(+0))).to.equal(true);
expect(isNegativeZero(Math.tanh(-0))).to.equal(true);
expect(Math.tanh(Infinity)).to.equal(1);
expect(Math.tanh(-Infinity)).to.equal(-1);
expect(Math.tanh(19)).to.almostEqual(1);
expect(Math.tanh(-19)).to.almostEqual(-1);
expect(Math.tanh(20)).to.equal(1); // JS loses precision for true value at this integer
expect(Math.tanh(-20)).to.equal(-1); // JS loses precision for true value at this integer
expect(Math.tanh(10)).to.almostEqual(0.9999999958776927);
expect(Math.tanh(-2e-17)).to.equal(-2e-17);
});
});
describe('.trunc()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'trunc')) {
return it('exists', function () {
expect(Math).to.have.property('trunc');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.trunc).to.have.property('name', 'trunc');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('trunc').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.trunc).to.have.property('length', 1);
});
it('should be correct', function () {
expect(numberIsNaN(Math.trunc(NaN))).to.equal(true);
expect(isNegativeZero(Math.trunc(-0))).to.equal(true);
expect(isPositiveZero(Math.trunc(+0))).to.equal(true);
expect(Math.trunc(Infinity)).to.equal(Infinity);
expect(Math.trunc(-Infinity)).to.equal(-Infinity);
expect(Math.trunc(1.01)).to.equal(1);
expect(Math.trunc(1.99)).to.equal(1);
expect(Math.trunc(-555.555)).to.equal(-555);
expect(Math.trunc(-1.99)).to.equal(-1);
});
it('should coerce to a number immediately', function () {
expect(Math.trunc(valueOfIsInfinity)).to.equal(Infinity);
expect(numberIsNaN(Math.trunc(valueOfIsNaN))).to.equal(true);
});
});
describe('.imul()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'imul')) {
return it('exists', function () {
expect(Math).to.have.property('imul');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.imul).to.have.property('name', 'imul');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('imul').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.imul).to.have.property('length', 2);
});
var str = 'str';
var obj = {};
var arr = [];
it('should be correct for non-numbers', function () {
expect(Math.imul(false, 7)).to.equal(0);
expect(Math.imul(7, false)).to.equal(0);
expect(Math.imul(false, false)).to.equal(0);
expect(Math.imul(true, 7)).to.equal(7);
expect(Math.imul(7, true)).to.equal(7);
expect(Math.imul(true, true)).to.equal(1);
expect(Math.imul(undefined, 7)).to.equal(0);
expect(Math.imul(7, undefined)).to.equal(0);
expect(Math.imul(undefined, undefined)).to.equal(0);
expect(Math.imul(str, 7)).to.equal(0);
expect(Math.imul(7, str)).to.equal(0);
expect(Math.imul(obj, 7)).to.equal(0);
expect(Math.imul(7, obj)).to.equal(0);
expect(Math.imul(arr, 7)).to.equal(0);
expect(Math.imul(7, arr)).to.equal(0);
});
it('should be correct for hex values', function () {
expect(Math.imul(0xffffffff, 5)).to.equal(-5);
expect(Math.imul(0xfffffffe, 5)).to.equal(-10);
});
it('should be correct', function () {
expect(Math.imul(2, 4)).to.equal(8);
expect(Math.imul(-1, 8)).to.equal(-8);
expect(Math.imul(-2, -2)).to.equal(4);
expect(Math.imul(-0, 7)).to.equal(0);
expect(Math.imul(7, -0)).to.equal(0);
expect(Math.imul(0.1, 7)).to.equal(0);
expect(Math.imul(7, 0.1)).to.equal(0);
expect(Math.imul(0.9, 7)).to.equal(0);
expect(Math.imul(7, 0.9)).to.equal(0);
expect(Math.imul(1.1, 7)).to.equal(7);
expect(Math.imul(7, 1.1)).to.equal(7);
expect(Math.imul(1.9, 7)).to.equal(7);
expect(Math.imul(7, 1.9)).to.equal(7);
});
it('should be correct for objects with valueOf', function () {
var x = {
x: 0,
valueOf: function () { this.x += 1; return this.x; }
};
expect(Math.imul(x, 1)).to.equal(1);
expect(Math.imul(1, x)).to.equal(2);
expect(Math.imul(x, 1)).to.equal(3);
expect(Math.imul(1, x)).to.equal(4);
expect(Math.imul(x, 1)).to.equal(5);
});
});
describe('.round()', function () {
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.round).to.have.property('name', 'round');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('round').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.round).to.have.property('length', 1);
});
it('works for edge cases', function () {
expect(numberIsNaN(Math.round(NaN))).to.equal(true);
expect(isPositiveZero(Math.round(0))).to.equal(true);
expect(isNegativeZero(Math.round(-0))).to.equal(true);
expect(Math.round(Infinity)).to.equal(Infinity);
expect(Math.round(-Infinity)).to.equal(-Infinity);
});
it('returns 0 for (0,0.5)', function () {
expect(Math.round(0.5)).not.to.equal(0);
expect(Math.round(0.5 - (EPSILON / 4))).to.equal(0);
expect(Math.round(0 + (EPSILON / 4))).to.equal(0);
});
it('returns -0 for (-0.5,0)', function () {
expect(Math.round(-0.5)).to.equal(0);
expect(Math.round(-0.5 - (EPSILON / 3.99))).not.to.equal(0);
expect(isNegativeZero(Math.round(-0.5 + (EPSILON / 3.99)))).to.equal(true);
expect(isNegativeZero(Math.round(0 - (EPSILON / 3.99)))).to.equal(true);
});
it('returns 1 / Number.EPSILON + 1 for 1 / Number.EPSILON + 1', function () {
var inverseEpsilonPlus1 = (1 / EPSILON) + 1;
expect(Math.round(inverseEpsilonPlus1)).to.equal(inverseEpsilonPlus1);
});
it('returns 2 / Number.EPSILON - 1 for 2 / Number.EPSILON - 1', function () {
var twiceInverseEpsilonMinus1 = (2 / EPSILON) - 1;
expect(Math.round(twiceInverseEpsilonMinus1)).to.equal(twiceInverseEpsilonMinus1);
});
});
describe('.fround()', function () {
if (!Object.prototype.hasOwnProperty.call(Math, 'fround')) {
return it('exists', function () {
expect(Math).to.have.property('fround');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Math.fround).to.have.property('name', 'fround');
});
it('is not enumerable', function () {
expect(Math).ownPropertyDescriptor('fround').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Math.fround).to.have.property('length', 1);
});
// Mozilla's reference tests: https://bug900125.bugzilla.mozilla.org/attachment.cgi?id=793163
it('returns NaN for undefined', function () {
expect(numberIsNaN(Math.fround())).to.equal(true);
});
it('returns NaN for NaN', function () {
expect(numberIsNaN(Math.fround(NaN))).to.equal(true);
});
it('works for zeroes and infinities', function () {
expect(isPositiveZero(Math.fround(0))).to.equal(true);
expect(isPositiveZero(Math.fround({ valueOf: function () { return 0; } }))).to.equal(true);
expect(isNegativeZero(Math.fround(-0))).to.equal(true);
expect(isNegativeZero(Math.fround({ valueOf: function () { return -0; } }))).to.equal(true);
expect(Math.fround(Infinity)).to.equal(Infinity);
expect(Math.fround({ valueOf: function () { return Infinity; } })).to.equal(Infinity);
expect(Math.fround(-Infinity)).to.equal(-Infinity);
expect(Math.fround({ valueOf: function () { return -Infinity; } })).to.equal(-Infinity);
});
it('returns infinity for large numbers', function () {
expect(Math.fround(1.7976931348623157e+308)).to.equal(Infinity);
expect(Math.fround(-1.7976931348623157e+308)).to.equal(-Infinity);
expect(Math.fround(3.4028235677973366e+38)).to.equal(Infinity);
});
it('returns zero for really small numbers', function () {
expect(Number.MIN_VALUE).to.equal(5e-324);
expect(Math.fround(Number.MIN_VALUE)).to.equal(0);
expect(Math.fround(-Number.MIN_VALUE)).to.equal(0);
});
it('rounds properly', function () {
expect(Math.fround(3)).to.equal(3);
expect(Math.fround(-3)).to.equal(-3);
});
it('rounds properly with the max float 32', function () {
var maxFloat32 = 3.4028234663852886e+38;
expect(Math.fround(maxFloat32)).to.equal(maxFloat32);
expect(Math.fround(-maxFloat32)).to.equal(-maxFloat32);
// round-nearest rounds down to maxFloat32
expect(Math.fround(maxFloat32 + Math.pow(2, Math.pow(2, 8 - 1) - 1 - 23 - 2))).to.equal(maxFloat32);
});
it('rounds properly with the min float 32', function () {
var minFloat32 = 1.401298464324817e-45;
expect(Math.fround(minFloat32)).to.equal(minFloat32);
expect(Math.fround(-minFloat32)).to.equal(-minFloat32);
expect(Math.fround(minFloat32 / 2)).to.equal(0);
expect(Math.fround(-minFloat32 / 2)).to.equal(0);
expect(Math.fround((minFloat32 / 2) + Math.pow(2, -202))).to.equal(minFloat32);
expect(Math.fround((-minFloat32 / 2) - Math.pow(2, -202))).to.equal(-minFloat32);
});
});
});

2
node_modules/es6-shim/test/mocha.opts generated vendored Normal file
View File

@ -0,0 +1,2 @@
--require test/test_helpers.js

39
node_modules/es6-shim/test/native.html generated vendored Normal file
View File

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>es6-shim tests</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="browser-setup.js"></script>
<script src="array.js"></script>
<script src="map.js"></script>
<script src="set.js"></script>
<script src="json.js"></script>
<script src="math.js"></script>
<script src="number.js"></script>
<script src="object.js"></script>
<script src="promise.js"></script>
<script src="regexp.js"></script>
<script src="string.js"></script>
<script src="reflect.js"></script>
<script src="worker-test.js"></script>
<script src="promise/all.js"></script>
<script src="promise/evil-promises.js"></script>
<!--
<script src="promise/promises-aplus.js"></script>
-->
<script src="promise/race.js"></script>
<script src="promise/reject.js"></script>
<script src="promise/resolve.js"></script>
<script src="promise/simple.js"></script>
<script src="promise/subclass.js"></script>
<script src="browser-onload.js"></script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>

482
node_modules/es6-shim/test/number.js generated vendored Normal file
View File

@ -0,0 +1,482 @@
describe('Number', function () {
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
var integers = [5295, -5295, -9007199254740991, 9007199254740991, 0, -0];
var nonIntegers = [-9007199254741992, 9007199254741992, 5.9];
var infinities = [Infinity, -Infinity];
var valueOfThree = { valueOf: function () { return 3; } };
var valueOfNaN = { valueOf: function () { return NaN; } };
var valueOfThrows = { valueOf: function () { throw Object(17); } };
var toStringThrows = { toString: function () { throw Object(42); } };
var toPrimitiveThrows = {
valueOf: function () { throw Object(17); },
toString: function () { throw Object(42); }
};
var nonNumbers = [
undefined,
true,
false,
null,
{},
[],
'str',
'',
valueOfThree,
valueOfNaN,
valueOfThrows,
toStringThrows,
toPrimitiveThrows,
/a/g
];
var expectTrue = function (item) {
expect(item).to.equal(true);
};
var expectFalse = function (item) {
expect(item).to.equal(false);
};
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.Number).to.equal(Number);
});
describe('Number constants', function () {
it('should have max safe integer', function () {
expect(Number).to.have.property('MAX_SAFE_INTEGER');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'MAX_SAFE_INTEGER')).to.equal(false);
expect(Number.MAX_SAFE_INTEGER).to.equal(Math.pow(2, 53) - 1);
});
it('should have min safe integer', function () {
expect(Number).to.have.property('MIN_SAFE_INTEGER');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'MIN_SAFE_INTEGER')).to.equal(false);
expect(Number.MIN_SAFE_INTEGER).to.equal(-Math.pow(2, 53) + 1);
});
it('should have epsilon', function () {
expect(Number).to.have.property('EPSILON');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'EPSILON')).to.equal(false);
expect(Number.EPSILON).to.equal(2.2204460492503130808472633361816e-16);
});
it('should have NaN', function () {
expect(Number).to.have.property('NaN');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'NaN')).to.equal(false);
expect(isNaN(Number.NaN)).to.equal(true);
});
it('should have MAX_VALUE', function () {
expect(Number).to.have.property('MAX_VALUE');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'MAX_VALUE')).to.equal(false);
expect(Number.MAX_VALUE).to.equal(1.7976931348623157e+308);
});
it('should have MIN_VALUE', function () {
expect(Number).to.have.property('MIN_VALUE');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'MIN_VALUE')).to.equal(false);
expect(Number.MIN_VALUE).to.equal(5e-324);
});
it('should have NEGATIVE_INFINITY', function () {
expect(Number).to.have.property('NEGATIVE_INFINITY');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'NEGATIVE_INFINITY')).to.equal(false);
expect(Number.NEGATIVE_INFINITY).to.equal(-Infinity);
});
it('should have POSITIVE_INFINITY', function () {
expect(Number).to.have.property('POSITIVE_INFINITY');
expect(Object.prototype.propertyIsEnumerable.call(Number, 'POSITIVE_INFINITY')).to.equal(false);
expect(Number.POSITIVE_INFINITY).to.equal(Infinity);
});
});
describe('.parseInt()', function () {
if (!Object.prototype.hasOwnProperty.call(Number, 'parseInt')) {
return it('exists', function () {
expect(Number).to.have.property('parseInt');
});
}
it('should work', function () {
/* eslint-disable radix */
expect(Number.parseInt('601')).to.equal(601);
/* eslint-enable radix */
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Number.parseInt).to.have.property('name', 'parseInt');
});
it('is not enumerable', function () {
expect(Number).ownPropertyDescriptor('parseInt').to.have.property('enumerable', false);
});
it('has the right arity', function () {
// WebKit nightly had the wrong length; fixed in https://bugs.webkit.org/show_bug.cgi?id=143657
expect(Number.parseInt).to.have.property('length', 2);
});
it('is the same object as the global parseInt', function () {
// fixed in WebKit nightly in https://bugs.webkit.org/show_bug.cgi?id=143799#add_comment
expect(Number.parseInt).to.equal(parseInt);
});
});
describe('.parseFloat()', function () {
if (!Object.prototype.hasOwnProperty.call(Number, 'parseFloat')) {
return it('exists', function () {
expect(Number).to.have.property('parseFloat');
});
}
it('should work', function () {
expect(Number.parseFloat('5.5')).to.equal(5.5);
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Number.parseFloat).to.have.property('name', 'parseFloat');
});
it('is not enumerable', function () {
expect(Number).ownPropertyDescriptor('parseFloat').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Number.parseFloat).to.have.property('length', 1);
});
});
describe('.isFinite()', function () {
if (!Object.prototype.hasOwnProperty.call(Number, 'isFinite')) {
return it('exists', function () {
expect(Number).to.have.property('isFinite');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Number.isFinite).to.have.property('name', 'isFinite');
});
it('is not enumerable', function () {
expect(Number).ownPropertyDescriptor('isFinite').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Number.isFinite).to.have.property('length', 1);
});
it('should work', function () {
integers.map(Number.isFinite).forEach(expectTrue);
infinities.map(Number.isFinite).forEach(expectFalse);
expect(Number.isFinite(Infinity)).to.equal(false);
expect(Number.isFinite(-Infinity)).to.equal(false);
expect(Number.isFinite(NaN)).to.equal(false);
expect(Number.isFinite(4)).to.equal(true);
expect(Number.isFinite(4.5)).to.equal(true);
expect(Number.isFinite('hi')).to.equal(false);
expect(Number.isFinite('1.3')).to.equal(false);
expect(Number.isFinite('51')).to.equal(false);
expect(Number.isFinite(0)).to.equal(true);
expect(Number.isFinite(-0)).to.equal(true);
expect(Number.isFinite(valueOfThree)).to.equal(false);
expect(Number.isFinite(valueOfNaN)).to.equal(false);
expect(Number.isFinite(valueOfThrows)).to.equal(false);
expect(Number.isFinite(toStringThrows)).to.equal(false);
expect(Number.isFinite(toPrimitiveThrows)).to.equal(false);
});
it('should not be confused by type coercion', function () {
nonNumbers.map(Number.isFinite).forEach(expectFalse);
});
});
describe('.isInteger()', function () {
if (!Object.prototype.hasOwnProperty.call(Number, 'isInteger')) {
return it('exists', function () {
expect(Number).to.have.property('isInteger');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Number.isInteger).to.have.property('name', 'isInteger');
});
it('is not enumerable', function () {
expect(Number).ownPropertyDescriptor('isInteger').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Number.isInteger).to.have.property('length', 1);
});
it('should be truthy on integers', function () {
integers.map(Number.isInteger).forEach(expectTrue);
expect(Number.isInteger(4)).to.equal(true);
expect(Number.isInteger(4.0)).to.equal(true);
expect(Number.isInteger(1801439850948)).to.equal(true);
});
it('should be false when the type is not number', function () {
nonNumbers.forEach(function (thing) {
expect(Number.isInteger(thing)).to.equal(false);
});
});
it('should be false when NaN', function () {
expect(Number.isInteger(NaN)).to.equal(false);
});
it('should be false when ∞', function () {
expect(Number.isInteger(Infinity)).to.equal(false);
expect(Number.isInteger(-Infinity)).to.equal(false);
});
it('should be false when number is not integer', function () {
expect(Number.isInteger(3.4)).to.equal(false);
expect(Number.isInteger(-3.4)).to.equal(false);
});
it('should be true when abs(number) is 2^53 or larger', function () {
expect(Number.isInteger(Math.pow(2, 53))).to.equal(true);
expect(Number.isInteger(Math.pow(2, 54))).to.equal(true);
expect(Number.isInteger(-Math.pow(2, 53))).to.equal(true);
expect(Number.isInteger(-Math.pow(2, 54))).to.equal(true);
});
it('should be true when abs(number) is less than 2^53', function () {
var safeIntegers = [0, 1, Math.pow(2, 53) - 1];
safeIntegers.forEach(function (integer) {
expect(Number.isInteger(integer)).to.equal(true);
expect(Number.isInteger(-integer)).to.equal(true);
});
});
});
describe('.isSafeInteger()', function () {
if (!Object.prototype.hasOwnProperty.call(Number, 'isSafeInteger')) {
return it('exists', function () {
expect(Number).to.have.property('isSafeInteger');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Number.isSafeInteger).to.have.property('name', 'isSafeInteger');
});
it('is not enumerable', function () {
expect(Number).ownPropertyDescriptor('isSafeInteger').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Number.isSafeInteger).to.have.property('length', 1);
});
it('should be truthy on integers', function () {
integers.map(Number.isSafeInteger).forEach(expectTrue);
expect(Number.isSafeInteger(4)).to.equal(true);
expect(Number.isSafeInteger(4.0)).to.equal(true);
expect(Number.isSafeInteger(1801439850948)).to.equal(true);
});
it('should be false when the type is not number', function () {
nonNumbers.forEach(function (thing) {
expect(Number.isSafeInteger(thing)).to.equal(false);
});
});
it('should be false when NaN', function () {
expect(Number.isSafeInteger(NaN)).to.equal(false);
});
it('should be false when ∞', function () {
expect(Number.isSafeInteger(Infinity)).to.equal(false);
expect(Number.isSafeInteger(-Infinity)).to.equal(false);
});
it('should be false when number is not integer', function () {
expect(Number.isSafeInteger(3.4)).to.equal(false);
expect(Number.isSafeInteger(-3.4)).to.equal(false);
});
it('should be false when abs(number) is 2^53 or larger', function () {
expect(Number.isSafeInteger(Math.pow(2, 53))).to.equal(false);
expect(Number.isSafeInteger(Math.pow(2, 54))).to.equal(false);
expect(Number.isSafeInteger(-Math.pow(2, 53))).to.equal(false);
expect(Number.isSafeInteger(-Math.pow(2, 54))).to.equal(false);
});
it('should be true when abs(number) is less than 2^53', function () {
var safeIntegers = [0, 1, Math.pow(2, 53) - 1];
safeIntegers.forEach(function (integer) {
expect(Number.isSafeInteger(integer)).to.equal(true);
expect(Number.isSafeInteger(-integer)).to.equal(true);
});
});
});
describe('.isNaN()', function () {
if (!Object.prototype.hasOwnProperty.call(Number, 'isNaN')) {
return it('exists', function () {
expect(Number).to.have.property('isNaN');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Number.isNaN).to.have.property('name', 'isNaN');
});
it('is not enumerable', function () {
expect(Number).ownPropertyDescriptor('isNaN').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Number.isNaN).to.have.property('length', 1);
});
it('should be truthy only on NaN', function () {
integers.concat(nonIntegers).map(Number.isNaN).forEach(expectFalse);
nonNumbers.map(Number.isNaN).forEach(expectFalse);
expect(Number.isNaN(NaN)).to.equal(true);
expect(Number.isNaN(0 / 0)).to.equal(true);
expect(Number.isNaN(Number('NaN'))).to.equal(true);
expect(Number.isNaN(4)).to.equal(false);
expect(Number.isNaN(4.5)).to.equal(false);
expect(Number.isNaN('hi')).to.equal(false);
expect(Number.isNaN('1.3')).to.equal(false);
expect(Number.isNaN('51')).to.equal(false);
expect(Number.isNaN(0)).to.equal(false);
expect(Number.isNaN(-0)).to.equal(false);
expect(Number.isNaN(valueOfThree)).to.equal(false);
expect(Number.isNaN(valueOfNaN)).to.equal(false);
expect(Number.isNaN(valueOfThrows)).to.equal(false);
expect(Number.isNaN(toStringThrows)).to.equal(false);
expect(Number.isNaN(toPrimitiveThrows)).to.equal(false);
});
});
describe('constructor', function () {
it('behaves like the builtin', function () {
expect((1).constructor).to.equal(Number);
expect(Number()).to.equal(0);
});
describe('strings in the constructor', function () {
it('works on normal literals', function () {
expect(Number('1')).to.equal(+'1');
expect(Number('1.1')).to.equal(+'1.1');
expect(Number('0xA')).to.equal(0xA);
});
});
describe('when called with a receiver', function () {
it('returns a primitive when called with a primitive receiver', function () {
expect((1).constructor(2)).to.equal(2);
expect((1).constructor.call(null, 3)).to.equal(3);
expect(Object(1).constructor.call(null, 5)).to.equal(5);
});
it('returns a primitive when called with a different number as an object receiver', function () {
expect(Object(1).constructor(6)).to.equal(6);
expect(Object(1).constructor.call(Object(1), 7)).to.equal(7);
});
it('returns a primitive when called with the same number as an object receiver', function () {
expect(Object(1).constructor.call(Object(8), 8)).to.equal(8);
});
});
it('works with boxed primitives', function () {
expect(1 instanceof Number).to.equal(false);
expect(Object(1) instanceof Number).to.equal(true);
});
it('works with `new`', function () {
/* eslint-disable no-new-wrappers */
var one = new Number('1');
var a = new Number('0xA');
/* eslint-enable no-new-wrappers */
expect(+one).to.equal(1);
expect(one instanceof Number).to.equal(true);
expect(+a).to.equal(0xA);
expect(a instanceof Number).to.equal(true);
});
it('works with binary literals in string form', function () {
expect(Number('0b1')).to.equal(1);
expect(Number(' 0b1')).to.equal(1);
expect(Number('0b1 ')).to.equal(1);
expect(Number('0b10')).to.equal(2);
expect(Number(' 0b10')).to.equal(2);
expect(Number('0b10 ')).to.equal(2);
expect(Number('0b11')).to.equal(3);
expect(Number(' 0b11')).to.equal(3);
expect(Number('0b11 ')).to.equal(3);
expect(Number({
toString: function () { return '0b100'; },
valueOf: function () { return '0b101'; }
})).to.equal(5);
});
it('works with octal literals in string form', function () {
expect(Number('0o7')).to.equal(7);
expect(Number('0o10')).to.equal(8);
expect(Number('0o11')).to.equal(9);
expect(Number({
toString: function () { return '0o12'; },
valueOf: function () { return '0o13'; }
})).to.equal(11);
});
it('should produce NaN', function () {
expect(String(Number('0b12'))).to.equal('NaN');
expect(String(Number('0o18'))).to.equal('NaN');
expect(String(Number('0x1g'))).to.equal('NaN');
expect(String(Number('+0b1'))).to.equal('NaN');
expect(String(Number('+0o1'))).to.equal('NaN');
expect(String(Number('+0x1'))).to.equal('NaN');
expect(String(Number('-0b1'))).to.equal('NaN');
expect(String(Number('-0o1'))).to.equal('NaN');
expect(String(Number('-0x1'))).to.equal('NaN');
});
it('should work with well formed and poorly formed objects', function () {
expect(String(Number({}))).to.equal('NaN');
expect(String(Number({ valueOf: '1.1' }))).to.equal('NaN');
expect(Number({ valueOf: '1.1', toString: function () { return '2.2'; } })).to.equal(2.2);
expect(Number({ valueOf: function () { return '1.1'; }, toString: '2.2' })).to.equal(1.1);
expect(Number({
valueOf: function () { return '1.1'; },
toString: function () { return '2.2'; }
})).to.equal(1.1);
expect(String(Number({ valueOf: function () { return '-0x1a2b3c'; } }))).to.equal('NaN');
expect(String(Number({ toString: function () { return '-0x1a2b3c'; } }))).to.equal('NaN');
expect(Number({ valueOf: function () { return '0o12345'; } })).to.equal(5349);
expect(Number({ toString: function () { return '0o12345'; } })).to.equal(5349);
expect(Number({ valueOf: function () { return '0b101010'; } })).to.equal(42);
expect(Number({ toString: function () { return '0b101010'; } })).to.equal(42);
});
it('should work with correct whitespaces', function () {
// Zero-width space (zws), next line character (nel), and non-character (bom) are not whitespace.
var nonWhitespaces = ['\u0085', '\u200b', '\ufffe'];
expect(String(Number(nonWhitespaces[0] + '0' + nonWhitespaces[0]))).to.equal('NaN');
expect(String(Number(nonWhitespaces[1] + '1' + nonWhitespaces[1]))).to.equal('NaN');
expect(String(Number(nonWhitespaces[2] + '2' + nonWhitespaces[2]))).to.equal('NaN');
});
it.skip('it works with updated unicode values', function () {
var whitespace = ' \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000';
expect(String(Number(whitespace + '3' + whitespace))).to.equal('3');
});
});
});

365
node_modules/es6-shim/test/object.js generated vendored Normal file
View File

@ -0,0 +1,365 @@
describe('Object', function () {
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.Object).to.equal(Object);
});
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var ifExtensionsPreventable = Object.preventExtensions ? it : xit;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
var ifSymbolsIt = hasSymbols ? it : xit;
var ifBrowserIt = typeof window === 'object' && typeof document === 'object' ? it : xit;
var ifObjectGetPrototypeOfIt = typeof Object.getPrototypeOf === 'function' ? it : xit;
if (Object.getOwnPropertyNames) {
describe('.getOwnPropertyNames()', function () {
it('throws on null or undefined', function () {
expect(function () { Object.getOwnPropertyNames(); }).to['throw'](TypeError);
expect(function () { Object.getOwnPropertyNames(undefined); }).to['throw'](TypeError);
expect(function () { Object.getOwnPropertyNames(null); }).to['throw'](TypeError);
});
it('works on primitives', function () {
[true, false, NaN, 42, /a/g, 'foo'].forEach(function (item) {
expect(Object.getOwnPropertyNames(item)).to.eql(Object.getOwnPropertyNames(Object(item)));
});
});
ifBrowserIt('does not break when an iframe is added', function () {
/*global window, document */
var div = document.createElement('div');
div.innerHTML = '<iframe src="http://xkcd.com"></iframe>';
document.body.appendChild(div);
setTimeout(function () {
document.body.removeChild(div);
}, 0);
expect(Array.isArray(Object.getOwnPropertyNames(window))).to.eql(true);
});
});
}
if (Object.getOwnPropertyDescriptor) {
describe('.getOwnPropertyDescriptor()', function () {
it('throws on null or undefined', function () {
expect(function () { Object.getOwnPropertyDescriptor(); }).to['throw'](TypeError);
expect(function () { Object.getOwnPropertyDescriptor(undefined); }).to['throw'](TypeError);
expect(function () { Object.getOwnPropertyDescriptor(null); }).to['throw'](TypeError);
});
it('works on primitives', function () {
[true, false, NaN, 42, /a/g, 'foo'].forEach(function (item) {
expect(Object.getOwnPropertyDescriptor(item, 'foo')).to.eql(Object.getOwnPropertyDescriptor(Object(item), 'foo'));
});
});
});
}
if (Object.seal) {
describe('.seal()', function () {
it('works on primitives', function () {
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
expect(Object.seal(item)).to.eql(item);
});
});
});
}
if (Object.isSealed) {
describe('.isSealed()', function () {
it('works on primitives', function () {
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
expect(Object.isSealed(item)).to.equal(true);
});
});
});
}
if (Object.freeze) {
describe('.freeze()', function () {
it('works on primitives', function () {
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
expect(Object.freeze(item)).to.eql(item);
});
});
});
}
if (Object.isFrozen) {
describe('.isFrozen()', function () {
it('works on primitives', function () {
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
expect(Object.isFrozen(item)).to.equal(true);
});
});
});
}
if (Object.preventExtensions) {
describe('.preventExtensions()', function () {
it('works on primitives', function () {
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
expect(Object.preventExtensions(item)).to.eql(item);
});
});
});
}
if (Object.isExtensible) {
describe('.isExtensible()', function () {
it('works on primitives', function () {
[null, undefined, true, false, NaN, 42, 'foo'].forEach(function (item) {
expect(Object.isExtensible(item)).to.equal(false);
});
});
});
}
describe('.keys()', function () {
it('works on strings', function () {
expect(Object.keys('foo')).to.eql(['0', '1', '2']);
});
it('throws on null or undefined', function () {
expect(function () { Object.keys(); }).to['throw'](TypeError);
expect(function () { Object.keys(undefined); }).to['throw'](TypeError);
expect(function () { Object.keys(null); }).to['throw'](TypeError);
});
it('works on other primitives', function () {
[true, false, NaN, 42, /a/g].forEach(function (item) {
expect(Object.keys(item)).to.eql([]);
});
});
});
describe('.is()', function () {
if (!Object.prototype.hasOwnProperty.call(Object, 'is')) {
return it('exists', function () {
expect(Object).to.have.property('is');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Object.is).to.have.property('name', 'is');
});
it('should have the right arity', function () {
expect(Object.is).to.have.property('length', 2);
});
it('should compare regular objects correctly', function () {
[null, undefined, [0], 5, 'str', { a: null }].map(function (item) {
return Object.is(item, item);
}).forEach(function (result) {
expect(result).to.equal(true);
});
});
it('should compare 0 and -0 correctly', function () {
expect(Object.is(0, -0)).to.equal(false);
});
it('should compare NaNs correctly', function () {
expect(Object.is(NaN, NaN)).to.equal(true);
});
});
describe('.assign()', function () {
if (!Object.prototype.hasOwnProperty.call(Object, 'assign')) {
return it('exists', function () {
expect(Object).to.have.property('assign');
});
}
it('has the correct length', function () {
expect(Object.assign.length).to.eql(2);
});
it('returns the modified target object', function () {
var target = {};
var returned = Object.assign(target, { a: 1 });
expect(returned).to.equal(target);
});
it('should merge two objects', function () {
var target = { a: 1 };
var returned = Object.assign(target, { b: 2 });
expect(returned).to.eql({ a: 1, b: 2 });
});
it('should merge three objects', function () {
var target = { a: 1 };
var source1 = { b: 2 };
var source2 = { c: 3 };
var returned = Object.assign(target, source1, source2);
expect(returned).to.eql({ a: 1, b: 2, c: 3 });
});
it('only iterates over own keys', function () {
var Foo = function () {};
Foo.prototype.bar = true;
var foo = new Foo();
foo.baz = true;
var target = { a: 1 };
var returned = Object.assign(target, foo);
expect(returned).to.equal(target);
expect(target).to.eql({ baz: true, a: 1 });
});
it('throws when target is null or undefined', function () {
expect(function () { Object.assign(null); }).to['throw'](TypeError);
expect(function () { Object.assign(undefined); }).to['throw'](TypeError);
});
it('coerces lone target to an object', function () {
var result = {
bool: Object.assign(true),
number: Object.assign(1),
string: Object.assign('1')
};
expect(typeof result.bool).to.equal('object');
expect(Boolean.prototype.valueOf.call(result.bool)).to.equal(true);
expect(typeof result.number).to.equal('object');
expect(Number.prototype.valueOf.call(result.number)).to.equal(1);
expect(typeof result.string).to.equal('object');
expect(String.prototype.valueOf.call(result.string)).to.equal('1');
});
it('coerces target to an object, assigns from sources', function () {
var sourceA = { a: 1 };
var sourceB = { b: 1 };
var result = {
bool: Object.assign(true, sourceA, sourceB),
number: Object.assign(1, sourceA, sourceB),
string: Object.assign('1', sourceA, sourceB)
};
expect(typeof result.bool).to.equal('object');
expect(Boolean.prototype.valueOf.call(result.bool)).to.equal(true);
expect(result.bool).to.eql({ a: 1, b: 1 });
expect(typeof result.number).to.equal('object');
expect(Number.prototype.valueOf.call(result.number)).to.equal(1);
expect(typeof result.string).to.equal('object');
expect(String.prototype.valueOf.call(result.string)).to.equal('1');
expect(result.string).to.eql({ 0: '1', a: 1, b: 1 });
});
it('ignores non-object sources', function () {
expect(Object.assign({ a: 1 }, null, { b: 2 })).to.eql({ a: 1, b: 2 });
expect(Object.assign({ a: 1 }, undefined, { b: 2 })).to.eql({ a: 1, b: 2 });
expect(Object.assign({ a: 1 }, { b: 2 }, null)).to.eql({ a: 1, b: 2 });
});
ifExtensionsPreventable('does not have pending exceptions', function () {
'use strict';
// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
// which is 72% slower than our shim, and Firefox 40's native implementation.
var thrower = { 1: 2, 2: 3, 3: 4 };
Object.defineProperty(thrower, 2, {
get: function () { return 3; },
set: function (v) { throw new RangeError('IE 9 does not throw on preventExtensions: ' + v); }
});
Object.preventExtensions(thrower);
expect(thrower).to.have.property(2, 3);
var error;
try {
Object.assign(thrower, 'wxyz');
} catch (e) {
error = e;
}
expect(thrower).not.to.have.property(0);
if (thrower[1] === 'x') {
// IE 9 doesn't throw in strict mode with preventExtensions
expect(error).to.be.an.instanceOf(RangeError);
} else {
expect(error).to.be.an.instanceOf(TypeError);
expect(thrower).to.have.property(1, 2);
}
expect(thrower).to.have.property(2, 3);
expect(thrower).to.have.property(3, 4);
});
ifSymbolsIt('includes enumerable symbols, after keys', function () {
/* eslint max-statements-per-line: 1 */
var visited = [];
var obj = {};
Object.defineProperty(obj, 'a', { get: function () { visited.push('a'); return 42; }, enumerable: true });
var symbol = Symbol('enumerable');
Object.defineProperty(obj, symbol, {
get: function () { visited.push(symbol); return Infinity; },
enumerable: true
});
var nonEnumSymbol = Symbol('non-enumerable');
Object.defineProperty(obj, nonEnumSymbol, {
get: function () { visited.push(nonEnumSymbol); return -Infinity; },
enumerable: false
});
var target = Object.assign({}, obj);
expect(visited).to.eql(['a', symbol]);
expect(target.a).to.equal(42);
expect(target[symbol]).to.equal(Infinity);
expect(target[nonEnumSymbol]).not.to.equal(-Infinity);
});
});
describe('Object.setPrototypeOf()', function () {
if (!Object.setPrototypeOf) {
return; // IE < 11
}
describe('argument checking', function () {
it('should throw TypeError if first arg is not object', function () {
var nonObjects = [null, undefined, true, false, 1, 3, 'foo'];
nonObjects.forEach(function (value) {
expect(function () { Object.setPrototypeOf(value); }).to['throw'](TypeError);
});
});
it('should throw TypeError if second arg is not object or null', function () {
expect(function () { Object.setPrototypeOf({}, null); }).not.to['throw'](TypeError);
var invalidPrototypes = [true, false, 1, 3, 'foo'];
invalidPrototypes.forEach(function (proto) {
expect(function () { Object.setPrototypeOf({}, proto); }).to['throw'](TypeError);
});
});
});
describe('set prototype', function () {
it('should work', function () {
var Foo = function () {};
var Bar = {};
var foo = new Foo();
expect(Object.getPrototypeOf(foo)).to.equal(Foo.prototype);
var fooBar = Object.setPrototypeOf(foo, Bar);
expect(fooBar).to.equal(foo);
expect(Object.getPrototypeOf(foo)).to.equal(Bar);
});
it('should be able to set to null', function () {
var Foo = function () {};
var foo = new Foo();
var fooNull = Object.setPrototypeOf(foo, null);
expect(fooNull).to.equal(foo);
expect(Object.getPrototypeOf(foo)).to.equal(null);
});
});
});
describe('.getPrototypeOf()', function () {
ifObjectGetPrototypeOfIt('does not throw for a primitive', function () {
expect(Object.getPrototypeOf(3)).to.equal(Number.prototype);
});
});
});

43
node_modules/es6-shim/test/promise.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
/* This file is for testing implementation regressions of Promises. */
describe('Promise', function () {
if (typeof Promise === 'undefined') {
return it('exists', function () {
expect(typeof Promise).to.be('function');
});
}
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.Promise).to.equal(Promise);
});
it('ignores non-function .then arguments', function () {
expect(function () {
Promise.reject(42).then(null, 5).then(null, function () {});
}).not.to['throw']();
});
describe('extra methods (bad Chrome!)', function () {
it('does not have accept', function () {
expect(Promise).not.to.have.property('accept');
});
it('does not have defer', function () {
expect(Promise).not.to.have.property('defer');
});
it('does not have chain', function () {
expect(Promise.prototype).not.to.have.property('chain');
});
});
it('requires an object context', function () {
// this fails in Safari 7.1 - 9
expect(function promiseDotCallThree() {
Promise.call(3, function () {});
}).to['throw']();
});
});

197
node_modules/es6-shim/test/promise/all.js generated vendored Normal file
View File

@ -0,0 +1,197 @@
/* global it, describe, expect, assert, Promise */
var failIfThrows = function (done) {
'use strict';
return function (e) {
done(e || new Error());
};
};
describe('Promise.all', function () {
'use strict';
it('should not be enumerable', function () {
expect(Promise).ownPropertyDescriptor('all').to.have.property('enumerable', false);
});
it('fulfills if passed an empty array', function (done) {
var iterable = [];
Promise.all(iterable).then(function (value) {
assert(Array.isArray(value));
assert.deepEqual(value, []);
}).then(done, failIfThrows(done));
});
it('fulfills if passed an empty array-like', function (done) {
var f = function () {
Promise.all(arguments).then(function (value) {
assert(Array.isArray(value));
assert.deepEqual(value, []);
}).then(done, failIfThrows(done));
};
f();
});
it('fulfills if passed an array of mixed fulfilled promises and values', function (done) {
var iterable = [0, Promise.resolve(1), 2, Promise.resolve(3)];
Promise.all(iterable).then(function (value) {
assert(Array.isArray(value));
assert.deepEqual(value, [0, 1, 2, 3]);
}).then(done, failIfThrows(done));
});
it('rejects if any passed promise is rejected', function (done) {
var foreverPending = new Promise(function () { });
var error = new Error('Rejected');
var rejected = Promise.reject(error);
var iterable = [foreverPending, rejected];
Promise.all(iterable).then(
function () {
assert(false, 'should never get here');
},
function (reason) {
assert.strictEqual(reason, error);
}
).then(done, failIfThrows(done));
});
it('resolves foreign thenables', function (done) {
var normal = Promise.resolve(1);
var foreign = { then: function (f) { f(2); } };
var iterable = [normal, foreign];
Promise.all(iterable).then(function (value) {
assert.deepEqual(value, [1, 2]);
}).then(done, failIfThrows(done));
});
it('fulfills when passed an sparse array, giving `undefined` for the omitted values', function (done) {
/* eslint-disable no-sparse-arrays */
var iterable = [Promise.resolve(0), , , Promise.resolve(1)];
/* eslint-enable no-sparse-arrays */
Promise.all(iterable).then(function (value) {
assert.deepEqual(value, [0, undefined, undefined, 1]);
}).then(done, failIfThrows(done));
});
it('does not modify the input array', function (done) {
var input = [0, 1];
var iterable = input;
Promise.all(iterable).then(function (value) {
assert.notStrictEqual(input, value);
}).then(done, failIfThrows(done));
});
it('should reject with a TypeError if given a non-iterable', function (done) {
var notIterable = {};
Promise.all(notIterable).then(
function () {
assert(false, 'should never get here');
},
function (reason) {
assert(reason instanceof TypeError);
}
).then(done, failIfThrows(done));
});
// test cases from
// https://github.com/domenic/promises-unwrapping/issues/89#issuecomment-33110203
var tamper = function (p) {
p.then = function (fulfill, reject) {
fulfill('tampered');
return Promise.prototype.then.call(this, fulfill, reject);
};
return p;
};
it('should be robust against tampering (1)', function (done) {
var g = [tamper(Promise.resolve(0))];
// Prevent countdownHolder.[[Countdown]] from ever reaching zero
Promise.all(g).then(
function () { done(); },
failIfThrows(done)
);
});
it('should be robust against tampering (2)', function (done) {
// Promise from Promise.all resolved before arguments
var fulfillCalled = false;
var g = [
Promise.resolve(0),
tamper(Promise.resolve(1)),
Promise.resolve(2).then(function () {
assert(!fulfillCalled, 'should be resolved before all()');
}).then(function () {
assert(!fulfillCalled, 'should be resolved before all()');
})['catch'](failIfThrows(done))
];
Promise.all(g).then(function () {
assert(!fulfillCalled, 'should be resolved last');
fulfillCalled = true;
}).then(done, failIfThrows(done));
});
it('should be robust against tampering (3)', function (done) {
var g = [
Promise.resolve(0),
tamper(Promise.resolve(1)),
Promise.reject(2)
];
// Promise from Promise.all resolved despite rejected promise in arguments
Promise.all(g).then(function () {
throw new Error('should not reach here!');
}, function (e) {
assert.strictEqual(e, 2);
}).then(done, failIfThrows(done));
});
it('should be robust against tampering (4)', function (done) {
var hijack = true;
var actualArguments = [];
var P = function (resolver) {
var self;
if (hijack) {
hijack = false;
self = new Promise(function (resolve, reject) {
return resolver(function (values) {
// record arguments & # of times resolve function is called
actualArguments.push(values.slice());
return resolve(values);
}, reject);
});
} else {
self = new Promise(resolver);
}
Object.setPrototypeOf(self, P.prototype);
return self;
};
if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11
Object.setPrototypeOf(P, Promise);
P.prototype = Object.create(Promise.prototype, {
constructor: { value: P }
});
P.resolve = function (p) { return p; };
var g = [
Promise.resolve(0),
tamper(Promise.resolve(1)),
Promise.resolve(2)
];
// Promise.all calls resolver twice
P.all(g)['catch'](failIfThrows(done));
Promise.resolve().then(function () {
assert.deepEqual(actualArguments, [[0, 'tampered', 2]]);
}).then(done, failIfThrows(done));
});
});

36
node_modules/es6-shim/test/promise/evil-promises.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
describe('Evil promises should not be able to break invariants', function () {
'use strict';
specify('resolving to a promise that calls onFulfilled twice', function (done) {
// note that we have to create a trivial subclass, as otherwise the
// Promise.resolve(evilPromise) is just the identity function.
// (And in fact, most native Promise implementations use a private
// [[PromiseConstructor]] field in `Promise.resolve` which can't be
// easily patched in an ES5 engine, so instead of
// `Promise.resolve(evilPromise)` we'll use
// `new Promise(function(r){r(evilPromise);})` below.)
var EvilPromise = function (executor) {
var self = new Promise(executor);
Object.setPrototypeOf(self, EvilPromise.prototype);
return self;
};
if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11
Object.setPrototypeOf(EvilPromise, Promise);
EvilPromise.prototype = Object.create(Promise.prototype, {
constructor: { value: EvilPromise }
});
var evilPromise = EvilPromise.resolve();
evilPromise.then = function (f) {
f(1);
f(2);
};
var calledAlready = false;
new Promise(function (r) { r(evilPromise); }).then(function (value) {
assert.strictEqual(calledAlready, false);
calledAlready = true;
assert.strictEqual(value, 1);
}).then(done, done);
});
});

23
node_modules/es6-shim/test/promise/promises-aplus.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
// tests from promises-aplus-tests
describe('Promises/A+ Tests', function () {
'use strict';
if (typeof Promise === 'undefined') {
return;
}
require('promises-aplus-tests').mocha({
// an adapter from es6 spec to Promises/A+
deferred: function () {
var result = {};
result.promise = new Promise(function (resolve, reject) {
result.resolve = resolve;
result.reject = reject;
});
return result;
},
resolved: Promise.resolve.bind(Promise),
rejected: Promise.reject.bind(Promise)
});
});

22
node_modules/es6-shim/test/promise/promises-es6.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
// tests from promises-es6-tests
(function () {
'use strict';
if (typeof Promise === 'undefined') {
return;
}
describe('Promises/ES6 Tests', function () {
// an adapter that sets up global.Promise
// since it's already set up, empty functions will suffice
var adapter = {
defineGlobalPromise: function () {
},
removeGlobalPromise: function () {
}
};
require('promises-es6-tests').mocha(adapter);
});
}());

88
node_modules/es6-shim/test/promise/race.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
var failIfThrows = function (done) {
'use strict';
return function (e) {
done(e || new Error());
};
};
var delayPromise = function (value, ms) {
'use strict';
return new Promise(function (resolve) {
setTimeout(function () {
resolve(value);
}, ms);
});
};
describe('Promise.race', function () {
'use strict';
it('should not be enumerable', function () {
expect(Promise).ownPropertyDescriptor('race').to.have.property('enumerable', false);
});
it('should fulfill if all promises are settled and the ordinally-first is fulfilled', function (done) {
var iterable = [Promise.resolve(1), Promise.reject(2), Promise.resolve(3)];
Promise.race(iterable).then(function (value) {
assert.strictEqual(value, 1);
}).then(done, failIfThrows(done));
});
it('should reject if all promises are settled and the ordinally-first is rejected', function (done) {
var iterable = [Promise.reject(1), Promise.reject(2), Promise.resolve(3)];
Promise.race(iterable).then(
function () {
assert(false, 'should never get here');
},
function (reason) {
assert.strictEqual(reason, 1);
}
).then(done, failIfThrows(done));
});
it('should settle in the same way as the first promise to settle', function (done) {
// ensure that even if timeouts are delayed an all execute together,
// p2 will settle first.
var p2 = delayPromise(2, 200);
var p1 = delayPromise(1, 1000);
var p3 = delayPromise(3, 500);
var iterable = [p1, p2, p3];
Promise.race(iterable).then(function (value) {
assert.strictEqual(value, 2);
}).then(done, failIfThrows(done));
});
// see https://github.com/domenic/promises-unwrapping/issues/75
it('should never settle when given an empty iterable', function (done) {
var iterable = [];
var settled = false;
Promise.race(iterable).then(
function () { settled = true; },
function () { settled = true; }
);
setTimeout(function () {
assert.strictEqual(settled, false);
done();
}, 300);
});
it('should reject with a TypeError if given a non-iterable', function (done) {
var notIterable = {};
Promise.race(notIterable).then(
function () {
assert(false, 'should never get here');
},
function (reason) {
assert(reason instanceof TypeError);
}
).then(done, failIfThrows(done));
});
});

34
node_modules/es6-shim/test/promise/reject.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
var failIfThrows = function (done) {
'use strict';
return function (e) {
done(e || new Error());
};
};
describe('Promise.reject', function () {
'use strict';
it('should not be enumerable', function () {
expect(Promise).ownPropertyDescriptor('reject').to.have.property('enumerable', false);
});
it('should return a rejected promise', function (done) {
var value = {};
Promise.reject(value).then(failIfThrows(done), function (result) {
expect(result).to.equal(value);
done();
});
});
it('throws when receiver is a primitive', function () {
var promise = Promise.reject();
expect(function () { Promise.reject.call(undefined, promise); }).to['throw']();
expect(function () { Promise.reject.call(null, promise); }).to['throw']();
expect(function () { Promise.reject.call('', promise); }).to['throw']();
expect(function () { Promise.reject.call(42, promise); }).to['throw']();
expect(function () { Promise.reject.call(false, promise); }).to['throw']();
expect(function () { Promise.reject.call(true, promise); }).to['throw']();
promise.then(null, function () {}); // silence unhandled rejection errors in Chrome
});
});

33
node_modules/es6-shim/test/promise/resolve.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
var failIfThrows = function (done) {
'use strict';
return function (e) {
done(e || new Error());
};
};
describe('Promise.resolve', function () {
'use strict';
it('should not be enumerable', function () {
expect(Promise).ownPropertyDescriptor('resolve').to.have.property('enumerable', false);
});
it('should return a resolved promise', function (done) {
var value = {};
Promise.resolve(value).then(function (result) {
expect(result).to.equal(value);
done();
}, failIfThrows(done));
});
it('throws when receiver is a primitive', function () {
var promise = Promise.resolve();
expect(function () { Promise.resolve.call(undefined, promise); }).to['throw']();
expect(function () { Promise.resolve.call(null, promise); }).to['throw']();
expect(function () { Promise.resolve.call('', promise); }).to['throw']();
expect(function () { Promise.resolve.call(42, promise); }).to['throw']();
expect(function () { Promise.resolve.call(false, promise); }).to['throw']();
expect(function () { Promise.resolve.call(true, promise); }).to['throw']();
});
});

96
node_modules/es6-shim/test/promise/simple.js generated vendored Normal file
View File

@ -0,0 +1,96 @@
var failIfThrows = function (done) {
'use strict';
return function (e) {
done(e || new Error());
};
};
describe('Promise', function () {
'use strict';
specify('sanity check: a fulfilled promise calls its fulfillment handler', function (done) {
Promise.resolve(5).then(function (value) {
assert.strictEqual(value, 5);
}).then(done, failIfThrows(done));
});
specify('directly resolving the promise with itself', function (done) {
var resolvePromise;
var promise = new Promise(function (resolve) { resolvePromise = resolve; });
resolvePromise(promise);
promise.then(
function () {
assert(false, 'Should not be fulfilled');
},
function (err) {
assert(err instanceof TypeError);
}
).then(done, failIfThrows(done));
});
specify('Stealing a resolver and using it to trigger possible reentrancy bug (#83)', function () {
var stolenResolver;
var StealingPromiseConstructor = function StealingPromiseConstructor(resolver) {
stolenResolver = resolver;
resolver(function () { }, function () { });
};
var iterable = {};
var atAtIterator = '@@iterator'; // on firefox, at least.
iterable[atAtIterator] = function () {
stolenResolver(null, null);
throw new Error(0);
};
assert.doesNotThrow(function () {
Promise.all.call(StealingPromiseConstructor, iterable);
});
});
specify('resolve with a thenable calls it once', function () {
var resolve;
var p = new Promise(function (r) { resolve = r; });
var count = 0;
resolve({
then: function () {
count += 1;
throw new RangeError('reject the promise');
}
});
var a = p.then(function () {})['catch'](function (err) {
assert.equal(count, 1);
assert.ok(err instanceof RangeError);
});
var b = p.then(function () {})['catch'](function (err) {
assert.equal(count, 1);
assert.ok(err instanceof RangeError);
});
return Promise.all([a, b]);
});
specify('resolve with a thenable that throws on .then, rejects the promise synchronously', function () {
var resolve;
var p = new Promise(function (r) { resolve = r; });
var count = 0;
var thenable = Object.defineProperty({}, 'then', {
get: function () {
count += 1;
throw new RangeError('no then for you');
}
});
resolve(thenable);
assert.equal(count, 1);
var a = p.then(function () {})['catch'](function (err) {
assert.equal(count, 1);
assert.ok(err instanceof RangeError);
});
var b = p.then(function () {})['catch'](function (err) {
assert.equal(count, 1);
assert.ok(err instanceof RangeError);
});
return Promise.all([a, b]);
});
});

47
node_modules/es6-shim/test/promise/subclass.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
/* global it, describe, assert, Promise */
describe('Support user subclassing of Promise', function () {
'use strict';
it('should work if you do it right', function (done) {
// This is the "correct" es6-compatible way.
// (Thanks, @domenic and @zloirock!)
var MyPromise = function (executor) {
var self = new Promise(executor);
Object.setPrototypeOf(self, MyPromise.prototype);
self.mine = 'yeah';
return self;
};
if (!Object.setPrototypeOf) { return done(); } // skip test if on IE < 11
Object.setPrototypeOf(MyPromise, Promise);
MyPromise.prototype = Object.create(Promise.prototype, {
constructor: { value: MyPromise }
});
// let's try it!
var p1 = MyPromise.resolve(5);
assert.strictEqual(p1.mine, 'yeah');
p1 = p1.then(function (x) {
assert.strictEqual(x, 5);
});
assert.strictEqual(p1.mine, 'yeah');
var p2 = new MyPromise(function (r) { r(6); });
assert.strictEqual(p2.mine, 'yeah');
p2 = p2.then(function (x) {
assert.strictEqual(x, 6);
});
assert.strictEqual(p2.mine, 'yeah');
var p3 = MyPromise.all([p1, p2]);
assert.strictEqual(p3.mine, 'yeah');
p3.then(function () { done(); }, done);
});
it("should throw if you don't inherit at all", function () {
var MyPromise = function () {};
assert['throws'](function () {
Promise.all.call(MyPromise, []);
}, TypeError);
});
});

679
node_modules/es6-shim/test/reflect.js generated vendored Normal file
View File

@ -0,0 +1,679 @@
var arePropertyDescriptorsSupported = function () {
try {
Object.defineProperty({}, 'x', {});
return true;
} catch (e) { /* this is IE 8. */
return false;
}
};
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
var functionsHaveNames = function f() {}.name === 'f';
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
var ifSymbolsIt = hasSymbols ? it : xit;
var describeIfGetProto = Object.getPrototypeOf ? describe : xdescribe;
var describeIfSetProto = Object.setPrototypeOf ? describe : xdescribe;
var describeIfES5 = supportsDescriptors ? describe : xdescribe;
var describeIfExtensionsPreventible = Object.preventExtensions ? describe : xdescribe;
var describeIfGetOwnPropertyNames = Object.getOwnPropertyNames ? describe : xdescribe;
var ifExtensionsPreventibleIt = Object.preventExtensions ? it : xit;
var ifES5It = supportsDescriptors ? it : xit;
var ifFreezeIt = typeof Object.freeze === 'function' ? it : xit;
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
describe('Reflect', function () {
if (typeof Reflect === 'undefined') {
return it('exists', function () {
expect(this).to.have.property('Reflect');
});
}
var object = {
something: 1,
_value: 0
};
if (supportsDescriptors) {
/* eslint-disable accessor-pairs */
Object.defineProperties(object, {
value: {
get: function () {
return this._value;
}
},
setter: {
set: function (val) {
this._value = val;
}
},
bool: {
value: true
}
});
/* eslint-enable accessor-pairs */
}
var testXThrow = function (values, func) {
var checker = function checker(item) {
try {
func(item);
return false;
} catch (e) {
return e instanceof TypeError;
}
};
values.forEach(function (item) {
expect(item).to.satisfy(checker);
});
};
var testCallableThrow = testXThrow.bind(null, [null, undefined, 1, 'string', true, [], {}]);
var testPrimitiveThrow = testXThrow.bind(null, [null, undefined, 1, 'string', true]);
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.Reflect).to.equal(Reflect);
});
describe('.apply()', function () {
if (typeof Reflect.apply === 'undefined') {
return it('exists', function () {
expect(Reflect).to.have.property('apply');
});
}
it('is a function', function () {
expect(typeof Reflect.apply).to.equal('function');
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Reflect.apply.name).to.equal('apply');
});
it('throws if target isnt 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 isnt 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 isnt an object', function () {
testPrimitiveThrow(function (item) {
return Reflect.defineProperty(item, 'prop', { value: true });
});
});
ifExtensionsPreventibleIt('returns false for non-extensible objects', function () {
var o = Object.preventExtensions({});
expect(Reflect.defineProperty(o, 'prop', {})).to.equal(false);
});
it('can return true, even for non-configurable, non-writable properties', function () {
var o = {};
var desc = {
value: 13,
enumerable: false,
writable: false,
configurable: false
};
expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(true);
// Defined as non-configurable, but descriptor is identical.
expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(true);
desc.value = 37; // Change
expect(Reflect.defineProperty(o, 'prop', desc)).to.equal(false);
});
it('can change from one property type to another, if configurable', function () {
var o = {};
var desc1 = {
set: function () {},
configurable: true
};
var desc2 = {
value: 13,
configurable: false
};
var desc3 = {
get: function () {}
};
expect(Reflect.defineProperty(o, 'prop', desc1)).to.equal(true);
expect(Reflect.defineProperty(o, 'prop', desc2)).to.equal(true);
expect(Reflect.defineProperty(o, 'prop', desc3)).to.equal(false);
});
});
describe('.deleteProperty()', function () {
if (typeof Reflect.deleteProperty === 'undefined') {
return it('exists', function () {
expect(Reflect).to.have.property('deleteProperty');
});
}
it('is a function', function () {
expect(typeof Reflect.deleteProperty).to.equal('function');
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Reflect.deleteProperty.name).to.equal('deleteProperty');
});
it('throws if the target isnt 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 arrays length property', function () {
expect(Reflect.deleteProperty([], 'length')).to.equal(false);
});
});
describeIfES5('.get()', function () {
if (typeof Reflect.get === 'undefined') {
return it('exists', function () {
expect(Reflect).to.have.property('get');
});
}
it('is a function', function () {
expect(typeof Reflect.get).to.equal('function');
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Reflect.get.name).to.equal('get');
});
it('throws on null and undefined', function () {
[null, undefined].forEach(function (item) {
expect(function () {
return Reflect.get(item, 'property');
}).to['throw'](TypeError);
});
});
it('can retrieve a simple value, from the target', function () {
var p = { something: 2, bool: false };
expect(Reflect.get(object, 'something')).to.equal(1);
// p has no effect
expect(Reflect.get(object, 'something', p)).to.equal(1);
// Value-defined properties take the target's value,
// and ignore that of the receiver.
expect(Reflect.get(object, 'bool', p)).to.equal(true);
// Undefined values
expect(Reflect.get(object, 'undefined_property')).to.equal(undefined);
});
it('will invoke getters on the receiver rather than target', function () {
var other = { _value: 1337 };
expect(Reflect.get(object, 'value', other)).to.equal(1337);
// No getter for setter property
expect(Reflect.get(object, 'setter', other)).to.equal(undefined);
});
it('will search the prototype chain', function () {
var other = Object.create(object);
other._value = 17;
var yetAnother = { _value: 4711 };
expect(Reflect.get(other, 'value', yetAnother)).to.equal(4711);
expect(Reflect.get(other, 'bool', yetAnother)).to.equal(true);
});
});
describeIfES5('.set()', function () {
if (typeof Reflect.set === 'undefined') {
return it('exists', function () {
expect(Reflect).to.have.property('set');
});
}
it('is a function', function () {
expect(typeof Reflect.set).to.equal('function');
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Reflect.set.name).to.equal('set');
});
it('throws if the target isnt 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 isnt 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 isnt 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 isnt 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 isnt 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 isnt 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 isnt 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 isnt 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);
});
});
});

413
node_modules/es6-shim/test/regexp.js generated vendored Normal file
View File

@ -0,0 +1,413 @@
var getRegexLiteral = function (stringRegex) {
try {
/* eslint-disable no-new-func */
return Function('return ' + stringRegex + ';')();
/* eslint-enable no-new-func */
} catch (e) { /**/ }
};
var describeIfSupportsDescriptors = Object.getOwnPropertyDescriptor ? describe : describe.skip;
var callAllowsPrimitives = (function () { return this === 3; }.call(3));
var ifCallAllowsPrimitivesIt = callAllowsPrimitives ? it : it.skip;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && typeof Symbol('') === 'symbol';
var ifSymbolsDescribe = hasSymbols ? describe : describe.skip;
var defaultRegex = (function () {
// Chrome Canary 51 has an undefined RegExp#toSource, and
// RegExp#toString produces `/undefined/`
try {
return RegExp.prototype.source ? String(RegExp.prototype) : '/(?:)/';
} catch (e) {
return '/(?:)/';
}
}());
describe('RegExp', function () {
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.RegExp).to.equal(RegExp);
});
it('can be called with no arguments', function () {
var regex = RegExp();
expect(String(regex)).to.equal(defaultRegex);
expect(regex).to.be.an.instanceOf(RegExp);
});
it('can be called with null/undefined', function () {
expect(String(RegExp(null))).to.equal('/null/');
expect(String(RegExp(undefined))).to.equal(defaultRegex);
});
describe('constructor', function () {
it('allows a regex as the pattern', function () {
var a = /a/g;
var b = new RegExp(a);
if (typeof a !== 'function') {
// in browsers like Safari 5, new RegExp with a regex returns the same instance.
expect(a).not.to.equal(b);
}
expect(a).to.eql(b);
});
it('allows a string with flags', function () {
expect(new RegExp('a', 'mgi')).to.eql(/a/gim);
expect(String(new RegExp('a', 'mgi'))).to.equal('/a/gim');
});
it('allows a regex with flags', function () {
var a = /a/g;
var makeRegex = function () { return new RegExp(a, 'mi'); };
expect(makeRegex).not.to['throw'](TypeError);
expect(makeRegex()).to.eql(/a/mi);
expect(String(makeRegex())).to.equal('/a/im');
});
it('works with instanceof', function () {
expect(/a/g).to.be.an.instanceOf(RegExp);
expect(new RegExp('a', 'im')).to.be.an.instanceOf(RegExp);
expect(new RegExp(/a/g, 'im')).to.be.an.instanceOf(RegExp);
});
it('has the right constructor', function () {
expect(/a/g).to.have.property('constructor', RegExp);
expect(new RegExp('a', 'im')).to.have.property('constructor', RegExp);
expect(new RegExp(/a/g, 'im')).to.have.property('constructor', RegExp);
});
it('toStrings properly', function () {
expect(Object.prototype.toString.call(/a/g)).to.equal('[object RegExp]');
expect(Object.prototype.toString.call(new RegExp('a', 'g'))).to.equal('[object RegExp]');
expect(Object.prototype.toString.call(new RegExp(/a/g, 'im'))).to.equal('[object RegExp]');
});
it('functions as a boxed primitive wrapper', function () {
var regex = /a/g;
expect(RegExp(regex)).to.equal(regex);
});
ifSymbolsDescribe('Symbol.replace', function () {
if (!hasSymbols || typeof Symbol.replace === 'undefined') {
return;
}
it('is a function', function () {
expect(RegExp.prototype).to.have.property(Symbol.replace);
expect(typeof RegExp.prototype[Symbol.replace]).to.equal('function');
});
it('is the same as String#replace', function () {
var regex = /a/g;
var str = 'abc';
var symbolReplace = regex[Symbol.replace](str);
var stringReplace = str.replace(regex);
expect(Object.keys(symbolReplace)).to.eql(Object.keys(stringReplace));
expect(symbolReplace).to.eql(stringReplace);
});
});
ifSymbolsDescribe('Symbol.search', function () {
if (!hasSymbols || typeof Symbol.search === 'undefined') {
return;
}
it('is a function', function () {
expect(RegExp.prototype).to.have.property(Symbol.search);
expect(typeof RegExp.prototype[Symbol.search]).to.equal('function');
});
it('is the same as String#search', function () {
var regex = /a/g;
var str = 'abc';
var symbolSearch = regex[Symbol.search](str);
var stringSearch = str.search(regex);
expect(Object.keys(symbolSearch)).to.eql(Object.keys(stringSearch));
expect(symbolSearch).to.eql(stringSearch);
});
});
ifSymbolsDescribe('Symbol.split', function () {
if (!hasSymbols || typeof Symbol.split === 'undefined') {
return;
}
it('is a function', function () {
expect(RegExp.prototype).to.have.property(Symbol.split);
expect(typeof RegExp.prototype[Symbol.split]).to.equal('function');
});
it('is the same as String#split', function () {
var regex = /a/g;
var str = 'abcabc';
var symbolSplit = regex[Symbol.split](str, 1);
var stringSplit = str.split(regex, 1);
expect(Object.keys(symbolSplit)).to.eql(Object.keys(stringSplit));
expect(symbolSplit).to.eql(stringSplit);
});
});
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || typeof Symbol.match === 'undefined') {
return;
}
var regexFalsyMatch;
var nonregexTruthyMatch;
beforeEach(function () {
regexFalsyMatch = /./;
regexFalsyMatch[Symbol.match] = false;
nonregexTruthyMatch = { constructor: RegExp };
nonregexTruthyMatch[Symbol.match] = true;
});
it('is a function', function () {
expect(RegExp.prototype).to.have.property(Symbol.match);
expect(typeof RegExp.prototype[Symbol.match]).to.equal('function');
});
it('is the same as String#match', function () {
var regex = /a/g;
var str = 'abc';
var symbolMatch = regex[Symbol.match](str);
var stringMatch = str.match(regex);
expect(Object.keys(symbolMatch)).to.eql(Object.keys(stringMatch));
expect(symbolMatch).to.eql(stringMatch);
});
it('function does not passthrough regexes with a falsy Symbol.match', function () {
expect(RegExp(regexFalsyMatch)).not.to.equal(regexFalsyMatch);
});
it('constructor does not passthrough regexes with a falsy Symbol.match', function () {
expect(new RegExp(regexFalsyMatch)).not.to.equal(regexFalsyMatch);
});
it('function passes through non-regexes with a truthy Symbol.match', function () {
expect(RegExp(nonregexTruthyMatch)).to.equal(nonregexTruthyMatch);
});
it('constructor does not pass through non-regexes with a truthy Symbol.match', function () {
expect(new RegExp(nonregexTruthyMatch)).not.to.equal(nonregexTruthyMatch);
});
});
});
describeIfSupportsDescriptors('#flags', function () {
if (!Object.prototype.hasOwnProperty.call(RegExp.prototype, 'flags')) {
return it('exists', function () {
expect(RegExp.prototype).to.have.property('flags');
});
}
var regexpFlagsDescriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
var testGenericRegExpFlags = function (object) {
return regexpFlagsDescriptor.get.call(object);
};
it('has the correct descriptor', function () {
expect(regexpFlagsDescriptor.configurable).to.equal(true);
expect(regexpFlagsDescriptor.enumerable).to.equal(false);
expect(regexpFlagsDescriptor.get instanceof Function).to.equal(true);
expect(regexpFlagsDescriptor.set).to.equal(undefined);
});
ifCallAllowsPrimitivesIt('throws when not called on an object', function () {
var nonObjects = ['', false, true, 42, NaN, null, undefined];
nonObjects.forEach(function (nonObject) {
expect(function () { testGenericRegExpFlags(nonObject); }).to['throw'](TypeError);
});
});
it('has the correct flags on a literal', function () {
expect((/a/g).flags).to.equal('g');
expect((/a/i).flags).to.equal('i');
expect((/a/m).flags).to.equal('m');
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(getRegexLiteral('/a/y').flags).to.equal('y');
}
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(getRegexLiteral('/a/u').flags).to.equal('u');
}
});
it('has the correct flags on a constructed RegExp', function () {
expect(new RegExp('a', 'g').flags).to.equal('g');
expect(new RegExp('a', 'i').flags).to.equal('i');
expect(new RegExp('a', 'm').flags).to.equal('m');
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(new RegExp('a', 'y').flags).to.equal('y');
}
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(new RegExp('a', 'u').flags).to.equal('u');
}
});
it('returns flags sorted on a literal', function () {
expect((/a/gim).flags).to.equal('gim');
expect((/a/mig).flags).to.equal('gim');
expect((/a/mgi).flags).to.equal('gim');
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(getRegexLiteral('/a/gyim').flags).to.equal('gimy');
}
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(getRegexLiteral('/a/ugmi').flags).to.equal('gimu');
}
});
it('returns flags sorted on a constructed RegExp', function () {
expect(new RegExp('a', 'gim').flags).to.equal('gim');
expect(new RegExp('a', 'mig').flags).to.equal('gim');
expect(new RegExp('a', 'mgi').flags).to.equal('gim');
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'sticky')) {
expect(new RegExp('a', 'mygi').flags).to.equal('gimy');
}
if (Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode')) {
expect(new RegExp('a', 'mugi').flags).to.equal('gimu');
}
});
});
describe('#toString()', function () {
it('throws on null/undefined', function () {
expect(function () { RegExp.prototype.toString.call(null); }).to['throw'](TypeError);
expect(function () { RegExp.prototype.toString.call(undefined); }).to['throw'](TypeError);
});
it('works on regexes', function () {
expect(RegExp.prototype.toString.call(/a/g)).to.equal('/a/g');
expect(RegExp.prototype.toString.call(new RegExp('a', 'g'))).to.equal('/a/g');
});
it('works on non-regexes', function () {
expect(RegExp.prototype.toString.call({ source: 'abc', flags: '' })).to.equal('/abc/');
expect(RegExp.prototype.toString.call({ source: 'abc', flags: 'xyz' })).to.equal('/abc/xyz');
});
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || typeof Symbol.match === 'undefined') {
return;
}
it('accepts a non-regex with Symbol.match', function () {
var obj = { source: 'abc', flags: 'def' };
obj[Symbol.match] = RegExp.prototype[Symbol.match];
expect(RegExp.prototype.toString.call(obj)).to.equal('/abc/def');
});
});
});
describe('Object properties', function () {
it('does not have the nonstandard $input property', function () {
expect(RegExp).not.to.have.property('$input'); // Chrome < 39, Opera < 26 have this
});
it('has "input" property', function () {
expect(RegExp).to.have.ownProperty('input');
expect(RegExp).to.have.ownProperty('$_');
});
it('has "last match" property', function () {
expect(RegExp).to.have.ownProperty('lastMatch');
expect(RegExp).to.have.ownProperty('$+');
});
it('has "last paren" property', function () {
expect(RegExp).to.have.ownProperty('lastParen');
expect(RegExp).to.have.ownProperty('$&');
});
it('has "leftContext" property', function () {
expect(RegExp).to.have.ownProperty('leftContext');
expect(RegExp).to.have.ownProperty('$`');
});
it('has "rightContext" property', function () {
expect(RegExp).to.have.ownProperty('rightContext');
expect(RegExp).to.have.ownProperty("$'");
});
it.skip('has "multiline" property', function () {
// fails in IE 9, 10, 11
expect(RegExp).to.have.ownProperty('multiline');
expect(RegExp).to.have.ownProperty('$*');
});
it('has the right globals', function () {
var matchVars = [
'$1',
'$2',
'$3',
'$4',
'$5',
'$6',
'$7',
'$8',
'$9'
];
matchVars.forEach(function (match) {
expect(RegExp).to.have.property(match);
});
});
describe('updates RegExp globals', function () {
var str = 'abcdefghijklmnopq';
var re;
beforeEach(function () {
re = /(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)/;
re.exec(str);
});
it('has "input"', function () {
expect(RegExp.input).to.equal(str);
expect(RegExp.$_).to.equal(str);
});
it('has "multiline"', function () {
if (Object.prototype.hasOwnProperty.call(RegExp, 'multiline')) {
expect(RegExp.multiline).to.equal(false);
}
if (Object.prototype.hasOwnProperty.call(RegExp, '$*')) {
expect(RegExp['$*']).to.equal(false);
}
});
it('has "lastMatch"', function () {
expect(RegExp.lastMatch).to.equal('bcdefghijklmnop');
expect(RegExp['$&']).to.equal('bcdefghijklmnop');
});
// in all but IE, this works. IE lastParen breaks after 11 tokens.
it.skip('has "lastParen"', function () {
expect(RegExp.lastParen).to.equal('p');
expect(RegExp['$+']).to.equal('p');
});
it('has "lastParen" for less than 11 tokens', function () {
(/(b)(c)(d)/).exec('abcdef');
expect(RegExp.lastParen).to.equal('d');
expect(RegExp['$+']).to.equal('d');
});
it('has "leftContext"', function () {
expect(RegExp.leftContext).to.equal('a');
expect(RegExp['$`']).to.equal('a');
});
it('has "rightContext"', function () {
expect(RegExp.rightContext).to.equal('q');
expect(RegExp["$'"]).to.equal('q');
});
it('has $1 - $9', function () {
expect(RegExp.$1).to.equal('b');
expect(RegExp.$2).to.equal('c');
expect(RegExp.$3).to.equal('d');
expect(RegExp.$4).to.equal('e');
expect(RegExp.$5).to.equal('f');
expect(RegExp.$6).to.equal('g');
expect(RegExp.$7).to.equal('h');
expect(RegExp.$8).to.equal('i');
expect(RegExp.$9).to.equal('j');
});
});
});
});

656
node_modules/es6-shim/test/set.js generated vendored Normal file
View File

@ -0,0 +1,656 @@
// Big thanks to V8 folks for test ideas.
// v8/test/mjsunit/harmony/collections.js
var Assertion = expect().constructor;
Assertion.addMethod('theSameSet', function (otherArray) {
var array = this._obj;
expect(Array.isArray(array)).to.equal(true);
expect(Array.isArray(otherArray)).to.equal(true);
var diff = array.filter(function (value) {
return otherArray.every(function (otherValue) {
var areBothNaN = typeof value === 'number' && typeof otherValue === 'number' && value !== value && otherValue !== otherValue;
return !areBothNaN && value !== otherValue;
});
});
this.assert(
diff.length === 0,
'expected #{this} to be equal to #{exp} (as sets, i.e. no order)',
array,
otherArray
);
});
var $iterator$ = typeof Symbol === 'function' ? Symbol.iterator : '_es6-shim iterator_';
if (typeof Set === 'function' && typeof Set.prototype['@@iterator'] === 'function') {
$iterator$ = '@@iterator';
}
Assertion.addMethod('iterations', function (expected) {
var iterator = this._obj[$iterator$]();
expect(Array.isArray(expected)).to.equal(true);
var expectedValues = expected.slice();
var result;
do {
result = iterator.next();
expect(result.value).to.eql(expectedValues.shift());
} while (!result.done);
});
describe('Set', function () {
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
var ifGetPrototypeOfIt = Object.getPrototypeOf ? it : xit;
var range = function (from, to) {
var result = [];
for (var value = from; value < to; value++) {
result.push(value);
}
return result;
};
var prototypePropIsEnumerable = Object.prototype.propertyIsEnumerable.call(function () {}, 'prototype');
var expectNotEnumerable = function (object) {
if (prototypePropIsEnumerable && typeof object === 'function') {
expect(Object.keys(object)).to.eql(['prototype']);
} else {
expect(Object.keys(object)).to.eql([]);
}
};
var Sym = typeof Symbol === 'undefined' ? {} : Symbol;
var isSymbol = function (sym) {
return typeof Sym === 'function' && typeof sym === 'symbol';
};
var ifSymbolIteratorIt = isSymbol(Sym.iterator) ? it : xit;
var testSet = function (set, key) {
expect(set.has(key)).to.equal(false);
expect(set['delete'](key)).to.equal(false);
expect(set.add(key)).to.equal(set);
expect(set.has(key)).to.equal(true);
expect(set['delete'](key)).to.equal(true);
expect(set.has(key)).to.equal(false);
expect(set.add(key)).to.equal(set); // add it back
};
if (typeof Set === 'undefined') {
return it('exists', function () {
expect(typeof Set).to.equal('function');
});
}
var set;
beforeEach(function () {
set = new Set();
});
afterEach(function () {
set = null;
});
it('set iteration', function () {
expect(set.add('a')).to.equal(set);
expect(set.add('b')).to.equal(set);
expect(set.add('c')).to.equal(set);
expect(set.add('d')).to.equal(set);
var keys = [];
var iterator = set.keys();
keys.push(iterator.next().value);
expect(set['delete']('a')).to.equal(true);
expect(set['delete']('b')).to.equal(true);
expect(set['delete']('c')).to.equal(true);
expect(set.add('e')).to.equal(set);
keys.push(iterator.next().value);
keys.push(iterator.next().value);
expect(iterator.next().done).to.equal(true);
expect(set.add('f')).to.equal(set);
expect(iterator.next().done).to.equal(true);
expect(keys).to.eql(['a', 'd', 'e']);
});
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.Set).to.equal(Set);
});
it('should exist in global namespace', function () {
expect(typeof Set).to.equal('function');
});
it('has the right arity', function () {
expect(Set).to.have.property('length', 0);
});
it('returns the set from #add() for chaining', function () {
expect(set.add({})).to.equal(set);
});
it('should return false when deleting an item not in the set', function () {
expect(set.has('a')).to.equal(false);
expect(set['delete']('a')).to.equal(false);
});
it('should accept an iterable as argument', function () {
testSet(set, 'a');
testSet(set, 'b');
var set2 = new Set(set);
expect(set2.has('a')).to.equal(true);
expect(set2.has('b')).to.equal(true);
expect(set2).to.have.iterations(['a', 'b']);
});
it('accepts an array as an argument', function () {
var arr = ['a', 'b', 'c'];
var setFromArray = new Set(arr);
expect(setFromArray).to.have.iterations(['a', 'b', 'c']);
});
it('should not be callable without "new"', function () {
expect(Set).to['throw'](TypeError);
});
it('should be subclassable', function () {
if (!Object.setPrototypeOf) { return; } // skip test if on IE < 11
var MySet = function MySet() {
var actualSet = new Set(['a', 'b']);
Object.setPrototypeOf(actualSet, MySet.prototype);
return actualSet;
};
Object.setPrototypeOf(MySet, Set);
MySet.prototype = Object.create(Set.prototype, {
constructor: { value: MySet }
});
var mySet = new MySet();
testSet(mySet, 'c');
testSet(mySet, 'd');
expect(mySet).to.have.iterations(['a', 'b', 'c', 'd']);
});
it('should has valid getter and setter calls', function () {
['add', 'has', 'delete'].forEach(function (method) {
expect(function () {
set[method]({});
}).to.not['throw']();
});
});
it('uses SameValueZero even on a Set of size > 4', function () {
var firstFour = [1, 2, 3, 4];
var fourSet = new Set(firstFour);
expect(fourSet.size).to.equal(4);
expect(fourSet.has(-0)).to.equal(false);
expect(fourSet.has(0)).to.equal(false);
fourSet.add(-0);
expect(fourSet.size).to.equal(5);
expect(fourSet.has(0)).to.equal(true);
expect(fourSet.has(-0)).to.equal(true);
});
it('should work as expected', function () {
// Run this test twice, one with the "fast" implementation (which only
// allows string and numeric keys) and once with the "slow" impl.
[true, false].forEach(function (slowkeys) {
set = new Set();
range(1, 20).forEach(function (number) {
if (slowkeys) { testSet(set, {}); }
testSet(set, number);
testSet(set, number / 100);
testSet(set, 'key-' + number);
testSet(set, String(number));
if (slowkeys) { testSet(set, Object(String(number))); }
});
var testkeys = [+0, Infinity, -Infinity, NaN];
if (slowkeys) {
testkeys.push(true, false, null, undefined);
}
testkeys.forEach(function (number) {
testSet(set, number);
testSet(set, String(number));
});
testSet(set, '');
// -0 and +0 should be the same key (Set uses SameValueZero)
expect(set.has(-0)).to.equal(true);
expect(set['delete'](+0)).to.equal(true);
testSet(set, -0);
expect(set.has(+0)).to.equal(true);
// verify that properties of Object don't peek through.
[
'hasOwnProperty',
'constructor',
'toString',
'isPrototypeOf',
'__proto__',
'__parent__',
'__count__'
].forEach(function (prop) { testSet(set, prop); });
});
});
describe('#size', function () {
it('returns the expected size', function () {
expect(set.add(1)).to.equal(set);
expect(set.add(5)).to.equal(set);
expect(set.size).to.equal(2);
});
});
describe('#clear()', function () {
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Set.prototype.clear).to.have.property('name', 'clear');
});
it('is not enumerable', function () {
expect(Set.prototype).ownPropertyDescriptor('clear').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Set.prototype.clear).to.have.property('length', 0);
});
it('clears a Set with only primitives', function () {
expect(set.add(1)).to.equal(set);
expect(set.size).to.equal(1);
expect(set.add(5)).to.equal(set);
expect(set.size).to.equal(2);
expect(set.has(5)).to.equal(true);
set.clear();
expect(set.size).to.equal(0);
expect(set.has(5)).to.equal(false);
});
it('clears a Set with primitives and objects', function () {
expect(set.add(1)).to.equal(set);
expect(set.size).to.equal(1);
var obj = {};
expect(set.add(obj)).to.equal(set);
expect(set.size).to.equal(2);
expect(set.has(obj)).to.equal(true);
set.clear();
expect(set.size).to.equal(0);
expect(set.has(obj)).to.equal(false);
});
});
describe('#keys()', function () {
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'keys')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('keys');
});
}
it('is the same object as #values()', function () {
expect(Set.prototype.keys).to.equal(Set.prototype.values);
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Set.prototype.keys).to.have.property('name', 'values');
});
it('is not enumerable', function () {
expect(Set.prototype).ownPropertyDescriptor('keys').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Set.prototype.keys).to.have.property('length', 0);
});
});
describe('#values()', function () {
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'values')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('values');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Set.prototype.values).to.have.property('name', 'values');
});
it('is not enumerable', function () {
expect(Set.prototype).ownPropertyDescriptor('values').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Set.prototype.values).to.have.property('length', 0);
});
it('throws when called on a non-Set', function () {
var expectedMessage = /^(Method )?Set.prototype.values called on incompatible receiver |^values method called on incompatible |^Cannot create a Set value iterator for a non-Set object.$|^Set.prototype.values: 'this' is not a Set object$|^std_Set_iterator method called on incompatible \w+$/;
var nonSets = [true, false, 'abc', NaN, new Map([[1, 2]]), { a: true }, [1], Object('abc'), Object(NaN)];
nonSets.forEach(function (nonSet) {
expect(function () { return Set.prototype.values.call(nonSet); }).to['throw'](TypeError, expectedMessage);
});
});
});
describe('#entries()', function () {
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'entries')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('entries');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Set.prototype.entries).to.have.property('name', 'entries');
});
it('is not enumerable', function () {
expect(Set.prototype).ownPropertyDescriptor('entries').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Set.prototype.entries).to.have.property('length', 0);
});
});
describe('#has()', function () {
if (!Object.prototype.hasOwnProperty.call(Set.prototype, 'has')) {
return it('exists', function () {
expect(Set.prototype).to.have.property('has');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Set.prototype.has).to.have.property('name', 'has');
});
it('is not enumerable', function () {
expect(Set.prototype).ownPropertyDescriptor('has').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Set.prototype.has).to.have.property('length', 1);
});
});
it('should allow NaN values as keys', function () {
expect(set.has(NaN)).to.equal(false);
expect(set.has(NaN + 1)).to.equal(false);
expect(set.has(23)).to.equal(false);
expect(set.add(NaN)).to.equal(set);
expect(set.has(NaN)).to.equal(true);
expect(set.has(NaN + 1)).to.equal(true);
expect(set.has(23)).to.equal(false);
});
it('should not have [[Enumerable]] props', function () {
expectNotEnumerable(Set);
expectNotEnumerable(Set.prototype);
expectNotEnumerable(new Set());
});
it('should not have an own constructor', function () {
var s = new Set();
expect(s).not.to.haveOwnPropertyDescriptor('constructor');
expect(s.constructor).to.equal(Set);
});
it('should allow common ecmascript idioms', function () {
expect(set instanceof Set).to.equal(true);
expect(typeof Set.prototype.add).to.equal('function');
expect(typeof Set.prototype.has).to.equal('function');
expect(typeof Set.prototype['delete']).to.equal('function');
});
it('should have a unique constructor', function () {
expect(Set.prototype).to.not.equal(Object.prototype);
});
describe('has an iterator that works with Array.from', function () {
if (!Object.prototype.hasOwnProperty.call(Array, 'from')) {
return it('requires Array.from to exist', function () {
expect(Array).to.have.property('from');
});
}
var values = [1, NaN, false, true, null, undefined, 'a'];
it('works with the full set', function () {
expect(new Set(values)).to.have.iterations(values);
});
it('works with Set#keys()', function () {
expect(new Set(values).keys()).to.have.iterations(values);
});
it('works with Set#values()', function () {
expect(new Set(values).values()).to.have.iterations(values);
});
it('works with Set#entries()', function () {
expect(new Set(values).entries()).to.have.iterations([
[1, 1],
[NaN, NaN],
[false, false],
[true, true],
[null, null],
[undefined, undefined],
['a', 'a']
]);
});
});
ifSymbolIteratorIt('has the right default iteration function', function () {
// fixed in Webkit https://bugs.webkit.org/show_bug.cgi?id=143838
expect(Set.prototype).to.have.property(Sym.iterator, Set.prototype.values);
});
it('should preserve insertion order', function () {
var arr1 = ['d', 'a', 'b'];
var arr2 = [3, 2, 'z', 'a', 1];
var arr3 = [3, 2, 'z', {}, 'a', 1];
[arr1, arr2, arr3].forEach(function (array) {
expect(new Set(array)).to.have.iterations(array);
});
});
describe('#forEach', function () {
var setToIterate;
beforeEach(function () {
setToIterate = new Set();
expect(setToIterate.add('a')).to.equal(setToIterate);
expect(setToIterate.add('b')).to.equal(setToIterate);
expect(setToIterate.add('c')).to.equal(setToIterate);
});
afterEach(function () {
setToIterate = null;
});
ifFunctionsHaveNamesIt('has the right name', function () {
expect(Set.prototype.forEach).to.have.property('name', 'forEach');
});
it('is not enumerable', function () {
expect(Set.prototype).ownPropertyDescriptor('forEach').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(Set.prototype.forEach).to.have.property('length', 1);
});
it('should be iterable via forEach', function () {
var expectedSet = ['a', 'b', 'c'];
var foundSet = [];
setToIterate.forEach(function (value, alsoValue, entireSet) {
expect(entireSet).to.equal(setToIterate);
expect(value).to.equal(alsoValue);
foundSet.push(value);
});
expect(foundSet).to.eql(expectedSet);
});
it('should iterate over empty keys', function () {
var setWithEmptyKeys = new Set();
var expectedKeys = [{}, null, undefined, '', NaN, 0];
expectedKeys.forEach(function (key) {
expect(setWithEmptyKeys.add(key)).to.equal(setWithEmptyKeys);
});
var foundKeys = [];
setWithEmptyKeys.forEach(function (value, key, entireSet) {
expect([key]).to.be.theSameSet([value]); // handles NaN correctly
expect(entireSet.has(key)).to.equal(true);
foundKeys.push(key);
});
expect(foundKeys).to.be.theSameSet(expectedKeys);
});
it('should support the thisArg', function () {
var context = function () {};
setToIterate.forEach(function () {
expect(this).to.equal(context);
}, context);
});
it('should have a length of 1', function () {
expect(Set.prototype.forEach.length).to.equal(1);
});
it('should not revisit modified keys', function () {
var hasModifiedA = false;
setToIterate.forEach(function (value, key) {
if (!hasModifiedA && key === 'a') {
expect(setToIterate.add('a')).to.equal(setToIterate);
hasModifiedA = true;
} else {
expect(key).not.to.equal('a');
}
});
});
it('visits keys added in the iterator', function () {
var hasAdded = false;
var hasFoundD = false;
setToIterate.forEach(function (value, key) {
if (!hasAdded) {
expect(setToIterate.add('d')).to.equal(setToIterate);
hasAdded = true;
} else if (key === 'd') {
hasFoundD = true;
}
});
expect(hasFoundD).to.equal(true);
});
it('visits keys added in the iterator when there is a deletion (slow path)', function () {
var hasSeenFour = false;
var setToMutate = new Set();
expect(setToMutate.add({})).to.equal(setToMutate); // force use of the slow O(N) implementation
expect(setToMutate.add('0')).to.equal(setToMutate);
setToMutate.forEach(function (value, key) {
if (key === '0') {
expect(setToMutate['delete']('0')).to.equal(true);
expect(setToMutate.add('4')).to.equal(setToMutate);
} else if (key === '4') {
hasSeenFour = true;
}
});
expect(hasSeenFour).to.equal(true);
});
it('visits keys added in the iterator when there is a deletion (fast path)', function () {
var hasSeenFour = false;
var setToMutate = new Set();
expect(setToMutate.add('0')).to.equal(setToMutate);
setToMutate.forEach(function (value, key) {
if (key === '0') {
expect(setToMutate['delete']('0')).to.equal(true);
expect(setToMutate.add('4')).to.equal(setToMutate);
} else if (key === '4') {
hasSeenFour = true;
}
});
expect(hasSeenFour).to.equal(true);
});
it('does not visit keys deleted before a visit', function () {
var hasVisitedC = false;
var hasDeletedC = false;
setToIterate.forEach(function (value, key) {
if (key === 'c') {
hasVisitedC = true;
}
if (!hasVisitedC && !hasDeletedC) {
hasDeletedC = setToIterate['delete']('c');
expect(hasDeletedC).to.equal(true);
}
});
expect(hasVisitedC).to.equal(false);
});
it('should work after deletion of the current key', function () {
var expectedSet = {
a: 'a',
b: 'b',
c: 'c'
};
var foundSet = {};
setToIterate.forEach(function (value, key) {
foundSet[key] = value;
expect(setToIterate['delete'](key)).to.equal(true);
});
expect(foundSet).to.eql(expectedSet);
});
it('should convert key -0 to +0', function () {
var zeroSet = new Set();
var result = [];
expect(zeroSet.add(-0)).to.equal(zeroSet);
zeroSet.forEach(function (key) {
result.push(String(1 / key));
});
expect(zeroSet.add(1)).to.equal(zeroSet);
expect(zeroSet.add(0)).to.equal(zeroSet); // shouldn't cause reordering
zeroSet.forEach(function (key) {
result.push(String(1 / key));
});
expect(result.join(', ')).to.equal('Infinity, Infinity, 1');
});
});
it('Set.prototype.size should throw TypeError', function () {
// see https://github.com/paulmillr/es6-shim/issues/176
expect(function () { return Set.prototype.size; }).to['throw'](TypeError);
expect(function () { return Set.prototype.size; }).to['throw'](TypeError);
});
it.skip('should throw proper errors when user invokes methods with wrong types of receiver', function () {
});
ifGetPrototypeOfIt('SetIterator identification test prototype inequality', function () {
var mapEntriesProto = Object.getPrototypeOf(new Map().entries());
var setEntriesProto = Object.getPrototypeOf(new Set().entries());
expect(mapEntriesProto).to.not.equal(setEntriesProto);
});
it('SetIterator identification', function () {
var fnSetValues = Set.prototype.values;
var setSentinel = new Set(['SetSentinel']);
var testSet1 = new Set();
var testSetValues = testSet1.values();
expect(testSetValues.next.call(fnSetValues.call(setSentinel)).value).to.equal('SetSentinel');
var testMap = new Map();
var testMapValues = testMap.values();
expect(function () {
return testMapValues.next.call(fnSetValues.call(setSentinel)).value;
}).to['throw'](TypeError);
});
});

927
node_modules/es6-shim/test/string.js generated vendored Normal file
View File

@ -0,0 +1,927 @@
var runStringTests = function (it) {
'use strict';
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : it.skip;
var ifShimIt = (typeof process !== 'undefined' && process.env.NO_ES6_SHIM) ? it.skip : it;
var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && typeof Symbol.iterator === 'symbol';
var ifSymbolsDescribe = hasSymbols ? describe : describe.skip;
describe('String', function () {
var hasStrictMode = (function () { return this === null; }.call(null));
var testObjectCoercible = function (methodName) {
var fn = String.prototype[methodName];
if (!hasStrictMode) { return; } // skip these tests on IE <= 10
expect(function () { return fn.call(undefined); }).to['throw'](TypeError);
expect(function () { return fn.call(null); }).to['throw'](TypeError);
expect(function () { return fn.apply(undefined); }).to['throw'](TypeError);
expect(function () { return fn.apply(null); }).to['throw'](TypeError);
};
ifShimIt('is on the exported object', function () {
var exported = require('../');
expect(exported.String).to.equal(String);
});
describe('#repeat()', function () {
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'repeat')) {
return it('exists', function () {
expect(String.prototype).to.have.property('repeat');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.prototype.repeat).to.have.property('name', 'repeat');
});
it('is not enumerable', function () {
expect(String.prototype).ownPropertyDescriptor('repeat').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(String.prototype.repeat).to.have.property('length', 1);
});
it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('repeat');
});
it('should throw a RangeError when negative or infinite', function () {
expect(function negativeOne() { return 'test'.repeat(-1); }).to['throw'](RangeError);
expect(function infinite() { return 'test'.repeat(Infinity); }).to['throw'](RangeError);
});
it('should coerce to an integer', function () {
expect('test'.repeat(null)).to.eql('');
expect('test'.repeat(false)).to.eql('');
expect('test'.repeat('')).to.eql('');
expect('test'.repeat(NaN)).to.eql('');
expect('test'.repeat({})).to.eql('');
expect('test'.repeat([])).to.eql('');
expect('test'.repeat({
valueOf: function () { return 2; }
})).to.eql('testtest');
});
it('should work', function () {
expect('test'.repeat(3)).to.eql('testtesttest');
});
it('should work on integers', function () {
expect(String.prototype.repeat.call(2, 3)).to.eql('222');
});
it('should work on booleans', function () {
expect(String.prototype.repeat.call(true, 3)).to.eql('truetruetrue');
});
it('should work on dates', function () {
var d = new Date();
expect(String.prototype.repeat.call(d, 3)).to.eql([d, d, d].join(''));
});
});
describe('#startsWith()', function () {
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'startsWith')) {
return it('exists', function () {
expect(String.prototype).to.have.property('startsWith');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.prototype.startsWith).to.have.property('name', 'startsWith');
});
it('is not enumerable', function () {
expect(String.prototype).ownPropertyDescriptor('startsWith').to.have.property('enumerable', false);
});
it('has the right arity', function () {
// WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659
expect(String.prototype.startsWith).to.have.property('length', 1);
});
it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('startsWith');
});
it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('startsWith');
});
it('should be truthy on correct results', function () {
expect('test'.startsWith('te')).to.equal(true);
expect('test'.startsWith('st')).to.equal(false);
expect(''.startsWith('/')).to.equal(false);
expect('#'.startsWith('/')).to.equal(false);
expect('##'.startsWith('///')).to.equal(false);
expect('abc'.startsWith('abc')).to.equal(true);
expect('abcd'.startsWith('abc')).to.equal(true);
expect('abc'.startsWith('a')).to.equal(true);
expect('abc'.startsWith('abcd')).to.equal(false);
expect('abc'.startsWith('bcde')).to.equal(false);
expect('abc'.startsWith('b')).to.equal(false);
expect('abc'.startsWith('abc', 0)).to.equal(true);
expect('abc'.startsWith('bc', 0)).to.equal(false);
expect('abc'.startsWith('bc', 1)).to.equal(true);
expect('abc'.startsWith('c', 1)).to.equal(false);
expect('abc'.startsWith('abc', 1)).to.equal(false);
expect('abc'.startsWith('c', 2)).to.equal(true);
expect('abc'.startsWith('d', 2)).to.equal(false);
expect('abc'.startsWith('dcd', 2)).to.equal(false);
expect('abc'.startsWith('a', NaN)).to.equal(true);
expect('abc'.startsWith('b', NaN)).to.equal(false);
expect('abc'.startsWith('ab', -43)).to.equal(true);
expect('abc'.startsWith('ab', -Infinity)).to.equal(true);
expect('abc'.startsWith('bc', -42)).to.equal(false);
expect('abc'.startsWith('bc', -Infinity)).to.equal(false);
if (hasStrictMode) {
expect(function () {
return ''.startsWith.call(null, 'nu');
}).to['throw'](TypeError);
expect(function () {
return ''.startsWith.call(undefined, 'un');
}).to['throw'](TypeError);
}
var myobj = {
toString: function () { return 'abc'; },
startsWith: String.prototype.startsWith
};
expect(myobj.startsWith('abc')).to.equal(true);
expect(myobj.startsWith('bc')).to.equal(false);
var gotStr = false;
var gotPos = false;
myobj = {
toString: function () {
expect(gotPos).to.equal(false);
gotStr = true;
return 'xyz';
},
startsWith: String.prototype.startsWith
};
var idx = {
valueOf: function () {
expect(gotStr).to.equal(true);
gotPos = true;
return 42;
}
};
myobj.startsWith('elephant', idx);
expect(gotPos).to.equal(true);
});
it('should handle large positions', function () {
expect('abc'.startsWith('a', 42)).to.equal(false);
expect('abc'.startsWith('a', Infinity)).to.equal(false);
});
it('should coerce to a string', function () {
expect('abcd'.startsWith({ toString: function () { return 'ab'; } })).to.equal(true);
expect('abcd'.startsWith({ toString: function () { return 'foo'; } })).to.equal(false);
});
it('should not allow a regex', function () {
expect(function () { return 'abcd'.startsWith(/abc/); }).to['throw'](TypeError);
expect(function () { return 'abcd'.startsWith(new RegExp('abc')); }).to['throw'](TypeError);
});
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || !Symbol.match) {
return it('exists', function () {
expect(Symbol).to.have.property('match');
});
}
it('allows a regex with Symbol.match set to a falsy value', function () {
var re = /a/g;
re[Symbol.match] = false;
expect(function () { return 'abcd'.startsWith(re); }).not.to['throw']();
expect('abcd'.startsWith(re)).to.equal('abcd'.startsWith(String(re)));
});
});
});
describe('#endsWith()', function () {
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'endsWith')) {
return it('exists', function () {
expect(String.prototype).to.have.property('endsWith');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.prototype.endsWith).to.have.property('name', 'endsWith');
});
it('is not enumerable', function () {
expect(String.prototype).ownPropertyDescriptor('endsWith').to.have.property('enumerable', false);
});
it('has the right arity', function () {
// WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659
expect(String.prototype.endsWith).to.have.property('length', 1);
});
it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('endsWith');
});
it('should be truthy on correct results', function () {
expect('test'.endsWith('st')).to.equal(true);
expect('test'.endsWith('te')).to.equal(false);
expect(''.endsWith('/')).to.equal(false);
expect('#'.endsWith('/')).to.equal(false);
expect('##'.endsWith('///')).to.equal(false);
expect('abc'.endsWith('abc')).to.equal(true);
expect('abcd'.endsWith('bcd')).to.equal(true);
expect('abc'.endsWith('c')).to.equal(true);
expect('abc'.endsWith('abcd')).to.equal(false);
expect('abc'.endsWith('bbc')).to.equal(false);
expect('abc'.endsWith('b')).to.equal(false);
expect('abc'.endsWith('abc', 3)).to.equal(true);
expect('abc'.endsWith('bc', 3)).to.equal(true);
expect('abc'.endsWith('a', 3)).to.equal(false);
expect('abc'.endsWith('bc', 3)).to.equal(true);
expect('abc'.endsWith('a', 1)).to.equal(true);
expect('abc'.endsWith('abc', 1)).to.equal(false);
expect('abc'.endsWith('b', 2)).to.equal(true);
expect('abc'.endsWith('d', 2)).to.equal(false);
expect('abc'.endsWith('dcd', 2)).to.equal(false);
expect('abc'.endsWith('bc', undefined)).to.equal(true);
expect('abc'.endsWith('bc', NaN)).to.equal(false);
if (hasStrictMode) {
expect(function () {
return ''.endsWith.call(null, 'ull');
}).to['throw'](TypeError);
expect(function () {
return ''.endsWith.call(undefined, 'ned');
}).to['throw'](TypeError);
}
var myobj = {
toString: function () { return 'abc'; },
endsWith: String.prototype.endsWith
};
expect(myobj.endsWith('abc')).to.equal(true);
expect(myobj.endsWith('ab')).to.equal(false);
var gotStr = false;
var gotPos = false;
myobj = {
toString: function () {
expect(gotPos).to.equal(false);
gotStr = true;
return 'xyz';
},
endsWith: String.prototype.endsWith
};
var idx = {
valueOf: function () {
expect(gotStr).to.equal(true);
gotPos = true;
return 42;
}
};
myobj.endsWith('elephant', idx);
expect(gotPos).to.equal(true);
});
it('should coerce to a string', function () {
expect('abcd'.endsWith({ toString: function () { return 'cd'; } })).to.equal(true);
expect('abcd'.endsWith({ toString: function () { return 'foo'; } })).to.equal(false);
});
it('should not allow a regex', function () {
expect(function () { return 'abcd'.endsWith(/abc/); }).to['throw'](TypeError);
expect(function () { return 'abcd'.endsWith(new RegExp('abc')); }).to['throw'](TypeError);
});
it('should handle negative and zero endPositions properly', function () {
expect('abcd'.endsWith('bcd', 0)).to.equal(false);
expect('abcd'.endsWith('bcd', -2)).to.equal(false);
expect('abcd'.endsWith('b', -2)).to.equal(false);
expect('abcd'.endsWith('ab', -2)).to.equal(false);
expect('abc'.endsWith('bc', -43)).to.equal(false);
expect('abc'.endsWith('bc', -Infinity)).to.equal(false);
});
it('should handle large endPositions properly', function () {
expect('abc'.endsWith('a', 42)).to.equal(false);
expect('abc'.endsWith('bc', Infinity)).to.equal(true);
expect('abc'.endsWith('a', Infinity)).to.equal(false);
});
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || !Symbol.match) {
return it('exists', function () {
expect(Symbol).to.have.property('match');
});
}
it('allows a regex with Symbol.match set to a falsy value', function () {
var re = /a/g;
re[Symbol.match] = false;
expect(function () { return 'abcd'.startsWith(re); }).not.to['throw']();
expect('abcd'.endsWith(re)).to.equal('abcd'.endsWith(String(re)));
});
});
});
describe('#includes()', function () {
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'includes')) {
return it('exists', function () {
expect(String.prototype).to.have.property('includes');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.prototype.includes).to.have.property('name', 'includes');
});
it('is not enumerable', function () {
expect(String.prototype).ownPropertyDescriptor('includes').to.have.property('enumerable', false);
});
it('has the right arity', function () {
// WebKit nightly had this bug, fixed in https://bugs.webkit.org/show_bug.cgi?id=143659
expect(String.prototype.includes).to.have.property('length', 1);
});
it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('includes');
});
it('throws a TypeError when given a regex', function () {
expect(function () { 'foo'.includes(/a/g); }).to['throw'](TypeError);
});
it('should be truthy on correct results', function () {
expect('test'.includes('es')).to.equal(true);
expect('abc'.includes('a')).to.equal(true);
expect('abc'.includes('b')).to.equal(true);
expect('abc'.includes('abc')).to.equal(true);
expect('abc'.includes('bc')).to.equal(true);
expect('abc'.includes('d')).to.equal(false);
expect('abc'.includes('abcd')).to.equal(false);
expect('abc'.includes('ac')).to.equal(false);
expect('abc'.includes('abc', 0)).to.equal(true);
expect('abc'.includes('bc', 0)).to.equal(true);
expect('abc'.includes('de', 0)).to.equal(false);
expect('abc'.includes('bc', 1)).to.equal(true);
expect('abc'.includes('c', 1)).to.equal(true);
expect('abc'.includes('a', 1)).to.equal(false);
expect('abc'.includes('abc', 1)).to.equal(false);
expect('abc'.includes('c', 2)).to.equal(true);
expect('abc'.includes('d', 2)).to.equal(false);
expect('abc'.includes('dcd', 2)).to.equal(false);
expect('abc'.includes('ab', NaN)).to.equal(true);
expect('abc'.includes('cd', NaN)).to.equal(false);
var myobj = {
toString: function () { return 'abc'; },
includes: String.prototype.includes
};
expect(myobj.includes('abc')).to.equal(true);
expect(myobj.includes('cd')).to.equal(false);
var gotStr = false;
var gotPos = false;
myobj = {
toString: function () {
expect(gotPos).to.equal(false);
gotStr = true;
return 'xyz';
},
includes: String.prototype.includes
};
var idx = {
valueOf: function () {
expect(gotStr).to.equal(true);
gotPos = true;
return 42;
}
};
myobj.includes('elephant', idx);
expect(gotPos).to.equal(true);
});
it('should handle large positions', function () {
expect('abc'.includes('a', 42)).to.equal(false);
expect('abc'.includes('a', Infinity)).to.equal(false);
});
it('should handle negative positions', function () {
expect('abc'.includes('ab', -43)).to.equal(true);
expect('abc'.includes('cd', -42)).to.equal(false);
expect('abc'.includes('ab', -Infinity)).to.equal(true);
expect('abc'.includes('cd', -Infinity)).to.equal(false);
});
it('should be falsy on incorrect results', function () {
expect('test'.includes('1290')).to.equal(false);
});
ifSymbolsDescribe('Symbol.match', function () {
if (!hasSymbols || !Symbol.match) {
return it('exists', function () {
expect(Symbol).to.have.property('match');
});
}
it('allows a regex with Symbol.match set to a falsy value', function () {
var re = /a/g;
re[Symbol.match] = false;
expect(function () { return 'abcd'.includes(re); }).not.to['throw']();
expect('abcd'.includes(re)).to.equal('abcd'.includes(String(re)));
});
});
});
describe('.fromCodePoint()', function () {
if (!Object.prototype.hasOwnProperty.call(String, 'fromCodePoint')) {
return it('exists', function () {
expect(String).to.have.property('fromCodePoint');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.fromCodePoint).to.have.property('name', 'fromCodePoint');
});
it('is not enumerable', function () {
expect(String).ownPropertyDescriptor('fromCodePoint').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(String.fromCodePoint).to.have.property('length', 1);
});
it('throws a RangeError', function () {
var invalidValues = [
'abc',
{},
-1,
0x10FFFF + 1
];
invalidValues.forEach(function (value) {
expect(function () { return String.fromCodePoint(value); }).to['throw'](RangeError);
});
});
it('returns the empty string with no args', function () {
expect(String.fromCodePoint()).to.equal('');
});
it('works', function () {
var codePoints = [];
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789…?!';
for (var i = 0; i < chars.length; ++i) {
codePoints.push(chars.charCodeAt(i));
expect(String.fromCodePoint(chars.charCodeAt(i))).to.equal(chars[i]);
}
expect(String.fromCodePoint.apply(String, codePoints)).to.equal(chars);
});
it('works with unicode', function () {
expect(String.fromCodePoint(0x2500)).to.equal('\u2500');
expect(String.fromCodePoint(0x010000)).to.equal('\ud800\udc00');
expect(String.fromCodePoint(0x10FFFF)).to.equal('\udbff\udfff');
});
});
describe('#codePointAt()', function () {
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'codePointAt')) {
return it('exists', function () {
expect(String.prototype).to.have.property('codePointAt');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.prototype.codePointAt).to.have.property('name', 'codePointAt');
});
it('is not enumerable', function () {
expect(String.prototype).ownPropertyDescriptor('codePointAt').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(String.prototype.codePointAt).to.have.property('length', 1);
});
it('should throw a TypeError when called on null or undefined', function () {
testObjectCoercible('codePointAt');
});
it('should work', function () {
var str = 'abc';
expect(str.codePointAt(0)).to.equal(97);
expect(str.codePointAt(1)).to.equal(98);
expect(str.codePointAt(2)).to.equal(99);
});
it('should work with unicode', function () {
expect('\u2500'.codePointAt(0)).to.equal(0x2500);
expect('\ud800\udc00'.codePointAt(0)).to.equal(0x10000);
expect('\udbff\udfff'.codePointAt(0)).to.equal(0x10ffff);
expect('\ud800\udc00\udbff\udfff'.codePointAt(0)).to.equal(0x10000);
expect('\ud800\udc00\udbff\udfff'.codePointAt(1)).to.equal(0xdc00);
expect('\ud800\udc00\udbff\udfff'.codePointAt(2)).to.equal(0x10ffff);
expect('\ud800\udc00\udbff\udfff'.codePointAt(3)).to.equal(0xdfff);
});
it('should return undefined when pos is negative or too large', function () {
var str = 'abc';
expect(str.codePointAt(-1)).to.equal(undefined);
expect(str.codePointAt(str.length)).to.equal(undefined);
});
});
describe('#[Symbol.iterator]()', function () {
if (!Object.prototype.hasOwnProperty.call(Array, 'from')) {
return it('requires Array.from to test', function () {
expect(Array).to.have.property('from');
});
}
it('should work with plain strings', function () {
var str = 'abc';
expect(Array.from(str)).to.eql(['a', 'b', 'c']);
});
it('should work with surrogate characters', function () {
var str = '\u2500\ud800\udc00\udbff\udfff\ud800';
expect(Array.from(str)).to.eql(['\u2500', '\ud800\udc00', '\udbff\udfff', '\ud800']);
});
});
describe('.raw()', function () {
if (!Object.prototype.hasOwnProperty.call(String, 'raw')) {
return it('exists', function () {
expect(String).to.have.property('raw');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.raw).to.have.property('name', 'raw');
});
it('is not enumerable', function () {
expect(String).ownPropertyDescriptor('raw').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(String.raw).to.have.property('length', 1);
});
it('works with callSite.raw: Array', function () {
var callSite = {};
var str = 'The total is 10 ($11 with tax)';
callSite.raw = ['The total is ', ' ($', ' with tax)'];
expect(String.raw(callSite, 10, 11)).to.eql(str);
// eslint-disable-next-line no-template-curly-in-string
str = 'The total is {total} (${total * 1.01} with tax)';
callSite.raw = ['The total is ', ' ($', ' with tax)'];
expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql(str);
});
it('works with callSite.raw: array-like object', function () {
var callSite = {};
var str = 'The total is 10 ($11 with tax)';
callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 };
expect(String.raw(callSite, 10, 11)).to.eql(str);
// eslint-disable-next-line no-template-curly-in-string
str = 'The total is {total} (${total * 1.01} with tax)';
callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 };
expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql(str);
});
it('works with callSite.raw: empty Objects', function () {
var callSite = { raw: {} };
expect(String.raw(callSite, '{total}', '{total * 1.01}')).to.eql('');
expect(String.raw(callSite)).to.equal('');
});
it('ReturnIfAbrupt - Less Substitutions', function () {
var callSite = {
raw: { 0: 'The total is ', 1: ' ($', 2: ' with tax)', length: 3 }
};
var str = 'The total is 10 ($ with tax)';
expect(String.raw(callSite, 10)).to.equal(str);
});
});
describe('#trim()', function () {
if (!Object.prototype.hasOwnProperty.call(String.prototype, 'trim')) {
return it('exists', function () {
expect(String.prototype).to.have.property('trim');
});
}
ifFunctionsHaveNamesIt('has the right name', function () {
expect(String.prototype.trim).to.have.property('name', 'trim');
});
it('is not enumerable', function () {
expect(String.prototype).ownPropertyDescriptor('trim').to.have.property('enumerable', false);
});
it('has the right arity', function () {
expect(String.prototype.trim).to.have.property('length', 0);
});
it('should trim the correct characters', function () {
var whitespace = [
'\u0009',
'\u000b',
'\u000c',
'\u0020',
'\u00a0',
'\u1680',
'\u2000',
'\u2001',
'\u2002',
'\u2003',
'\u2004',
'\u2005',
'\u2006',
'\u2007',
'\u2008',
'\u2009',
'\u200A',
'\u202f',
'\u205f',
'\u3000'
].join('');
var lineTerminators = [
'\u000a',
'\u000d',
'\u2028',
'\u2029'
].join('');
var trimmed = (whitespace + lineTerminators).trim();
expect(trimmed).to.have.property('length', 0);
expect(trimmed).to.equal('');
});
it('should not trim U+0085', function () {
var trimmed = '\u0085'.trim();
expect(trimmed).to.have.property('length', 1);
expect(trimmed).to.equal('\u0085');
});
it('should trim on both sides', function () {
var trimmed = ' a '.trim();
expect(trimmed).to.have.property('length', 1);
expect(trimmed).to.equal('a');
});
});
describe('#search()', function () {
it('works with strings', function () {
expect('abc'.search('a')).to.equal(0);
expect('abc'.search('b')).to.equal(1);
expect('abc'.search('c')).to.equal(2);
expect('abc'.search('d')).to.equal(-1);
});
it('works with regexes', function () {
expect('abc'.search(/a/)).to.equal(0);
expect('abc'.search(/b/)).to.equal(1);
expect('abc'.search(/c/)).to.equal(2);
expect('abc'.search(/d/)).to.equal(-1);
});
ifSymbolsDescribe('Symbol.search', function () {
it('is a symbol', function () {
expect(typeof Symbol.search).to.equal('symbol');
});
if (!hasSymbols || typeof Symbol.search !== 'symbol') {
return;
}
it('is nonconfigurable', function () {
expect(Symbol).ownPropertyDescriptor('search').to.have.property('configurable', false);
});
it('is nonenumerable', function () {
expect(Symbol).ownPropertyDescriptor('search').to.have.property('enumerable', false);
});
it('is nonwritable', function () {
expect(Symbol).ownPropertyDescriptor('search').to.have.property('writable', false);
});
it('is respected', function () {
var str = Object('a');
var obj = {};
obj[Symbol.search] = function (string) { return string === str && this === obj; };
expect(str.search(obj)).to.equal(true);
});
});
});
describe('#replace()', function () {
it('works', function () {
expect('abcabc'.replace('c', 'd')).to.equal('abdabc');
expect('abcabc'.replace(/c/, 'd')).to.equal('abdabc');
expect('abcabc'.replace(/c/g, 'd')).to.equal('abdabd');
expect('abcabc'.replace(/C/ig, 'd')).to.equal('abdabd');
});
ifSymbolsDescribe('Symbol.replace', function () {
it('is a symbol', function () {
expect(typeof Symbol.replace).to.equal('symbol');
});
if (!hasSymbols || typeof Symbol.replace !== 'symbol') {
return;
}
it('is nonconfigurable', function () {
expect(Symbol).ownPropertyDescriptor('replace').to.have.property('configurable', false);
});
it('is nonenumerable', function () {
expect(Symbol).ownPropertyDescriptor('replace').to.have.property('enumerable', false);
});
it('is nonwritable', function () {
expect(Symbol).ownPropertyDescriptor('replace').to.have.property('writable', false);
});
it('respects Symbol.replace', function () {
var str = Object('a');
var replaceVal = Object('replaceValue');
var obj = {};
obj[Symbol.replace] = function (string, replaceValue) {
return string === str && replaceValue === replaceVal && this === obj;
};
expect(str.replace(obj, replaceVal)).to.equal(true);
});
});
});
describe('#split()', function () {
it('works', function () {
expect('abcabc'.split('b')).to.eql(['a', 'ca', 'c']);
expect('abcabc'.split('b', 2)).to.eql(['a', 'ca']);
expect('abcabc'.split(/b.?/)).to.eql(['a', 'a', '']);
expect('abcabc'.split(/b.?/, 2)).to.eql(['a', 'a']);
expect('abcabc'.split(/b/)).to.eql(['a', 'ca', 'c']);
expect('abcabc'.split(/b/, 2)).to.eql(['a', 'ca']);
expect('abcabc'.split(/b/g)).to.eql(['a', 'ca', 'c']);
expect('abcabc'.split(/b/g, 2)).to.eql(['a', 'ca']);
expect('abcabc'.split(/B/i)).to.eql(['a', 'ca', 'c']);
expect('abcabc'.split(/B/i, 2)).to.eql(['a', 'ca']);
expect('abcabc'.split(/B/gi)).to.eql(['a', 'ca', 'c']);
expect('abcabc'.split(/B/gi, 2)).to.eql(['a', 'ca']);
});
ifSymbolsDescribe('Symbol.split', function () {
it('is a symbol', function () {
expect(typeof Symbol.split).to.equal('symbol');
});
if (!hasSymbols || typeof Symbol.split !== 'symbol') {
return;
}
it('is nonconfigurable', function () {
expect(Symbol).ownPropertyDescriptor('split').to.have.property('configurable', false);
});
it('is nonenumerable', function () {
expect(Symbol).ownPropertyDescriptor('split').to.have.property('enumerable', false);
});
it('is nonwritable', function () {
expect(Symbol).ownPropertyDescriptor('split').to.have.property('writable', false);
});
it('respects Symbol.split', function () {
var str = Object('a');
var limitVal = Object(42);
var obj = {};
obj[Symbol.split] = function (string, limit) { return string === str && limit === limitVal && this === obj; };
expect(str.split(obj, limitVal)).to.equal(true);
});
});
});
describe('#match()', function () {
it('works with a string', function () {
var str = 'abca';
var match = str.match('a');
expect(match.index).to.equal(0);
expect(match.input).to.equal(str);
expect(Array.prototype.slice.call(match)).to.eql(['a']);
});
it('works with a regex', function () {
var str = 'abca';
var match = str.match(/a/);
expect(match.index).to.equal(0);
expect(match.input).to.equal(str);
expect(Array.prototype.slice.call(match)).to.eql(['a']);
});
ifSymbolsDescribe('Symbol.match', function () {
it('is a symbol', function () {
expect(typeof Symbol.match).to.equal('symbol');
});
if (!hasSymbols || typeof Symbol.match !== 'symbol') {
return;
}
it('is nonconfigurable', function () {
expect(Symbol).ownPropertyDescriptor('match').to.have.property('configurable', false);
});
it('is nonenumerable', function () {
expect(Symbol).ownPropertyDescriptor('match').to.have.property('enumerable', false);
});
it('is nonwritable', function () {
expect(Symbol).ownPropertyDescriptor('match').to.have.property('writable', false);
});
it('respects Symbol.match', function () {
var str = Object('a');
var obj = {};
obj[Symbol.match] = function (string) { return string === str && this === obj; };
expect(str.match(obj)).to.equal(true);
});
});
});
});
describe('Annex B', function () {
it('has #anchor', function () {
expect('foo'.anchor('bar"baz"')).to.equal('<a name="bar&quot;baz&quot;">foo</a>');
});
it('has #big', function () {
expect('foo'.big()).to.equal('<big>foo</big>');
});
it('has #blink', function () {
expect('foo'.blink()).to.equal('<blink>foo</blink>');
});
it('has #bold', function () {
expect('foo'.bold()).to.equal('<b>foo</b>');
});
it('has #fixed', function () {
expect('foo'.fixed()).to.equal('<tt>foo</tt>');
});
it('has #fontcolor', function () {
expect('foo'.fontcolor('blue"red"green')).to.equal('<font color="blue&quot;red&quot;green">foo</font>');
});
it('has #fontsize', function () {
expect('foo'.fontsize('10"large"small')).to.equal('<font size="10&quot;large&quot;small">foo</font>');
});
it('has #italics', function () {
expect('foo'.italics()).to.equal('<i>foo</i>');
});
it('has #link', function () {
expect('foo'.link('url"http://"')).to.equal('<a href="url&quot;http://&quot;">foo</a>');
});
it('has #small', function () {
expect('foo'.small()).to.equal('<small>foo</small>');
});
it('has #strike', function () {
expect('foo'.strike()).to.equal('<strike>foo</strike>');
});
it('has #sub', function () {
expect('foo'.sub()).to.equal('<sub>foo</sub>');
});
it('has #sup', function () {
expect('foo'.sup()).to.equal('<sup>foo</sup>');
});
});
};
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);
});

17
node_modules/es6-shim/test/test_helpers.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/* global expect: true, assert: true, require, process */
expect = (function () {
var chai = require('chai');
chai.config.includeStack = true;
return chai.expect;
}());
assert = (function () {
var chai = require('chai');
chai.config.includeStack = true;
return chai.assert;
}());
if (typeof process === 'undefined' || !process.env.NO_ES6_SHIM) {
require('../');
}

7
node_modules/es6-shim/test/worker-runner.workerjs generated vendored Normal file
View File

@ -0,0 +1,7 @@
importScripts(
'../node_modules/es5-shim/es5-shim.js',
'../node_modules/es5-shim/es5-sham.js',
'../es6-shim.js'
);
postMessage('ready');

39
node_modules/es6-shim/test/worker-test.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
/* globals Worker, location */
describe('Worker', function () {
var workerErrorEventToError = function (errorEvent) {
var errorText = 'Error in Worker';
if (errorEvent.filename !== undefined) {
errorText += ' ' + errorEvent.filename;
}
if (errorEvent.lineno !== undefined) {
errorText += '(' + errorEvent.lineno + ')';
}
if (errorEvent.message !== undefined) {
errorText += ': ' + errorEvent.message;
}
return new Error(errorText);
};
var canRunWorkerTestInCurrentContext = function () {
var workerConstructorExists = typeof Worker !== 'undefined';
var locationPropertyExists = typeof location !== 'undefined';
var runningOnFileUriScheme = locationPropertyExists && location.protocol === 'file:';
// The Worker constructor doesn't exist in some older browsers nor does it exist in non-browser contexts like Node.
// Additionally some browsers (at least Chrome) don't allow Workers over file URIs.
// To prevent false negative test failures in the cases where Workers are unavailable for either of those reasons
// we skip this test.
return workerConstructorExists && !runningOnFileUriScheme;
};
if (canRunWorkerTestInCurrentContext()) {
it('can import es6-shim', function (done) {
var worker = new Worker('worker-runner.workerjs');
worker.addEventListener('error', function (errorEvent) { throw workerErrorEventToError(errorEvent); });
worker.addEventListener('message', function (messageEvent) {
expect(messageEvent.data).to.eql('ready');
done();
});
});
}
});

18
package-lock.json generated Normal file
View File

@ -0,0 +1,18 @@
{
"name": "welsonjs",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"es5-shim": {
"version": "4.5.14",
"resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.14.tgz",
"integrity": "sha512-7SwlpL+2JpymWTt8sNLuC2zdhhc+wrfe5cMPI2j0o6WsPdfAiPwmFy2f0AocPB4RQVBOZ9kNTgi5YF7TdhkvEg=="
},
"es6-shim": {
"version": "0.35.5",
"resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.5.tgz",
"integrity": "sha512-E9kK/bjtCQRpN1K28Xh4BlmP8egvZBGJJ+9GtnzOwt7mdqtrjHFuVGr7QJfdjBIKqrlU5duPf3pCBoDrkjVYFg=="
}
}
}

41
package.json Normal file
View File

@ -0,0 +1,41 @@
{
"name": "welsonjs",
"version": "0.1.0",
"description": "Build a windows desktop apps ultra-fastly with WSH.js and HTA",
"main": "app.js",
"directories": {
"lib": "lib"
},
"scripts": {
"test": "cscript app.js helloworld"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gnh1201/welsonjs.git"
},
"keywords": [
"wsh",
"javascript",
"windows",
"desktop",
"alternative",
"hta",
"uri",
"jscript",
"electronjs",
"js",
"ie",
"mshta",
"mshtml"
],
"author": "Go Namhyeon",
"license": "LGPL-2.1",
"bugs": {
"url": "https://github.com/gnh1201/welsonjs/issues"
},
"homepage": "https://github.com/gnh1201/welsonjs#readme",
"dependencies": {
"es5-shim": "^4.5.14",
"es6-shim": "^0.35.5"
}
}