Skip to content

Commit 5778cd6

Browse files
JacksonGLfacebook-github-bot
authored andcommitted
chore(doc): improves the documentation and fix some typos
Summary: improves the documentation and fixes some typos Differential Revision: D79866349 fbshipit-source-id: 78278a216fa467636a25070e2e9a406cff3da36a
1 parent 86dcc99 commit 5778cd6

File tree

5 files changed

+208
-201
lines changed

5 files changed

+208
-201
lines changed

packages/core/src/lib/Types.ts

Lines changed: 58 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ export type RecordValue =
2626
| {[key: string]: RecordValue};
2727

2828
/**
29-
* Given any type `T`, return the union type `T` and `null`
29+
* Given any type `T`, returns the union type `T` and `null`.
3030
* @typeParam T - The type that will be made nullable.
3131
*/
3232
export type Nullable<T> = T | null;
3333

3434
/**
35-
* Given any type `T`, return the union type `T`, `null`, and `undefined`.
35+
* Given any type `T`, returns the union type `T`, `null`, and `undefined`.
3636
* @typeParam T - The type that will be made both nullable and undefinable.
3737
*/
3838
export type Optional<T> = T | null | undefined;
3939

4040
/**
41-
* Given any type `T`, return the union type `T` and `undefined`.
41+
* Given any type `T`, returns the union type `T` and `undefined`.
4242
* @typeParam T - The type that will be made undefinable.
4343
*/
4444
export type Undefinable<T> = T | undefined;
@@ -238,14 +238,14 @@ export type Cookie = {
238238
name: string;
239239
/** Mandatory: Represents the value assigned to the cookie */
240240
value: string;
241-
/** Add when possible: Defines the domain associated with the cookie */
241+
/** Optional: Defines the domain associated with the cookie */
242242
domain?: string;
243243
/**
244244
* Optional: Specifies the request-URI linked with the cookie setup.
245-
* This can influence the cookie's default domain and path
245+
* This can influence the cookie's default domain and path.
246246
*/
247247
url?: Undefinable<string>;
248-
/** Optional: Defines the domain associated with the cookie */
248+
/** Optional: Defines the path associated with the cookie */
249249
path?: Undefinable<string>;
250250
/** Optional: Indicates when the cookie will expire, in Unix time (seconds) */
251251
expires?: Undefinable<number>;
@@ -255,7 +255,7 @@ export type Cookie = {
255255
session?: Undefinable<boolean>;
256256
/**
257257
* Optional: Flag to indicate if the cookie transmission
258-
* requires a secure protocol (e.g., HTTPS)
258+
* requires a secure protocol (e.g., HTTPS).
259259
*/
260260
secure?: Undefinable<boolean>;
261261
/**
@@ -1768,21 +1768,21 @@ export interface IHeapEdges {
17681768
/** @internal */
17691769
export interface IHeapNodeBasic {
17701770
/**
1771-
* the type of the heap node object. All possible types:
1771+
* The type of the heap node object. All possible types:
17721772
* This is engine-specific, for example all types in V8:
17731773
* `hidden`, `array`, `string`, `object`, `code`, `closure`, `regexp`,
17741774
* `number`, `native`, `synthetic`, `concatenated string`, `sliced string`,
17751775
* `symbol`, `bigint`
17761776
*/
17771777
type: string;
17781778
/**
1779-
* this is the `name` field associated with the heap object,
1780-
* for JS object instances (type `object`), `name` is the constructor's name
1781-
* of the object instance. for `string`, `name` is the string value.
1779+
* This is the `name` field associated with the heap object.
1780+
* For JS object instances (type `object`), `name` is the constructor's name
1781+
* of the object instance. For `string`, `name` is the string value.
17821782
*/
17831783
name: string;
17841784
/**
1785-
* unique id of the heap object
1785+
* Unique id of the heap object.
17861786
*/
17871787
id: number;
17881788
}
@@ -1797,7 +1797,6 @@ export interface IHeapNodeBasic {
17971797
export type EdgeIterationCallback = (
17981798
edge: IHeapEdge,
17991799
) => Optional<{stop: boolean}> | void;
1800-
18011800
/**
18021801
* An `IHeapNode` instance represents a JS heap object in a heap snapshot.
18031802
* A heap snapshot is generally a graph where graph nodes are JS heap objects
@@ -1829,15 +1828,15 @@ export type EdgeIterationCallback = (
18291828
*/
18301829
export interface IHeapNode extends IHeapNodeBasic {
18311830
/**
1832-
* get the {@link IHeapSnapshot} containing this heap object
1831+
* Gets the {@link IHeapSnapshot} containing this heap object.
18331832
*/
18341833
snapshot: IHeapSnapshot;
18351834
/**
18361835
* * If the heap object is a DOM element and the DOM element is detached
18371836
* from the DOM tree, `is_detached` will be `true`;
18381837
* * If the heap object is a React Fiber node and the Fiber node is unmounted
18391838
* from the React Fiber tree, `is_detached` will be `true`;
1840-
* otherwise it will be `false`
1839+
* otherwise it will be `false`.
18411840
*/
18421841
is_detached: boolean;
18431842
/** @internal */
@@ -1848,7 +1847,7 @@ export interface IHeapNode extends IHeapNodeBasic {
18481847
attributes: number;
18491848
/**
18501849
* The *shallow size* of the heap object (i.e., the size of memory that is held
1851-
* by the object itself.). For difference between **shallow size** and
1850+
* by the object itself). For difference between **shallow size** and
18521851
* **retained size**, check out
18531852
* [this doc](https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#object_sizes).
18541853
*/
@@ -1861,22 +1860,22 @@ export interface IHeapNode extends IHeapNodeBasic {
18611860
/** @internal */
18621861
trace_node_id: number;
18631862
/**
1864-
* Get a JS array containing all outgoing JS references from this heap object
1863+
* Gets a JS array containing all outgoing JS references from this heap object
18651864
* (including engine-internal, native, and JS references).
18661865
*/
18671866
references: IHeapEdge[];
18681867
/**
1869-
* Get a JS array containing all incoming JS references pointing to this heap
1868+
* Gets a JS array containing all incoming JS references pointing to this heap
18701869
* object (including engine-internal, native, and JS references).
18711870
*/
18721871
referrers: IHeapEdge[];
18731872
/**
1874-
* Get the number of all incoming references pointing to this heap object
1873+
* Gets the number of all incoming references pointing to this heap object
18751874
* (including engine-internal, native, and JS references).
18761875
*/
18771876
numOfReferrers: number;
18781877
/**
1879-
* returns true if the heap node has been set an incoming edge
1878+
* Returns true if the heap node has been set an incoming edge
18801879
* which leads to the parent node on the shortest path to GC root.
18811880
*/
18821881
hasPathEdge: boolean;
@@ -1886,7 +1885,7 @@ export interface IHeapNode extends IHeapNodeBasic {
18861885
*/
18871886
pathEdge: IHeapEdge | null;
18881887
/**
1889-
* index of this heap object inside the `node.snapshot.nodes` pseudo array
1888+
* Index of this heap object inside the `node.snapshot.nodes` pseudo array.
18901889
*/
18911890
nodeIndex: number;
18921891
/**
@@ -1897,42 +1896,41 @@ export interface IHeapNode extends IHeapNodeBasic {
18971896
*/
18981897
retainedSize: number;
18991898
/**
1900-
* get the dominator node of this node. If the dominator node gets released
1899+
* Gets the dominator node of this node. If the dominator node gets released
19011900
* there will be no path from GC to this node, and therefore this node can
19021901
* also be released.
19031902
* For more information on what a dominator node is, please check out
19041903
* [this doc](https://developer.chrome.com/docs/devtools/memory-problems/memory-101/#dominators).
19051904
*/
19061905
dominatorNode: Nullable<IHeapNode>;
19071906
/**
1908-
* source location information of this heap object (if it is recorded by
1907+
* Source location information of this heap object (if it is recorded by
19091908
* the heap snapshot).
19101909
*/
19111910
location: Nullable<IHeapLocation>;
19121911
/** @internal */
19131912
highlight?: boolean;
19141913
/**
1915-
* check if this a string node (normal string node, concatenated string node
1916-
* or sliced string node)
1914+
* Checks if this is a string node (normal string node, concatenated string node
1915+
* or sliced string node).
19171916
*/
19181917
isString: boolean;
19191918
/**
1920-
* convert to an {@link IHeapStringNode} object if this node is a string node.
1919+
* Converts to an {@link IHeapStringNode} object if this node is a string node.
19211920
* The {@link IHeapStringNode} object supports querying the string content
19221921
* inside the string node.
19231922
*/
19241923
toStringNode(): Nullable<IHeapStringNode>;
19251924
/**
1926-
* convert to a concise readable object that can be used for serialization
1925+
* Converts to a concise readable object that can be used for serialization
19271926
* (like calling `JSON.stringify(node, ...args)`).
19281927
*
19291928
* This API does not contain all the information
19301929
* captured by the hosting object.
19311930
*/
1932-
19331931
getJSONifyableObject(): AnyRecord;
19341932
/**
1935-
* convert to a concise readable string output
1933+
* Converts to a concise readable string output
19361934
* (like calling `JSON.stringify(node, ...args)`).
19371935
*
19381936
* Note: Please be aware that using `JSON.stringify(node, ...args)` is
@@ -1945,8 +1943,8 @@ export interface IHeapNode extends IHeapNodeBasic {
19451943
*/
19461944
toJSONString(...args: Array<AnyValue>): string;
19471945
/**
1948-
* executes a provided callback once for each JavaScript reference in the
1949-
* hosting node (or outgoing edges from the node)
1946+
* Executes a provided callback once for each JavaScript reference in the
1947+
* hosting node (or outgoing edges from the node).
19501948
* @param callback the callback for each outgoing JavaScript reference
19511949
* @returns this API returns void
19521950
*
@@ -1963,8 +1961,8 @@ export interface IHeapNode extends IHeapNodeBasic {
19631961
*/
19641962
forEachReference(callback: EdgeIterationCallback): void;
19651963
/**
1966-
* executes a provided callback once for each JavaScript reference pointing
1967-
* to the hosting node (or incoming edges to the node)
1964+
* Executes a provided callback once for each JavaScript reference pointing
1965+
* to the hosting node (or incoming edges to the node).
19681966
* @param callback the callback for each incoming JavaScript reference
19691967
* @returns this API returns void
19701968
*
@@ -1981,9 +1979,9 @@ export interface IHeapNode extends IHeapNodeBasic {
19811979
*/
19821980
forEachReferrer(callback: EdgeIterationCallback): void;
19831981
/**
1984-
* executes a provided predicate callback once for each JavaScript reference
1982+
* Executes a provided predicate callback once for each JavaScript reference
19851983
* in the hosting node (or outgoing edges from the node) until the predicate
1986-
* returns `true`
1984+
* returns `true`.
19871985
* @param predicate the callback for each outgoing JavaScript reference
19881986
* @returns the first outgoing edge for which the predicate returns `true`,
19891987
* otherwise returns `null` if no such edge is found.
@@ -1998,9 +1996,9 @@ export interface IHeapNode extends IHeapNodeBasic {
19981996
*/
19991997
findAnyReference: (predicate: Predicator<IHeapEdge>) => Nullable<IHeapEdge>;
20001998
/**
2001-
* executes a provided predicate callback once for each JavaScript reference
1999+
* Executes a provided predicate callback once for each JavaScript reference
20022000
* pointing to the hosting node (or incoming edges to the node) until the
2003-
* predicate returns `true`
2001+
* predicate returns `true`.
20042002
* @param predicate the callback for each incoming JavaScript reference
20052003
* @returns the first incoming edge for which the predicate returns `true`,
20062004
* otherwise returns `null` if no such edge is found.
@@ -2015,10 +2013,10 @@ export interface IHeapNode extends IHeapNodeBasic {
20152013
*/
20162014
findAnyReferrer: (predicate: Predicator<IHeapEdge>) => Nullable<IHeapEdge>;
20172015
/**
2018-
* executes a provided predicate callback once for each JavaScript heap
2016+
* Executes a provided predicate callback once for each JavaScript heap
20192017
* object (heap graph node) pointing to the hosting node
20202018
* (or nodes having edges to the hosting node) until the predicate
2021-
* returns `true`
2019+
* returns `true`.
20222020
* @param predicate the callback for each incoming JavaScript heap object
20232021
* @returns the first referring node for which the predicate returns `true`,
20242022
* otherwise returns `null` if no such node is found.
@@ -2033,8 +2031,8 @@ export interface IHeapNode extends IHeapNodeBasic {
20332031
*/
20342032
findAnyReferrerNode(predicate: Predicator<IHeapNode>): Nullable<IHeapNode>;
20352033
/**
2036-
* executes a provided predicate callback once for each JavaScript reference
2037-
* pointing to the hosting node (or incoming edges to the node)
2034+
* Executes a provided predicate callback once for each JavaScript reference
2035+
* pointing to the hosting node (or incoming edges to the node).
20382036
* @param predicate the callback for each incoming JavaScript reference
20392037
* @returns an array containing all the incoming edges for which the
20402038
* predicate returns `true`, otherwise returns an empty array if no such
@@ -2050,9 +2048,9 @@ export interface IHeapNode extends IHeapNodeBasic {
20502048
*/
20512049
findReferrers: (predicate: Predicator<IHeapEdge>) => IHeapEdge[];
20522050
/**
2053-
* executes a provided predicate callback once for each JavaScript heap
2051+
* Executes a provided predicate callback once for each JavaScript heap
20542052
* object (heap graph node) pointing to the hosting node
2055-
* (or nodes having edges to the hosting node)
2053+
* (or nodes having edges to the hosting node).
20562054
* @param predicate the callback for each referrer nodes
20572055
* @returns an array containing all the referrer nodes for which the
20582056
* predicate returns `true`, otherwise returns an empty array if no such
@@ -2150,7 +2148,7 @@ export interface IHeapNode extends IHeapNodeBasic {
21502148
) => Nullable<IHeapNode>;
21512149
/**
21522150
* Given a JS reference's name and type, this API finds all the incoming JS
2153-
* reference pointing to the hosting node.
2151+
* references pointing to the hosting node.
21542152
* @param edgeName the name of the incoming JavaScript reference
21552153
* @param edgeType optional parameter specifying the type of the incoming
21562154
* JavaScript reference
@@ -2159,7 +2157,7 @@ export interface IHeapNode extends IHeapNodeBasic {
21592157
*
21602158
* * **Examples**:
21612159
* ```typescript
2162-
* // find all of of the JS reference named "ref" pointing to node
2160+
* // find all of the JS references named "ref" pointing to node
21632161
* const referrers = node.getReferrers('ref', 'property');
21642162
* ```
21652163
*/
@@ -2176,7 +2174,7 @@ export interface IHeapNode extends IHeapNodeBasic {
21762174
*
21772175
* * **Examples**:
21782176
* ```typescript
2179-
* // find all of the JS heap object with a JS reference
2177+
* // find all of the JS heap objects with a JS reference
21802178
* // named "ref" pointing to node
21812179
* const nodes1 = node.getReferrerNodes('ref', 'property');
21822180
* // this is equivalent to
@@ -2212,7 +2210,7 @@ export interface IHeapNode extends IHeapNodeBasic {
22122210
* // iterate over each node (heap object)
22132211
* heap.nodes.forEach((node: IHeapNode, i: number) => {
22142212
* if (node.isString) {
2215-
* const stringNode: IheapStringNode = node.toStringNode();
2213+
* const stringNode: IHeapStringNode = node.toStringNode();
22162214
* // get the string value
22172215
* stringNode.stringValue;
22182216
* }
@@ -2222,8 +2220,8 @@ export interface IHeapNode extends IHeapNodeBasic {
22222220
*/
22232221
export interface IHeapStringNode extends IHeapNode {
22242222
/**
2225-
* get the string value of the JS string heap object associated with
2226-
* this `IHeapStringNode` instance in heap
2223+
* Gets the string value of the JS string heap object associated with
2224+
* this `IHeapStringNode` instance in heap.
22272225
*/
22282226
stringValue: string;
22292227
}
@@ -2264,15 +2262,15 @@ export interface IHeapNodes {
22642262
*/
22652263
length: number;
22662264
/**
2267-
* get an {@link IHeapNode} element at the specified index
2265+
* Gets an {@link IHeapNode} element at the specified index.
22682266
* @param index the index of an element in the pseudo array, the index ranges
22692267
* from 0 to array length - 1. Notice that this is not the heap node id.
22702268
* @returns When 0 <= `index` < array.length, this API returns the element
22712269
* at the specified index, otherwise it returns `null`.
22722270
*/
22732271
get(index: number): Nullable<IHeapNode>;
22742272
/**
2275-
* Iterate over all array elements and apply the callback
2273+
* Iterates over all array elements and applies the callback
22762274
* to each element in ascending order of element index.
22772275
* @param callback the callback does not need to return any value, if
22782276
* the callback returns `false` when iterating on element at index `i`,
@@ -2287,22 +2285,31 @@ export interface IHeapNodes {
22872285

22882286
/** @internal */
22892287
export type HeapNodeFields = string[];
2288+
22902289
/** @internal */
22912290
export type HeapNodeTypes = string[];
2291+
22922292
/** @internal */
22932293
export type RawHeapNodeTypes = Array<HeapNodeTypes | string>;
2294+
22942295
/** @internal */
22952296
export type HeapEdgeFields = string[];
2297+
22962298
/** @internal */
22972299
export type HeapEdgeTypes = string[] | string;
2300+
22982301
/** @internal */
22992302
export type RawHeapEdgeTypes = Array<HeapEdgeTypes | string>;
2303+
23002304
/** @internal */
23012305
export type HeapTraceFunctionInfoFields = string[];
2306+
23022307
/** @internal */
23032308
export type HeapTraceNodeFields = string[];
2309+
23042310
/** @internal */
23052311
export type HeapSampleFields = string[];
2312+
23062313
/** @internal */
23072314
export type HeapLocationFields = string[];
23082315

0 commit comments

Comments
 (0)