UNPKG

filetomarkdown

Version:

Convert various file types to markdown format with browser and Node.js support

2 lines 4.85 kB
/*! For license information please see filetomarkdown.browser.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.FileToMarkdown=e():t.FileToMarkdown=e()}(this,()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function n(){var t,e,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function u(r,n,i,a){var u=n&&n.prototype instanceof f?n:f,s=Object.create(u.prototype);return o(s,"_invoke",function(r,n,o){var i,a,u,f=0,s=o||[],l=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,a=0,u=t,p.n=r,c}};function y(r,n){for(a=r,u=n,e=0;!l&&f&&!o&&e<s.length;e++){var o,i=s[e],y=p.p,b=i[2];r>3?(o=b===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(a=0,p.v=n,p.n=i[1]):y<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,p.n=b,a=0))}if(o||r>1)return c;throw l=!0,n}return function(o,s,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===s&&y(s,b),a=s,u=b;(e=a<2?t:u)||!l;){i||(a?a<3?(a>1&&(p.n=-1),y(a,u)):p.n=u:p.v=u);try{if(f=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(l=p.n<0)?u:r.call(n,p))!==c)break}catch(e){i=t,a=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,i,a),!0),s}var c={};function f(){}function s(){}function l(){}e=Object.getPrototypeOf;var p=[][i]?e(e([][i]())):(o(e={},i,function(){return this}),e),y=l.prototype=f.prototype=Object.create(p);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,o(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t}return s.prototype=l,o(y,"constructor",l),o(l,"constructor",s),s.displayName="GeneratorFunction",o(l,a,"GeneratorFunction"),o(y),o(y,a,"Generator"),o(y,i,function(){return this}),o(y,"toString",function(){return"[object Generator]"}),(n=function(){return{w:u,m:b}})()}function o(t,e,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}o=function(t,e,r,n){if(e)i?i(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r;else{var a=function(e,r){o(t,e,function(t){return this._invoke(e,r,t)})};a("next",0),a("throw",1),a("return",2)}},o(t,e,r,n)}function i(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)})}}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}t.r(e),t.d(e,{FileToMarkdownClient:()=>f});var f=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.baseURL=e.baseURL||this.baseURL||""},e=[{key:"convertFile",value:(o=a(n().m(function t(e){var r,o;return n().w(function(t){for(;;)switch(t.n){case 0:return(r=new FormData).append("file",e),t.n=1,fetch("".concat(this.baseURL,"/api/convert"),{method:"POST",body:r});case 1:if((o=t.v).ok){t.n=2;break}throw new Error("HTTP error! status: ".concat(o.status));case 2:return t.a(2,o.json())}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"getSupportedTypes",value:(r=a(n().m(function t(){var e;return n().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,fetch("".concat(this.baseURL,"/api/filetypes"));case 1:if((e=t.v).ok){t.n=2;break}throw new Error("HTTP error! status: ".concat(e.status));case 2:return t.a(2,e.json())}},t,this)})),function(){return r.apply(this,arguments)})}],e&&u(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,o}();return e})());