mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 06:32:26 +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";
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver";
|
||||
import {isString} from "../utils/StringHelperFunctions";
|
||||
import {isString} from "../utils/helpers/isString";
|
||||
|
||||
//Augmentations
|
||||
function Augmentation(params) {
|
||||
|
@ -2,7 +2,7 @@ import {Engine} from "./engine";
|
||||
|
||||
import {removeChildrenFromElement,
|
||||
createElement, exceptionAlert} from "../utils/HelperFunctions";
|
||||
import {isString} from "../utils/StringHelperFunctions";
|
||||
import {isString} from "../utils/helpers/isString";
|
||||
|
||||
var cinematicTextFlag = false;
|
||||
|
||||
|
@ -14,7 +14,8 @@ import {getRandomInt, removeElementById,
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver";
|
||||
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,
|
||||
yesNoBoxGetYesButton, yesNoBoxGetNoButton,
|
||||
yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton,
|
||||
|
@ -6,7 +6,8 @@ import {dialogBoxCreate} from "../utils/DialogBox";
|
||||
import {addOffset, getRandomInt,
|
||||
clearEventListenersEl,
|
||||
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'
|
||||
|
||||
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 {printArray} from "../utils/HelperFunctions";
|
||||
import {isValidIPAddress} from "../utils/IPAddress";
|
||||
import {isString} from "../utils/StringHelperFunctions";
|
||||
import {isString} from "../utils/helpers/isString";
|
||||
|
||||
var Promise = require("bluebird");
|
||||
|
||||
|
@ -50,7 +50,8 @@ import Decimal from "decimal.js";
|
||||
import {dialogBoxCreate} from "../utils/DialogBox";
|
||||
import {printArray, powerOfTwo} from "../utils/HelperFunctions";
|
||||
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,
|
||||
yesNoBoxGetNoButton, yesNoBoxCreate,
|
||||
yesNoBoxOpen} from "../utils/YesNoBox";
|
||||
|
@ -34,7 +34,8 @@ import {SpecialServerIps,
|
||||
import {TextFile, getTextFile} from "./TextFile";
|
||||
|
||||
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 {logBoxCreate} from "../utils/LogBox";
|
||||
import {yesNoBoxCreate,
|
||||
|
@ -1,5 +1,5 @@
|
||||
//General helper functions
|
||||
import {isString} from "./StringHelperFunctions";
|
||||
import {isString} from "./helpers/isString";
|
||||
import {dialogBoxCreate} from "./DialogBox";
|
||||
|
||||
//Returns the size (number of keys) of an object
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { EqualityFunc } from "../src/types";
|
||||
import { dialogBoxCreate } from "./DialogBox";
|
||||
import { isString } from "./helpers/isString";
|
||||
|
||||
// Netburner String helper functions
|
||||
|
||||
@ -63,11 +64,6 @@ function longestCommonStart(strings: string[]): string {
|
||||
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
|
||||
function containsAllStrings(arr: string[]): boolean {
|
||||
return arr.every(isString);
|
||||
@ -155,5 +151,5 @@ function generateRandomString(n: number): string {
|
||||
}
|
||||
|
||||
export {convertTimeMsToTimeElapsedString, longestCommonStart,
|
||||
isString, containsAllStrings, formatNumber,
|
||||
containsAllStrings, formatNumber,
|
||||
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