buffer-source-converter.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.BufferSourceConverter = void 0;
  4. const index_js_1 = require("../bytes/index.js");
  5. class BufferSourceConverter {
  6. static isArrayBuffer(data) {
  7. return (0, index_js_1.isArrayBuffer)(data);
  8. }
  9. static toArrayBuffer(data) {
  10. return (0, index_js_1.toArrayBuffer)(data);
  11. }
  12. static toUint8Array(data) {
  13. return (0, index_js_1.toUint8Array)(data);
  14. }
  15. static toView(data, type) {
  16. return (0, index_js_1.toView)(data, type);
  17. }
  18. static isBufferSource(data) {
  19. return (0, index_js_1.isBufferSource)(data);
  20. }
  21. static isArrayBufferView(data) {
  22. return (0, index_js_1.isArrayBufferView)(data);
  23. }
  24. static isEqual(a, b) {
  25. return (0, index_js_1.equal)(a, b);
  26. }
  27. static concat(first, second, ...rest) {
  28. if (Array.isArray(first)) {
  29. return typeof second === "function"
  30. ? (0, index_js_1.concat)(first, second)
  31. : (0, index_js_1.concat)(first);
  32. }
  33. const buffers = [first, second, ...rest].filter(Boolean);
  34. return (0, index_js_1.concat)(buffers);
  35. }
  36. }
  37. exports.BufferSourceConverter = BufferSourceConverter;