예제 #1
0
 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());
 }
예제 #2
0
 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());
 }