{"version":3,"sources":["../../../src/php/strings/ord.js"],"names":["module","exports","ord","string","str","code","charCodeAt","hi","length","low"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,GAAT,CAAcC,MAAd,EAAsB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,MAAMD,SAAS,EAAnB;AACA,MAAIE,OAAOD,IAAIE,UAAJ,CAAe,CAAf,CAAX;;AAEA,MAAID,QAAQ,MAAR,IAAkBA,QAAQ,MAA9B,EAAsC;AACpC;AACA;AACA,QAAIE,KAAKF,IAAT;AACA,QAAID,IAAII,MAAJ,KAAe,CAAnB,EAAsB;AACpB;AACA;AACA,aAAOH,IAAP;AACA;AACA;AACD;AACD,QAAII,MAAML,IAAIE,UAAJ,CAAe,CAAf,CAAV;AACA,WAAQ,CAACC,KAAK,MAAN,IAAgB,KAAjB,IAA2BE,MAAM,MAAjC,IAA2C,OAAlD;AACD;AACD,MAAIJ,QAAQ,MAAR,IAAkBA,QAAQ,MAA9B,EAAsC;AACpC;AACA;AACA;AACA,WAAOA,IAAP;AACA;AACA;AACD;;AAED,SAAOA,IAAP;AACD,CAtCD","file":"ord.js","sourcesContent":["module.exports = function ord (string) {\n // discuss at: http://locutus.io/php/ord/\n // original by: Kevin van Zonneveld (http://kvz.io)\n // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)\n // improved by: Brett Zamir (http://brett-zamir.me)\n // input by: incidence\n // example 1: ord('K')\n // returns 1: 75\n // example 2: ord('\\uD800\\uDC00'); // surrogate pair to create a single Unicode character\n // returns 2: 65536\n\n var str = string + ''\n var code = str.charCodeAt(0)\n\n if (code >= 0xD800 && code <= 0xDBFF) {\n // High surrogate (could change last hex to 0xDB7F to treat\n // high private surrogates as single characters)\n var hi = code\n if (str.length === 1) {\n // This is just a high surrogate with no following low surrogate,\n // so we return its value;\n return code\n // we could also throw an error as it is not a complete character,\n // but someone may want to know\n }\n var low = str.charCodeAt(1)\n return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000\n }\n if (code >= 0xDC00 && code <= 0xDFFF) {\n // Low surrogate\n // This is just a low surrogate with no preceding high surrogate,\n // so we return its value;\n return code\n // we could also throw an error as it is not a complete character,\n // but someone may want to know\n }\n\n return code\n}\n"]}