promisify-file-reader
Version:
Promise File Reader
3 lines (2 loc) • 1.26 kB
JavaScript
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).PromisifyFileReader=e()}(this,(function(){"use strict";var r=new Function("return this")(),e=r.FileReader,t=r.Promise,n=r.Blob;function o(r){return function(n,o){return new t((function(t,a){var i=new e;i.onload=function(){return t(i.result)},i.onerror=function(){return a(i.error)},r.call(i,n,o)}))}}var a,i=n.prototype.arrayBuffer?(a=n.prototype.arrayBuffer,function(r,e){return a.call(r,e)}):o(e.prototype.readAsArrayBuffer),f=String.fromCharCode;function u(r){for(var e=new Uint8Array(r),t=e.byteLength,n="",o=0;o<t;o+=1)n+=f(e[o]);return n}var s=e.prototype.readAsBinaryString?o(e.prototype.readAsBinaryString):function(r){return i(r).then(u)},d=o(e.prototype.readAsDataURL),y=o(e.prototype.readAsText),p=Object.freeze({__proto__:null,readAsArrayBuffer:i,readAsBinaryString:s,readAsDataURL:d,readAsText:y}),c=Object.freeze({__proto__:null,readAsArrayBuffer:i,readAsBinaryString:s,readAsDataURL:d,readAsText:y,arrayBuffer:i,binaryString:s,dataURL:d,text:y}),l=function(){};return Object.assign(l.prototype,p),Object.assign(l,c),l}));
//# sourceMappingURL=index.min.js.map