input-format
Version:
Formatting user's text input on-the-fly
1 lines • 1.2 kB
Source Map (JSON)
{"version":3,"file":"helpers.js","names":["count_occurences","symbol","string","count","split","character"],"sources":["../source/helpers.js"],"sourcesContent":["// Counts all occurences of a symbol in a string\r\nexport function count_occurences(symbol, string) {\r\n\tlet count = 0\r\n\t// Using `.split('')` here instead of normal `for ... of`\r\n\t// because the importing application doesn't neccessarily include an ES6 polyfill.\r\n\t// The `.split('')` approach discards \"exotic\" UTF-8 characters\r\n\t// (the ones consisting of four bytes)\r\n\t// but template placeholder characters don't fall into that range\r\n\t// so skipping such miscellaneous \"exotic\" characters\r\n\t// won't matter here for just counting placeholder character occurrences.\r\n\tfor (const character of string.split('')) {\r\n\t\tif (character === symbol) {\r\n\t\t\tcount++\r\n\t\t}\r\n\t}\r\n\treturn count\r\n}"],"mappings":";;;;;;AAAA;AACA,OAAO,SAASA,gBAAT,CAA0BC,MAA1B,EAAkCC,MAAlC,EAA0C;EAChD,IAAIC,KAAK,GAAG,CAAZ,CADgD,CAEhD;EACA;EACA;EACA;EACA;EACA;EACA;;EACA,qDAAwBD,MAAM,CAACE,KAAP,CAAa,EAAb,CAAxB,wCAA0C;IAAA,IAA/BC,SAA+B;;IACzC,IAAIA,SAAS,KAAKJ,MAAlB,EAA0B;MACzBE,KAAK;IACL;EACD;;EACD,OAAOA,KAAP;AACA"}