(that, obj)
| 78652 | } |
| 78653 | |
| 78654 | function fromObject (that, obj) { |
| 78655 | if (Buffer.isBuffer(obj)) { |
| 78656 | var len = checked(obj.length) | 0 |
| 78657 | that = createBuffer(that, len) |
| 78658 | |
| 78659 | if (that.length === 0) { |
| 78660 | return that |
| 78661 | } |
| 78662 | |
| 78663 | obj.copy(that, 0, 0, len) |
| 78664 | return that |
| 78665 | } |
| 78666 | |
| 78667 | if (obj) { |
| 78668 | if ((typeof ArrayBuffer !== 'undefined' && |
| 78669 | obj.buffer instanceof ArrayBuffer) || 'length' in obj) { |
| 78670 | if (typeof obj.length !== 'number' || isnan(obj.length)) { |
| 78671 | return createBuffer(that, 0) |
| 78672 | } |
| 78673 | return fromArrayLike(that, obj) |
| 78674 | } |
| 78675 | |
| 78676 | if (obj.type === 'Buffer' && isArray(obj.data)) { |
| 78677 | return fromArrayLike(that, obj.data) |
| 78678 | } |
| 78679 | } |
| 78680 | |
| 78681 | throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') |
| 78682 | } |
| 78683 | |
| 78684 | function checked (length) { |
| 78685 | // Note: cannot use `length < kMaxLength()` here because that fails when |
no test coverage detected