GlobalOperations.js [plain text]
@globalPrivate
function toInteger(target)
{
"use strict";
var numberValue = +target;
if (numberValue !== numberValue)
return 0;
return @trunc(numberValue);
}
@globalPrivate
function toLength(target)
{
"use strict";
var length = @toInteger(target);
return +(length > 0 ? (length < @MAX_SAFE_INTEGER ? length : @MAX_SAFE_INTEGER) : 0);
}
@globalPrivate
function isDictionary(object)
{
"use strict";
return object == null || typeof object === "object";
}
@globalPrivate
function speciesGetter()
{
return this;
}
@globalPrivate
function speciesConstructor(obj, defaultConstructor)
{
var constructor = obj.constructor;
if (constructor === @undefined)
return defaultConstructor;
if (!@isObject(constructor))
@throwTypeError("|this|.constructor is not an Object or undefined");
constructor = constructor.@speciesSymbol;
if (constructor == null)
return defaultConstructor;
if (@isConstructor(constructor))
return constructor;
@throwTypeError("|this|.constructor[Symbol.species] is not a constructor");
}
@globalPrivate
function copyDataProperties(target, source, excludedSet)
{
if (!@isObject(target))
@throwTypeError("target needs to be an object");
if (source == null)
return target;
let from = @Object(source);
let keys = @Reflect.@ownKeys(from);
let keysLength = keys.length;
for (let i = 0; i < keysLength; i++) {
let nextKey = keys[i];
if (!excludedSet.@has(nextKey)) {
if (@propertyIsEnumerable(from, nextKey)) {
let propValue = from[nextKey];
@defineEnumerableWritableConfigurableDataProperty(target, nextKey, propValue);
}
}
}
return target;
}
@globalPrivate
function copyDataPropertiesNoExclusions(target, source)
{
if (!@isObject(target))
@throwTypeError("target needs to be an object");
if (source == null)
return target;
let from = @Object(source);
let keys = @Reflect.@ownKeys(from);
let keysLength = keys.length;
for (let i = 0; i < keysLength; i++) {
let nextKey = keys[i];
if (@propertyIsEnumerable(from, nextKey)) {
let propValue = from[nextKey];
@defineEnumerableWritableConfigurableDataProperty(target, nextKey, propValue);
}
}
return target;
}