Skip to content

Align Flow lib defs for Node.js util with v24#55016

Closed
robhogan wants to merge 1 commit into
mainfrom
export-D89942136
Closed

Align Flow lib defs for Node.js util with v24#55016
robhogan wants to merge 1 commit into
mainfrom
export-D89942136

Conversation

@robhogan

@robhogan robhogan commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

Summary:
This is an AI-assisted change to align the Flow definitions for the util module with the Node.js docs as at v24.

New v20-v24 APIs:

  1. parseEnv(content) - Environment file (.env) parser (added in v20.12.0)

  2. diff(actual, expected) - String/array comparison (added in v22.15.0) 🧪

  3. getSystemErrorMessage(err) - Error code to message (added in v22.12.0)

  4. getCallSites([frameCount | options]) - Call stack capture (added in v22.9.0)

  5. types.isFloat16Array() - Type check for Float16Array (added in v24.0.0)

New Classes (v19):

  1. MIMEType class - MIME type parsing and manipulation (added in v19.1.0, v18.13.0)

  2. MIMEParams class - MIME parameters handler (added in v19.1.0, v18.13.0)

Updated APIs:

  1. parseArgs() - Added allowNegative option (added in v22.4.0)

Type Safety Improvements:

  1. Exact-by-default syntax - Simplified object types

    • Changed {|...|} {} in parseArgs types (Flow configured with exact-by-default)
    • Changed default generic types from {||}{}
  2. styleText() already present with full type definitions

References:

Changelog: [Internal]

Generated by Confucius Code Assist (CCA)
Confucius Session, Trace

Reviewed By: vzaidman

Differential Revision: D89942136

Summary:
This is an AI-assisted change to align the Flow definitions for the `util` module with the Node.js docs as at v24.

**New v20-v24 APIs:**

1. **`parseEnv(content)`** - Environment file (.env) parser (added in v20.12.0)
   - Parses `.env` file content into key-value object
   - Last value wins for duplicate keys
   - https://nodejs.org/api/util.html#utilparseenvcontent

2. **`diff(actual, expected)`** - String/array comparison (added in v22.15.0) 🧪
   - Uses Myers diff algorithm for comparison
   - Returns array of tuples: `[operation: -1 | 0 | 1, value: string]`
     - `-1` = expected only (deletion)
     - `0` = both (unchanged)
     - `1` = actual only (insertion)
   - Experimental API
   - https://nodejs.org/api/util.html#utildiffactual-expected

3. **`getSystemErrorMessage(err)`** - Error code to message (added in v22.12.0)
   - Returns the error message string for a numeric error code
   - https://nodejs.org/api/util.html#utilgetsystemerrormessageerr

4. **`getCallSites([frameCount | options])`** - Call stack capture (added in v22.9.0)
   - Captures call stack as `CallSiteObject` instances with:
     - `functionName`, `scriptName`, `scriptId`, `lineNumber`, `columnNumber`
   - `scriptId` property added in v22.14.0
   - https://nodejs.org/api/util.html#utilgetcallsitesframecount

5. **`types.isFloat16Array()`** - Type check for Float16Array (added in v24.0.0)
   - Checks if value is a Float16Array instance
   - https://nodejs.org/api/util.html#utiltypesisfloat16arrayvalue

**New Classes (v19):**

6. **`MIMEType` class** - MIME type parsing and manipulation (added in v19.1.0, v18.13.0)
   - Properties: `type`, `subtype`, `essence`, `params`
   - Methods: `toString()`
   - Implements MIMEType proposal spec
   - https://nodejs.org/api/util.html#class-utilmimetype

7. **`MIMEParams` class** - MIME parameters handler (added in v19.1.0, v18.13.0)
   - Methods: `delete()`, `get()`, `has()`, `set()`, `entries()`, `keys()`, `values()`
   - https://nodejs.org/api/util.html#class-utilmimeparams

**Updated APIs:**

8. **`parseArgs()` - Added `allowNegative` option** (added in v22.4.0)
   - Allows explicitly setting boolean options to false with `--no-` prefix
   - Example: `--no-verbose` sets `verbose: false`
   - https://nodejs.org/api/util.html#utilparseargsconfig

**Type Safety Improvements:**

9. **Exact-by-default syntax** - Simplified object types
   - Changed `{|...|}`  `{}` in parseArgs types (Flow configured with exact-by-default)
   - Changed default generic types from `{||}` → `{}`

