(that, obj)
| 2145 | } |
| 2146 | |
| 2147 | function fromObject (that, obj) { |
| 2148 | if (internalIsBuffer(obj)) { |
| 2149 | var len = checked(obj.length) | 0; |
| 2150 | that = createBuffer(that, len); |
| 2151 | |
| 2152 | if (that.length === 0) { |
| 2153 | return that |
| 2154 | } |
| 2155 | |
| 2156 | obj.copy(that, 0, 0, len); |
| 2157 | return that |
| 2158 | } |
| 2159 | |
| 2160 | if (obj) { |
| 2161 | if ((typeof ArrayBuffer !== 'undefined' && |
| 2162 | obj.buffer instanceof ArrayBuffer) || 'length' in obj) { |
| 2163 | if (typeof obj.length !== 'number' || isnan(obj.length)) { |
| 2164 | return createBuffer(that, 0) |
| 2165 | } |
| 2166 | return fromArrayLike(that, obj) |
| 2167 | } |
| 2168 | |
| 2169 | if (obj.type === 'Buffer' && isArray$1(obj.data)) { |
| 2170 | return fromArrayLike(that, obj.data) |
| 2171 | } |
| 2172 | } |
| 2173 | |
| 2174 | throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') |
| 2175 | } |
| 2176 | |
| 2177 | function checked (length) { |
| 2178 | // Note: cannot use `length < kMaxLength()` here because that fails when |
no test coverage detected