(value, encodingOrOffset, length)
| 130 | Buffer.poolSize = 8192; // not used by this implementation |
| 131 | |
| 132 | function from(value, encodingOrOffset, length) { |
| 133 | if (typeof value === 'string') { |
| 134 | return fromString(value, encodingOrOffset); |
| 135 | } |
| 136 | if (ArrayBuffer.isView(value)) { |
| 137 | return fromArrayView(value); |
| 138 | } |
| 139 | if (value == null) { |
| 140 | throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value)); |
| 141 | } |
| 142 | if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { |
| 143 | return fromArrayBuffer(value, encodingOrOffset, length); |
| 144 | } |
| 145 | if (typeof SharedArrayBuffer !== 'undefined' && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { |
| 146 | return fromArrayBuffer(value, encodingOrOffset, length); |
| 147 | } |
| 148 | if (typeof value === 'number') { |
| 149 | throw new TypeError('The "value" argument must not be of type number. Received type number'); |
| 150 | } |
| 151 | var valueOf = value.valueOf && value.valueOf(); |
| 152 | if (valueOf != null && valueOf !== value) { |
| 153 | return Buffer.from(valueOf, encodingOrOffset, length); |
| 154 | } |
| 155 | var b = fromObject(value); |
| 156 | if (b) return b; |
| 157 | if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') { |
| 158 | return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length); |
| 159 | } |
| 160 | throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value)); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError |
no test coverage detected
searching dependent graphs…