TypeArrayHelper.cs 487 B

1234567891011121314151617181920
  1. using Jint.Runtime;
  2. namespace Jint.Native.TypedArray;
  3. internal static class TypeArrayHelper
  4. {
  5. internal static JsTypedArray ValidateTypedArray(this JsValue o, Realm realm)
  6. {
  7. var typedArrayInstance = o as JsTypedArray;
  8. if (typedArrayInstance is null)
  9. {
  10. ExceptionHelper.ThrowTypeError(realm);
  11. }
  12. var buffer = typedArrayInstance._viewedArrayBuffer;
  13. buffer.AssertNotDetached();
  14. return typedArrayInstance;
  15. }
  16. }