mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
[refactor] Moved "isString()" to its own TS file
This commit is contained in:
parent
187b5051b9
commit
a6293474a9
@ -16,7 +16,7 @@ import {createElement, createAccordionElement,
|
|||||||
removeChildrenFromElement, clearObject} from "../utils/HelperFunctions";
|
removeChildrenFromElement, clearObject} from "../utils/HelperFunctions";
|
||||||
import {Reviver, Generic_toJSON,
|
import {Reviver, Generic_toJSON,
|
||||||
Generic_fromJSON} from "../utils/JSONReviver";
|
Generic_fromJSON} from "../utils/JSONReviver";
|
||||||
import {isString} from "../utils/StringHelperFunctions";
|
import {isString} from "../utils/helpers/isString";
|
||||||
|
|
||||||
//Augmentations
|
//Augmentations
|
||||||
function Augmentation(params) {
|
function Augmentation(params) {
|
||||||
|
@ -2,7 +2,7 @@ import {Engine} from "./engine";
|
|||||||
|
|
||||||
import {removeChildrenFromElement,
|
import {removeChildrenFromElement,
|
||||||
createElement, exceptionAlert} from "../utils/HelperFunctions";
|
createElement, exceptionAlert} from "../utils/HelperFunctions";
|
||||||
import {isString} from "../utils/StringHelperFunctions";
|
import {isString} from "../utils/helpers/isString";
|
||||||
|
|
||||||
var cinematicTextFlag = false;
|
var cinematicTextFlag = false;
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ import {getRandomInt, removeElementById,
|
|||||||
import {Reviver, Generic_toJSON,
|
import {Reviver, Generic_toJSON,
|
||||||
Generic_fromJSON} from "../utils/JSONReviver";
|
Generic_fromJSON} from "../utils/JSONReviver";
|
||||||
import numeral from "numeral/min/numeral.min";
|
import numeral from "numeral/min/numeral.min";
|
||||||
import {formatNumber, isString, generateRandomString} from "../utils/StringHelperFunctions";
|
import {formatNumber, generateRandomString} from "../utils/StringHelperFunctions";
|
||||||
|
import {isString} from "../utils/helpers/isString";
|
||||||
import {yesNoBoxCreate, yesNoTxtInpBoxCreate,
|
import {yesNoBoxCreate, yesNoTxtInpBoxCreate,
|
||||||
yesNoBoxGetYesButton, yesNoBoxGetNoButton,
|
yesNoBoxGetYesButton, yesNoBoxGetNoButton,
|
||||||
yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton,
|
yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton,
|
||||||
|
@ -6,7 +6,8 @@ import {dialogBoxCreate} from "../utils/DialogBox";
|
|||||||
import {addOffset, getRandomInt,
|
import {addOffset, getRandomInt,
|
||||||
clearEventListenersEl,
|
clearEventListenersEl,
|
||||||
clearEventListeners} from "../utils/HelperFunctions";
|
clearEventListeners} from "../utils/HelperFunctions";
|
||||||
import {formatNumber, isString} from "../utils/StringHelperFunctions";
|
import {formatNumber} from "../utils/StringHelperFunctions";
|
||||||
|
import {isString} from "../utils/helpers/isString";
|
||||||
import jsplumb from 'jsplumb'
|
import jsplumb from 'jsplumb'
|
||||||
|
|
||||||
let inMission = false; //Flag to denote whether a mission is running
|
let inMission = false; //Flag to denote whether a mission is running
|
||||||
|
@ -11,7 +11,7 @@ import {Script, findRunningScript,
|
|||||||
import {parse, Node} from "../utils/acorn";
|
import {parse, Node} from "../utils/acorn";
|
||||||
import {printArray} from "../utils/HelperFunctions";
|
import {printArray} from "../utils/HelperFunctions";
|
||||||
import {isValidIPAddress} from "../utils/IPAddress";
|
import {isValidIPAddress} from "../utils/IPAddress";
|
||||||
import {isString} from "../utils/StringHelperFunctions";
|
import {isString} from "../utils/helpers/isString";
|
||||||
|
|
||||||
var Promise = require("bluebird");
|
var Promise = require("bluebird");
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ import Decimal from "decimal.js";
|
|||||||
import {dialogBoxCreate} from "../utils/DialogBox";
|
import {dialogBoxCreate} from "../utils/DialogBox";
|
||||||
import {printArray, powerOfTwo} from "../utils/HelperFunctions";
|
import {printArray, powerOfTwo} from "../utils/HelperFunctions";
|
||||||
import {createRandomIp} from "../utils/IPAddress";
|
import {createRandomIp} from "../utils/IPAddress";
|
||||||
import {formatNumber, isString, isHTML} from "../utils/StringHelperFunctions";
|
import {formatNumber, isHTML} from "../utils/StringHelperFunctions";
|
||||||
|
import {isString} from "../utils/helpers/isString";
|
||||||
import {yesNoBoxClose, yesNoBoxGetYesButton,
|
import {yesNoBoxClose, yesNoBoxGetYesButton,
|
||||||
yesNoBoxGetNoButton, yesNoBoxCreate,
|
yesNoBoxGetNoButton, yesNoBoxCreate,
|
||||||
yesNoBoxOpen} from "../utils/YesNoBox";
|
yesNoBoxOpen} from "../utils/YesNoBox";
|
||||||
|
@ -34,7 +34,8 @@ import {SpecialServerIps,
|
|||||||
import {TextFile, getTextFile} from "./TextFile";
|
import {TextFile, getTextFile} from "./TextFile";
|
||||||
|
|
||||||
import {containsAllStrings, longestCommonStart,
|
import {containsAllStrings, longestCommonStart,
|
||||||
formatNumber, isString} from "../utils/StringHelperFunctions";
|
formatNumber} from "../utils/StringHelperFunctions";
|
||||||
|
import {isString} from "../utils/helpers/isString";
|
||||||
import {addOffset, printArray} from "../utils/HelperFunctions";
|
import {addOffset, printArray} from "../utils/HelperFunctions";
|
||||||
import {logBoxCreate} from "../utils/LogBox";
|
import {logBoxCreate} from "../utils/LogBox";
|
||||||
import {yesNoBoxCreate,
|
import {yesNoBoxCreate,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//General helper functions
|
//General helper functions
|
||||||
import {isString} from "./StringHelperFunctions";
|
import {isString} from "./helpers/isString";
|
||||||
import {dialogBoxCreate} from "./DialogBox";
|
import {dialogBoxCreate} from "./DialogBox";
|
||||||
|
|
||||||
//Returns the size (number of keys) of an object
|
//Returns the size (number of keys) of an object
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { EqualityFunc } from "../src/types";
|
import { EqualityFunc } from "../src/types";
|
||||||
import { dialogBoxCreate } from "./DialogBox";
|
import { dialogBoxCreate } from "./DialogBox";
|
||||||
|
import { isString } from "./helpers/isString";
|
||||||
|
|
||||||
// Netburner String helper functions
|
// Netburner String helper functions
|
||||||
|
|
||||||
@ -63,11 +64,6 @@ function longestCommonStart(strings: string[]): string {
|
|||||||
return a1.substring(0, i);
|
return a1.substring(0, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether a variable is a string
|
|
||||||
function isString(str: any): boolean {
|
|
||||||
return (typeof str === "string" || str instanceof String);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns whether an array contains entirely of string objects
|
// Returns whether an array contains entirely of string objects
|
||||||
function containsAllStrings(arr: string[]): boolean {
|
function containsAllStrings(arr: string[]): boolean {
|
||||||
return arr.every(isString);
|
return arr.every(isString);
|
||||||
@ -155,5 +151,5 @@ function generateRandomString(n: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {convertTimeMsToTimeElapsedString, longestCommonStart,
|
export {convertTimeMsToTimeElapsedString, longestCommonStart,
|
||||||
isString, containsAllStrings, formatNumber,
|
containsAllStrings, formatNumber,
|
||||||
numOccurrences, numNetscriptOperators, isHTML, generateRandomString, replaceAt};
|
numOccurrences, numNetscriptOperators, isHTML, generateRandomString, replaceAt};
|
||||||
|
7
utils/helpers/isString.ts
Normal file
7
utils/helpers/isString.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Checks whether the value passed in can be considered a string.
|
||||||
|
* @param value The value to check if it is a string.
|
||||||
|
*/
|
||||||
|
export function isString(value: any): boolean {
|
||||||
|
return (typeof value === "string" || value instanceof String);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user