| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5cb0de9 commit ae3459a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -292,17 +292,21 @@ Buffer.from = function from(value, encodingOrOffset, length) { | |||
| 292 | 292 | return fromArrayBuffer(value, encodingOrOffset, length); | |
| 293 | 293 | ||
| 294 | 294 | const valueOf = value.valueOf && value.valueOf(); | |
| 295 | - if (valueOf !== null && valueOf !== undefined && valueOf !== value) | ||
| 296 | - return Buffer.from(valueOf, encodingOrOffset, length); | ||
| 295 | + if (valueOf != null && | ||
| 296 | + valueOf !== value && | ||
| 297 | + (typeof valueOf === 'string' || typeof valueOf === 'object')) { | ||
| 298 | + return from(valueOf, encodingOrOffset, length); | ||
| 299 | + } | ||
| 297 | 300 | ||
| 298 | 301 | const b = fromObject(value); | |
| 299 | 302 | if (b) | |
| 300 | 303 | return b; | |
| 301 | 304 | ||
| 302 | 305 | if (typeof value[SymbolToPrimitive] === 'function') { | |
| 303 | - return Buffer.from(value[SymbolToPrimitive]('string'), | ||
| 304 | - encodingOrOffset, | ||
| 305 | - length); | ||
| 306 | + const primitive = value[SymbolToPrimitive]('string'); | ||
| 307 | + if (typeof primitive === 'string') { | ||
| 308 | + return fromString(primitive, encodingOrOffset); | ||
| 309 | + } | ||
| 306 | 310 | } | |
| 307 | 311 | } | |
| 308 | 312 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments