(array, byteOffset, length)
| 271 | } |
| 272 | |
| 273 | function fromArrayBuffer (array, byteOffset, length) { |
| 274 | if (byteOffset < 0 || array.byteLength < byteOffset) { |
| 275 | throw new RangeError('"offset" is outside of buffer bounds') |
| 276 | } |
| 277 | |
| 278 | if (array.byteLength < byteOffset + (length || 0)) { |
| 279 | throw new RangeError('"length" is outside of buffer bounds') |
| 280 | } |
| 281 | |
| 282 | let buf |
| 283 | if (byteOffset === undefined && length === undefined) { |
| 284 | buf = new Uint8Array(array) |
| 285 | } else if (length === undefined) { |
| 286 | buf = new Uint8Array(array, byteOffset) |
| 287 | } else { |
| 288 | buf = new Uint8Array(array, byteOffset, length) |
| 289 | } |
| 290 | |
| 291 | // Return an augmented `Uint8Array` instance |
| 292 | Object.setPrototypeOf(buf, Buffer.prototype) |
| 293 | |
| 294 | return buf |
| 295 | } |
| 296 | |
| 297 | function fromObject (obj) { |
| 298 | if (Buffer.isBuffer(obj)) { |
no outgoing calls
no test coverage detected
searching dependent graphs…