File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -367,7 +367,5 @@ export function isomorphicDecode(input) {
367367}
368368
369369export function isomorphicEncode ( str ) {
370- const res = latin1fromString ( str )
371- // match new Uint8Array, which is non-pooled
372- return res . byteOffset === 0 && res . length === res . buffer . byteLength ? res : res . slice ( 0 )
370+ return latin1fromString ( str )
373371}
Original file line number Diff line number Diff line change @@ -90,8 +90,9 @@ function encode(s, m) {
9090export function latin1fromString ( s ) {
9191 if ( typeof s !== 'string' ) throw new TypeError ( E_STRING )
9292 if ( NON_LATIN . test ( s ) ) throw new TypeError ( E_STRICT )
93- const b = Buffer . from ( s , 'latin1' )
94- return new Uint8Array ( b . buffer , b . byteOffset , b . byteLength )
93+ const ab = new ArrayBuffer ( s . length )
94+ Buffer . from ( ab ) . latin1Write ( s )
95+ return new Uint8Array ( ab )
9596}
9697
9798export function createSinglebyteEncoder ( encoding , { mode = 'fatal' } = { } ) {
You can’t perform that action at this time.
0 commit comments