From 650cf51acb4c3dab8bed5750d8dc667e062d6ed3 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:27:35 +0700 Subject: [PATCH] DOCUMENTATION: Add more information for deprecated nFormat API (#1762) --- markdown/bitburner.ns.hackanalyzethreads.md | 2 +- markdown/bitburner.ns.md | 2 +- markdown/bitburner.ns.nformat.md | 10 ++++++---- src/NetscriptFunctions.ts | 3 ++- src/ScriptEditor/NetscriptDefinitions.d.ts | 14 ++++++++++---- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/markdown/bitburner.ns.hackanalyzethreads.md b/markdown/bitburner.ns.hackanalyzethreads.md index 21aee624f..5f2245163 100644 --- a/markdown/bitburner.ns.hackanalyzethreads.md +++ b/markdown/bitburner.ns.hackanalyzethreads.md @@ -29,7 +29,7 @@ The number of threads needed to hack the server for hackAmount money. RAM cost: 1 GB -This function returns the decimal number of script threads you need when running the hack command to steal the specified amount of money from the target server. If hackAmount is less than zero or greater than the amount of money available on the server, then this function returns -1. +This function returns the decimal number of script threads you need when running the hack command to steal the specified amount of money from the target server. If hackAmount is less than zero, greater than the amount of money available on the server, or your hacking level is below the required level for the target server, then this function returns -1. ## Example diff --git a/markdown/bitburner.ns.md b/markdown/bitburner.ns.md index c753bea4a..b0fe3cc36 100644 --- a/markdown/bitburner.ns.md +++ b/markdown/bitburner.ns.md @@ -134,7 +134,7 @@ export async function main(ns) { | [moveTail(x, y, pid)](./bitburner.ns.movetail.md) | Move a tail window. | | [mv(host, source, destination)](./bitburner.ns.mv.md) | Move a file on the target server. | | [nextPortWrite(port)](./bitburner.ns.nextportwrite.md) | Listen for a port write. | -| [nFormat(n, format)](./bitburner.ns.nformat.md) | Format a number using the numeral library. This function is deprecated and will be removed in 2.4. | +| [nFormat(n, format)](./bitburner.ns.nformat.md) | Format a number using the numeral library. This function is deprecated and will be removed in a later version. | | [nuke(host)](./bitburner.ns.nuke.md) | Runs NUKE.exe on a server. | | [peek(portNumber)](./bitburner.ns.peek.md) | Get a copy of the data from a port without popping it. | | [print(args)](./bitburner.ns.print.md) | Prints one or more values or variables to the script’s logs. | diff --git a/markdown/bitburner.ns.nformat.md b/markdown/bitburner.ns.nformat.md index ff39390eb..a5cb1150d 100644 --- a/markdown/bitburner.ns.nformat.md +++ b/markdown/bitburner.ns.nformat.md @@ -6,10 +6,14 @@ > Warning: This API is now obsolete. > -> Use ns.formatNumber, formatRam, or formatPercent instead. Will be removed in 2.4. +> Use alternatives: +> +> - NS APIs: ns.formatNumber, ns.formatRam, ns.formatPercent +> +> - JS built-in objects/functions: Intl.NumberFormat, Intl.PluralRules, Intl.Locale, etc. > -Format a number using the numeral library. This function is deprecated and will be removed in 2.4. +Format a number using the numeral library. This function is deprecated and will be removed in a later version. **Signature:** @@ -36,5 +40,3 @@ RAM cost: 0 GB Converts a number into a string with the specified format options. See http://numeraljs.com/\#format for documentation on format strings supported. -This function is deprecated and will be removed in 2.3. - diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index d2e224726..11f8fcd75 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1635,7 +1635,8 @@ export const ns: InternalAPI = { nFormat: (ctx) => (_n, _format) => { deprecationWarning( "ns.nFormat", - "Use ns.formatNumber, formatRam, formatPercent, or js builtins like Intl.NumberFormat instead.", + "Use ns.formatNumber, ns.formatRam, ns.formatPercent, or JS built-in objects/functions (e.g., Intl namespace) instead. " + + "Check the NS API documentation for details.", ); const n = helpers.number(ctx, "n", _n); const format = helpers.string(ctx, "format", _format); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 56e9389c9..3d45508ca 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -7637,16 +7637,22 @@ export interface NS { formatPercent(n: number, fractionalDigits?: number, suffixStart?: number): string; /** - * Format a number using the numeral library. This function is deprecated and will be removed in 2.4. - * @deprecated Use ns.formatNumber, formatRam, or formatPercent instead. Will be removed in 2.4. + * Format a number using the numeral library. This function is deprecated and will be removed in a later version. + * + * @deprecated + * + * Use alternatives: + * + * - NS APIs: ns.formatNumber, ns.formatRam, ns.formatPercent + * + * - JS built-in objects/functions: Intl.NumberFormat, Intl.PluralRules, Intl.Locale, etc. + * * @remarks * RAM cost: 0 GB * * Converts a number into a string with the specified format options. * See http://numeraljs.com/#format for documentation on format strings supported. * - * This function is deprecated and will be removed in 2.3. - * * @param n - Number to format. * @param format - Formatting options. See http://numeraljs.com/#format for valid formats. * @returns Formatted number.