Remove async, and add es6-shim
This commit is contained in:
parent
46eabf2342
commit
0b9d4bf7c1
|
@ -1,3 +0,0 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
|
@ -1,19 +0,0 @@
|
|||
Copyright (c) 2010-2014 Caolan McMahon
|
||||
|
||||
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.
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"name": "async",
|
||||
"repo": "caolan/async",
|
||||
"description": "Higher-order functions and common patterns for asynchronous code",
|
||||
"version": "0.1.23",
|
||||
"keywords": [],
|
||||
"dependencies": {},
|
||||
"development": {},
|
||||
"main": "lib/async.js",
|
||||
"scripts": [ "lib/async.js" ]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"additionalRules": [],
|
||||
|
||||
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
|
||||
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],
|
||||
|
||||
"disallowSpaceAfterKeywords": [],
|
||||
|
||||
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
|
||||
"requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
|
||||
"disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true },
|
||||
"requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
|
||||
"disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
|
||||
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
|
||||
"disallowQuotedKeysInObjects": "allButReserved",
|
||||
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
|
||||
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
|
||||
"requireSpaceAfterPrefixUnaryOperators": [],
|
||||
|
||||
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
|
||||
"requireSpaceBeforePostfixUnaryOperators": [],
|
||||
|
||||
"disallowSpaceBeforeBinaryOperators": [],
|
||||
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
|
||||
|
||||
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
|
||||
"disallowSpaceAfterBinaryOperators": [],
|
||||
|
||||
"disallowImplicitTypeConversion": ["binary", "string"],
|
||||
|
||||
"disallowKeywords": ["with", "eval"],
|
||||
|
||||
"requireKeywordsOnNewLine": [],
|
||||
"disallowKeywordsOnNewLine": ["else"],
|
||||
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
|
||||
"disallowTrailingWhitespace": true,
|
||||
|
||||
"disallowTrailingComma": true,
|
||||
|
||||
"excludeFiles": ["node_modules/**", "vendor/**"],
|
||||
|
||||
"disallowMultipleLineStrings": true,
|
||||
|
||||
"requireDotNotation": true,
|
||||
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
|
||||
"validateLineBreaks": "LF",
|
||||
|
||||
"validateQuoteMarks": {
|
||||
"escape": true,
|
||||
"mark": "'"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
.DS_Store
|
||||
node_modules/
|
||||
test/
|
||||
components
|
||||
build
|
||||
.travis.yml
|
||||
testling.html
|
|
@ -0,0 +1,187 @@
|
|||
# es6-shim x.x.x (not yet released)
|
||||
|
||||
# es6-shim 0.20.1 (27 Oct 2014)
|
||||
* Set#delete and Map#delete should return false unless a deletion occurred. (#298)
|
||||
|
||||
# es6-shim 0.20.0 (26 Oct 2014)
|
||||
* Use a more reliable UMD
|
||||
* export the global object rather than undefined
|
||||
|
||||
# es6-shim 0.19.2 (25 Oct 2014)
|
||||
* Set#delete and Map#delete should return a boolean indicating success. (#298)
|
||||
* Make style consistent; add jscs
|
||||
|
||||
# es6-shim 0.19.1 (14 Oct 2014)
|
||||
* Fix Map#set and Set#add to be chainable (#295)
|
||||
* Update mocha
|
||||
|
||||
# es6-shim 0.19.0 (9 Oct 2014)
|
||||
* Detect and override noncompliant Map in Firefox 32 (#294)
|
||||
* Fix Map and Set for engines that don't preserve numeric key order (#292, #290)
|
||||
* Detect and override noncompliant Safari 7.1 Promises (#289)
|
||||
* Fix Array#keys and Array#entries in Safari 7.1
|
||||
* General style and whitespace cleanup
|
||||
* Update dependencies
|
||||
* Clean up tests for ES3 by removing reserved words
|
||||
|
||||
# es6-shim 0.18.0 (6 Sep 2014)
|
||||
* Speed up String#trim replacement (#284)
|
||||
* named Array#find and Array#findIndex for easier debugging
|
||||
* Replace broken native implementation in Firefox 25-31 for Array#find and Array#findIndex
|
||||
* Ensure String.fromCodePoint has the correct length in Firefox
|
||||
* List the license in `package.json` for `npm`
|
||||
* Array.from: fix spec bug with Array.from([], undefined) throwing
|
||||
* Array.from: fix Firefox Array.from bug wrt swallowing negative lengths vs throwing
|
||||
|
||||
# es6-shim 0.17.0 (31 Aug 2014)
|
||||
* Added es6-sham (#281)
|
||||
* Fixing some flaky tests (#268)
|
||||
* Tweaking how ArrayIterator is checked in its "next" function
|
||||
* Cleaning up some of the logic in Array.from
|
||||
|
||||
# es6-shim 0.16.0 (6 Aug 2014)
|
||||
* Array#find and Array#findIndex: no longer skips holes in sparse arrays, per https://bugs.ecmascript.org/show_bug.cgi?id=3107
|
||||
|
||||
# es6-shim 0.15.1 (5 Aug 2014)
|
||||
* Array.from: now correctly throws if provided `undefined` as a mapper function
|
||||
* Array.from: now correctly works if provided a falsy `thisArg`
|
||||
* Fix tests so they work properly when Array#(values|keys|entries) are not present
|
||||
* Add `npm run lint` to run style checks independently
|
||||
* Add `test/native.html` so browsers can be easily checked for shim-less compliance.
|
||||
|
||||
# es6-shim 0.15.0 (31 Jul 2014)
|
||||
* Object.assign no longer throws on null or undefined sources, per https://bugs.ecmascript.org/show_bug.cgi?id=3096
|
||||
|
||||
# es6-shim 0.14.0 (20 Jul 2014)
|
||||
* Properly recognize Symbol.iterator when it is present (#277)
|
||||
* Fix Math.clz's improper handling of values that coerce to NaN (#269)
|
||||
* Fix incorrect handling of negative end index on Array#fill (#270)
|
||||
* Removed Object.getOwnPropertyKeys, which shouldn't be anywhere (#267)
|
||||
* Fixed arity of Map and Set constructors, per 2014.04.27 draft spec (rev 24)
|
||||
* Added a full additional suite of ES6 promise tests (thanks to @smikes!) (#265)
|
||||
* Make Number.isInteger a bit more efficient (#266)
|
||||
* Added `npm run test-native` to expose how broken implementations are without the shim ;-)
|
||||
* Added additional tests
|
||||
|
||||
# es6-shim 0.13.0 (11 Jun 2014)
|
||||
* Adapt to new Array.from changes: mapper function is now called with both value and index (#261, #262)
|
||||
* More reliably getting the global object in strict mode to fix node-webkit (#258, #259)
|
||||
* Properly test the global Promise for ignoring non-function callbacks (#258)
|
||||
|
||||
# es6-shim 0.12.0 (4 Jun 2014)
|
||||
* Fix String#trim implementations that incorrectly trim \u0085
|
||||
* Stop relying on ArrayIterator being a public var, fixing Safari 8
|
||||
|
||||
# es6-shim 0.11.1 (2 Jun 2014)
|
||||
* Make sure to shim Object.assign in all environments, not just true ES5
|
||||
* Now including minified file and source map
|
||||
|
||||
# es6-shim 0.11.0 (11 May 2014)
|
||||
* Remove `Object.getOwnPropertyDescriptors`, per spec. (#234, #235)
|
||||
* IE8 fixes. (#163, #236)
|
||||
* Improve `Promise` scheduling. (#231)
|
||||
* Add some more standalone shims
|
||||
* Use an Object.create fallback, for better ES3 compatibility
|
||||
* Fix Math.expm1 in more browsers (#84)
|
||||
* Fix es6-shim in Web Workers (#247, #248)
|
||||
* Correct Object.assign to take multiple sources (#241)
|
||||
|
||||
# es6-shim 0.10.1 (13 Mar 2014)
|
||||
* Update bower.json, component.json, and .npmignore (#229, #230, #233)
|
||||
* Minor updates to `Promise` implementation and test suite.
|
||||
* Workaround lack of 'strict mode' in IE9. (#232)
|
||||
|
||||
# es6-shim 0.10.0 (1 March 2014)
|
||||
* Implement `Promise`, per spec. (#209, #215, #224, #225)
|
||||
* Make `Map`/`Set` subclassable; support `iterable` argument to
|
||||
constructor (#218)
|
||||
* Rename `Number#clz` to `Math.clz32` (#217)
|
||||
* Bug fixes to `Array#find` and `Array#findIndex` on sparse arrays (#213)
|
||||
* Re-add `Number.isInteger` (mistakenly removed in 0.9.0)
|
||||
* Allow use of `arguments` as an iterable
|
||||
* Minor spec-compliance fixes for `String.raw`
|
||||
* In ES6, `Object.keys` accepts non-Object types (#220)
|
||||
* Improved browser compatibility with IE 9/10, Opera 12 (#225)
|
||||
|
||||
# es6-shim 0.9.3 (5 February 2014)
|
||||
* Per spec, removed `Object.mixin` (#192)
|
||||
* Per spec, treat -0 and +0 keys as identical in Map/Set (#129, #204)
|
||||
* Per spec, `ArrayIterator`/`Array#values()` skips sparse indexes now. (#189)
|
||||
* Added `Array.from`, supporting Map/Set/Array/String iterators (the String iterator iterates over codepoints, not indexes) (#182)
|
||||
* Bug fixes to Map/Set iteration after concurrent delete. (#183)
|
||||
* Bug fixes to `Number.clz`: 0 and 0x100000000 are handled correctly now. (#196)
|
||||
* Added `Math.fround` to truncate to a 32-bit floating point number. (#140)
|
||||
* Bug fix for `Math.cosh` (#178)
|
||||
* Work around Firefox bugs in `String#startsWith` and `String#endsWith` (#172)
|
||||
* Work around Safari bug in `Math.imul`
|
||||
|
||||
# es6-shim 0.9.2 (18 December 2013)
|
||||
* Negative `String#endsWith` position is now handled properly.
|
||||
* `TypeError` is now thrown when string methods are called
|
||||
on `null` / `undefined`.
|
||||
|
||||
# es6-shim 0.9.1 (28 October 2013)
|
||||
* Added `Array#copyWithin` and `Number.MIN_SAFE_INTEGER`
|
||||
* Big speed-up of Maps / Sets for string / number keys:
|
||||
they are O(1) now.
|
||||
* Changed `Math.hypot` according to spec.
|
||||
* Other small fixes.
|
||||
|
||||
# es6-shim 0.9.0 (30 August 2013)
|
||||
* Added Array iteration methods: `Array#keys`, `Array#values`, `Array#entries`, which return an `ArrayIterator`
|
||||
* Changed `Map` and `Set` constructors to conform to spec when called without `new`
|
||||
* Added `Math.imul`
|
||||
* Per spec, removed `Number.toInteger`, `Number.isInteger`, and `Number.MAX_INTEGER`; added `Number.isSafeInteger`, `Number.MAX_SAFE_INTEGER`
|
||||
* Added extensive additional tests for many methods
|
||||
|
||||
# es6-shim 0.8.0 (8 June 2013)
|
||||
* Added `Object.setPrototypeOf`, `Set#keys`, `Set#values`, `Map#keys`, `Map#values`, `Map#entries`, `Set#entries`.
|
||||
* Fixed `String#repeat` according to spec.
|
||||
|
||||
# es6-shim 0.7.0 (2 April 2013)
|
||||
* Added `Array#find`, `Array#findIndex`, `Object.assign`, `Object.mixin`,
|
||||
`Math.cbrt`, `String.fromCodePoint`, `String#codePointAt`.
|
||||
* Removed `Object.isnt`.
|
||||
* Made Math functions fully conform spec.
|
||||
|
||||
# es6-shim 0.6.0 (15 January 2013)
|
||||
* Added `Map#keys`, `Map#values`, `Map#size`, `Set#size`, `Set#clear`.
|
||||
|
||||
# es6-shim 0.5.3 (2 September 2012)
|
||||
* Made `String#startsWith`, `String#endsWith` fully conform spec.
|
||||
|
||||
# es6-shim 0.5.2 (17 June 2012)
|
||||
* Removed `String#toArray` and `Object.isObject` as per spec updates.
|
||||
|
||||
# es6-shim 0.5.1 (14 June 2012)
|
||||
* Made Map and Set follow Spidermonkey implementation instead of V8.
|
||||
`var m = Map(); m.set('key', void 0); m.has('key');` now gives true.
|
||||
|
||||
# es6-shim 0.5.0 (13 June 2012)
|
||||
* Added Number.MAX_INTEGER, Number.EPSILON, Number.parseInt,
|
||||
Number.parseFloat, Number.prototype.clz, Object.isObject.
|
||||
|
||||
# es6-shim 0.4.1 (11 May 2012)
|
||||
* Fixed boundary checking in Number.isInteger.
|
||||
|
||||
# es6-shim 0.4.0 (8 February 2012)
|
||||
* Added Math.log10, Math.log2, Math.log1p, Math.expm1, Math.cosh,
|
||||
Math.sinh, Math.tanh, Math.acosh, Math.asinh, Math.atanh, Math.hypot,
|
||||
Math.trunc.
|
||||
|
||||
# es6-shim 0.3.1 (30 January 2012)
|
||||
* Added IE8 support.
|
||||
|
||||
# es6-shim 0.3.0 (27 January 2012)
|
||||
* Added Number.isFinite() and Object.isnt().
|
||||
|
||||
# es6-shim 0.2.1 (7 January 2012)
|
||||
* Fixed a bug in String#endsWith().
|
||||
|
||||
# es6-shim 0.2.0 (25 December 2011)
|
||||
* Added browser support.
|
||||
* Added tests.
|
||||
* Added Math.sign().
|
||||
|
||||
# es6-shim 0.1.0 (25 December 2011)
|
||||
* Initial release
|
|
@ -0,0 +1,98 @@
|
|||
module.exports = function (grunt) {
|
||||
var browsers = [
|
||||
{ browserName: "firefox", version: "19", platform: "XP" },
|
||||
{ browserName: "firefox", platform: "linux" },
|
||||
{ browserName: "chrome", platform: "linux" },
|
||||
{ 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: '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: "firefox", platform: "OS X 10.9" },
|
||||
{ browserName: "chrome", platform: "XP" },
|
||||
{ browserName: "chrome", platform: "OS X 10.9" },
|
||||
{ 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 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"]);
|
||||
};
|
|
@ -0,0 +1,216 @@
|
|||
# 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)
|
||||
|
||||
## Installation
|
||||
If you want to use it in browser:
|
||||
|
||||
* Just include es6-shim before your scripts.
|
||||
* Include [es5-shim](https://github.com/kriskowal/es5-shim) if your browser doesn't support ECMAScript 5.
|
||||
* `component install paulmillr/es6-shim` if you’re using [component(1)](https://github.com/component/component).
|
||||
* `bower install es6-shim` if you’re using [Twitter Bower](http://bower.io/).
|
||||
|
||||
For node.js:
|
||||
|
||||
npm install es6-shim
|
||||
|
||||
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)
|
||||
* `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))
|
||||
* `repeat()` ([a standalone shim is also available](http://mths.be/repeat))
|
||||
* `startsWith()` ([a standalone shim is also available](http://mths.be/startswith))
|
||||
* `endsWith()` ([a standalone shim is also available](http://mths.be/endswith))
|
||||
* `contains()` ([a standalone shim is also available](http://mths.be/contains))
|
||||
* `Number`:
|
||||
* `MAX_SAFE_INTEGER`
|
||||
* `MIN_SAFE_INTEGER`
|
||||
* `EPSILON`
|
||||
* `parseInt()`
|
||||
* `parseFloat()`
|
||||
* `isNaN()`([a standalone shim is also available](https://npmjs.org/package/is-nan))
|
||||
* `isInteger()`
|
||||
* `isSafeInteger()`
|
||||
* `isFinite()`
|
||||
* `Array`:
|
||||
* `from()` ([a standalone shim is also available](https://npmjs.org/package/array.from))
|
||||
* `of()` ([a standalone shim is also available](https://npmjs.org/package/array.of))
|
||||
* `Array.prototype`:
|
||||
* `copyWithin()`
|
||||
* `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)
|
||||
* `entries()`
|
||||
* `values()`
|
||||
* `Object`:
|
||||
* `getPropertyDescriptor()` (ES5)
|
||||
* `getPropertyNames()` (ES5)
|
||||
* `getPropertyKeys()` (ES5)
|
||||
* `keys()` (ES5, but no longer throws on non-object non-null/undefined values in ES6)
|
||||
* `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is))
|
||||
* `assign()` ([a standalone shim is also available](https://github.com/ljharb/object.assign))
|
||||
* `setPrototypeOf()` (IE >= 11)
|
||||
* `Math`:
|
||||
* `acosh()`
|
||||
* `asinh()`
|
||||
* `atanh()`
|
||||
* `cbrt()`
|
||||
* `clz32()`
|
||||
* `cosh()`
|
||||
* `expm1()`
|
||||
* `hypot()`
|
||||
* `log2()`
|
||||
* `log10()`
|
||||
* `log1p()`
|
||||
* `sign()`
|
||||
* `sinh()`
|
||||
* `tanh()`
|
||||
* `trunc()`
|
||||
* `imul()`
|
||||
* `fround()`
|
||||
|
||||
Math functions accuracy is 1e-11.
|
||||
|
||||
## 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
|
||||
function MyPromise(exec) {
|
||||
Promise.call(this, exec);
|
||||
// ...
|
||||
}
|
||||
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 a very unusual use-case so you probably won't need it at all
|
||||
(use simple `Map` instead).
|
||||
|
||||
## Getting started
|
||||
|
||||
```javascript
|
||||
'abc'.startsWith('a') // true
|
||||
'abc'.endsWith('a') // false
|
||||
'john alice'.contains('john') // true
|
||||
'123'.repeat(2) // '123123'
|
||||
|
||||
Object.is(NaN, NaN) // Fixes ===. 0 isnt -0, NaN is NaN
|
||||
Object.assign({a: 1}, {b: 2}) // {a: 1, b: 2}
|
||||
|
||||
Number.isNaN('123') // false. isNaN('123') will give true.
|
||||
Number.isFinite('asd') // false. Global isFinite() will give true.
|
||||
// Tests if value is a number, finite,
|
||||
// >= -9007199254740992 && <= 9007199254740992 and floor(value) === value
|
||||
Number.isInteger(2.4) // false.
|
||||
|
||||
Math.sign(400) // 1, 0 or -1 depending on sign. In this case 1.
|
||||
|
||||
[5, 10, 15, 10].find(function (item) {return item / 2 === 5;}) // 10
|
||||
[5, 10, 15, 10].findIndex(function (item) {return item / 2 === 5;}) // 1
|
||||
|
||||
// Replacement for `{}` key-value storage.
|
||||
// Keys can be anything.
|
||||
var map = new Map()
|
||||
map.set('John', 25)
|
||||
map.set('Alice', 400)
|
||||
map.set(['meh'], 555)
|
||||
map.get(['meh']) // undefined because you need to use exactly the same object.
|
||||
map.delete('Alice')
|
||||
map.keys()
|
||||
map.values()
|
||||
map.size // 2
|
||||
|
||||
// Useful for storing unique items.
|
||||
var set = new Set()
|
||||
set.add(1)
|
||||
set.add(5)
|
||||
set.has(1)
|
||||
set.has(4) // => false
|
||||
set.delete(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) {
|
||||
if ( ... ) throw new Error("whoops!");
|
||||
// do some stuff
|
||||
return anotherPromise();
|
||||
}).catch(function (e) {
|
||||
// any errors thrown asynchronously end up here
|
||||
});
|
||||
```
|
||||
|
||||
Other stuff:
|
||||
|
||||
* [ECMAScript 6 drafts](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts)
|
||||
* [Harmony proposals](http://wiki.ecmascript.org/doku.php?id=harmony:harmony)
|
||||
|
||||
## License
|
||||
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-2014 Paul Miller (http://paulmillr.com)
|
||||
|
||||
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.
|
||||
|
||||
[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
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "es6-shim",
|
||||
"version": "0.20.1",
|
||||
"repo": "paulmillr/es6-shim",
|
||||
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
|
||||
"keywords": [
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"es6",
|
||||
"shim",
|
||||
"promise",
|
||||
"promises",
|
||||
"setPrototypeOf",
|
||||
"map",
|
||||
"set",
|
||||
"__proto__"
|
||||
],
|
||||
"main": "es6-shim.js",
|
||||
"scripts": ["es6-shim.js"],
|
||||
"dependencies": {},
|
||||
"development": {},
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"components",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "es6-shim",
|
||||
"version": "0.20.1",
|
||||
"repo": "paulmillr/es6-shim",
|
||||
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
|
||||
"keywords": [
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"es6",
|
||||
"shim",
|
||||
"promise",
|
||||
"promises",
|
||||
"setPrototypeOf",
|
||||
"map",
|
||||
"set",
|
||||
"__proto__"
|
||||
],
|
||||
"main": "es6-shim.js",
|
||||
"scripts": ["es6-shim.js"],
|
||||
"dependencies": {},
|
||||
"development": {}
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
/*!
|
||||
* https://github.com/paulmillr/es6-shim
|
||||
* @license es6-shim Copyright 2013-2014 by Paul Miller (http://paulmillr.com)
|
||||
* and contributors, MIT License
|
||||
* es6-sham: v0.20.1
|
||||
* see https://github.com/paulmillr/es6-shim/blob/master/LICENSE
|
||||
* Details and documentation:
|
||||
* https://github.com/paulmillr/es6-shim/
|
||||
*/
|
||||
|
||||
(function (undefined) {
|
||||
'use strict';
|
||||
|
||||
/*jshint evil: true */
|
||||
var getGlobal = new Function('return this;');
|
||||
/*jshint evil: false */
|
||||
|
||||
var main = function () {
|
||||
var globals = getGlobal();
|
||||
var Object = globals.Object;
|
||||
|
||||
// NOTE: This versions needs object ownership
|
||||
// beacuse every promoted object needs to be reassigned
|
||||
// otherwise uncompatible browsers cannot work as expected
|
||||
//
|
||||
// NOTE: This might need es5-shim or polyfills upfront
|
||||
// because it's based on ES5 API.
|
||||
// (probably just an IE <= 8 problem)
|
||||
//
|
||||
// NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
|
||||
(function () {
|
||||
if (Object.setPrototypeOf) { return; }
|
||||
|
||||
/*jshint proto: true */
|
||||
// @author Andrea Giammarchi - @WebReflection
|
||||
// define into target descriptors from source
|
||||
var copyDescriptors = function (target, 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 create = Object.create;
|
||||
var defineProperty = Object.defineProperty;
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
||||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||
var proto = Object.prototype;
|
||||
var set, setPrototypeOf;
|
||||
|
||||
try {
|
||||
// this might fail for various reasons
|
||||
// ignore if Chrome cought it at runtime
|
||||
set = getOwnPropertyDescriptor(proto, '__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
|
||||
set.__proto__ = 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
|
||||
origin.__proto__ = proto;
|
||||
return origin;
|
||||
};
|
||||
} else {
|
||||
// try to use proto or fallback
|
||||
// Safari, old Firefox, many others
|
||||
setPrototypeOf = function (origin, proto) {
|
||||
// if proto is not null
|
||||
return getPrototypeOf(origin) ?
|
||||
// use __proto__ to promote
|
||||
((origin.__proto__ = proto), origin) :
|
||||
// otherwise unable to promote: fallback
|
||||
createAndCopy(origin, proto);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.setPrototypeOf = setPrototypeOf;
|
||||
}());
|
||||
|
||||
};
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(main); // RequireJS
|
||||
} else {
|
||||
main(); // CommonJS and <script>
|
||||
}
|
||||
}());
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["es6-sham.js"],"names":["undefined","getGlobal","Function","main","globals","Object","setPrototypeOf","copyDescriptors","target","source","getOwnPropertyNames","forEach","key","defineProperty","getOwnPropertyDescriptor","createAndCopy","origin","proto","create","getPrototypeOf","prototype","set","call","e","__proto__","define","amd"],"mappings":";;;;;;;;;CAUC,SAAUA,GACT,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAO,WACT,GAAIC,GAAUH,GACd,IAAII,GAASD,EAAQC,QAWpB,WACC,GAAIA,EAAOC,eAAgB,CAAE,OAK7B,GAAIC,GAAkB,SAAUC,EAAQC,GACtCC,EAAoBD,GAAQE,QAAQ,SAAUC,GAC5CC,EACEL,EACAI,EACAE,EAAyBL,EAAQG,KAGrC,OAAOJ,GAGT,IAAIO,GAAgB,SAAUC,EAAQC,GACpC,MAAOV,GAAgBW,EAAOD,GAAQD,GAExC,IAAIE,GAASb,EAAOa,MACpB,IAAIL,GAAiBR,EAAOQ,cAC5B,IAAIM,GAAiBd,EAAOc,cAC5B,IAAIT,GAAsBL,EAAOK,mBACjC,IAAII,GAA2BT,EAAOS,wBACtC,IAAIG,GAAQZ,EAAOe,SACnB,IAAIC,GAAKf,CAET,KAGEe,EAAMP,EAAyBG,EAAO,aAAaI,GACnDA,GAAIC,QAAS,KAGbhB,GAAiB,SAAUU,EAAQC,GACjCI,EAAIC,KAAKN,EAAQC,EACjB,OAAOD,IAET,MAAOO,GAEPF,GAAOG,UAAW,KAGlB,IAAIH,YAAehB,GAAQ,CACzBC,EAAiBS,MACZ,CAELM,EAAIG,UAAYP,CAGhB,IAAII,YAAehB,GAAQ,CACzBC,EAAiB,SAAUU,EAAQC,GAEjCD,EAAOQ,UAAYP,CACnB,OAAOD,QAEJ,CAGLV,EAAiB,SAAUU,EAAQC,GAEjC,MAAOE,GAAeH,IAElBA,EAAOQ,UAAYP,EAAQD,GAE7BD,EAAcC,EAAQC,MAKhCZ,EAAOC,eAAiBA,MAK5B,UAAWmB,UAAW,YAAcA,OAAOC,IAAK,CAC9CD,OAAOtB,OACF,CACLA"}
|
|
@ -0,0 +1,11 @@
|
|||
/*!
|
||||
* https://github.com/paulmillr/es6-shim
|
||||
* @license es6-shim Copyright 2013-2014 by Paul Miller (http://paulmillr.com)
|
||||
* and contributors, MIT License
|
||||
* es6-sham: v0.20.1
|
||||
* see https://github.com/paulmillr/es6-shim/blob/master/LICENSE
|
||||
* Details and documentation:
|
||||
* https://github.com/paulmillr/es6-shim/
|
||||
*/
|
||||
(function(t){"use strict";var r=new Function("return this;");var e=function(){var t=r();var e=t.Object;(function(){if(e.setPrototypeOf){return}var t=function(t,r){i(r).forEach(function(e){o(t,e,a(r,e))});return t};var r=function(r,e){return t(n(e),r)};var n=e.create;var o=e.defineProperty;var f=e.getPrototypeOf;var i=e.getOwnPropertyNames;var a=e.getOwnPropertyDescriptor;var c=e.prototype;var u,_;try{u=a(c,"__proto__").set;u.call({},null);_=function(t,r){u.call(t,r);return t}}catch(p){u={__proto__:null};if(u instanceof e){_=r}else{u.__proto__=c;if(u instanceof e){_=function(t,r){t.__proto__=r;return t}}else{_=function(t,e){return f(t)?(t.__proto__=e,t):r(t,e)}}}}e.setPrototypeOf=_})()};if(typeof define==="function"&&define.amd){define(e)}else{e()}})();
|
||||
//# sourceMappingURL=es6-sham.map
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
"name": "es6-shim",
|
||||
"version": "0.20.1",
|
||||
"author": {
|
||||
"name": "Paul Miller",
|
||||
"url": "http://paulmillr.com"
|
||||
},
|
||||
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
|
||||
"keywords": [
|
||||
"ecmascript",
|
||||
"harmony",
|
||||
"es6",
|
||||
"shim",
|
||||
"promise",
|
||||
"promises",
|
||||
"setPrototypeOf",
|
||||
"map",
|
||||
"set",
|
||||
"__proto__"
|
||||
],
|
||||
"homepage": "https://github.com/paulmillr/es6-shim/",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/paulmillr/es6-shim.git"
|
||||
},
|
||||
"main": "es6-shim",
|
||||
"scripts": {
|
||||
"test": "npm run test-shim && npm run test-sham",
|
||||
"lint": "npm run lint-shim && npm run lint-sham",
|
||||
"lint-shim": "jshint es6-shim.js test/*.js test/*/*.js && jscs es6-shim.js test/*.js test/*/*.js",
|
||||
"lint-sham": "jshint es6-sham.js test-sham/*.js && jscs es6-sham.js test-sham/*.js",
|
||||
"test-shim": "npm run lint-shim && mocha test/*.js test/*/*.js",
|
||||
"test-sham": "npm run lint-sham && mocha test-sham/*.js",
|
||||
"test-native": "jshint es6-shim.js && NO_ES6_SHIM=1 mocha test/*.js test/*/*.js",
|
||||
"minify": "npm run minify-shim && npm run minify-sham",
|
||||
"minify-shim": "uglifyjs es6-shim.js --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js",
|
||||
"minify-sham": "uglifyjs es6-sham.js --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js",
|
||||
"sauce": "grunt sauce"
|
||||
},
|
||||
"testling": {
|
||||
"html": "testling.html",
|
||||
"browsers": [
|
||||
"iexplore/9.0..latest",
|
||||
"firefox/10.0",
|
||||
"firefox/17.0",
|
||||
"firefox/22.0..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25.0..latest",
|
||||
"chrome/canary",
|
||||
"safari/5.0.5..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"opera/12.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"chai": "~1.9.2",
|
||||
"es5-shim": "~4.0.3",
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-contrib-connect": "~0.8.0",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-saucelabs": "~8.3.2",
|
||||
"jscs": "~1.7.3",
|
||||
"jshint": "~2.5.6",
|
||||
"mocha": "~2.0.1",
|
||||
"promises-aplus-tests": "~2.1.0",
|
||||
"promises-es6-tests": "~0.5.0",
|
||||
"uglify-js": "~2.4.15"
|
||||
},
|
||||
"gitHead": "c70e0007f247e2db6c1bd967c1d7ed9809d2c8bf",
|
||||
"bugs": {
|
||||
"url": "https://github.com/paulmillr/es6-shim/issues"
|
||||
},
|
||||
"_id": "es6-shim@0.20.1",
|
||||
"_shasum": "9f86fcece9b9c9af3133b3c9db795e44a20499a4",
|
||||
"_from": "es6-shim@",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "ljharb",
|
||||
"email": "ljharb@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "paulmillr",
|
||||
"email": "paul@paulmillr.com"
|
||||
},
|
||||
{
|
||||
"name": "ljharb",
|
||||
"email": "ljharb@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "9f86fcece9b9c9af3133b3c9db795e44a20499a4",
|
||||
"tarball": "http://registry.npmjs.org/es6-shim/-/es6-shim-0.20.1.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.20.1.tgz"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<!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="../test/browser-onload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
describe('Object.setPrototypeOf(o, p)', function () {
|
||||
|
||||
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, {});
|
||||
expect(obj instanceof Object).to.equal(true);
|
||||
expect(obj.a).to.equal(456);
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue