Arguments.cs 958 B

12345678910111213141516171819202122232425262728293031
  1. using Jint.Native;
  2. namespace Jint.Runtime
  3. {
  4. public static class Arguments
  5. {
  6. public static JsValue[] Empty = new JsValue[0];
  7. public static JsValue[] From(params JsValue[] o)
  8. {
  9. return o;
  10. }
  11. /// <summary>
  12. /// Returns the arguments at the provided position or Undefined if not present
  13. /// </summary>
  14. /// <param name="args"></param>
  15. /// <param name="index">The index of the parameter to return</param>
  16. /// <param name="undefinedValue">The value to return is the parameter is not provided</param>
  17. /// <returns></returns>
  18. public static JsValue At(this JsValue[] args, int index, JsValue undefinedValue)
  19. {
  20. return args.Length > index ? args[index] : undefinedValue;
  21. }
  22. public static JsValue At(this JsValue[] args, int index)
  23. {
  24. return At(args, index, Undefined.Instance);
  25. }
  26. }
  27. }