Yet another ridiculous approach (requires node.js):
constinput="Input string lol.\nNicely done haha.\nLook at it go!"constbuf=Buffer.from(input,'latin1')for(letl=buf.length;l>0;l--){for(leti=0;i<l-1;i++){buf.slice(i,i+2).swap16();}}constoutput=buf.toString('latin1')console.log(input)console.log(output)
Among the reasons it is ridiculous is the fact that Buffers inherit .reverse() from Uint8Array, so I could just use that.
Yet another ridiculous approach (requires node.js):
Among the reasons it is ridiculous is the fact that
Buffer
s inherit.reverse()
fromUint8Array
, so I could just use that.Or: