(source: AllowSharedBufferSource)
| 325 | }; |
| 326 | |
| 327 | export const toUint8Array = (source: AllowSharedBufferSource): Uint8Array => { |
| 328 | if (source.constructor === Uint8Array) { // We want a true Uint8Array, not something that extends it like Buffer |
| 329 | return source; |
| 330 | } else if (ArrayBuffer.isView(source)) { |
| 331 | return new Uint8Array(source.buffer, source.byteOffset, source.byteLength); |
| 332 | } else { |
| 333 | return new Uint8Array(source); |
| 334 | } |
| 335 | }; |
| 336 | |
| 337 | export const toDataView = (source: AllowSharedBufferSource): DataView => { |
| 338 | if (source.constructor === DataView) { |
no outgoing calls
no test coverage detected