summaryrefslogtreecommitdiff
path: root/data/extensions/jsr@javascriptrestrictor/helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/extensions/jsr@javascriptrestrictor/helpers.js')
-rw-r--r--data/extensions/jsr@javascriptrestrictor/helpers.js22
1 files changed, 7 insertions, 15 deletions
diff --git a/data/extensions/jsr@javascriptrestrictor/helpers.js b/data/extensions/jsr@javascriptrestrictor/helpers.js
index 6396790..caf65a9 100644
--- a/data/extensions/jsr@javascriptrestrictor/helpers.js
+++ b/data/extensions/jsr@javascriptrestrictor/helpers.js
@@ -146,19 +146,6 @@ function shuffleArray(array) {
[array[i], array[j]] = [array[j], array[i]];
}
}
-/**
- * \brief makes number from substring of given string - should work as reinterpret_cast
- * \param str String
- * \param length Number specifying substring length
- */
-function strToUint(str, length){
- var sub = str.substring(0,length);
- var ret = "";
- for (var i = sub.length-1; i >= 0; i--) {
- ret += ((sub[i].charCodeAt(0)).toString(2).padStart(8, "0"));
- }
- return "0b"+ret;
-};
/**
* \brief Asynchronously sleep for given number of milliseconds
@@ -223,10 +210,15 @@ Observable.prototype = {
*/
function create_short_text(text, LIMIT) {
if (text.length > LIMIT) {
- let remove_parentheses = / \([^)]*\)/;;
+ let remove_parentheses = / \([^)]*\)/;
text = text.replace(remove_parentheses, "");
let sentences = text.split(".");
- sentences = sentences.map(s => s + ".");
+ sentences = sentences.map(function (s) {
+ if (s.length === 0) {
+ return s;
+ }
+ return s + ".";
+ });
let done = false;
text = sentences.reduce(function (acc, current) {
if (!done) {