{"ScriptPreparationCode":"var TestString = \u0027\u002B\u0027.repeat(200) \u002B \u0027=\u0027.repeat(20000) \u002B \u0027\u002B\u0027.repeat(200);\r\nvar TestString2 = \u0027-\u0027.repeat(200) \u002B \u0027=\u0027.repeat(20000) \u002B \u0027\u002B\u0027.repeat(200);\r\nvar TestString3 = \u0027a\u0027.repeat(200) \u002B \u0027b\u0027.repeat(200) \u002B \u0027c\u0027.repeat(200) \u002B \u0027d\u0027.repeat(200) \u002B \u0027e\u0027.repeat(200) \u002B \u0027f\u0027.repeat(200) \u002B \u0027g\u0027.repeat(200) \u002B \u0027h\u0027.repeat(200) \u002B \u0027i\u0027.repeat(200) \u002B \u0027j\u0027.repeat(200) \u002B \u0027k\u0027.repeat(200) \u002B \u0027l\u0027.repeat(200);\r\n\r\nfunction trimAnySet(str, chars) {\r\n var start = 0, \r\n end = str.length;\r\n\r\n while(start \u003C end \u0026\u0026 chars.has(str[start]))\r\n \u002B\u002Bstart;\r\n\r\n while(end \u003E start \u0026\u0026 chars.has(str[end - 1]))\r\n --end;\r\n\r\n return (start \u003E 0 || end \u003C str.length) ? str.substring(start, end) : str;\r\n}\r\n\r\nfunction trimAny(str, chars) {\r\n var start = 0, \r\n end = str.length;\r\n\r\n while(start \u003C end \u0026\u0026 chars.indexOf(str[start]) \u003E= 0)\r\n \u002B\u002Bstart;\r\n\r\n while(end \u003E start \u0026\u0026 chars.indexOf(str[end - 1]) \u003E= 0)\r\n --end;\r\n\r\n return (start \u003E 0 || end \u003C str.length) ? str.substring(start, end) : str;\r\n}","TestCases":[{"Name":"Array single","Code":"trimAny(TestString, [\u0027\u002B\u0027]);","IsDeferred":false},{"Name":"Set single","Code":"trimAnySet(TestString, new Set([\u0027\u002B\u0027]));","IsDeferred":false},{"Name":"Array double","Code":"trimAny(TestString2, [\u0027\u002B\u0027, \u0027-\u0027]);","IsDeferred":false},{"Name":"Set double","Code":"trimAnySet(TestString2, new Set([\u0027\u002B\u0027, \u0027-\u0027]));","IsDeferred":false},{"Name":"Array 5","Code":"trimAny(TestString3, [\u0027a\u0027, \u0027b\u0027, \u0027c\u0027, \u0027d\u0027, \u0027e\u0027]);","IsDeferred":false},{"Name":"Set 5","Code":"trimAnySet(TestString3, new Set([\u0027a\u0027, \u0027b\u0027, \u0027c\u0027, \u0027d\u0027, \u0027e\u0027]));","IsDeferred":false}]}