(obj)
| 113034 | return buf; |
| 113035 | } |
| 113036 | function fromObject(obj) { |
| 113037 | if (Buffer.isBuffer(obj)) { |
| 113038 | var len = checked(obj.length) | 0; |
| 113039 | var buf = createBuffer(len); |
| 113040 | if (buf.length === 0) return buf; |
| 113041 | obj.copy(buf, 0, 0, len); |
| 113042 | return buf; |
| 113043 | } |
| 113044 | if (obj.length !== undefined) { |
| 113045 | if (typeof obj.length !== "number" || numberIsNaN(obj.length)) return createBuffer(0); |
| 113046 | return fromArrayLike(obj); |
| 113047 | } |
| 113048 | if (obj.type === "Buffer" && Array.isArray(obj.data)) return fromArrayLike(obj.data); |
| 113049 | } |
| 113050 | function checked(length) { |
| 113051 | // Note: cannot use `length < K_MAX_LENGTH` here because that fails when |
| 113052 | // length is NaN (which is otherwise coerced to zero.) |
no test coverage detected