(value, encodingOrOffset, length)
| 2731 | Buffer.poolSize = 8192 // not used by this implementation |
| 2732 | |
| 2733 | function from (value, encodingOrOffset, length) { |
| 2734 | if (typeof value === 'string') { |
| 2735 | return fromString(value, encodingOrOffset) |
| 2736 | } |
| 2737 | |
| 2738 | if (ArrayBuffer.isView(value)) { |
| 2739 | return fromArrayLike(value) |
| 2740 | } |
| 2741 | |
| 2742 | if (value == null) { |
| 2743 | throw TypeError( |
| 2744 | 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + |
| 2745 | 'or Array-like Object. Received type ' + (typeof value) |
| 2746 | ) |
| 2747 | } |
| 2748 | |
| 2749 | if (isInstance(value, ArrayBuffer) || |
| 2750 | (value && isInstance(value.buffer, ArrayBuffer))) { |
| 2751 | return fromArrayBuffer(value, encodingOrOffset, length) |
| 2752 | } |
| 2753 | |
| 2754 | if (typeof value === 'number') { |
| 2755 | throw new TypeError( |
| 2756 | 'The "value" argument must not be of type number. Received type number' |
| 2757 | ) |
| 2758 | } |
| 2759 | |
| 2760 | var valueOf = value.valueOf && value.valueOf() |
| 2761 | if (valueOf != null && valueOf !== value) { |
| 2762 | return Buffer.from(valueOf, encodingOrOffset, length) |
| 2763 | } |
| 2764 | |
| 2765 | var b = fromObject(value) |
| 2766 | if (b) return b |
| 2767 | |
| 2768 | if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && |
| 2769 | typeof value[Symbol.toPrimitive] === 'function') { |
| 2770 | return Buffer.from( |
| 2771 | value[Symbol.toPrimitive]('string'), encodingOrOffset, length |
| 2772 | ) |
| 2773 | } |
| 2774 | |
| 2775 | throw new TypeError( |
| 2776 | 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + |
| 2777 | 'or Array-like Object. Received type ' + (typeof value) |
| 2778 | ) |
| 2779 | } |
| 2780 | |
| 2781 | /** |
| 2782 | * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError |
no test coverage detected
searching dependent graphs…