Skip to content

Commit 19d5012

Browse files
committed
prettier
1 parent 7dd2fc1 commit 19d5012

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/jest-util/Readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,85 @@
33
This packages is a collection of utilities and helper functions
44

55
## `ErrorWithStack`
6+
67
This custom error class can be useful when you need to capture the stack trace of an error and provide additional context to the error message. By default, JavaScript errors only capture the stack trace when they are thrown, but this class allows you to capture the stack trace at any point in your code by calling its constructor.
78

89
## `clearLine`
10+
911
It ensures that the clearing operation is only performed when running in a terminal environment, and not when the output is redirected to a file or another non-terminal destination.
1012

1113
## `convertDescriptorToString`
14+
1215
It defines a function named `convertDescriptorToString` that takes a descriptor as input and converts it to a string based on its type. It handles various types such as functions, numbers, strings, and undefined values. If the input doesn't match any of these types, it throws an error with a descriptive message.
1316

1417
## `createDirectory`
18+
1519
It creates new directory and also allows creation of nested directories.
1620

1721
## `deepCyclicCopy`
22+
1823
The `deepCyclicCopy` function provides deep copying of JavaScript objects and arrays, including handling circular references. It offers optional customization through a `DeepCyclicCopyOptions` parameter, allowing users to blacklist properties and preserve object prototypes. The function returns a completely independent deep copy of the input data structure.
1924

2025
## `formatTime`
26+
2127
This function is useful for formatting time values with appropriate SI unit prefixes for readability. It expresses time in various units (e.g., milliseconds, microseconds, nanoseconds) while ensuring the formatting is consistent and human-readable.
2228

2329
## `globsToMatcher`
30+
2431
The code efficiently converts a list of glob patterns into a reusable function for matching paths against those patterns, considering negated patterns and optimizing for performance.
2532

2633
## `installCommonGlobals`
34+
2735
Sets up various global variables and functions needed by the Jest testing framework. It ensures that these globals are properly set up for testing scenarios while maintaining compatibility with the environment's global object.
2836

2937
## `interopRequireDefault`
38+
3039
Provides a way to ensure compatibility between ES modules and CommonJS modules by handling the default export behavior appropriately.
3140

3241
## `invariant`
42+
3343
It is a utility used for asserting that a given condition is true. It's often used as a debugging aid during development to catch situations where an expected condition is not met.
3444

3545
## `isInteractive`
46+
3647
Checks whether the current environment is suitable for interactive terminal interactions.
3748

3849
## `isNonNullable`
50+
3951
Used to narrow down the type of a variable within a TypeScript code block, ensuring that it is safe to assume that the value is non-nullable. This can help avoid runtime errors related to null or undefined values.
4052

4153
## `isPromise`
54+
4255
It helps in order to determine whether a given value conforms to the structure of a Promise-like object, which typically has a `then` method. This can be useful when working with asynchronous code to ensure dealing with promises correctly.
4356

4457
## `pluralize`
58+
4559
This function is used to easily generate grammatically correct phrases in text output that depend on the count of items. It ensures that the word is correctly pluralized when needed.
4660

4761
## `preRunMessage`
62+
4863
These functions are intended for use in interactive command-line tools or scripts which provide informative messages to the user while ensuring a clean and responsive interface.
4964

5065
## `replacePathSepForGlob`
66+
5167
The function takes a string `path` as input and replaces backslashes ('\\') with forward slashes ('/') in the path. Used to normalize file paths to be compatible with glob patterns, ensuring consistency in path representation for different operating systems.
5268

5369
## `requireOrImportModule`
70+
5471
This function provides a unified way to load modules regardless of whether they use CommonJS or ESM syntax. It ensures that the default export is applied consistently when needed, allowing users to work with modules that might use different module systems.
5572

5673
## `setGlobal`
74+
5775
Used to set properties with specified values within a global object. It is designed to work in both browser-like and Node.js environments by accepting different types of global objects as input.
5876

5977
## `specialChars`
78+
6079
It defines constants and conditional values for handling platform-specific behaviors in a terminal environment. It determines if the current platform is Windows ('win32') and sets up constants for various symbols and terminal screen clearing escape sequences accordingly, ensuring proper display and behavior on both Windows and non-Windows operating systems.
6180

6281
## `testPathPatternToRegExp`
82+
6383
This function is used for consistency when serializing/deserializing global configurations and ensures that consistent regular expressions are produced for matching test paths.
6484

6585
## `tryRealpath`
86+
6687
Used to resolve the real path of a given path, but if the path doesn't exist or is a directory, it doesn't throw an error and returns the original path string. This can be useful for gracefully handling path resolution in scenarios where some paths might not exist or might be directories.

0 commit comments

Comments
 (0)