mirror of https://github.com/status-im/metro.git
Add polyfills to jest setup scripts
Reviewed By: cpojer Differential Revision: D2627866 fb-gh-sync-id: 6d2c95ebc1fe05da3a90f8f6df3287bdbac870bd
This commit is contained in:
parent
9373eb73ac
commit
ef0b3e9338
|
@ -35,6 +35,7 @@ describe('BundlesLayout', () => {
|
|||
'polyfills/error-guard.js',
|
||||
'polyfills/String.prototype.es6.js',
|
||||
'polyfills/Array.prototype.es6.js',
|
||||
'polyfills/Array.es6.js',
|
||||
];
|
||||
const baseFs = getBaseFs();
|
||||
|
||||
|
|
|
@ -135,6 +135,19 @@ describe('Resolver', function() {
|
|||
'polyfills/String.prototype.es6.js',
|
||||
],
|
||||
},
|
||||
{ id: 'polyfills/Array.es6.js',
|
||||
isPolyfill: true,
|
||||
path: 'polyfills/Array.es6.js',
|
||||
dependencies: [
|
||||
'polyfills/prelude.js',
|
||||
'polyfills/require.js',
|
||||
'polyfills/polyfills.js',
|
||||
'polyfills/console.js',
|
||||
'polyfills/error-guard.js',
|
||||
'polyfills/String.prototype.es6.js',
|
||||
'polyfills/Array.prototype.es6.js',
|
||||
],
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -196,7 +209,8 @@ describe('Resolver', function() {
|
|||
'polyfills/console.js',
|
||||
'polyfills/error-guard.js',
|
||||
'polyfills/String.prototype.es6.js',
|
||||
'polyfills/Array.prototype.es6.js'
|
||||
'polyfills/Array.prototype.es6.js',
|
||||
'polyfills/Array.es6.js',
|
||||
]
|
||||
},
|
||||
]);
|
||||
|
|
|
@ -105,6 +105,7 @@ class Resolver {
|
|||
path.join(__dirname, 'polyfills/error-guard.js'),
|
||||
path.join(__dirname, 'polyfills/String.prototype.es6.js'),
|
||||
path.join(__dirname, 'polyfills/Array.prototype.es6.js'),
|
||||
path.join(__dirname, 'polyfills/Array.es6.js'),
|
||||
].concat(this._polyfillModuleNames);
|
||||
|
||||
return polyfillModuleNames.map(
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* Copyright 2013-2014 Facebook, Inc.
|
||||
* @provides Array.es6
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
/*eslint-disable */
|
||||
|
||||
/**
|
||||
* Creates an array from array like objects.
|
||||
*
|
||||
* https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
|
||||
*/
|
||||
if (!Array.from) {
|
||||
Array.from = function(arrayLike /*, mapFn, thisArg */) {
|
||||
if (arrayLike == null) {
|
||||
throw new TypeError('Object is null or undefined');
|
||||
}
|
||||
|
||||
// Optional args.
|
||||
var mapFn = arguments[1];
|
||||
var thisArg = arguments[2];
|
||||
|
||||
var C = this;
|
||||
var items = Object(arrayLike);
|
||||
var symbolIterator = typeof Symbol === 'function'
|
||||
? Symbol.iterator
|
||||
: '@@iterator';
|
||||
var mapping = typeof mapFn === 'function';
|
||||
var usingIterator = typeof items[symbolIterator] === 'function';
|
||||
var key = 0;
|
||||
var ret;
|
||||
var value;
|
||||
|
||||
if (usingIterator) {
|
||||
ret = typeof C === 'function'
|
||||
? new C()
|
||||
: [];
|
||||
var it = items[symbolIterator]();
|
||||
var next;
|
||||
|
||||
while (!(next = it.next()).done) {
|
||||
value = next.value;
|
||||
|
||||
if (mapping) {
|
||||
value = mapFn.call(thisArg, value, key);
|
||||
}
|
||||
|
||||
ret[key] = value;
|
||||
key += 1;
|
||||
}
|
||||
|
||||
ret.length = key;
|
||||
return ret;
|
||||
}
|
||||
|
||||
var len = items.length;
|
||||
if (isNaN(len) || len < 0) {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
ret = typeof C === 'function'
|
||||
? new C(len)
|
||||
: new Array(len);
|
||||
|
||||
while (key < len) {
|
||||
value = items[key];
|
||||
|
||||
if (mapping) {
|
||||
value = mapFn.call(thisArg, value, key);
|
||||
}
|
||||
|
||||
ret[key] = value;
|
||||
|
||||
key += 1;
|
||||
}
|
||||
|
||||
ret.length = key;
|
||||
return ret;
|
||||
};
|
||||
}
|
|
@ -55,78 +55,4 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array from array like objects.
|
||||
*
|
||||
* https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
|
||||
*/
|
||||
if (!Array.from) {
|
||||
Array.from = function(arrayLike /*, mapFn, thisArg */) {
|
||||
if (arrayLike == null) {
|
||||
throw new TypeError('Object is null or undefined');
|
||||
}
|
||||
|
||||
// Optional args.
|
||||
var mapFn = arguments[1];
|
||||
var thisArg = arguments[2];
|
||||
|
||||
var C = this;
|
||||
var items = Object(arrayLike);
|
||||
var symbolIterator = typeof Symbol === 'function'
|
||||
? Symbol.iterator
|
||||
: '@@iterator';
|
||||
var mapping = typeof mapFn === 'function';
|
||||
var usingIterator = typeof items[symbolIterator] === 'function';
|
||||
var key = 0;
|
||||
var ret;
|
||||
var value;
|
||||
|
||||
if (usingIterator) {
|
||||
ret = typeof C === 'function'
|
||||
? new C()
|
||||
: [];
|
||||
var it = items[symbolIterator]();
|
||||
var next;
|
||||
|
||||
while (!(next = it.next()).done) {
|
||||
value = next.value;
|
||||
|
||||
if (mapping) {
|
||||
value = mapFn.call(thisArg, value, key);
|
||||
}
|
||||
|
||||
ret[key] = value;
|
||||
key += 1;
|
||||
}
|
||||
|
||||
ret.length = key;
|
||||
return ret;
|
||||
}
|
||||
|
||||
var len = items.length;
|
||||
if (isNaN(len) || len < 0) {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
ret = typeof C === 'function'
|
||||
? new C(len)
|
||||
: new Array(len);
|
||||
|
||||
while (key < len) {
|
||||
value = items[key];
|
||||
|
||||
if (mapping) {
|
||||
value = mapFn.call(thisArg, value, key);
|
||||
}
|
||||
|
||||
ret[key] = value;
|
||||
|
||||
key += 1;
|
||||
}
|
||||
|
||||
ret.length = key;
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue