This is similar to the `queryObjects()` console API provided by the Chromium DevTools console. It can be used to search for objects that have the matching constructor on its prototype chain in the entire heap, which can be useful for memory leak regression tests. To avoid surprising results, users should avoid using this API on constructors whose implementation they don't control, or on constructors that can be invoked by other parties in the application. To avoid accidental leaks, this API does not return raw references to the objects found. By default, it returns the count of the objects found. If `options.format` is `'summary'`, it returns an array containing brief string representations for each object. The visibility provided in this API is similar to what the heap snapshot provides, while users can save the cost of serialization and parsing and directly filer the target objects during the search. We have been using this API internally for the test suite, which has been more stable than any other leak regression testing strategies in the CI. With a public implementation we can now use the public API instead. PR-URL: https://github.com/nodejs/node/pull/51927 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Documentation style guide
This style guide helps us create organized and easy-to-read documentation. It provides guidelines for organization, spelling, formatting, and more.
These are guidelines rather than strict rules. Content is more important than formatting. You do not need to learn the entire style guide before contributing to documentation. Someone can always edit your material later to conform with this guide.
- Documentation is in markdown files with names formatted as
lowercase-with-dashes.md.- Use an underscore in the filename only if the underscore is part of the
topic name (e.g.,
child_process). - Some files, such as top-level markdown files, are exceptions.
- Use an underscore in the filename only if the underscore is part of the
topic name (e.g.,
- Documents should be word-wrapped at 80 characters.
.editorconfigdescribes the preferred formatting.- A plugin is available for some editors to apply these rules.
- Check changes to documentation with
make test-doc -jorvcbuild test-doc. - Use US spelling.
- Use serial commas.
- Avoid first-person pronouns (I, we).
- Exception: we recommend foo is preferable to foo is recommended.
- Use gender-neutral pronouns and gender-neutral plural nouns.
- OK: they, their, them, folks, people, developers
- NOT OK: his, hers, him, her, guys, dudes
- When combining wrapping elements (parentheses and quotes), place terminal
punctuation:
- Inside the wrapping element if the wrapping element contains a complete clause.
- Outside of the wrapping element if the wrapping element contains only a fragment of a clause.
- Documents must start with a level-one heading.
- Prefer affixing links (
[a link][]) to inlining links ([a link](http://example.com)). - When documenting APIs, update the YAML comment associated with the API as appropriate. This is especially true when introducing or deprecating an API.
- When documenting APIs, every function should have a usage example or link to an example that uses the function.
- For code blocks:
-
Use language-aware fences. (
```js) -
For the info string, use one of the following.
Meaning Info string Bash bashC cC++ cppCoffeeScript coffeeDiff diffHTTP httpJavaScript jsJSON jsonMarkdown markdownPlaintext textPowershell powershellR rShell Session consoleIf one of your language-aware fences needs an info string that is not already on this list, you may use
textuntil the grammar gets added toremark-preset-lint-node. -
Code need not be complete. Treat code blocks as an illustration or aid to your point, not as complete running programs. If a complete running program is necessary, include it as an asset in
assets/code-examplesand link to it.
-
- When using underscores, asterisks, and backticks, please use
backslash-escaping:
\_,\*, and\`. - Constructors should use PascalCase.
- Instances should use camelCase.
- Denote methods with parentheses:
socket.end()instead ofsocket.end. - Function arguments or object properties should use the following format:
* `name` {type|type2} Optional description. **Default:** `value`.
- For example:
*byteOffset{integer} Index of first byte to expose. Default:0.
- The
typeshould refer to a Node.js type or a JavaScript type.
- Function returns should use the following format:
* Returns: {type|type2} Optional description.- E.g.
* Returns: {AsyncHook} A reference toasyncHook.
- Use official styling for capitalization in products and projects.
- OK: JavaScript, Google's V8
- NOT OK: Javascript, Google's v8
- Use Node.js and not Node, NodeJS, or similar variants.
- When referring to the executable,
nodeis acceptable.
- When referring to the executable,
- Be direct.
- When referring to a version of Node.js in prose, use Node.js and the version
number. Do not prefix the version number with v in prose. This is to avoid
confusion about whether v8 refers to Node.js 8.x or the V8 JavaScript
engine.
- OK: Node.js 14.x, Node.js 14.3.1
- NOT OK: Node.js v14
- Use sentence-style capitalization for headings.
See also API documentation structure overview in doctools README.
For topics not covered here, refer to the Microsoft Writing Style Guide.