public static EcmaValue Store(TypedArray array, EcmaValue index, EcmaValue value) { int pos = ValidateArrayAndIndex(array, index); value = value.ToInteger(); array.SetValueInBuffer(pos, value); return(value); }
public static long GetBoundIndex(EcmaValue index, long len, long defaultValue) { if (index == default) { return(defaultValue); } index = index.ToInteger(); return((index < 0 ? EcmaMath.Max(len + index, 0) : EcmaMath.Min(index, len)).ToInt64()); }
public static int GetBoundIndexClamped(EcmaValue index, int len, int defaultValue) { if (index == default) { return(defaultValue); } index = index.ToInteger(); return((index < 0 ? 0 : EcmaMath.Min(index, len)).ToInt32()); }
public static int ToInteger(this EcmaValue thisValue, int min, int max) { EcmaValue value = thisValue.ToInteger(); return(value > max ? max : value < min ? min : (int)value); }