buffer
                                
                                
                                
                                    buffer copied to clipboard
                            
                            
                            
                        BugFix: NodeJS Buffer behavior fix + performance increase
In NodeJS, the behavior of Buffer.from(x, 'hex') differed slightly on its handling of bad hex parsing.
My fix also increased performance. I tried parsing a hex string '7c'.repeat(5e7) and it went from 2.8 s to ~800ms.
// node
> Buffer.from('abc def01','hex')
<Buffer ab>
// this library
> require('./index.js').Buffer.from('abc def01','hex')
<Buffer ab 0c de f0>
                                    
                                    
                                    
                                
Note: This new implementation also mimics the code for NodeJS hex parser used in the from(x, 'hex') portion.
https://github.com/nodejs/node/blob/v14.18.1/src/string_bytes.cc#L246-L261