summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/var/print_r.js.map
blob: 964adcc8fe2307a6eac346bc2dd2dbc1b46a154b (plain) (blame)
1
{"version":3,"sources":["../../../src/php/var/print_r.js"],"names":["module","exports","print_r","array","returnVal","echo","require","output","padChar","padVal","_repeatChar","len","str","i","_formatArray","obj","curDepth","basePad","thickPad","constructor","key","Object","prototype","toString","call","undefined"],"mappings":";;;;AAAAA,OAAOC,OAAP,GAAiB,SAASC,OAAT,CAAkBC,KAAlB,EAAyBC,SAAzB,EAAoC;AAAE;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,OAAOC,QAAQ,iBAAR,CAAX;;AAEA,MAAIC,SAAS,EAAb;AACA,MAAIC,UAAU,GAAd;AACA,MAAIC,SAAS,CAAb;;AAEA,MAAIC,cAAc,SAAdA,WAAc,CAAUC,GAAV,EAAeH,OAAf,EAAwB;AACxC,QAAII,MAAM,EAAV;AACA,SAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAIF,GAApB,EAAyBE,GAAzB,EAA8B;AAC5BD,aAAOJ,OAAP;AACD;AACD,WAAOI,GAAP;AACD,GAND;AAOA,MAAIE,eAAe,SAAfA,YAAe,CAAUC,GAAV,EAAeC,QAAf,EAAyBP,MAAzB,EAAiCD,OAAjC,EAA0C;AAC3D,QAAIQ,WAAW,CAAf,EAAkB;AAChBA;AACD;;AAED,QAAIC,UAAUP,YAAYD,SAASO,QAArB,EAA+BR,OAA/B,CAAd;AACA,QAAIU,WAAWR,YAAYD,UAAUO,WAAW,CAArB,CAAZ,EAAqCR,OAArC,CAAf;AACA,QAAII,MAAM,EAAV;;AAEA,QAAI,QAAOG,GAAP,yCAAOA,GAAP,OAAe,QAAf,IACFA,QAAQ,IADN,IAEFA,IAAII,WAFN,EAEmB;AACjBP,aAAO,YAAYK,OAAZ,GAAsB,KAA7B;AACA,WAAK,IAAIG,GAAT,IAAgBL,GAAhB,EAAqB;AACnB,YAAIM,OAAOC,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BT,IAAIK,GAAJ,CAA/B,MAA6C,gBAAjD,EAAmE;AACjER,iBAAOM,QAAP;AACAN,iBAAO,GAAP;AACAA,iBAAOQ,GAAP;AACAR,iBAAO,OAAP;AACAA,iBAAOE,aAAaC,IAAIK,GAAJ,CAAb,EAAuBJ,WAAW,CAAlC,EAAqCP,MAArC,EAA6CD,OAA7C,CAAP;AACD,SAND,MAMO;AACLI,iBAAOM,QAAP;AACAN,iBAAO,GAAP;AACAA,iBAAOQ,GAAP;AACAR,iBAAO,OAAP;AACAA,iBAAOG,IAAIK,GAAJ,CAAP;AACAR,iBAAO,IAAP;AACD;AACF;AACDA,aAAOK,UAAU,KAAjB;AACD,KArBD,MAqBO,IAAIF,QAAQ,IAAR,IAAgBA,QAAQU,SAA5B,EAAuC;AAC5Cb,YAAM,EAAN;AACD,KAFM,MAEA;AACL;AACAA,YAAMG,IAAIQ,QAAJ,EAAN;AACD;;AAED,WAAOX,GAAP;AACD,GAtCD;;AAwCAL,WAASO,aAAaX,KAAb,EAAoB,CAApB,EAAuBM,MAAvB,EAA+BD,OAA/B,CAAT;;AAEA,MAAIJ,cAAc,IAAlB,EAAwB;AACtBC,SAAKE,MAAL;AACA,WAAO,IAAP;AACD;AACD,SAAOA,MAAP;AACD,CAtED","file":"print_r.js","sourcesContent":["module.exports = function print_r (array, returnVal) { // eslint-disable-line camelcase\n  //  discuss at: http://locutus.io/php/print_r/\n  // original by: Michael White (http://getsprink.com)\n  // improved by: Ben Bryan\n  // improved by: Brett Zamir (http://brett-zamir.me)\n  // improved by: Kevin van Zonneveld (http://kvz.io)\n  //    input by: Brett Zamir (http://brett-zamir.me)\n  //   example 1: print_r(1, true)\n  //   returns 1: '1'\n\n  var echo = require('../strings/echo')\n\n  var output = ''\n  var padChar = ' '\n  var padVal = 4\n\n  var _repeatChar = function (len, padChar) {\n    var str = ''\n    for (var i = 0; i < len; i++) {\n      str += padChar\n    }\n    return str\n  }\n  var _formatArray = function (obj, curDepth, padVal, padChar) {\n    if (curDepth > 0) {\n      curDepth++\n    }\n\n    var basePad = _repeatChar(padVal * curDepth, padChar)\n    var thickPad = _repeatChar(padVal * (curDepth + 1), padChar)\n    var str = ''\n\n    if (typeof obj === 'object' &&\n      obj !== null &&\n      obj.constructor) {\n      str += 'Array\\n' + basePad + '(\\n'\n      for (var key in obj) {\n        if (Object.prototype.toString.call(obj[key]) === '[object Array]') {\n          str += thickPad\n          str += '['\n          str += key\n          str += '] => '\n          str += _formatArray(obj[key], curDepth + 1, padVal, padChar)\n        } else {\n          str += thickPad\n          str += '['\n          str += key\n          str += '] => '\n          str += obj[key]\n          str += '\\n'\n        }\n      }\n      str += basePad + ')\\n'\n    } else if (obj === null || obj === undefined) {\n      str = ''\n    } else {\n      // for our \"resource\" class\n      str = obj.toString()\n    }\n\n    return str\n  }\n\n  output = _formatArray(array, 0, padVal, padChar)\n\n  if (returnVal !== true) {\n    echo(output)\n    return true\n  }\n  return output\n}\n"]}