mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 05:47:14 +02:00
moved a bunch of files
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Returns the input array as a comma separated string.
|
||||
*
|
||||
* Does several things that Array.toString() doesn't do
|
||||
* - Adds brackets around the array
|
||||
* - Adds quotation marks around strings
|
||||
*/
|
||||
export function arrayToString<T>(a: T[]): string {
|
||||
const vals: any[] = [];
|
||||
for (let i = 0; i < a.length; ++i) {
|
||||
let elem: any = a[i];
|
||||
if (Array.isArray(elem)) {
|
||||
elem = arrayToString(elem);
|
||||
} else if (typeof elem === "string") {
|
||||
elem = `"${elem}"`;
|
||||
}
|
||||
vals.push(elem);
|
||||
}
|
||||
|
||||
return `[${vals.join(", ")}]`;
|
||||
}
|
||||
Reference in New Issue
Block a user