summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/strings/trim.js.map
blob: 9d1638ea639fd6fc91e64b682084af3e2232cb89 (plain) (blame)
1
{"version":3,"sources":["../../../src/php/strings/trim.js"],"names":["module","exports","trim","str","charlist","whitespace","join","l","i","replace","length","indexOf","charAt","substring"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,IAAT,CAAeC,GAAf,EAAoBC,QAApB,EAA8B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,aAAa,CACf,GADe,EAEf,IAFe,EAGf,IAHe,EAIf,IAJe,EAKf,IALe,EAMf,MANe,EAOf,MAPe,EAQf,QARe,EASf,QATe,EAUf,QAVe,EAWf,QAXe,EAYf,QAZe,EAaf,QAbe,EAcf,QAde,EAef,QAfe,EAgBf,QAhBe,EAiBf,QAjBe,EAkBf,QAlBe,EAmBf,QAnBe,EAoBf,QApBe,EAqBf,QArBe,EAsBf,QAtBe,EAuBfC,IAvBe,CAuBV,EAvBU,CAAjB;AAwBA,MAAIC,IAAI,CAAR;AACA,MAAIC,IAAI,CAAR;AACAL,SAAO,EAAP;;AAEA,MAAIC,QAAJ,EAAc;AACZC,iBAAa,CAACD,WAAW,EAAZ,EAAgBK,OAAhB,CAAwB,sBAAxB,EAAgD,IAAhD,CAAb;AACD;;AAEDF,MAAIJ,IAAIO,MAAR;AACA,OAAKF,IAAI,CAAT,EAAYA,IAAID,CAAhB,EAAmBC,GAAnB,EAAwB;AACtB,QAAIH,WAAWM,OAAX,CAAmBR,IAAIS,MAAJ,CAAWJ,CAAX,CAAnB,MAAsC,CAAC,CAA3C,EAA8C;AAC5CL,YAAMA,IAAIU,SAAJ,CAAcL,CAAd,CAAN;AACA;AACD;AACF;;AAEDD,MAAIJ,IAAIO,MAAR;AACA,OAAKF,IAAID,IAAI,CAAb,EAAgBC,KAAK,CAArB,EAAwBA,GAAxB,EAA6B;AAC3B,QAAIH,WAAWM,OAAX,CAAmBR,IAAIS,MAAJ,CAAWJ,CAAX,CAAnB,MAAsC,CAAC,CAA3C,EAA8C;AAC5CL,YAAMA,IAAIU,SAAJ,CAAc,CAAd,EAAiBL,IAAI,CAArB,CAAN;AACA;AACD;AACF;;AAED,SAAOH,WAAWM,OAAX,CAAmBR,IAAIS,MAAJ,CAAW,CAAX,CAAnB,MAAsC,CAAC,CAAvC,GAA2CT,GAA3C,GAAiD,EAAxD;AACD,CAnED","file":"trim.js","sourcesContent":["module.exports = function trim (str, charlist) {\n  //  discuss at: http://locutus.io/php/trim/\n  // original by: Kevin van Zonneveld (http://kvz.io)\n  // improved by: mdsjack (http://www.mdsjack.bo.it)\n  // improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)\n  // improved by: Kevin van Zonneveld (http://kvz.io)\n  // improved by: Steven Levithan (http://blog.stevenlevithan.com)\n  // improved by: Jack\n  //    input by: Erkekjetter\n  //    input by: DxGx\n  // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)\n  //   example 1: trim('    Kevin van Zonneveld    ')\n  //   returns 1: 'Kevin van Zonneveld'\n  //   example 2: trim('Hello World', 'Hdle')\n  //   returns 2: 'o Wor'\n  //   example 3: trim(16, 1)\n  //   returns 3: '6'\n\n  var whitespace = [\n    ' ',\n    '\\n',\n    '\\r',\n    '\\t',\n    '\\f',\n    '\\x0b',\n    '\\xa0',\n    '\\u2000',\n    '\\u2001',\n    '\\u2002',\n    '\\u2003',\n    '\\u2004',\n    '\\u2005',\n    '\\u2006',\n    '\\u2007',\n    '\\u2008',\n    '\\u2009',\n    '\\u200a',\n    '\\u200b',\n    '\\u2028',\n    '\\u2029',\n    '\\u3000'\n  ].join('')\n  var l = 0\n  var i = 0\n  str += ''\n\n  if (charlist) {\n    whitespace = (charlist + '').replace(/([[\\]().?/*{}+$^:])/g, '$1')\n  }\n\n  l = str.length\n  for (i = 0; i < l; i++) {\n    if (whitespace.indexOf(str.charAt(i)) === -1) {\n      str = str.substring(i)\n      break\n    }\n  }\n\n  l = str.length\n  for (i = l - 1; i >= 0; i--) {\n    if (whitespace.indexOf(str.charAt(i)) === -1) {\n      str = str.substring(0, i + 1)\n      break\n    }\n  }\n\n  return whitespace.indexOf(str.charAt(0)) === -1 ? str : ''\n}\n"]}