mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 01:03:01 +02:00
Evaluator + Netscript should now properly handle errors in syntax/runtime errors (almost..still have to implement the properly closing down script when an error is thrown. Check file for TODO). Player skill level should now properly be updated
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
//Netscript String helper functions
|
||||
|
||||
//Searches for every occurence of searchStr within str and returns an array of the indices of
|
||||
//all these occurences
|
||||
function getIndicesOf(searchStr, str, caseSensitive) {
|
||||
var searchStrLen = searchStr.length;
|
||||
if (searchStrLen == 0) {
|
||||
return [];
|
||||
}
|
||||
var startIndex = 0, index, indices = [];
|
||||
if (!caseSensitive) {
|
||||
str = str.toLowerCase();
|
||||
searchStr = searchStr.toLowerCase();
|
||||
}
|
||||
while ((index = str.indexOf(searchStr, startIndex)) > -1) {
|
||||
indices.push(index);
|
||||
startIndex = index + searchStrLen;
|
||||
}
|
||||
return indices;
|
||||
}
|
||||
Reference in New Issue
Block a user