Assume ES5+ built-ins exist.

This commit is contained in:
John-David Dalton
2017-01-09 19:06:04 -08:00
parent 8501b0c2ef
commit 8bc7e006db
26 changed files with 18 additions and 117 deletions

View File

@@ -1,6 +0,0 @@
import getNative from './_getNative.js';
import root from './_root.js';
const DataView = getNative(root, 'DataView');
export default DataView;

View File

@@ -1,6 +0,0 @@
import getNative from './_getNative.js';
import root from './_root.js';
const Map = getNative(root, 'Map');
export default Map;

View File

@@ -1,6 +0,0 @@
import getNative from './_getNative.js';
import root from './_root.js';
const Promise = getNative(root, 'Promise');
export default Promise;

View File

@@ -1,6 +0,0 @@
import getNative from './_getNative.js';
import root from './_root.js';
const Set = getNative(root, 'Set');
export default Set;

View File

@@ -1,3 +0,0 @@
import root from './_root.js';
export default root.Symbol;

View File

@@ -1,3 +0,0 @@
import root from './_root.js';
export default root.Uint8Array;

View File

@@ -1,6 +0,0 @@
import getNative from './_getNative.js';
import root from './_root.js';
const WeakMap = getNative(root, 'WeakMap');
export default WeakMap;

View File

@@ -1,5 +1,3 @@
import defineProperty from './_defineProperty.js';
/**
* The base implementation of `assignValue` and `assignMergeValue` without
* value checks.
@@ -10,8 +8,8 @@ import defineProperty from './_defineProperty.js';
* @param {*} value The value to assign.
*/
function baseAssignValue(object, key, value) {
if (key == '__proto__' && defineProperty) {
defineProperty(object, key, {
if (key == '__proto__') {
Object.defineProperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,

View File

@@ -1,4 +1,3 @@
import Symbol from './_Symbol.js';
import getRawTag from './_getRawTag.js';
import objectToString from './_objectToString.js';

View File

@@ -1,5 +1,4 @@
import constant from './constant.js';
import defineProperty from './_defineProperty.js';
import identity from './identity.js';
/**
@@ -10,11 +9,13 @@ import identity from './identity.js';
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
const baseSetToString = !defineProperty ? identity : (func, string) => defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});
function baseSetToString(func, string){
return Object.defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});
}
export default baseSetToString;

View File

@@ -1,4 +1,3 @@
import Symbol from './_Symbol.js';
import arrayMap from './_arrayMap.js';
import isSymbol from './isSymbol.js';

View File

@@ -1,5 +1,3 @@
import Uint8Array from './_Uint8Array.js';
/**
* Creates a clone of `arrayBuffer`.
*

View File

@@ -1,8 +1,5 @@
import Symbol from './_Symbol.js';
/** Used to convert symbols to primitives and strings. */
const symbolProto = Symbol ? Symbol.prototype : undefined;
const symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
const symbolValueOf = Symbol.prototype.valueOf;
/**
* Creates a clone of the `symbol` object.

View File

@@ -1,4 +1,3 @@
import Set from './_Set.js';
import setToArray from './_setToArray.js';
/** Used as references for various `Number` constants. */

View File

@@ -1,11 +0,0 @@
import getNative from './_getNative.js';
const defineProperty = ((() => {
try {
const func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
})());
export default defineProperty;

View File

@@ -1,5 +1,3 @@
import Symbol from './_Symbol.js';
import Uint8Array from './_Uint8Array.js';
import eq from './eq.js';
import equalArrays from './_equalArrays.js';
import mapToArray from './_mapToArray.js';

View File

@@ -1,16 +0,0 @@
import isNative from './isNative.js';
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
const value = object == null ? undefined : object[key];
return isNative(value) ? value : undefined;
}
export default getNative;

View File

@@ -1,5 +1,3 @@
import Symbol from './_Symbol.js';
/** Used for built-in method references. */
const objectProto = Object.prototype;

View File

@@ -1,8 +1,3 @@
import DataView from './_DataView.js';
import Map from './_Map.js';
import Promise from './_Promise.js';
import Set from './_Set.js';
import WeakMap from './_WeakMap.js';
import baseGetTag from './_baseGetTag.js';
import toSource from './_toSource.js';
@@ -32,10 +27,10 @@ let getTag = baseGetTag;
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
(Map && getTag(new Map) != mapTag) ||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
(Set && getTag(new Set) != setTag) ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
(getTag(new Map) != mapTag) ||
(getTag(Promise.resolve()) != promiseTag) ||
(getTag(new Set) != setTag) ||
(getTag(new WeakMap) != weakMapTag)) {
getTag = value => {
const result = baseGetTag(value);
const Ctor = result == objectTag ? value.constructor : undefined;

View File

@@ -1,9 +1,5 @@
import Symbol from './_Symbol.js';
import isArguments from './isArguments.js';
/** Built-in value references. */
const spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
/**
* Checks if `value` is a flattenable `arguments` object or array.
*
@@ -13,7 +9,7 @@ const spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
*/
function isFlattenable(value) {
return Array.isArray(value) || isArguments(value) ||
!!(spreadableSymbol && value && value[spreadableSymbol]);
!!(Symbol.isConcatSpreadable && value && value[spreadableSymbol]);
}
export default isFlattenable;

View File

@@ -1,6 +1,5 @@
import Hash from './_Hash.js';
import ListCache from './_ListCache.js';
import Map from './_Map.js';
/**
* Removes all key-value entries from the map.

View File

@@ -1,6 +1 @@
import WeakMap from './_WeakMap.js';
/** Used to store function metadata. */
const metaMap = WeakMap && new WeakMap;
export default metaMap;
export default new WeakMap;

View File

@@ -1,6 +0,0 @@
import getNative from './_getNative.js';
/* Built-in method references that are verified to be native. */
const nativeCreate = getNative(Object, 'create');
export default nativeCreate;

View File

@@ -1,5 +1,4 @@
import ListCache from './_ListCache.js';
import Map from './_Map.js';
import MapCache from './_MapCache.js';
/** Used as the size to enable large array optimizations. */

View File

@@ -38,7 +38,7 @@ const reIsNative = RegExp(`^${
* isNative(Array.prototype.push);
* // => true
*
* isNative(_);
* isNative(isDate);
* // => false
*/
function isNative(value) {

View File

@@ -1,4 +1,3 @@
import Symbol from './_Symbol.js';
import copyArray from './_copyArray.js';
import getTag from './_getTag.js';
import isArrayLike from './isArrayLike.js';