summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/var/var_dump.js.map
blob: dacfb433efe281ab43297ecc081f53eaa7aeca6e (plain) (blame)
1
{"version":3,"sources":["../../../src/php/var/var_dump.js"],"names":["module","exports","var_dump","echo","require","output","padChar","padVal","lgth","i","_getFuncName","fn","name","exec","_repeatChar","len","str","_getInnerVal","val","thickPad","ret","length","parseFloat","parseInt","funcLines","toString","split","fll","Date","RegExp","nodeName","nodeType","namespaceURI","nodeValue","_formatArray","obj","curDepth","basePad","constructor","someProp","hasOwnProperty","key","objVal","arguments"],"mappings":";;;;AAAAA,OAAOC,OAAP,GAAiB,SAASC,QAAT,GAAqB;AAAE;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,OAAOC,QAAQ,iBAAR,CAAX;AACA,MAAIC,SAAS,EAAb;AACA,MAAIC,UAAU,GAAd;AACA,MAAIC,SAAS,CAAb;AACA,MAAIC,OAAO,CAAX;AACA,MAAIC,IAAI,CAAR;;AAEA,MAAIC,eAAe,SAAfA,YAAe,CAAUC,EAAV,EAAc;AAC/B,QAAIC,OAAQ,6BAAD,CACRC,IADQ,CACHF,EADG,CAAX;AAEA,QAAI,CAACC,IAAL,EAAW;AACT,aAAO,aAAP;AACD;AACD,WAAOA,KAAK,CAAL,CAAP;AACD,GAPD;;AASA,MAAIE,cAAc,SAAdA,WAAc,CAAUC,GAAV,EAAeT,OAAf,EAAwB;AACxC,QAAIU,MAAM,EAAV;AACA,SAAK,IAAIP,IAAI,CAAb,EAAgBA,IAAIM,GAApB,EAAyBN,GAAzB,EAA8B;AAC5BO,aAAOV,OAAP;AACD;AACD,WAAOU,GAAP;AACD,GAND;AAOA,MAAIC,eAAe,SAAfA,YAAe,CAAUC,GAAV,EAAeC,QAAf,EAAyB;AAC1C,QAAIC,MAAM,EAAV;AACA,QAAIF,QAAQ,IAAZ,EAAkB;AAChBE,YAAM,MAAN;AACD,KAFD,MAEO,IAAI,OAAOF,GAAP,KAAe,SA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I,CAAT,EAAYA,IAAIkC,UAAUtB,MAA1B,EAAkCZ,GAAlC,EAAuC;AACrCJ,cAAU,OAAO6B,aAAaS,UAAUlC,CAAV,CAAb,EAA2B,CAA3B,EAA8BF,MAA9B,EAAsCD,OAAtC,CAAjB;AACD;;AAEDH,OAAKE,MAAL;;AAEA;AACA,SAAOA,MAAP;AACD,CA7KD","file":"var_dump.js","sourcesContent":["module.exports = function var_dump () { // eslint-disable-line camelcase\n  //  discuss at: http://locutus.io/php/var_dump/\n  // original by: Brett Zamir (http://brett-zamir.me)\n  // improved by: Zahlii\n  // improved by: Brett Zamir (http://brett-zamir.me)\n  //      note 1: For returning a string, use var_export() with the second argument set to true\n  //        test: skip-all\n  //   example 1: var_dump(1)\n  //   returns 1: 'int(1)'\n\n  var echo = require('../strings/echo')\n  var output = ''\n  var padChar = ' '\n  var padVal = 4\n  var lgth = 0\n  var i = 0\n\n  var _getFuncName = function (fn) {\n    var name = (/\\W*function\\s+([\\w$]+)\\s*\\(/)\n      .exec(fn)\n    if (!name) {\n      return '(Anonymous)'\n    }\n    return name[1]\n  }\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 _getInnerVal = function (val, thickPad) {\n    var ret = ''\n    if (val === null) {\n      ret = 'NULL'\n    } else if (typeof val === 'boolean') {\n      ret = 'bool(' + val + ')'\n    } else if (typeof val === 'string') {\n      ret = 'string(' + val.length + ') \"' + val + '\"'\n    } else if (typeof val === 'number') {\n      if (parseFloat(val) === parseInt(val, 10)) {\n        ret = 'int(' + val + ')'\n      } else {\n        ret = 'float(' + val + ')'\n      }\n    } else if (typeof val === 'undefined') {\n      // The remaining are not PHP behavior because these values\n      // only exist in this exact form in JavaScript\n      ret = 'undefined'\n    } else if (typeof val === 'function') {\n      var funcLines = val.toString()\n        .split('\\n')\n      ret = ''\n      for (var i = 0, fll = funcLines.length; i < fll; i++) {\n        ret += (i !== 0 ? '\\n' + thickPad : '') + funcLines[i]\n      }\n    } else if (val instanceof Date) {\n      ret = 'Date(' + val + ')'\n    } else if (val instanceof RegExp) {\n      ret = 'RegExp(' + val + ')'\n    } else if (val.nodeName) {\n      // Different than PHP's DOMElement\n      switch (val.nodeType) {\n        case 1:\n          if (typeof val.namespaceURI === 'undefined' ||\n            val.namespaceURI === 'http://www.w3.org/1999/xhtml') {\n          // Undefined namespace could be plain XML, but namespaceURI not widely supported\n            ret = 'HTMLElement(\"' + val.nodeName + '\")'\n          } else {\n            ret = 'XML Element(\"' + val.nodeName + '\")'\n          }\n          break\n        case 2:\n          ret = 'ATTRIBUTE_NODE(' + val.nodeName + ')'\n          break\n        case 3:\n          ret = 'TEXT_NODE(' + val.nodeValue + ')'\n          break\n        case 4:\n          ret = 'CDATA_SECTION_NODE(' + val.nodeValue + ')'\n          break\n        case 5:\n          ret = 'ENTITY_REFERENCE_NODE'\n          break\n        case 6:\n          ret = 'ENTITY_NODE'\n          break\n        case 7:\n          ret = 'PROCESSING_INSTRUCTION_NODE(' + val.nodeName + ':' + val.nodeValue + ')'\n          break\n        case 8:\n          ret = 'COMMENT_NODE(' + val.nodeValue + ')'\n          break\n        case 9:\n          ret = 'DOCUMENT_NODE'\n          break\n        case 10:\n          ret = 'DOCUMENT_TYPE_NODE'\n          break\n        case 11:\n          ret = 'DOCUMENT_FRAGMENT_NODE'\n          break\n        case 12:\n          ret = 'NOTATION_NODE'\n          break\n      }\n    }\n    return ret\n  }\n\n  var _formatArray = function (obj, curDepth, padVal, padChar) {\n    if (curDepth > 0) {\n      curDepth++\n    }\n\n    var basePad = _repeatChar(padVal * (curDepth - 1), padChar)\n    var thickPad = _repeatChar(padVal * (curDepth + 1), padChar)\n    var str = ''\n    var val = ''\n\n    if (typeof obj === 'object' && obj !== null) {\n      if (obj.constructor && _getFuncName(obj.constructor) === 'LOCUTUS_Resource') {\n        return obj.var_dump()\n      }\n      lgth = 0\n      for (var someProp in obj) {\n        if (obj.hasOwnProperty(someProp)) {\n          lgth++\n        }\n      }\n      str += 'array(' + lgth + ') {\\n'\n      for (var key in obj) {\n        var objVal = obj[key]\n        if (typeof objVal === 'object' &&\n          objVal !== null &&\n          !(objVal instanceof Date) &&\n          !(objVal instanceof RegExp) &&\n          !objVal.nodeName) {\n          str += thickPad\n          str += '['\n          str += key\n          str += '] =>\\n'\n          str += thickPad\n          str += _formatArray(objVal, curDepth + 1, padVal, padChar)\n        } else {\n          val = _getInnerVal(objVal, thickPad)\n          str += thickPad\n          str += '['\n          str += key\n          str += '] =>\\n'\n          str += thickPad\n          str += val\n          str += '\\n'\n        }\n      }\n      str += basePad + '}\\n'\n    } else {\n      str = _getInnerVal(obj, thickPad)\n    }\n    return str\n  }\n\n  output = _formatArray(arguments[0], 0, padVal, padChar)\n  for (i = 1; i < arguments.length; i++) {\n    output += '\\n' + _formatArray(arguments[i], 0, padVal, padChar)\n  }\n\n  echo(output)\n\n  // Not how PHP does it, but helps us test:\n  return output\n}\n"]}