forked from briancray/tinyamd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinyamd.min.js
1 lines (1 loc) · 2.41 KB
/
tinyamd.min.js
1
!function(e,n){var r,t,i,a,o=document,c=o.head||o.getElementsByTagName("head")[0]||o.documentElement,u=(r=o.getElementsByTagName("script"))[r.length-1].getAttribute("data-main"),s=[],f={baseUrl:(t=e.location.href.split("?")[0],a=t.split("/").slice(0,3).join("/"),u?(i=u.slice(0,a.length)===a?u:"/"===u[0]?a+u:t.slice(0,t.lastIndexOf("/")+1)+u,u=u.slice(u.lastIndexOf("/")+1)):i=t,i.slice(0,i.lastIndexOf("/")+1))},l={};function d(a,e,o){var n=arguments.length;1===n?(o=a,e=["require","exports","module"],a=null):2===n&&("[object Array]"===f.toString.call(a)?(o=e,e=a,a=null):(o=e,e=["require","exports","module"])),a?p(e,function(){var e,n,r;l[a]&&(e=l[a].handlers,n=l[a].context),(r=l[a]="function"==typeof o?o.apply(null,s.slice.call(arguments,0))||l[a]||{}:o).tinyamd=2,r.context=n;for(var t=0,i=e?e.length:0;t<i;t++)e[t](r)},a):s.push([e,o])}function p(e,r,t){var i=[],a=0,o=!1;if("string"==typeof e){if(l[e]&&2===l[e].tinyamd)return l[e];throw new Error(e+" has not been defined. Please include it as a dependency in "+t+"'s define()")}for(var n=0,c=e.length;n<c;n++)switch(e[n]){case"require":var u=function(e,n){return p(e,n,t)};u.toUrl=function(e){return h(e,t)},i[n]=u,a++;break;case"exports":i[n]=l[t]||(l[t]={}),a++;break;case"module":i[n]={id:t,uri:h(t)},a++;break;case l[t]?l[t].context:"":i[n]=l[l[t].context],a++;break;default:!function(n){v(e[n],function(e){i[n]=e,++a===c&&r&&(o=!0,r.apply(null,i))},t)}(n)}!o&&a===c&&r&&r.apply(null,i)}function v(n,e,r){n=r?h(n,r):n,l[n]?1===l[n].tinyamd?e&&l[n].handlers.push(e):e&&e(l[n]):(l[n]={tinyamd:1,handlers:[e],context:r},b(h(n)+".js",function(){var e;(e=s.shift())&&(e.unshift(n),1===l[n].tinyamd&&d.apply(null,e))}))}d.amd={};var h=p.toUrl=function(e,n){var r,t,i;switch(e){case"require":case"exports":case"module":return e}for((r=(n||f.baseUrl).split("/")).pop(),t=(e=e.split("/")).length;--t;)switch(e[0]){case"..":r.pop();case".":case"":e.shift(),i=!0}return(r.length&&i?r.join("/")+"/":"")+e.join("/")};function b(e,n){var r=o.createElement("script");r.onload=r.onreadystatechange=function(){this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(r.onload=r.onreadystatechange=null,c.removeChild(r),n&&n())},r.type="text/javascript",r.async=!0,r.src=e.replace(/(?:\.js){2,}$/,".js"),c.appendChild(r)}e.tinyamd={config:function(e){if("object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(f[n]=e[n])},inject:b,define:e.define=d,require:e.require=p,exports:l},u&&p([u])}(this);