UNPKG

str2buf

Version:

isomorphic string <=> buffer in 183 bytes

3 lines (2 loc) 621 B
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(r.str2buf={})}(this,function(r){function t(r){for(var t="",n=0,e=r.length;n<e;n++)t+=String.fromCharCode(r[n]);return t}function n(r){for(var t=new Uint8Array(r.length),n=0,e=r.length;n<e;n++)t[n]=r.charCodeAt(n);return t}function e(r){return t(new Uint8Array(r))}function f(r){return n(r).buffer}var o={fromUint8Array:t,toUint8Array:n,fromBuffer:e,toBuffer:f};r.fromUint8Array=t,r.toUint8Array=n,r.fromBuffer=e,r.toBuffer=f,r.default=o}); //# sourceMappingURL=str2buf.umd.js.map