{"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\nvar testArray = [\u0027\u002B\u0027];\r\nvar testSet = new Set(testArray);\r\nvar testArray2 = [\u0027\u002B\u0027, \u0027-\u0027];\r\nvar testSet2 = new Set(testArray2);\r\nvar testArray3 = [\u0027a\u0027, \u0027b\u0027, \u0027c\u0027, \u0027d\u0027, \u0027e\u0027];\r\nvar testSet3 = new Set(testArray3);\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, testArray);","IsDeferred":false},{"Name":"Set single","Code":"trimAnySet(testString, testSet);","IsDeferred":false},{"Name":"Array double","Code":"trimAny(testString2, testArray2);","IsDeferred":false},{"Name":"Set double","Code":"trimAnySet(testString2, testSet2);","IsDeferred":false},{"Name":"Array 5","Code":"trimAny(testString3, testArray3);","IsDeferred":false},{"Name":"Set 5","Code":"trimAnySet(testString3, testSet3);","IsDeferred":false}]}