core-js
Advanced tools
Comparing version 3.28.0 to 3.31.1
var parent = require('../../stable/array'); | ||
require('../../modules/es.map'); | ||
require('../../modules/es.promise'); | ||
require('../../modules/es.object.to-string'); | ||
@@ -4,0 +4,0 @@ require('../../modules/esnext.array.from-async'); |
var parent = require('../../stable/function'); | ||
require('../../modules/esnext.function.metadata'); | ||
module.exports = parent; |
@@ -1,10 +0,3 @@ | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/is-well-formed'); | ||
var parent = require('../../stable/instance/is-well-formed'); | ||
var StringPrototype = String.prototype; | ||
module.exports = function (it) { | ||
var own = it.isWellFormed; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.isWellFormed) ? method : own; | ||
}; | ||
module.exports = parent; |
@@ -1,10 +0,3 @@ | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/to-well-formed'); | ||
var parent = require('../../stable/instance/to-well-formed'); | ||
var StringPrototype = String.prototype; | ||
module.exports = function (it) { | ||
var own = it.toWellFormed; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.toWellFormed) ? method : own; | ||
}; | ||
module.exports = parent; |
@@ -1,3 +0,3 @@ | ||
var parent = require('../../stable/instance/push'); | ||
var parent = require('../../stable/instance/unshift'); | ||
module.exports = parent; |
var parent = require('../../stable/string'); | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.string.is-well-formed'); | ||
@@ -4,0 +5,0 @@ require('../../modules/esnext.string.to-well-formed'); |
@@ -0,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.string.is-well-formed'); | ||
module.exports = require('../../internals/entry-unbind')('String', 'isWellFormed'); | ||
var parent = require('../../stable/string/is-well-formed'); | ||
module.exports = parent; |
@@ -0,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.string.to-well-formed'); | ||
module.exports = require('../../internals/entry-unbind')('String', 'toWellFormed'); | ||
var parent = require('../../stable/string/to-well-formed'); | ||
module.exports = parent; |
var parent = require('../../../stable/string/virtual'); | ||
// TODO: Remove from `core-js@4` | ||
require('../../../modules/esnext.string.is-well-formed'); | ||
@@ -4,0 +5,0 @@ require('../../../modules/esnext.string.to-well-formed'); |
@@ -0,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../../modules/esnext.string.is-well-formed'); | ||
module.exports = require('../../../internals/entry-virtual')('String').isWellFormed; | ||
var parent = require('../../../stable/string/virtual/is-well-formed'); | ||
module.exports = parent; |
@@ -0,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../../modules/esnext.string.to-well-formed'); | ||
module.exports = require('../../../internals/entry-virtual')('String').toWellFormed; | ||
var parent = require('../../../stable/string/virtual/to-well-formed'); | ||
module.exports = parent; |
var parent = require('../../stable/symbol'); | ||
require('../../modules/esnext.function.metadata'); | ||
require('../../modules/esnext.symbol.dispose'); | ||
require('../../modules/esnext.symbol.metadata'); | ||
module.exports = parent; |
@@ -169,2 +169,3 @@ require('../modules/es.symbol'); | ||
require('../modules/es.string.includes'); | ||
require('../modules/es.string.is-well-formed'); | ||
require('../modules/es.string.iterator'); | ||
@@ -183,2 +184,3 @@ require('../modules/es.string.match'); | ||
require('../modules/es.string.substr'); | ||
require('../modules/es.string.to-well-formed'); | ||
require('../modules/es.string.trim'); | ||
@@ -185,0 +187,0 @@ require('../modules/es.string.trim-end'); |
@@ -9,2 +9,3 @@ require('../../modules/es.object.to-string'); | ||
require('../../modules/es.string.includes'); | ||
require('../../modules/es.string.is-well-formed'); | ||
require('../../modules/es.string.match'); | ||
@@ -21,2 +22,3 @@ require('../../modules/es.string.match-all'); | ||
require('../../modules/es.string.substr'); | ||
require('../../modules/es.string.to-well-formed'); | ||
require('../../modules/es.string.trim'); | ||
@@ -23,0 +25,0 @@ require('../../modules/es.string.trim-start'); |
@@ -1,1 +0,1 @@ | ||
require('../../modules/esnext.typed-array.to-reversed'); | ||
require('../../modules/es.typed-array.to-reversed'); |
@@ -1,1 +0,1 @@ | ||
require('../../modules/esnext.typed-array.with'); | ||
require('../../modules/es.typed-array.with'); |
var parent = require('../../actual/array'); | ||
require('../../modules/es.promise'); | ||
require('../../modules/es.map'); | ||
// TODO: Remove from `core-js@4` | ||
@@ -4,0 +4,0 @@ require('../../modules/esnext.array.at'); |
@@ -1,4 +0,3 @@ | ||
require('../../modules/esnext.array.to-reversed'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
var parent = require('../../actual/array/to-reversed'); | ||
module.exports = entryUnbind('Array', 'toReversed'); | ||
module.exports = parent; |
@@ -1,5 +0,3 @@ | ||
require('../../modules/es.array.sort'); | ||
require('../../modules/esnext.array.to-sorted'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
var parent = require('../../actual/array/to-sorted'); | ||
module.exports = entryUnbind('Array', 'toSorted'); | ||
module.exports = parent; |
@@ -1,4 +0,3 @@ | ||
require('../../modules/esnext.array.to-spliced'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
var parent = require('../../actual/array/to-spliced'); | ||
module.exports = entryUnbind('Array', 'toSpliced'); | ||
module.exports = parent; |
@@ -1,4 +0,3 @@ | ||
require('../../modules/esnext.array.with'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
var parent = require('../../actual/array/with'); | ||
module.exports = entryUnbind('Array', 'with'); | ||
module.exports = parent; |
@@ -169,2 +169,3 @@ require('../modules/es.symbol'); | ||
require('../modules/es.string.includes'); | ||
require('../modules/es.string.is-well-formed'); | ||
require('../modules/es.string.iterator'); | ||
@@ -183,2 +184,3 @@ require('../modules/es.string.match'); | ||
require('../modules/es.string.substr'); | ||
require('../modules/es.string.to-well-formed'); | ||
require('../modules/es.string.trim'); | ||
@@ -290,2 +292,3 @@ require('../modules/es.string.trim-end'); | ||
require('../modules/esnext.function.is-constructor'); | ||
require('../modules/esnext.function.metadata'); | ||
require('../modules/esnext.function.un-this'); | ||
@@ -353,2 +356,3 @@ require('../modules/esnext.global-this'); | ||
require('../modules/esnext.object.iterate-values'); | ||
require('../modules/esnext.object.group-by'); | ||
require('../modules/esnext.observable'); | ||
@@ -358,2 +362,3 @@ require('../modules/esnext.promise.all-settled'); | ||
require('../modules/esnext.promise.try'); | ||
require('../modules/esnext.promise.with-resolvers'); | ||
require('../modules/esnext.reflect.define-metadata'); | ||
@@ -403,3 +408,5 @@ require('../modules/esnext.reflect.delete-metadata'); | ||
require('../modules/esnext.symbol.dispose'); | ||
require('../modules/esnext.symbol.is-registered-symbol'); | ||
require('../modules/esnext.symbol.is-registered'); | ||
require('../modules/esnext.symbol.is-well-known-symbol'); | ||
require('../modules/esnext.symbol.is-well-known'); | ||
@@ -446,5 +453,9 @@ require('../modules/esnext.symbol.matcher'); | ||
require('../modules/web.url'); | ||
require('../modules/web.url.can-parse'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
require('../modules/web.url-search-params.delete'); | ||
require('../modules/web.url-search-params.has'); | ||
require('../modules/web.url-search-params.size'); | ||
module.exports = require('../internals/path'); |
@@ -0,3 +1,6 @@ | ||
// TODO: remove from `core-js@4` | ||
require('../../modules/esnext.string.replace-all'); | ||
var parent = require('../../actual/instance/replace-all'); | ||
module.exports = parent; |
@@ -1,3 +0,3 @@ | ||
var parent = require('../../actual/instance/push'); | ||
var parent = require('../../actual/instance/unshift'); | ||
module.exports = parent; |
var parent = require('../../actual/object'); | ||
require('../../modules/esnext.object.group-by'); | ||
// TODO: Remove from `core-js@4` | ||
@@ -3,0 +4,0 @@ require('../../modules/esnext.object.has-own'); |
var parent = require('../../actual/promise'); | ||
require('../../modules/esnext.promise.with-resolvers'); | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.aggregate-error'); | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.promise.all-settled'); | ||
@@ -5,0 +6,0 @@ require('../../modules/esnext.promise.try'); |
var parent = require('../../actual/symbol'); | ||
require('../../modules/esnext.symbol.async-dispose'); | ||
require('../../modules/esnext.symbol.is-registered-symbol'); | ||
require('../../modules/esnext.symbol.is-well-known-symbol'); | ||
require('../../modules/esnext.symbol.matcher'); | ||
require('../../modules/esnext.symbol.observable'); | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.symbol.is-registered'); | ||
require('../../modules/esnext.symbol.is-well-known'); | ||
require('../../modules/esnext.symbol.matcher'); | ||
require('../../modules/esnext.symbol.metadata-key'); | ||
require('../../modules/esnext.symbol.observable'); | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.symbol.metadata'); | ||
require('../../modules/esnext.symbol.pattern-match'); | ||
@@ -11,0 +12,0 @@ require('../../modules/esnext.symbol.replace-all'); |
@@ -1,4 +0,3 @@ | ||
require('../../modules/esnext.symbol.metadata'); | ||
var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped'); | ||
var parent = require('../../actual/symbol/metadata'); | ||
module.exports = WrappedWellKnownSymbolModule.f('metadata'); | ||
module.exports = parent; |
@@ -1,1 +0,1 @@ | ||
module.exports = require('./features'); | ||
module.exports = require('./full'); |
@@ -31,7 +31,5 @@ var uncurryThis = require('../internals/function-uncurry-this'); | ||
if (isNullOrUndefined(V)) return; | ||
resource = createDisposableResource(V, hint); | ||
} else if (isNullOrUndefined(V)) { | ||
resource = createDisposableResource(anObject(V), hint); | ||
} else { | ||
resource = createDisposableResource(undefined, hint, method); | ||
} else { | ||
resource = createDisposableResource(anObject(V), hint, method); | ||
} | ||
@@ -38,0 +36,0 @@ |
@@ -24,3 +24,3 @@ var global = require('../internals/global'); | ||
var byteLength = arrayBufferByteLength(arrayBuffer); | ||
var newByteLength = newLength === undefined ? byteLength : min(toIndex(newLength), byteLength); | ||
var newByteLength = newLength === undefined ? byteLength : toIndex(newLength); | ||
var fixedLength = !isResizable || !isResizable(arrayBuffer); | ||
@@ -30,8 +30,10 @@ if (isDetached(arrayBuffer)) throw TypeError('ArrayBuffer is detached'); | ||
if (byteLength == newByteLength && (preserveResizability || fixedLength)) return newBuffer; | ||
if (!preserveResizability || fixedLength) return slice(newBuffer, 0, newByteLength); | ||
var newNewBuffer = new ArrayBuffer(newByteLength, maxByteLength && { maxByteLength: maxByteLength(newBuffer) }); | ||
if (byteLength >= newByteLength && (!preserveResizability || fixedLength)) return slice(newBuffer, 0, newByteLength); | ||
var options = (preserveResizability && !fixedLength) && maxByteLength ? { maxByteLength: maxByteLength(newBuffer) } : undefined; | ||
var newNewBuffer = new ArrayBuffer(newByteLength, options); | ||
var a = new DataView(newBuffer); | ||
var b = new DataView(newNewBuffer); | ||
for (var i = 0; i < newByteLength; i++) setInt8(b, i, getInt8(a, i)); | ||
var copyLength = min(newByteLength, byteLength); | ||
for (var i = 0; i < copyLength; i++) setInt8(b, i, getInt8(a, i)); | ||
return newNewBuffer; | ||
}; |
@@ -82,4 +82,5 @@ 'use strict'; | ||
var get = function (view, count, index, isLittleEndian) { | ||
var store = getInternalDataViewState(view); | ||
var intIndex = toIndex(index); | ||
var store = getInternalDataViewState(view); | ||
var boolIsLittleEndian = !!isLittleEndian; | ||
if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX); | ||
@@ -89,13 +90,14 @@ var bytes = store.bytes; | ||
var pack = arraySlice(bytes, start, start + count); | ||
return isLittleEndian ? pack : reverse(pack); | ||
return boolIsLittleEndian ? pack : reverse(pack); | ||
}; | ||
var set = function (view, count, index, conversion, value, isLittleEndian) { | ||
var store = getInternalDataViewState(view); | ||
var intIndex = toIndex(index); | ||
var store = getInternalDataViewState(view); | ||
var pack = conversion(+value); | ||
var boolIsLittleEndian = !!isLittleEndian; | ||
if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX); | ||
var bytes = store.bytes; | ||
var start = intIndex + store.byteOffset; | ||
var pack = conversion(+value); | ||
for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; | ||
for (var i = 0; i < count; i++) bytes[start + i] = pack[boolIsLittleEndian ? i : count - i - 1]; | ||
}; | ||
@@ -160,20 +162,20 @@ | ||
getInt16: function getInt16(byteOffset /* , littleEndian */) { | ||
var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); | ||
var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); | ||
return (bytes[1] << 8 | bytes[0]) << 16 >> 16; | ||
}, | ||
getUint16: function getUint16(byteOffset /* , littleEndian */) { | ||
var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); | ||
var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); | ||
return bytes[1] << 8 | bytes[0]; | ||
}, | ||
getInt32: function getInt32(byteOffset /* , littleEndian */) { | ||
return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); | ||
return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)); | ||
}, | ||
getUint32: function getUint32(byteOffset /* , littleEndian */) { | ||
return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; | ||
return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)) >>> 0; | ||
}, | ||
getFloat32: function getFloat32(byteOffset /* , littleEndian */) { | ||
return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); | ||
return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false), 23); | ||
}, | ||
getFloat64: function getFloat64(byteOffset /* , littleEndian */) { | ||
return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); | ||
return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : false), 52); | ||
}, | ||
@@ -187,18 +189,18 @@ setInt8: function setInt8(byteOffset, value) { | ||
setInt16: function setInt16(byteOffset, value /* , littleEndian */) { | ||
set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); | ||
set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); | ||
}, | ||
setUint16: function setUint16(byteOffset, value /* , littleEndian */) { | ||
set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); | ||
set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); | ||
}, | ||
setInt32: function setInt32(byteOffset, value /* , littleEndian */) { | ||
set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); | ||
set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); | ||
}, | ||
setUint32: function setUint32(byteOffset, value /* , littleEndian */) { | ||
set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); | ||
set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); | ||
}, | ||
setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { | ||
set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); | ||
set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : false); | ||
}, | ||
setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { | ||
set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); | ||
set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : false); | ||
} | ||
@@ -205,0 +207,0 @@ }); |
@@ -24,3 +24,3 @@ var bind = require('../internals/function-bind-context'); | ||
key = toPropertyKey(boundFunction(value, index, O)); | ||
// in some IE10 builds, `hasOwnProperty` returns incorrect result on integer keys | ||
// in some IE versions, `hasOwnProperty` returns incorrect result on integer keys | ||
// but since it's a `null` prototype object, we can safely use `in` | ||
@@ -27,0 +27,0 @@ if (key in target) push(target[key], value); |
@@ -19,2 +19,5 @@ 'use strict'; | ||
return function (object, fn, target) { | ||
anObject(object); | ||
var MAPPING = fn !== undefined; | ||
if (MAPPING || !IS_TO_ARRAY) aCallable(fn); | ||
var record = getIteratorDirect(object); | ||
@@ -25,4 +28,2 @@ var Promise = getBuiltIn('Promise'); | ||
var counter = 0; | ||
var MAPPING = fn !== undefined; | ||
if (MAPPING || !IS_TO_ARRAY) aCallable(fn); | ||
@@ -29,0 +30,0 @@ return new Promise(function (resolve, reject) { |
@@ -52,5 +52,7 @@ 'use strict'; | ||
module.exports = function map(mapper) { | ||
anObject(this); | ||
aCallable(mapper); | ||
return new AsyncIteratorProxy(getIteratorDirect(this), { | ||
mapper: aCallable(mapper) | ||
mapper: mapper | ||
}); | ||
}; |
@@ -21,3 +21,3 @@ var call = require('../internals/function-call'); | ||
} | ||
if (isCallable(method)) { | ||
if (method !== undefined) { | ||
iterator = call(method, object); | ||
@@ -24,0 +24,0 @@ } else { |
@@ -1,9 +0,9 @@ | ||
var aCallable = require('../internals/a-callable'); | ||
var anObject = require('../internals/an-object'); | ||
// `GetIteratorDirect(obj)` abstract operation | ||
// https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect | ||
module.exports = function (obj) { | ||
return { | ||
iterator: obj, | ||
next: aCallable(anObject(obj).next) | ||
next: obj.next, | ||
done: false | ||
}; | ||
}; |
var call = require('../internals/function-call'); | ||
var isCallable = require('../internals/is-callable'); | ||
var anObject = require('../internals/an-object'); | ||
@@ -10,3 +9,3 @@ var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
var method = getIteratorMethod(object); | ||
return getIteratorDirect(anObject(isCallable(method) ? call(method, object) : object)); | ||
return getIteratorDirect(anObject(method !== undefined ? call(method, object) : object)); | ||
}; |
@@ -14,2 +14,2 @@ var check = function (it) { | ||
// eslint-disable-next-line no-new-func -- fallback | ||
(function () { return this; })() || Function('return this')(); | ||
(function () { return this; })() || this || Function('return this')(); |
@@ -19,5 +19,7 @@ 'use strict'; | ||
module.exports = function map(mapper) { | ||
anObject(this); | ||
aCallable(mapper); | ||
return new IteratorProxy(getIteratorDirect(this), { | ||
mapper: aCallable(mapper) | ||
mapper: mapper | ||
}); | ||
}; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var isObject = require('../internals/is-object'); | ||
var defineProperties = require('../internals/object-define-properties').f; | ||
var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); | ||
var DESCRIPTORS = require('../internals/descriptors'); | ||
@@ -21,3 +21,3 @@ | ||
var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(start, end, option, type, zero, one) { | ||
// TODO: Drop the first `typeof` check after removing lagacy methods in `core-js@4` | ||
// TODO: Drop the first `typeof` check after removing legacy methods in `core-js@4` | ||
if (typeof start != type || (end !== Infinity && end !== -Infinity && typeof end != type)) { | ||
@@ -58,3 +58,3 @@ throw $TypeError(INCORRECT_RANGE); | ||
step: step, | ||
inclusiveEnd: inclusiveEnd, | ||
inclusive: inclusiveEnd, | ||
hitsEnd: hitsEnd, | ||
@@ -78,3 +78,3 @@ currentCount: zero, | ||
if (currentYieldingValue === end) state.hitsEnd = true; | ||
var inclusiveEnd = state.inclusiveEnd; | ||
var inclusiveEnd = state.inclusive; | ||
var endCondition; | ||
@@ -92,23 +92,20 @@ if (end > start) { | ||
var getter = function (fn) { | ||
return { get: fn, set: function () { /* empty */ }, configurable: true, enumerable: false }; | ||
var addGetter = function (key) { | ||
defineBuiltInAccessor($RangeIterator.prototype, key, { | ||
get: function () { | ||
return getInternalState(this)[key]; | ||
}, | ||
set: function () { /* empty */ }, | ||
configurable: true, | ||
enumerable: false | ||
}); | ||
}; | ||
if (DESCRIPTORS) { | ||
defineProperties($RangeIterator.prototype, { | ||
start: getter(function () { | ||
return getInternalState(this).start; | ||
}), | ||
end: getter(function () { | ||
return getInternalState(this).end; | ||
}), | ||
inclusive: getter(function () { | ||
return getInternalState(this).inclusiveEnd; | ||
}), | ||
step: getter(function () { | ||
return getInternalState(this).step; | ||
}) | ||
}); | ||
addGetter('start'); | ||
addGetter('end'); | ||
addGetter('inclusive'); | ||
addGetter('step'); | ||
} | ||
module.exports = $RangeIterator; |
var DESCRIPTORS = require('../internals/descriptors'); | ||
var fails = require('../internals/fails'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var objectGetPrototypeOf = require('../internals/object-get-prototype-of'); | ||
var objectKeys = require('../internals/object-keys'); | ||
@@ -10,2 +12,11 @@ var toIndexedObject = require('../internals/to-indexed-object'); | ||
// in some IE versions, `propertyIsEnumerable` returns incorrect result on integer keys | ||
// of `null` prototype objects | ||
var IE_BUG = DESCRIPTORS && fails(function () { | ||
// eslint-disable-next-line es/no-object-create -- safe | ||
var O = Object.create(null); | ||
O[2] = 2; | ||
return !propertyIsEnumerable(O, 2); | ||
}); | ||
// `Object.{ entries, values }` methods implementation | ||
@@ -16,2 +27,3 @@ var createMethod = function (TO_ENTRIES) { | ||
var keys = objectKeys(O); | ||
var IE_WORKAROUND = IE_BUG && objectGetPrototypeOf(O) === null; | ||
var length = keys.length; | ||
@@ -23,3 +35,3 @@ var i = 0; | ||
key = keys[i++]; | ||
if (!DESCRIPTORS || propertyIsEnumerable(O, key)) { | ||
if (!DESCRIPTORS || (IE_WORKAROUND ? key in O : propertyIsEnumerable(O, key))) { | ||
push(result, TO_ENTRIES ? [key, O[key]] : O[key]); | ||
@@ -26,0 +38,0 @@ } |
@@ -12,5 +12,3 @@ var uncurryThis = require('../internals/function-uncurry-this'); | ||
remove: uncurryThis(SetPrototype['delete']), | ||
proto: SetPrototype, | ||
$has: SetPrototype.has, | ||
$keys: SetPrototype.keys | ||
proto: SetPrototype | ||
}; |
@@ -12,9 +12,3 @@ 'use strict'; | ||
var has = SetHelpers.has; | ||
var nativeHas = SetHelpers.$has; | ||
var nativeKeys = SetHelpers.$keys; | ||
var isNativeSetRecord = function (record) { | ||
return record.has === nativeHas && record.keys === nativeKeys; | ||
}; | ||
// `Set.prototype.intersection` method | ||
@@ -27,15 +21,6 @@ // https://github.com/tc39/proposal-set-methods | ||
// observable side effects | ||
if (!isNativeSetRecord(otherRec) && size(O) > otherRec.size) { | ||
if (size(O) > otherRec.size) { | ||
iterateSimple(otherRec.getIterator(), function (e) { | ||
if (has(O, e)) add(result, e); | ||
}); | ||
if (size(result) < 2) return result; | ||
var disordered = result; | ||
result = new Set(); | ||
iterateSet(O, function (e) { | ||
if (has(disordered, e)) add(result, e); | ||
}); | ||
} else { | ||
@@ -42,0 +27,0 @@ iterateSet(O, function (e) { |
@@ -7,7 +7,7 @@ var IS_PURE = require('../internals/is-pure'); | ||
})('versions', []).push({ | ||
version: '3.28.0', | ||
version: '3.31.1', | ||
mode: IS_PURE ? 'pure' : 'global', | ||
copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)', | ||
license: 'https://github.com/zloirock/core-js/blob/v3.28.0/LICENSE', | ||
license: 'https://github.com/zloirock/core-js/blob/v3.31.1/LICENSE', | ||
source: 'https://github.com/zloirock/core-js' | ||
}); |
/* eslint-disable es/no-symbol -- required for testing */ | ||
var V8_VERSION = require('../internals/engine-v8-version'); | ||
var fails = require('../internals/fails'); | ||
var global = require('../internals/global'); | ||
var $String = global.String; | ||
// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing | ||
@@ -10,5 +13,7 @@ module.exports = !!Object.getOwnPropertySymbols && !fails(function () { | ||
// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances | ||
return !String(symbol) || !(Object(symbol) instanceof Symbol) || | ||
// nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, | ||
// of course, fail. | ||
return !$String(symbol) || !(Object(symbol) instanceof Symbol) || | ||
// Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances | ||
!Symbol.sham && V8_VERSION && V8_VERSION < 41; | ||
}); |
@@ -18,3 +18,3 @@ var getBuiltIn = require('../internals/get-built-in'); | ||
if (isSetLike(it)) return it; | ||
if (isIterable(it)) return new Set(it); | ||
return isIterable(it) ? new Set(it) : it; | ||
}; |
var fails = require('../internals/fails'); | ||
var wellKnownSymbol = require('../internals/well-known-symbol'); | ||
var DESCRIPTORS = require('../internals/descriptors'); | ||
var IS_PURE = require('../internals/is-pure'); | ||
@@ -11,2 +12,3 @@ | ||
var searchParams = url.searchParams; | ||
var searchParams2 = new URLSearchParams('a=1&a=2'); | ||
var result = ''; | ||
@@ -18,3 +20,5 @@ url.pathname = 'c%20d'; | ||
}); | ||
return (IS_PURE && !url.toJSON) | ||
searchParams2['delete']('a', 2); | ||
return (IS_PURE && (!url.toJSON || !searchParams2.has('a', 1) || searchParams2.has('a', 2))) | ||
|| (!searchParams.size && (IS_PURE || !DESCRIPTORS)) | ||
|| !searchParams.sort | ||
@@ -21,0 +25,0 @@ || url.href !== 'http://a/c%20d?a=1&c=3' |
@@ -16,3 +16,3 @@ var $ = require('../internals/export'); | ||
// https://github.com/tc39/proposal-error-cause | ||
// https://tc39.es/ecma262/#sec-aggregate-error | ||
$({ global: true, constructor: true, arity: 2, forced: FORCED }, { | ||
@@ -19,0 +19,0 @@ AggregateError: wrapErrorConstructorWithCause(AGGREGATE_ERROR, function (init) { |
@@ -9,3 +9,3 @@ 'use strict'; | ||
// `Array.prototype.at` method | ||
// https://github.com/tc39/proposal-relative-indexing-method | ||
// https://tc39.es/ecma262/#sec-array.prototype.at | ||
$({ target: 'Array', proto: true }, { | ||
@@ -12,0 +12,0 @@ at: function at(index) { |
@@ -10,2 +10,3 @@ 'use strict'; | ||
// Shouldn't skip holes | ||
// eslint-disable-next-line es/no-array-prototype-findindex -- testing | ||
if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; }); | ||
@@ -12,0 +13,0 @@ |
@@ -7,3 +7,3 @@ 'use strict'; | ||
// `Array.prototype.findLastIndex` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
// https://tc39.es/ecma262/#sec-array.prototype.findlastindex | ||
$({ target: 'Array', proto: true }, { | ||
@@ -10,0 +10,0 @@ findLastIndex: function findLastIndex(callbackfn /* , that = undefined */) { |
@@ -7,3 +7,3 @@ 'use strict'; | ||
// `Array.prototype.findLast` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
// https://tc39.es/ecma262/#sec-array.prototype.findlast | ||
$({ target: 'Array', proto: true }, { | ||
@@ -10,0 +10,0 @@ findLast: function findLast(callbackfn /* , that = undefined */) { |
@@ -10,2 +10,3 @@ 'use strict'; | ||
// Shouldn't skip holes | ||
// eslint-disable-next-line es/no-array-prototype-find -- testing | ||
if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; }); | ||
@@ -12,0 +13,0 @@ |
@@ -10,3 +10,3 @@ 'use strict'; | ||
// `Array.prototype.toReversed` method | ||
// https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toReversed | ||
// https://tc39.es/ecma262/#sec-array.prototype.toreversed | ||
$({ target: 'Array', proto: true }, { | ||
@@ -13,0 +13,0 @@ toReversed: function toReversed() { |
@@ -14,3 +14,3 @@ 'use strict'; | ||
// `Array.prototype.toSorted` method | ||
// https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toSorted | ||
// https://tc39.es/ecma262/#sec-array.prototype.tosorted | ||
$({ target: 'Array', proto: true }, { | ||
@@ -17,0 +17,0 @@ toSorted: function toSorted(compareFn) { |
@@ -15,3 +15,3 @@ 'use strict'; | ||
// `Array.prototype.toSpliced` method | ||
// https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toSpliced | ||
// https://tc39.es/ecma262/#sec-array.prototype.tospliced | ||
$({ target: 'Array', proto: true }, { | ||
@@ -18,0 +18,0 @@ toSpliced: function toSpliced(start, deleteCount /* , ...items */) { |
@@ -9,3 +9,3 @@ 'use strict'; | ||
// `Array.prototype.with` method | ||
// https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.with | ||
// https://tc39.es/ecma262/#sec-array.prototype.with | ||
$({ target: 'Array', proto: true }, { | ||
@@ -12,0 +12,0 @@ 'with': function (index, value) { |
@@ -27,3 +27,2 @@ /* eslint-disable no-unused-vars -- required for functions `.length` */ | ||
// https://tc39.es/ecma262/#sec-nativeerror | ||
// https://github.com/tc39/proposal-error-cause | ||
exportGlobalErrorCauseWrapper('Error', function (init) { | ||
@@ -30,0 +29,0 @@ return function Error(message) { return apply(init, this, arguments); }; |
@@ -5,5 +5,5 @@ var $ = require('../internals/export'); | ||
// `Object.hasOwn` method | ||
// https://github.com/tc39/proposal-accessible-object-hasownproperty | ||
// https://tc39.es/ecma262/#sec-object.hasown | ||
$({ target: 'Object', stat: true }, { | ||
hasOwn: hasOwn | ||
}); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
// `String.prototype.at` method | ||
// https://github.com/tc39/proposal-relative-indexing-method | ||
// https://tc39.es/ecma262/#sec-string.prototype.at | ||
$({ target: 'String', proto: true, forced: FORCED }, { | ||
@@ -20,0 +20,0 @@ at: function at(index) { |
@@ -10,3 +10,3 @@ 'use strict'; | ||
// `%TypedArray%.prototype.at` method | ||
// https://github.com/tc39/proposal-relative-indexing-method | ||
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.at | ||
exportTypedArrayMethod('at', function at(index) { | ||
@@ -13,0 +13,0 @@ var O = aTypedArray(this); |
@@ -9,5 +9,5 @@ 'use strict'; | ||
// `%TypedArray%.prototype.findLastIndex` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.findlastindex | ||
exportTypedArrayMethod('findLastIndex', function findLastIndex(predicate /* , thisArg */) { | ||
return $findLastIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); | ||
}); |
@@ -9,5 +9,5 @@ 'use strict'; | ||
// `%TypedArray%.prototype.findLast` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.findlast | ||
exportTypedArrayMethod('findLast', function findLast(predicate /* , thisArg */) { | ||
return $findLast(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); | ||
}); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
var WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS = !fails(function () { | ||
var WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS = !fails(function () { | ||
// eslint-disable-next-line es/no-typed-arrays -- required for testing | ||
@@ -26,3 +26,3 @@ var array = new Uint8ClampedArray(2); | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=11294 and other | ||
var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS && ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () { | ||
var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS && ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () { | ||
var array = new Int8Array(2); | ||
@@ -40,3 +40,3 @@ array.set(1); | ||
var src = toIndexedObject(arrayLike); | ||
if (WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS) return call($set, this, src, offset); | ||
if (WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS) return call($set, this, src, offset); | ||
var length = this.length; | ||
@@ -47,2 +47,2 @@ var len = lengthOfArrayLike(src); | ||
while (index < len) this[offset + index] = src[index++]; | ||
}, !WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG); | ||
}, !WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG); |
@@ -10,5 +10,5 @@ 'use strict'; | ||
// `%TypedArray%.prototype.toReversed` method | ||
// https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toReversed | ||
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.toreversed | ||
exportTypedArrayMethod('toReversed', function toReversed() { | ||
return arrayToReversed(aTypedArray(this), getTypedArrayConstructor(this)); | ||
}); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
// `%TypedArray%.prototype.toSorted` method | ||
// https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toSorted | ||
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.tosorted | ||
exportTypedArrayMethod('toSorted', function toSorted(compareFn) { | ||
@@ -16,0 +16,0 @@ if (compareFn !== undefined) aCallable(compareFn); |
@@ -24,3 +24,3 @@ 'use strict'; | ||
// `%TypedArray%.prototype.with` method | ||
// https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.with | ||
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.with | ||
exportTypedArrayMethod('with', { 'with': function (index, value) { | ||
@@ -27,0 +27,0 @@ var O = aTypedArray(this); |
@@ -30,3 +30,7 @@ 'use strict'; | ||
var ALREADY_DISPOSED = ASYNC_DISPOSABLE_STACK + ' already disposed'; | ||
var getPendingAsyncDisposableStackInternalState = function (stack) { | ||
var internalState = getAsyncDisposableStackInternalState(stack); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ASYNC_DISPOSABLE_STACK + ' already disposed'); | ||
return internalState; | ||
}; | ||
@@ -88,13 +92,10 @@ var $AsyncDisposableStack = function AsyncDisposableStack() { | ||
use: function use(value) { | ||
var internalState = getAsyncDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
addDisposableResource(internalState, value, HINT); | ||
addDisposableResource(getPendingAsyncDisposableStackInternalState(this), value, HINT); | ||
return value; | ||
}, | ||
adopt: function adopt(value, onDispose) { | ||
var internalState = getAsyncDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
var internalState = getPendingAsyncDisposableStackInternalState(this); | ||
aCallable(onDispose); | ||
addDisposableResource(internalState, undefined, HINT, function () { | ||
onDispose(value); | ||
return onDispose(value); | ||
}); | ||
@@ -104,4 +105,3 @@ return value; | ||
defer: function defer(onDispose) { | ||
var internalState = getAsyncDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
var internalState = getPendingAsyncDisposableStackInternalState(this); | ||
aCallable(onDispose); | ||
@@ -111,7 +111,8 @@ addDisposableResource(internalState, undefined, HINT, onDispose); | ||
move: function move() { | ||
var internalState = getAsyncDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
var internalState = getPendingAsyncDisposableStackInternalState(this); | ||
var newAsyncDisposableStack = new $AsyncDisposableStack(); | ||
getAsyncDisposableStackInternalState(newAsyncDisposableStack).stack = internalState.stack; | ||
internalState.stack = []; | ||
internalState.state = DISPOSED; | ||
if (!DESCRIPTORS) this.disposed = true; | ||
return newAsyncDisposableStack; | ||
@@ -118,0 +119,0 @@ } |
@@ -44,6 +44,8 @@ 'use strict'; | ||
drop: function drop(limit) { | ||
anObject(this); | ||
var remaining = toPositiveInteger(notANaN(+limit)); | ||
return new AsyncIteratorProxy(getIteratorDirect(this), { | ||
remaining: toPositiveInteger(notANaN(+limit)) | ||
remaining: remaining | ||
}); | ||
} | ||
}); |
@@ -60,6 +60,8 @@ 'use strict'; | ||
filter: function filter(predicate) { | ||
anObject(this); | ||
aCallable(predicate); | ||
return new AsyncIteratorProxy(getIteratorDirect(this), { | ||
predicate: aCallable(predicate) | ||
predicate: predicate | ||
}); | ||
} | ||
}); |
@@ -80,4 +80,6 @@ 'use strict'; | ||
flatMap: function flatMap(mapper) { | ||
anObject(this); | ||
aCallable(mapper); | ||
return new AsyncIteratorProxy(getIteratorDirect(this), { | ||
mapper: aCallable(mapper), | ||
mapper: mapper, | ||
inner: null | ||
@@ -84,0 +86,0 @@ }); |
@@ -18,2 +18,4 @@ 'use strict'; | ||
reduce: function reduce(reducer /* , initialValue */) { | ||
anObject(this); | ||
aCallable(reducer); | ||
var record = getIteratorDirect(this); | ||
@@ -25,3 +27,2 @@ var iterator = record.iterator; | ||
var counter = 0; | ||
aCallable(reducer); | ||
@@ -28,0 +29,0 @@ return new Promise(function (resolve, reject) { |
@@ -41,6 +41,8 @@ 'use strict'; | ||
take: function take(limit) { | ||
anObject(this); | ||
var remaining = toPositiveInteger(notANaN(+limit)); | ||
return new AsyncIteratorProxy(getIteratorDirect(this), { | ||
remaining: toPositiveInteger(notANaN(+limit)) | ||
remaining: remaining | ||
}); | ||
} | ||
}); |
@@ -29,3 +29,7 @@ 'use strict'; | ||
var ALREADY_DISPOSED = DISPOSABLE_STACK + ' already disposed'; | ||
var getPendingDisposableStackInternalState = function (stack) { | ||
var internalState = getDisposableStackInternalState(stack); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(DISPOSABLE_STACK + ' already disposed'); | ||
return internalState; | ||
}; | ||
@@ -72,10 +76,7 @@ var $DisposableStack = function DisposableStack() { | ||
use: function use(value) { | ||
var internalState = getDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
addDisposableResource(internalState, value, HINT); | ||
addDisposableResource(getPendingDisposableStackInternalState(this), value, HINT); | ||
return value; | ||
}, | ||
adopt: function adopt(value, onDispose) { | ||
var internalState = getDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
var internalState = getPendingDisposableStackInternalState(this); | ||
aCallable(onDispose); | ||
@@ -88,4 +89,3 @@ addDisposableResource(internalState, undefined, HINT, function () { | ||
defer: function defer(onDispose) { | ||
var internalState = getDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
var internalState = getPendingDisposableStackInternalState(this); | ||
aCallable(onDispose); | ||
@@ -95,7 +95,8 @@ addDisposableResource(internalState, undefined, HINT, onDispose); | ||
move: function move() { | ||
var internalState = getDisposableStackInternalState(this); | ||
if (internalState.state == DISPOSED) throw $ReferenceError(ALREADY_DISPOSED); | ||
var internalState = getPendingDisposableStackInternalState(this); | ||
var newDisposableStack = new $DisposableStack(); | ||
getDisposableStackInternalState(newDisposableStack).stack = internalState.stack; | ||
internalState.stack = []; | ||
internalState.state = DISPOSED; | ||
if (!DESCRIPTORS) this.disposed = true; | ||
return newDisposableStack; | ||
@@ -102,0 +103,0 @@ } |
@@ -29,6 +29,8 @@ 'use strict'; | ||
drop: function drop(limit) { | ||
anObject(this); | ||
var remaining = toPositiveInteger(notANaN(+limit)); | ||
return new IteratorProxy(getIteratorDirect(this), { | ||
remaining: toPositiveInteger(notANaN(+limit)) | ||
remaining: remaining | ||
}); | ||
} | ||
}); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var aCallable = require('../internals/a-callable'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
@@ -12,5 +13,6 @@ | ||
every: function every(predicate) { | ||
anObject(this); | ||
aCallable(predicate); | ||
var record = getIteratorDirect(this); | ||
var counter = 0; | ||
aCallable(predicate); | ||
return !iterate(record, function (value, stop) { | ||
@@ -17,0 +19,0 @@ if (!predicate(value, counter++)) return stop(); |
@@ -28,6 +28,8 @@ 'use strict'; | ||
filter: function filter(predicate) { | ||
anObject(this); | ||
aCallable(predicate); | ||
return new IteratorProxy(getIteratorDirect(this), { | ||
predicate: aCallable(predicate) | ||
predicate: predicate | ||
}); | ||
} | ||
}); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var aCallable = require('../internals/a-callable'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
@@ -12,5 +13,6 @@ | ||
find: function find(predicate) { | ||
anObject(this); | ||
aCallable(predicate); | ||
var record = getIteratorDirect(this); | ||
var counter = 0; | ||
aCallable(predicate); | ||
return iterate(record, function (value, stop) { | ||
@@ -17,0 +19,0 @@ if (predicate(value, counter++)) return stop(value); |
@@ -37,4 +37,6 @@ 'use strict'; | ||
flatMap: function flatMap(mapper) { | ||
anObject(this); | ||
aCallable(mapper); | ||
return new IteratorProxy(getIteratorDirect(this), { | ||
mapper: aCallable(mapper), | ||
mapper: mapper, | ||
inner: null | ||
@@ -41,0 +43,0 @@ }); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var aCallable = require('../internals/a-callable'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
@@ -12,5 +13,6 @@ | ||
forEach: function forEach(fn) { | ||
anObject(this); | ||
aCallable(fn); | ||
var record = getIteratorDirect(this); | ||
var counter = 0; | ||
aCallable(fn); | ||
iterate(record, function (value) { | ||
@@ -17,0 +19,0 @@ fn(value, counter++); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var aCallable = require('../internals/a-callable'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
@@ -14,4 +15,5 @@ | ||
reduce: function reduce(reducer /* , initialValue */) { | ||
anObject(this); | ||
aCallable(reducer); | ||
var record = getIteratorDirect(this); | ||
aCallable(reducer); | ||
var noInitial = arguments.length < 2; | ||
@@ -18,0 +20,0 @@ var accumulator = noInitial ? undefined : arguments[1]; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var aCallable = require('../internals/a-callable'); | ||
var anObject = require('../internals/an-object'); | ||
var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
@@ -12,5 +13,6 @@ | ||
some: function some(predicate) { | ||
anObject(this); | ||
aCallable(predicate); | ||
var record = getIteratorDirect(this); | ||
var counter = 0; | ||
aCallable(predicate); | ||
return iterate(record, function (value, stop) { | ||
@@ -17,0 +19,0 @@ if (predicate(value, counter++)) return stop(); |
@@ -26,6 +26,8 @@ 'use strict'; | ||
take: function take(limit) { | ||
anObject(this); | ||
var remaining = toPositiveInteger(notANaN(+limit)); | ||
return new IteratorProxy(getIteratorDirect(this), { | ||
remaining: toPositiveInteger(notANaN(+limit)) | ||
remaining: remaining | ||
}); | ||
} | ||
}); |
'use strict'; | ||
var $ = require('../internals/export'); | ||
var anObject = require('../internals/an-object'); | ||
var iterate = require('../internals/iterate'); | ||
@@ -13,5 +14,5 @@ var getIteratorDirect = require('../internals/get-iterator-direct'); | ||
var result = []; | ||
iterate(getIteratorDirect(this), push, { that: result, IS_RECORD: true }); | ||
iterate(getIteratorDirect(anObject(this)), push, { that: result, IS_RECORD: true }); | ||
return result; | ||
} | ||
}); |
'use strict'; | ||
var $ = require('../internals/export'); | ||
var anObject = require('../internals/an-object'); | ||
var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator'); | ||
@@ -11,4 +12,4 @@ var WrapAsyncIterator = require('../internals/async-iterator-wrap'); | ||
toAsync: function toAsync() { | ||
return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(this)))); | ||
return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(anObject(this))))); | ||
} | ||
}); |
@@ -108,27 +108,17 @@ 'use strict'; | ||
var chr = at(source, i); | ||
var result; | ||
if (exec(IS_NUMBER_START, chr)) result = fork.number(); | ||
else switch (chr) { | ||
if (exec(IS_NUMBER_START, chr)) return fork.number(); | ||
switch (chr) { | ||
case '{': | ||
result = fork.object(); | ||
break; | ||
return fork.object(); | ||
case '[': | ||
result = fork.array(); | ||
break; | ||
return fork.array(); | ||
case '"': | ||
result = fork.string(); | ||
break; | ||
return fork.string(); | ||
case 't': | ||
result = fork.keyword(true); | ||
break; | ||
return fork.keyword(true); | ||
case 'f': | ||
result = fork.keyword(false); | ||
break; | ||
return fork.keyword(false); | ||
case 'n': | ||
result = fork.keyword(null); | ||
break; | ||
default: | ||
throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i); | ||
} | ||
return result; | ||
return fork.keyword(null); | ||
} throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i); | ||
}, | ||
@@ -135,0 +125,0 @@ node: function (type, value, start, end, nodes) { |
'use strict'; | ||
var $ = require('../internals/export'); | ||
var call = require('../internals/function-call'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var isCallable = require('../internals/is-callable'); | ||
var aCallable = require('../internals/a-callable'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var iterate = require('../internals/iterate'); | ||
var Map = require('../internals/map-helpers').Map; | ||
var MapHelpers = require('../internals/map-helpers'); | ||
var Map = MapHelpers.Map; | ||
var has = MapHelpers.has; | ||
var get = MapHelpers.get; | ||
var set = MapHelpers.set; | ||
var push = uncurryThis([].push); | ||
// `Map.groupBy` method | ||
// https://github.com/tc39/proposal-collection-methods | ||
// https://github.com/tc39/proposal-array-grouping | ||
$({ target: 'Map', stat: true, forced: true }, { | ||
groupBy: function groupBy(iterable, keyDerivative) { | ||
var C = isCallable(this) ? this : Map; | ||
var newMap = new C(); | ||
aCallable(keyDerivative); | ||
var has = aCallable(newMap.has); | ||
var get = aCallable(newMap.get); | ||
var set = aCallable(newMap.set); | ||
iterate(iterable, function (element) { | ||
var derivedKey = keyDerivative(element); | ||
if (!call(has, newMap, derivedKey)) call(set, newMap, derivedKey, [element]); | ||
else push(call(get, newMap, derivedKey), element); | ||
groupBy: function groupBy(items, callbackfn) { | ||
requireObjectCoercible(items); | ||
aCallable(callbackfn); | ||
var map = new Map(); | ||
var k = 0; | ||
iterate(items, function (value) { | ||
var key = callbackfn(value, k++); | ||
if (!has(map, key)) set(map, key, [value]); | ||
else push(get(map, key), value); | ||
}); | ||
return newMap; | ||
return map; | ||
} | ||
}); |
var $ = require('../internals/export'); | ||
var fails = require('../internals/fails'); | ||
var intersection = require('../internals/set-intersection'); | ||
var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); | ||
var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () { | ||
// eslint-disable-next-line es/no-array-from, es/no-set -- testing | ||
return Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2]))) != '3,2'; | ||
}); | ||
// `Set.prototype.intersection` method | ||
// https://github.com/tc39/proposal-set-methods | ||
$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('intersection') }, { | ||
$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { | ||
intersection: intersection | ||
}); |
@@ -1,23 +0,2 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var toString = require('../internals/to-string'); | ||
var charCodeAt = uncurryThis(''.charCodeAt); | ||
// `String.prototype.isWellFormed` method | ||
// https://github.com/tc39/proposal-is-usv-string | ||
$({ target: 'String', proto: true }, { | ||
isWellFormed: function isWellFormed() { | ||
var S = toString(requireObjectCoercible(this)); | ||
var length = S.length; | ||
for (var i = 0; i < length; i++) { | ||
var charCode = charCodeAt(S, i); | ||
// single UTF-16 code unit | ||
if ((charCode & 0xF800) != 0xD800) continue; | ||
// unpaired surrogate | ||
if (charCode >= 0xDC00 || ++i >= length || (charCodeAt(S, i) & 0xFC00) != 0xDC00) return false; | ||
} return true; | ||
} | ||
}); | ||
// TODO: Remove from `core-js@4` | ||
require('../modules/es.string.is-well-formed'); |
@@ -1,42 +0,2 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var call = require('../internals/function-call'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var toString = require('../internals/to-string'); | ||
var fails = require('../internals/fails'); | ||
var $Array = Array; | ||
var charAt = uncurryThis(''.charAt); | ||
var charCodeAt = uncurryThis(''.charCodeAt); | ||
var join = uncurryThis([].join); | ||
var $toWellFormed = ''.toWellFormed; | ||
var REPLACEMENT_CHARACTER = '\uFFFD'; | ||
// Safari bug | ||
var TO_STRING_CONVERSION_BUG = $toWellFormed && fails(function () { | ||
return call($toWellFormed, 1) !== '1'; | ||
}); | ||
// `String.prototype.toWellFormed` method | ||
// https://github.com/tc39/proposal-is-usv-string | ||
$({ target: 'String', proto: true, forced: TO_STRING_CONVERSION_BUG }, { | ||
toWellFormed: function toWellFormed() { | ||
var S = toString(requireObjectCoercible(this)); | ||
if (TO_STRING_CONVERSION_BUG) return call($toWellFormed, S); | ||
var length = S.length; | ||
var result = $Array(length); | ||
for (var i = 0; i < length; i++) { | ||
var charCode = charCodeAt(S, i); | ||
// single UTF-16 code unit | ||
if ((charCode & 0xF800) != 0xD800) result[i] = charAt(S, i); | ||
// unpaired surrogate | ||
else if (charCode >= 0xDC00 || i + 1 >= length || (charCodeAt(S, i + 1) & 0xFC00) != 0xDC00) result[i] = REPLACEMENT_CHARACTER; | ||
// surrogate pair | ||
else { | ||
result[i] = charAt(S, i); | ||
result[++i] = charAt(S, i); | ||
} | ||
} return join(result, ''); | ||
} | ||
}); | ||
// TODO: Remove from `core-js@4` | ||
require('../modules/es.string.to-well-formed'); |
var $ = require('../internals/export'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var isRegisteredSymbol = require('../internals/symbol-is-registered'); | ||
var Symbol = getBuiltIn('Symbol'); | ||
var keyFor = Symbol.keyFor; | ||
var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); | ||
// `Symbol.isRegistered` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregistered | ||
$({ target: 'Symbol', stat: true }, { | ||
isRegistered: function isRegistered(value) { | ||
try { | ||
return keyFor(thisSymbolValue(value)) !== undefined; | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
// obsolete version of https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregisteredsymbol | ||
$({ target: 'Symbol', stat: true, name: 'isRegisteredSymbol' }, { | ||
isRegistered: isRegisteredSymbol | ||
}); |
var $ = require('../internals/export'); | ||
var shared = require('../internals/shared'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var isSymbol = require('../internals/is-symbol'); | ||
var wellKnownSymbol = require('../internals/well-known-symbol'); | ||
var isWellKnownSymbol = require('../internals/symbol-is-well-known'); | ||
var Symbol = getBuiltIn('Symbol'); | ||
var $isWellKnown = Symbol.isWellKnown; | ||
var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames'); | ||
var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); | ||
var WellKnownSymbolsStore = shared('wks'); | ||
for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) { | ||
// some old engines throws on access to some keys like `arguments` or `caller` | ||
try { | ||
var symbolKey = symbolKeys[i]; | ||
if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey); | ||
} catch (error) { /* empty */ } | ||
} | ||
// `Symbol.isWellKnown` method | ||
// https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknown | ||
// obsolete version of https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol | ||
// We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected | ||
$({ target: 'Symbol', stat: true, forced: true }, { | ||
isWellKnown: function isWellKnown(value) { | ||
if ($isWellKnown && $isWellKnown(value)) return true; | ||
try { | ||
var symbol = thisSymbolValue(value); | ||
for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) { | ||
if (WellKnownSymbolsStore[keys[j]] == symbol) return true; | ||
} | ||
} catch (error) { /* empty */ } | ||
return false; | ||
} | ||
$({ target: 'Symbol', stat: true, name: 'isWellKnownSymbol', forced: true }, { | ||
isWellKnown: isWellKnownSymbol | ||
}); |
@@ -128,2 +128,7 @@ var IS_PURE = require('../internals/is-pure'); | ||
var tryNativeRestrictedStructuredClone = function (value, type) { | ||
if (!nativeRestrictedStructuredClone) throwUnpolyfillable(type); | ||
return nativeRestrictedStructuredClone(value); | ||
}; | ||
var createDataTransfer = function () { | ||
@@ -141,3 +146,57 @@ var dataTransfer; | ||
var structuredCloneInternal = function (value, map) { | ||
var cloneBuffer = function (value, map, $type) { | ||
if (mapHas(map, value)) return mapGet(map, value); | ||
var type = $type || classof(value); | ||
var clone, length, options, source, target, i; | ||
if (type === 'SharedArrayBuffer') { | ||
if (nativeRestrictedStructuredClone) clone = nativeRestrictedStructuredClone(value); | ||
// SharedArrayBuffer should use shared memory, we can't polyfill it, so return the original | ||
else clone = value; | ||
} else { | ||
var DataView = global.DataView; | ||
// `ArrayBuffer#slice` is not available in IE10 | ||
// `ArrayBuffer#slice` and `DataView` are not available in old FF | ||
if (!DataView && typeof value.slice != 'function') throwUnpolyfillable('ArrayBuffer'); | ||
// detached buffers throws in `DataView` and `.slice` | ||
try { | ||
if (typeof value.slice == 'function' && !value.resizable) { | ||
clone = value.slice(0); | ||
} else { | ||
length = value.byteLength; | ||
options = 'maxByteLength' in value ? { maxByteLength: value.maxByteLength } : undefined; | ||
clone = new ArrayBuffer(length, options); | ||
source = new DataView(value); | ||
target = new DataView(clone); | ||
for (i = 0; i < length; i++) { | ||
target.setUint8(i, source.getUint8(i)); | ||
} | ||
} | ||
} catch (error) { | ||
throw new DOMException('ArrayBuffer is detached', DATA_CLONE_ERROR); | ||
} | ||
} | ||
mapSet(map, value, clone); | ||
return clone; | ||
}; | ||
var cloneView = function (value, type, offset, length, map) { | ||
var C = global[type]; | ||
// in some old engines like Safari 9, typeof C is 'object' | ||
// on Uint8ClampedArray or some other constructors | ||
if (!isObject(C)) throwUnpolyfillable(type); | ||
return new C(cloneBuffer(value.buffer, map), offset, length); | ||
}; | ||
var Placeholder = function (object, type, metadata) { | ||
this.object = object; | ||
this.type = type; | ||
this.metadata = metadata; | ||
}; | ||
var structuredCloneInternal = function (value, map, transferredBuffers) { | ||
if (isSymbol(value)) throwUncloneable('Symbol'); | ||
@@ -151,4 +210,3 @@ if (!isObject(value)) return value; | ||
var type = classof(value); | ||
var deep = false; | ||
var C, name, cloned, dataTransfer, i, length, keys, key, source, target; | ||
var C, name, cloned, dataTransfer, i, length, keys, key; | ||
@@ -158,15 +216,11 @@ switch (type) { | ||
cloned = Array(lengthOfArrayLike(value)); | ||
deep = true; | ||
break; | ||
case 'Object': | ||
cloned = {}; | ||
deep = true; | ||
break; | ||
case 'Map': | ||
cloned = new Map(); | ||
deep = true; | ||
break; | ||
case 'Set': | ||
cloned = new Set(); | ||
deep = true; | ||
break; | ||
@@ -214,8 +268,12 @@ case 'RegExp': | ||
} | ||
deep = true; | ||
break; | ||
case 'DOMException': | ||
cloned = new DOMException(value.message, value.name); | ||
deep = true; | ||
break; | ||
case 'ArrayBuffer': | ||
case 'SharedArrayBuffer': | ||
cloned = transferredBuffers | ||
? new Placeholder(value, type) | ||
: cloneBuffer(value, map, type); | ||
break; | ||
case 'DataView': | ||
@@ -229,2 +287,3 @@ case 'Int8Array': | ||
case 'Uint32Array': | ||
case 'Float16Array': | ||
case 'Float32Array': | ||
@@ -234,12 +293,6 @@ case 'Float64Array': | ||
case 'BigUint64Array': | ||
C = global[type]; | ||
// in some old engines like Safari 9, typeof C is 'object' | ||
// on Uint8ClampedArray or some other constructors | ||
if (!isObject(C)) throwUnpolyfillable(type); | ||
cloned = new C( | ||
// this is safe, since arraybuffer cannot have circular references | ||
structuredCloneInternal(value.buffer, map), | ||
value.byteOffset, | ||
type === 'DataView' ? value.byteLength : value.length | ||
); | ||
length = type === 'DataView' ? value.byteLength : value.length; | ||
cloned = transferredBuffers | ||
? new Placeholder(value, type, { offset: value.byteOffset, length: length }) | ||
: cloneView(value, type, value.byteOffset, length, map); | ||
break; | ||
@@ -249,13 +302,22 @@ case 'DOMQuad': | ||
cloned = new DOMQuad( | ||
structuredCloneInternal(value.p1, map), | ||
structuredCloneInternal(value.p2, map), | ||
structuredCloneInternal(value.p3, map), | ||
structuredCloneInternal(value.p4, map) | ||
structuredCloneInternal(value.p1, map, transferredBuffers), | ||
structuredCloneInternal(value.p2, map, transferredBuffers), | ||
structuredCloneInternal(value.p3, map, transferredBuffers), | ||
structuredCloneInternal(value.p4, map, transferredBuffers) | ||
); | ||
} catch (error) { | ||
if (nativeRestrictedStructuredClone) { | ||
cloned = nativeRestrictedStructuredClone(value); | ||
} else throwUnpolyfillable(type); | ||
cloned = tryNativeRestrictedStructuredClone(value, type); | ||
} | ||
break; | ||
case 'File': | ||
if (nativeRestrictedStructuredClone) try { | ||
cloned = nativeRestrictedStructuredClone(value); | ||
// NodeJS 20.0.0 bug, https://github.com/nodejs/node/issues/47612 | ||
if (classof(cloned) !== type) cloned = undefined; | ||
} catch (error) { /* empty */ } | ||
if (!cloned) try { | ||
cloned = new File([value], value.name, value); | ||
} catch (error) { /* empty */ } | ||
if (!cloned) throwUnpolyfillable(type); | ||
break; | ||
case 'FileList': | ||
@@ -265,8 +327,6 @@ dataTransfer = createDataTransfer(); | ||
for (i = 0, length = lengthOfArrayLike(value); i < length; i++) { | ||
dataTransfer.items.add(structuredCloneInternal(value[i], map)); | ||
dataTransfer.items.add(structuredCloneInternal(value[i], map, transferredBuffers)); | ||
} | ||
cloned = dataTransfer.files; | ||
} else if (nativeRestrictedStructuredClone) { | ||
cloned = nativeRestrictedStructuredClone(value); | ||
} else throwUnpolyfillable(type); | ||
} else cloned = tryNativeRestrictedStructuredClone(value, type); | ||
break; | ||
@@ -277,3 +337,3 @@ case 'ImageData': | ||
cloned = new ImageData( | ||
structuredCloneInternal(value.data, map), | ||
structuredCloneInternal(value.data, map, transferredBuffers), | ||
value.width, | ||
@@ -284,5 +344,3 @@ value.height, | ||
} catch (error) { | ||
if (nativeRestrictedStructuredClone) { | ||
cloned = nativeRestrictedStructuredClone(value); | ||
} else throwUnpolyfillable(type); | ||
cloned = tryNativeRestrictedStructuredClone(value, type); | ||
} break; | ||
@@ -309,27 +367,2 @@ default: | ||
break; | ||
case 'ArrayBuffer': | ||
C = global.DataView; | ||
// `ArrayBuffer#slice` is not available in IE10 | ||
// `ArrayBuffer#slice` and `DataView` are not available in old FF | ||
if (!C && typeof value.slice != 'function') throwUnpolyfillable(type); | ||
// detached buffers throws in `DataView` and `.slice` | ||
try { | ||
if (typeof value.slice == 'function') { | ||
cloned = value.slice(0); | ||
} else { | ||
length = value.byteLength; | ||
cloned = new ArrayBuffer(length); | ||
source = new C(value); | ||
target = new C(cloned); | ||
for (i = 0; i < length; i++) { | ||
target.setUint8(i, source.getUint8(i)); | ||
} | ||
} | ||
} catch (error) { | ||
throw new DOMException('ArrayBuffer is detached', DATA_CLONE_ERROR); | ||
} break; | ||
case 'SharedArrayBuffer': | ||
// SharedArrayBuffer should use shared memory, we can't polyfill it, so return the original | ||
cloned = value; | ||
break; | ||
case 'Blob': | ||
@@ -379,8 +412,2 @@ try { | ||
} break; | ||
case 'File': | ||
try { | ||
cloned = new File([value], value.name, value); | ||
} catch (error) { | ||
throwUnpolyfillable(type); | ||
} break; | ||
case 'CropTarget': | ||
@@ -405,3 +432,3 @@ case 'CryptoKey': | ||
if (deep) switch (type) { | ||
switch (type) { | ||
case 'Array': | ||
@@ -412,7 +439,7 @@ case 'Object': | ||
key = keys[i]; | ||
createProperty(cloned, key, structuredCloneInternal(value[key], map)); | ||
createProperty(cloned, key, structuredCloneInternal(value[key], map, transferredBuffers)); | ||
} break; | ||
case 'Map': | ||
value.forEach(function (v, k) { | ||
mapSet(cloned, structuredCloneInternal(k, map), structuredCloneInternal(v, map)); | ||
mapSet(cloned, structuredCloneInternal(k, map, transferredBuffers), structuredCloneInternal(v, map, transferredBuffers)); | ||
}); | ||
@@ -422,16 +449,16 @@ break; | ||
value.forEach(function (v) { | ||
setAdd(cloned, structuredCloneInternal(v, map)); | ||
setAdd(cloned, structuredCloneInternal(v, map, transferredBuffers)); | ||
}); | ||
break; | ||
case 'Error': | ||
createNonEnumerableProperty(cloned, 'message', structuredCloneInternal(value.message, map)); | ||
createNonEnumerableProperty(cloned, 'message', structuredCloneInternal(value.message, map, transferredBuffers)); | ||
if (hasOwn(value, 'cause')) { | ||
createNonEnumerableProperty(cloned, 'cause', structuredCloneInternal(value.cause, map)); | ||
createNonEnumerableProperty(cloned, 'cause', structuredCloneInternal(value.cause, map, transferredBuffers)); | ||
} | ||
if (name == 'AggregateError') { | ||
cloned.errors = structuredCloneInternal(value.errors, map); | ||
cloned.errors = structuredCloneInternal(value.errors, map, transferredBuffers); | ||
} // break omitted | ||
case 'DOMException': | ||
if (ERROR_STACK_INSTALLABLE) { | ||
createNonEnumerableProperty(cloned, 'stack', structuredCloneInternal(value.stack, map)); | ||
createNonEnumerableProperty(cloned, 'stack', structuredCloneInternal(value.stack, map, transferredBuffers)); | ||
} | ||
@@ -443,2 +470,72 @@ } | ||
var replacePlaceholders = function (value, map) { | ||
if (!isObject(value)) return value; | ||
if (mapHas(map, value)) return mapGet(map, value); | ||
var type, object, metadata, i, length, keys, key, replacement; | ||
if (value instanceof Placeholder) { | ||
type = value.type; | ||
object = value.object; | ||
switch (type) { | ||
case 'ArrayBuffer': | ||
case 'SharedArrayBuffer': | ||
replacement = cloneBuffer(object, map, type); | ||
break; | ||
case 'DataView': | ||
case 'Int8Array': | ||
case 'Uint8Array': | ||
case 'Uint8ClampedArray': | ||
case 'Int16Array': | ||
case 'Uint16Array': | ||
case 'Int32Array': | ||
case 'Uint32Array': | ||
case 'Float16Array': | ||
case 'Float32Array': | ||
case 'Float64Array': | ||
case 'BigInt64Array': | ||
case 'BigUint64Array': | ||
metadata = value.metadata; | ||
replacement = cloneView(object, type, metadata.offset, metadata.length, map); | ||
} | ||
} else switch (classof(value)) { | ||
case 'Array': | ||
case 'Object': | ||
keys = objectKeys(value); | ||
for (i = 0, length = lengthOfArrayLike(keys); i < length; i++) { | ||
key = keys[i]; | ||
value[key] = replacePlaceholders(value[key], map); | ||
} break; | ||
case 'Map': | ||
replacement = new Map(); | ||
value.forEach(function (v, k) { | ||
mapSet(replacement, replacePlaceholders(k, map), replacePlaceholders(v, map)); | ||
}); | ||
break; | ||
case 'Set': | ||
replacement = new Set(); | ||
value.forEach(function (v) { | ||
setAdd(replacement, replacePlaceholders(v, map)); | ||
}); | ||
break; | ||
case 'Error': | ||
value.message = replacePlaceholders(value.message, map); | ||
if (hasOwn(value, 'cause')) { | ||
value.cause = replacePlaceholders(value.cause, map); | ||
} | ||
if (value.name == 'AggregateError') { | ||
value.errors = replacePlaceholders(value.errors, map); | ||
} // break omitted | ||
case 'DOMException': | ||
if (ERROR_STACK_INSTALLABLE) { | ||
value.stack = replacePlaceholders(value.stack, map); | ||
} | ||
} | ||
mapSet(map, value, replacement || value); | ||
return replacement || value; | ||
}; | ||
var tryToTransfer = function (rawTransfer, map) { | ||
@@ -455,14 +552,20 @@ if (!isObject(rawTransfer)) throw TypeError('Transfer option cannot be converted to a sequence'); | ||
var length = lengthOfArrayLike(transfer); | ||
var value, type, C, transferredArray, transferred, canvas, context; | ||
var buffers = []; | ||
var value, type, C, transferred, canvas, context; | ||
if (PROPER_TRANSFER) { | ||
transferredArray = nativeStructuredClone(transfer, { transfer: transfer }); | ||
while (i < length) mapSet(map, transfer[i], transferredArray[i++]); | ||
} else while (i < length) { | ||
while (i < length) { | ||
value = transfer[i++]; | ||
if (mapHas(map, value)) throw new DOMException('Duplicate transferable', DATA_CLONE_ERROR); | ||
type = classof(value); | ||
switch (type) { | ||
if (type === 'ArrayBuffer') { | ||
push(buffers, value); | ||
continue; | ||
} | ||
if (mapHas(map, value)) throw new DOMException('Duplicate transferable', DATA_CLONE_ERROR); | ||
if (PROPER_TRANSFER) { | ||
transferred = nativeStructuredClone(value, { transfer: [value] }); | ||
} else switch (type) { | ||
case 'ImageBitmap': | ||
@@ -486,6 +589,2 @@ C = global.OffscreenCanvas; | ||
break; | ||
case 'ArrayBuffer': | ||
if (!isCallable(value.transfer)) throwUnpolyfillable(type, TRANSFERRING); | ||
transferred = value.transfer(); | ||
break; | ||
case 'MediaSourceHandle': | ||
@@ -501,6 +600,30 @@ case 'MessagePort': | ||
if (transferred === undefined) throw new DOMException('This object cannot be transferred: ' + type, DATA_CLONE_ERROR); | ||
mapSet(map, value, transferred); | ||
} | ||
return buffers; | ||
}; | ||
var tryToTransferBuffers = function (transfer, map) { | ||
var i = 0; | ||
var length = lengthOfArrayLike(transfer); | ||
var value, transferred; | ||
while (i < length) { | ||
value = transfer[i++]; | ||
if (mapHas(map, value)) throw new DOMException('Duplicate transferable', DATA_CLONE_ERROR); | ||
if (PROPER_TRANSFER) { | ||
transferred = nativeStructuredClone(value, { transfer: [value] }); | ||
} else { | ||
if (!isCallable(value.transfer)) throwUnpolyfillable('ArrayBuffer', TRANSFERRING); | ||
transferred = value.transfer(); | ||
} | ||
mapSet(map, value, transferred); | ||
} | ||
}; | ||
// `structuredClone` method | ||
@@ -512,11 +635,23 @@ // https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone | ||
var transfer = options ? options.transfer : undefined; | ||
var map; | ||
var transferredBuffers = false; | ||
var map, buffers; | ||
if (transfer !== undefined) { | ||
map = new Map(); | ||
tryToTransfer(transfer, map); | ||
buffers = tryToTransfer(transfer, map); | ||
transferredBuffers = !!lengthOfArrayLike(buffers); | ||
} | ||
return structuredCloneInternal(value, map); | ||
var clone = structuredCloneInternal(value, map, transferredBuffers); | ||
// since of an issue with cloning views of transferred buffers, we a forced to transfer / clone them in 2 steps | ||
// https://github.com/zloirock/core-js/issues/1265 | ||
if (transferredBuffers) { | ||
map = new Map(); | ||
tryToTransferBuffers(transfer, map); | ||
clone = replacePlaceholders(clone, map); | ||
} | ||
return clone; | ||
} | ||
}); |
@@ -11,2 +11,3 @@ 'use strict'; | ||
var defineBuiltIn = require('../internals/define-built-in'); | ||
var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); | ||
var defineBuiltIns = require('../internals/define-built-ins'); | ||
@@ -207,3 +208,4 @@ var setToStringTag = require('../internals/set-to-string-tag'); | ||
var init = arguments.length > 0 ? arguments[0] : undefined; | ||
setInternalState(this, new URLSearchParamsState(init)); | ||
var state = setInternalState(this, new URLSearchParamsState(init)); | ||
if (!DESCRIPTORS) this.size = state.entries.length; | ||
}; | ||
@@ -217,5 +219,6 @@ | ||
append: function append(name, value) { | ||
var state = getInternalParamsState(this); | ||
validateArgumentsLength(arguments.length, 2); | ||
var state = getInternalParamsState(this); | ||
push(state.entries, { key: $toString(name), value: $toString(value) }); | ||
if (!DESCRIPTORS) this.length++; | ||
state.updateURL(); | ||
@@ -225,12 +228,18 @@ }, | ||
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete | ||
'delete': function (name) { | ||
validateArgumentsLength(arguments.length, 1); | ||
'delete': function (name /* , value */) { | ||
var state = getInternalParamsState(this); | ||
var length = validateArgumentsLength(arguments.length, 1); | ||
var entries = state.entries; | ||
var key = $toString(name); | ||
var $value = length < 2 ? undefined : arguments[1]; | ||
var value = $value === undefined ? $value : $toString($value); | ||
var index = 0; | ||
while (index < entries.length) { | ||
if (entries[index].key === key) splice(entries, index, 1); | ||
else index++; | ||
var entry = entries[index]; | ||
if (entry.key === key && (value === undefined || entry.value === value)) { | ||
splice(entries, index, 1); | ||
if (value !== undefined) break; | ||
} else index++; | ||
} | ||
if (!DESCRIPTORS) this.size = entries.length; | ||
state.updateURL(); | ||
@@ -241,4 +250,4 @@ }, | ||
get: function get(name) { | ||
var entries = getInternalParamsState(this).entries; | ||
validateArgumentsLength(arguments.length, 1); | ||
var entries = getInternalParamsState(this).entries; | ||
var key = $toString(name); | ||
@@ -254,4 +263,4 @@ var index = 0; | ||
getAll: function getAll(name) { | ||
var entries = getInternalParamsState(this).entries; | ||
validateArgumentsLength(arguments.length, 1); | ||
var entries = getInternalParamsState(this).entries; | ||
var key = $toString(name); | ||
@@ -267,9 +276,12 @@ var result = []; | ||
// https://url.spec.whatwg.org/#dom-urlsearchparams-has | ||
has: function has(name) { | ||
validateArgumentsLength(arguments.length, 1); | ||
has: function has(name /* , value */) { | ||
var entries = getInternalParamsState(this).entries; | ||
var length = validateArgumentsLength(arguments.length, 1); | ||
var key = $toString(name); | ||
var $value = length < 2 ? undefined : arguments[1]; | ||
var value = $value === undefined ? $value : $toString($value); | ||
var index = 0; | ||
while (index < entries.length) { | ||
if (entries[index++].key === key) return true; | ||
var entry = entries[index++]; | ||
if (entry.key === key && (value === undefined || entry.value === value)) return true; | ||
} | ||
@@ -281,4 +293,4 @@ return false; | ||
set: function set(name, value) { | ||
var state = getInternalParamsState(this); | ||
validateArgumentsLength(arguments.length, 1); | ||
var state = getInternalParamsState(this); | ||
var entries = state.entries; | ||
@@ -301,2 +313,3 @@ var found = false; | ||
if (!found) push(entries, { key: key, value: val }); | ||
if (!DESCRIPTORS) this.size = entries.length; | ||
state.updateURL(); | ||
@@ -347,2 +360,12 @@ }, | ||
// `URLSearchParams.prototype.size` getter | ||
// https://github.com/whatwg/url/pull/734 | ||
if (DESCRIPTORS) defineBuiltInAccessor(URLSearchParamsPrototype, 'size', { | ||
get: function size() { | ||
return getInternalParamsState(this).entries.length; | ||
}, | ||
configurable: true, | ||
enumerable: true | ||
}); | ||
setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS); | ||
@@ -349,0 +372,0 @@ |
{ | ||
"name": "core-js", | ||
"version": "3.28.0", | ||
"version": "3.31.1", | ||
"description": "Standard library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -23,5 +23,6 @@ var fs = require('fs'); | ||
var BANNER = '\u001B[96mThank you for using core-js (\u001B[94m https://github.com/zloirock/core-js \u001B[96m) for polyfilling JavaScript standard library!\u001B[0m\n\n' + | ||
'\u001B[96mThe project needs your help! Please consider supporting of core-js:\u001B[0m\n' + | ||
'\u001B[96mThe project needs your help! Please consider supporting core-js:\u001B[0m\n' + | ||
'\u001B[96m>\u001B[94m https://opencollective.com/core-js \u001B[0m\n' + | ||
'\u001B[96m>\u001B[94m https://patreon.com/zloirock \u001B[0m\n' + | ||
'\u001B[96m>\u001B[94m https://boosty.to/zloirock \u001B[0m\n' + | ||
'\u001B[96m>\u001B[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz \u001B[0m\n\n' + | ||
@@ -28,0 +29,0 @@ '\u001B[96mI highly recommend reading this:\u001B[94m https://github.com/zloirock/core-js/blob/master/docs/2023-02-14-so-whats-next.md \u001B[96m\u001B[0m\n'; |
@@ -0,2 +1,3 @@ | ||
// TODO: Remove from `core-js@4` | ||
// https://github.com/tc39/proposal-decorator-metadata | ||
require('../modules/esnext.symbol.metadata-key'); |
// https://github.com/jasnell/proposal-url | ||
require('../modules/web.url'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
require('../web/url'); |
@@ -16,3 +16,3 @@ ![logo](https://user-images.githubusercontent.com/2213682/146607186-8e13ddef-26a4-4ebf-befd-5aac9d77c090.png) | ||
`core-js` isn't backed by a company, so the future of this project depends on you. Become a sponsor or a backer if you are interested in `core-js`: [**Open Collective**](https://opencollective.com/core-js), [**Patreon**](https://patreon.com/zloirock), **Bitcoin ( bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz )**. | ||
`core-js` isn't backed by a company, so the future of this project depends on you. Become a sponsor or a backer if you are interested in `core-js`: [**Open Collective**](https://opencollective.com/core-js), [**Patreon**](https://patreon.com/zloirock), [**Boosty**](https://boosty.to/zloirock), **Bitcoin ( bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz )**, [**Alipay**](https://user-images.githubusercontent.com/2213682/219464783-c17ad329-17ce-4795-82a7-f609493345ed.png). | ||
@@ -19,0 +19,0 @@ --- |
@@ -169,2 +169,3 @@ require('../modules/es.symbol'); | ||
require('../modules/es.string.includes'); | ||
require('../modules/es.string.is-well-formed'); | ||
require('../modules/es.string.iterator'); | ||
@@ -183,2 +184,3 @@ require('../modules/es.string.match'); | ||
require('../modules/es.string.substr'); | ||
require('../modules/es.string.to-well-formed'); | ||
require('../modules/es.string.trim'); | ||
@@ -256,5 +258,9 @@ require('../modules/es.string.trim-end'); | ||
require('../modules/web.url'); | ||
require('../modules/web.url.can-parse'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
require('../modules/web.url-search-params.delete'); | ||
require('../modules/web.url-search-params.has'); | ||
require('../modules/web.url-search-params.size'); | ||
module.exports = require('../internals/path'); |
@@ -1,3 +0,3 @@ | ||
var parent = require('../../es/instance/push'); | ||
var parent = require('../../es/instance/unshift'); | ||
module.exports = parent; |
@@ -8,3 +8,2 @@ var parent = require('./2'); | ||
require('../proposals/collection-of-from'); | ||
require('../proposals/iterator-range'); | ||
require('../proposals/keys-composition'); | ||
@@ -11,0 +10,0 @@ require('../proposals/math-extensions'); |
var parent = require('./3'); | ||
require('../proposals/array-grouping-v2'); | ||
require('../proposals/array-is-template-object'); | ||
require('../proposals/async-explicit-resource-management'); | ||
require('../proposals/async-iterator-helpers'); | ||
require('../proposals/decorator-metadata'); | ||
require('../proposals/iterator-range'); | ||
require('../proposals/map-upsert-stage-2'); | ||
require('../proposals/promise-with-resolvers'); | ||
require('../proposals/string-dedent'); | ||
require('../proposals/symbol-predicates'); | ||
require('../proposals/symbol-predicates-v2'); | ||
// TODO: Obsolete versions, remove from `core-js@4` | ||
require('../proposals/array-grouping'); | ||
require('../proposals/decorators'); | ||
require('../proposals/decorator-metadata'); | ||
require('../proposals/iterator-helpers'); | ||
require('../proposals/set-methods'); | ||
require('../proposals/symbol-predicates'); | ||
require('../proposals/using-statement'); | ||
module.exports = parent; |
var parent = require('./4'); | ||
require('../proposals/array-from-async-stage-2'); | ||
require('../proposals/array-grouping-stage-3-2'); | ||
require('../proposals/array-buffer-transfer'); | ||
require('../proposals/decorator-metadata-v2'); | ||
require('../proposals/explicit-resource-management'); | ||
@@ -10,5 +10,5 @@ require('../proposals/iterator-helpers-stage-3-2'); | ||
require('../proposals/set-methods-v2'); | ||
require('../proposals/well-formed-unicode-strings'); | ||
// TODO: Obsolete versions, remove from `core-js@4` | ||
require('../proposals/array-grouping-stage-3'); | ||
require('../proposals/array-grouping-stage-3-2'); | ||
require('../proposals/change-array-by-copy'); | ||
@@ -15,0 +15,0 @@ require('../proposals/iterator-helpers-stage-3'); |
@@ -12,2 +12,3 @@ // TODO: Remove this entry from `core-js@4` | ||
require('../proposals/string-replace-all-stage-4'); | ||
require('../proposals/well-formed-unicode-strings'); | ||
@@ -14,0 +15,0 @@ var path = require('../internals/path'); |
@@ -14,6 +14,10 @@ require('../modules/web.atob'); | ||
require('../modules/web.url'); | ||
require('../modules/web.url.can-parse'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
require('../modules/web.url-search-params.delete'); | ||
require('../modules/web.url-search-params.has'); | ||
require('../modules/web.url-search-params.size'); | ||
var path = require('../internals/path'); | ||
module.exports = path; |
require('../modules/web.url-search-params'); | ||
require('../modules/web.url-search-params.delete'); | ||
require('../modules/web.url-search-params.has'); | ||
require('../modules/web.url-search-params.size'); | ||
var path = require('../internals/path'); | ||
module.exports = path.URLSearchParams; |
@@ -0,6 +1,7 @@ | ||
require('./url-search-params'); | ||
require('../modules/web.url'); | ||
require('../modules/web.url.can-parse'); | ||
require('../modules/web.url.to-json'); | ||
require('../modules/web.url-search-params'); | ||
var path = require('../internals/path'); | ||
module.exports = path.URL; |
1139818
3376
26483