10. **styleText()** already present with full type definitions
    - 18 foreground colors, 18 background colors, 12 modifiers
    - https://nodejs.org/api/util.html#utilstyletextformat-text

**References:**
- Node.js util module docs: https://nodejs.org/api/util.html
- MIMEType proposal: https://bmeck.github.io/node-proposal-mime-api/

Changelog: [Internal]
---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace)

Reviewed By: vzaidman

Differential Revision: D89942136
@meta-codesync

meta-codesync Bot commented Jan 2, 2026

Copy link
Copy Markdown

@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in D89942136.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 2, 2026
meta-codesync Bot pushed a commit to react/metro that referenced this pull request Jan 2, 2026
Summary:
X-link: react/react-native#55016

This is an AI-assisted change to align the Flow definitions for the `util` module with the Node.js docs as at v24.

**New v20-v24 APIs:**

1. **`parseEnv(content)`** - Environment file (.env) parser (added in v20.12.0)
   - Parses `.env` file content into key-value object
   - Last value wins for duplicate keys
   - https://nodejs.org/api/util.html#utilparseenvcontent

2. **`diff(actual, expected)`** - String/array comparison (added in v22.15.0) 🧪
   - Uses Myers diff algorithm for comparison
   - Returns array of tuples: `[operation: -1 | 0 | 1, value: string]`
     - `-1` = expected only (deletion)
     - `0` = both (unchanged)
     - `1` = actual only (insertion)
   - Experimental API
   - https://nodejs.org/api/util.html#utildiffactual-expected

3. **`getSystemErrorMessage(err)`** - Error code to message (added in v22.12.0)
   - Returns the error message string for a numeric error code
   - https://nodejs.org/api/util.html#utilgetsystemerrormessageerr

4. **`getCallSites([frameCount | options])`** - Call stack capture (added in v22.9.0)
   - Captures call stack as `CallSiteObject` instances with:
     - `functionName`, `scriptName`, `scriptId`, `lineNumber`, `columnNumber`
   - `scriptId` property added in v22.14.0
   - https://nodejs.org/api/util.html#utilgetcallsitesframecount

5. **`types.isFloat16Array()`** - Type check for Float16Array (added in v24.0.0)
   - Checks if value is a Float16Array instance
   - https://nodejs.org/api/util.html#utiltypesisfloat16arrayvalue

**New Classes (v19):**

6. **`MIMEType` class** - MIME type parsing and manipulation (added in v19.1.0, v18.13.0)
   - Properties: `type`, `subtype`, `essence`, `params`
   - Methods: `toString()`
   - Implements MIMEType proposal spec
   - https://nodejs.org/api/util.html#class-utilmimetype

7. **`MIMEParams` class** - MIME parameters handler (added in v19.1.0, v18.13.0)
   - Methods: `delete()`, `get()`, `has()`, `set()`, `entries()`, `keys()`, `values()`
   - https://nodejs.org/api/util.html#class-utilmimeparams

**Updated APIs:**

8. **`parseArgs()` - Added `allowNegative` option** (added in v22.4.0)
   - Allows explicitly setting boolean options to false with `--no-` prefix
   - Example: `--no-verbose` sets `verbose: false`
   - https://nodejs.org/api/util.html#utilparseargsconfig

**Type Safety Improvements:**

9. **Exact-by-default syntax** - Simplified object types
   - Changed `{|...|}`  `{}` in parseArgs types (Flow configured with exact-by-default)
   - Changed default generic types from `{||}` → `{}`

10. **styleText()** already present with full type definitions
    - 18 foreground colors, 18 background colors, 12 modifiers
    - https://nodejs.org/api/util.html#utilstyletextformat-text

**References:**
- Node.js util module docs: https://nodejs.org/api/util.html
- MIMEType proposal: https://bmeck.github.io/node-proposal-mime-api/

Changelog: [Internal]
 ---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace)

Reviewed By: vzaidman

Differential Revision: D89942136

fbshipit-source-id: c26d6c6a8003a30b50443020b06228ce2a012838
@meta-codesync meta-codesync Bot closed this in f5c1126 Jan 2, 2026
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 2, 2026
@meta-codesync

meta-codesync Bot commented Jan 2, 2026

Copy link
Copy Markdown

This pull request has been merged in f5c1126.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @robhogan in f5c1126

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants