javiercejudo/modelico

View on GitHub
lib/asciitree-1.0.2.js

Summary

Maintainability
A
0 mins
Test Coverage
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.asciitree=n()}}(function(){return function n(t,e,r){function o(f,u){if(!e[f]){if(!t[f]){var l="function"==typeof require&&require;if(!u&&l)return l(f,!0);if(i)return i(f,!0);var a=new Error("Cannot find module '"+f+"'");throw a.code="MODULE_NOT_FOUND",a}var c=e[f]={exports:{}};t[f][0].call(c.exports,function(n){var e=t[f][1][n];return o(e?e:n)},c,c.exports,n,t,e,r)}return e[f].exports}for(var i="function"==typeof require&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(n,t,e){t.exports=function(n,t,e){var r=" ",o=[],i=t||function(n){return"object"==typeof n?n[0].toString():n.toString()},f=e||function(n){return"object"==typeof n?n.slice(1):null},u=function(n){void 0==o[n]&&(o[n]="")},l=function(n,t){for(var e="",r=0;r<t;r++)e+=n;return e},a=function(n,t,e,r){u(t);var i=0,f=void 0!=r?r:2,l=o[t].length;return e<0&&(i=-e,e=0),l>=e&&(i+=l-e+f),i},c=function(n,t,e){u(t);var i=o[t].length;if(e<0)throw'Trying to insert "'+n+'" at negative position('+e+").";if(e<i)throw'Trying to insert "'+n+'" at position('+e+") less then length("+i+").";o[t]+=l(r,e-i)+n},g=function(n,t,e){var o,u,h=0,d=0,s=0,p=0,v=i(n).toString(),y=f(n);if(y){var w=e;if(1==y.length){o=y[0],u=i(o).toString();var x=Math.floor(v.length/2);p=Math.floor(u.length/2)-x,d=a(u,t+2,e-p),s=g(o,t+2,e-p+d),c("|",t+1,e+x+d+s),h=d+s}else for(var b=0;b<y.length;b++)o=y[b],u=i(o).toString(),0==b?(p=1==u.length?2:Math.floor(u.length/2)+1,d=a(u,t+2,e-p),s=g(o,t+2,e-p+d),c("/",t+1,e-1+d+s),c(l(r,v.length),t+1,e+d+s),h=d+s,w+=h+v.length):(p=1==u.length?-1:Math.floor(u.length/2)-1,d=a(u,t+2,w-p),s=g(o,t+2,w-p+d),w+=d+s,c("\\",t+1,w),v+=l("_",d+s))}return c(v,t,e+h),h};return g(n,0,0),o.join("\n")}},{}]},{},[1])(1)});