From 8bc7e006db74a3ef3a0491d644a89fc4814e4a4e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 9 Jan 2017 19:06:04 -0800 Subject: [PATCH] Assume ES5+ built-ins exist. --- _DataView.js | 6 ------ _Map.js | 6 ------ _Promise.js | 6 ------ _Set.js | 6 ------ _Symbol.js | 3 --- _Uint8Array.js | 3 --- _WeakMap.js | 6 ------ _baseAssignValue.js | 6 ++---- _baseGetTag.js | 1 - _baseSetToString.js | 15 ++++++++------- _baseToString.js | 1 - _cloneArrayBuffer.js | 2 -- _cloneSymbol.js | 5 +---- _createSet.js | 1 - _defineProperty.js | 11 ----------- _equalByTag.js | 2 -- _getNative.js | 16 ---------------- _getRawTag.js | 2 -- _getTag.js | 13 ++++--------- _isFlattenable.js | 6 +----- _mapCacheClear.js | 1 - _metaMap.js | 7 +------ _nativeCreate.js | 6 ------ _stackSet.js | 1 - isNative.js | 2 +- toArray.js | 1 - 26 files changed, 18 insertions(+), 117 deletions(-) delete mode 100644 _DataView.js delete mode 100644 _Map.js delete mode 100644 _Promise.js delete mode 100644 _Set.js delete mode 100644 _Symbol.js delete mode 100644 _Uint8Array.js delete mode 100644 _WeakMap.js delete mode 100644 _defineProperty.js delete mode 100644 _getNative.js delete mode 100644 _nativeCreate.js diff --git a/_DataView.js b/_DataView.js deleted file mode 100644 index 20a9e7e1e..000000000 --- a/_DataView.js +++ /dev/null @@ -1,6 +0,0 @@ -import getNative from './_getNative.js'; -import root from './_root.js'; - -const DataView = getNative(root, 'DataView'); - -export default DataView; diff --git a/_Map.js b/_Map.js deleted file mode 100644 index ab716ebdf..000000000 --- a/_Map.js +++ /dev/null @@ -1,6 +0,0 @@ -import getNative from './_getNative.js'; -import root from './_root.js'; - -const Map = getNative(root, 'Map'); - -export default Map; diff --git a/_Promise.js b/_Promise.js deleted file mode 100644 index 8b3a95260..000000000 --- a/_Promise.js +++ /dev/null @@ -1,6 +0,0 @@ -import getNative from './_getNative.js'; -import root from './_root.js'; - -const Promise = getNative(root, 'Promise'); - -export default Promise; diff --git a/_Set.js b/_Set.js deleted file mode 100644 index 5d95712dc..000000000 --- a/_Set.js +++ /dev/null @@ -1,6 +0,0 @@ -import getNative from './_getNative.js'; -import root from './_root.js'; - -const Set = getNative(root, 'Set'); - -export default Set; diff --git a/_Symbol.js b/_Symbol.js deleted file mode 100644 index 90a45dd31..000000000 --- a/_Symbol.js +++ /dev/null @@ -1,3 +0,0 @@ -import root from './_root.js'; - -export default root.Symbol; diff --git a/_Uint8Array.js b/_Uint8Array.js deleted file mode 100644 index 88daca59d..000000000 --- a/_Uint8Array.js +++ /dev/null @@ -1,3 +0,0 @@ -import root from './_root.js'; - -export default root.Uint8Array; diff --git a/_WeakMap.js b/_WeakMap.js deleted file mode 100644 index 4804f5300..000000000 --- a/_WeakMap.js +++ /dev/null @@ -1,6 +0,0 @@ -import getNative from './_getNative.js'; -import root from './_root.js'; - -const WeakMap = getNative(root, 'WeakMap'); - -export default WeakMap; diff --git a/_baseAssignValue.js b/_baseAssignValue.js index 8d559965d..ccdfdac9b 100644 --- a/_baseAssignValue.js +++ b/_baseAssignValue.js @@ -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, diff --git a/_baseGetTag.js b/_baseGetTag.js index 4dc4df2a7..974c0081f 100644 --- a/_baseGetTag.js +++ b/_baseGetTag.js @@ -1,4 +1,3 @@ -import Symbol from './_Symbol.js'; import getRawTag from './_getRawTag.js'; import objectToString from './_objectToString.js'; diff --git a/_baseSetToString.js b/_baseSetToString.js index d2bed4b79..1b0972e19 100644 --- a/_baseSetToString.js +++ b/_baseSetToString.js @@ -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; diff --git a/_baseToString.js b/_baseToString.js index a5f48ea16..a64eb2eab 100644 --- a/_baseToString.js +++ b/_baseToString.js @@ -1,4 +1,3 @@ -import Symbol from './_Symbol.js'; import arrayMap from './_arrayMap.js'; import isSymbol from './isSymbol.js'; diff --git a/_cloneArrayBuffer.js b/_cloneArrayBuffer.js index 2c8cb0fae..e40976ac0 100644 --- a/_cloneArrayBuffer.js +++ b/_cloneArrayBuffer.js @@ -1,5 +1,3 @@ -import Uint8Array from './_Uint8Array.js'; - /** * Creates a clone of `arrayBuffer`. * diff --git a/_cloneSymbol.js b/_cloneSymbol.js index 1fa2ef75d..b63ba4425 100644 --- a/_cloneSymbol.js +++ b/_cloneSymbol.js @@ -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. diff --git a/_createSet.js b/_createSet.js index e2a869817..846eac25d 100644 --- a/_createSet.js +++ b/_createSet.js @@ -1,4 +1,3 @@ -import Set from './_Set.js'; import setToArray from './_setToArray.js'; /** Used as references for various `Number` constants. */ diff --git a/_defineProperty.js b/_defineProperty.js deleted file mode 100644 index b2b07a94c..000000000 --- a/_defineProperty.js +++ /dev/null @@ -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; diff --git a/_equalByTag.js b/_equalByTag.js index c42b4c3ff..bd2a5493d 100644 --- a/_equalByTag.js +++ b/_equalByTag.js @@ -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'; diff --git a/_getNative.js b/_getNative.js deleted file mode 100644 index 007b1bbfb..000000000 --- a/_getNative.js +++ /dev/null @@ -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; diff --git a/_getRawTag.js b/_getRawTag.js index 0c200f40e..627678e5b 100644 --- a/_getRawTag.js +++ b/_getRawTag.js @@ -1,5 +1,3 @@ -import Symbol from './_Symbol.js'; - /** Used for built-in method references. */ const objectProto = Object.prototype; diff --git a/_getTag.js b/_getTag.js index 695a50d89..26887b6fe 100644 --- a/_getTag.js +++ b/_getTag.js @@ -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; diff --git a/_isFlattenable.js b/_isFlattenable.js index 96df7e753..e3c51cf73 100644 --- a/_isFlattenable.js +++ b/_isFlattenable.js @@ -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; diff --git a/_mapCacheClear.js b/_mapCacheClear.js index e6b3d9c26..021ebd425 100644 --- a/_mapCacheClear.js +++ b/_mapCacheClear.js @@ -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. diff --git a/_metaMap.js b/_metaMap.js index 440d454ca..467790caa 100644 --- a/_metaMap.js +++ b/_metaMap.js @@ -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; diff --git a/_nativeCreate.js b/_nativeCreate.js deleted file mode 100644 index fb591e3c3..000000000 --- a/_nativeCreate.js +++ /dev/null @@ -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; diff --git a/_stackSet.js b/_stackSet.js index b983616e4..7679647eb 100644 --- a/_stackSet.js +++ b/_stackSet.js @@ -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. */ diff --git a/isNative.js b/isNative.js index 2a799b6ff..9df620385 100644 --- a/isNative.js +++ b/isNative.js @@ -38,7 +38,7 @@ const reIsNative = RegExp(`^${ * isNative(Array.prototype.push); * // => true * - * isNative(_); + * isNative(isDate); * // => false */ function isNative(value) { diff --git a/toArray.js b/toArray.js index cf1373594..b1213a176 100644 --- a/toArray.js +++ b/toArray.js @@ -1,4 +1,3 @@ -import Symbol from './_Symbol.js'; import copyArray from './_copyArray.js'; import getTag from './_getTag.js'; import isArrayLike from './isArrayLike.js';