{ "source": "doc/api/util.md", "modules": [ { "textRaw": "Util", "name": "util", "introduced_in": "v0.10.0", "stability": 2, "stabilityText": "Stable", "desc": "

The util module is primarily designed to support the needs of Node.js' own\ninternal APIs. However, many of the utilities are useful for application and\nmodule developers as well. It can be accessed using:

\n
const util = require('util');\n
\n", "methods": [ { "textRaw": "util.callbackify(original)", "type": "method", "name": "callbackify", "meta": { "added": [ "v8.2.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {Function} a callback style function ", "name": "return", "type": "Function", "desc": "a callback style function" }, "params": [ { "textRaw": "`original` {Function} An `async` function ", "name": "original", "type": "Function", "desc": "An `async` function" } ] }, { "params": [ { "name": "original" } ] } ], "desc": "

Takes an async function (or a function that returns a Promise) and returns a\nfunction following the error-first callback style, i.e. taking\na (err, value) => ... callback as the last argument. In the callback, the\nfirst argument will be the rejection reason (or null if the Promise\nresolved), and the second argument will be the resolved value.

\n
const util = require('util');\n\nasync function fn() {\n  return 'hello world';\n}\nconst callbackFunction = util.callbackify(fn);\n\ncallbackFunction((err, ret) => {\n  if (err) throw err;\n  console.log(ret);\n});\n
\n

Will print:

\n
hello world\n
\n

The callback is executed asynchronously, and will have a limited stack trace.\nIf the callback throws, the process will emit an 'uncaughtException'\nevent, and if not handled will exit.

\n

Since null has a special meaning as the first argument to a callback, if a\nwrapped function rejects a Promise with a falsy value as a reason, the value\nis wrapped in an Error with the original value stored in a field named\nreason.

\n
  function fn() {\n    return Promise.reject(null);\n  }\n  const callbackFunction = util.callbackify(fn);\n\n  callbackFunction((err, ret) => {\n    // When the Promise was rejected with `null` it is wrapped with an Error and\n    // the original value is stored in `reason`.\n    err && err.hasOwnProperty('reason') && err.reason === null;  // true\n  });\n
\n" }, { "textRaw": "util.debuglog(section)", "type": "method", "name": "debuglog", "meta": { "added": [ "v0.11.3" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {Function} The logging function ", "name": "return", "type": "Function", "desc": "The logging function" }, "params": [ { "textRaw": "`section` {string} A string identifying the portion of the application for which the `debuglog` function is being created. ", "name": "section", "type": "string", "desc": "A string identifying the portion of the application for which the `debuglog` function is being created." } ] }, { "params": [ { "name": "section" } ] } ], "desc": "

The util.debuglog() method is used to create a function that conditionally\nwrites debug messages to stderr based on the existence of the NODE_DEBUG\nenvironment variable. If the section name appears within the value of that\nenvironment variable, then the returned function operates similar to\nconsole.error(). If not, then the returned function is a no-op.

\n
const util = require('util');\nconst debuglog = util.debuglog('foo');\n\ndebuglog('hello from foo [%d]', 123);\n
\n

If this program is run with NODE_DEBUG=foo in the environment, then\nit will output something like:

\n
FOO 3245: hello from foo [123]\n
\n

where 3245 is the process id. If it is not run with that\nenvironment variable set, then it will not print anything.

\n

The section supports wildcard also:

\n
const util = require('util');\nconst debuglog = util.debuglog('foo-bar');\n\ndebuglog('hi there, it\\'s foo-bar [%d]', 2333);\n
\n

if it is run with NODE_DEBUG=foo* in the environment, then it will output \nsomething like:

\n
FOO-BAR 3257: hi there, it's foo-bar [2333]\n
\n

Multiple comma-separated section names may be specified in the NODE_DEBUG\nenvironment variable: NODE_DEBUG=fs,net,tls.

\n" }, { "textRaw": "util.deprecate(function, string)", "type": "method", "name": "deprecate", "meta": { "added": [ "v0.8.0" ], "changes": [] }, "desc": "

The util.deprecate() method wraps the given function or class in such a way \nthat it is marked as deprecated.

\n\n
const util = require('util');\n\nexports.obsoleteFunction = util.deprecate(() => {\n  // Do something here.\n}, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');\n
\n

When called, util.deprecate() will return a function that will emit a\nDeprecationWarning using the process.on('warning') event. By default,\nthis warning will be emitted and printed to stderr exactly once, the first\ntime it is called. After the warning is emitted, the wrapped function\nis called.

\n

If either the --no-deprecation or --no-warnings command line flags are\nused, or if the process.noDeprecation property is set to true prior to\nthe first deprecation warning, the util.deprecate() method does nothing.

\n

If the --trace-deprecation or --trace-warnings command line flags are set,\nor the process.traceDeprecation property is set to true, a warning and a\nstack trace are printed to stderr the first time the deprecated function is\ncalled.

\n

If the --throw-deprecation command line flag is set, or the\nprocess.throwDeprecation property is set to true, then an exception will be\nthrown when the deprecated function is called.

\n

The --throw-deprecation command line flag and process.throwDeprecation\nproperty take precedence over --trace-deprecation and\nprocess.traceDeprecation.

\n", "signatures": [ { "params": [ { "name": "function" }, { "name": "string" } ] } ] }, { "textRaw": "util.format(format[, ...args])", "type": "method", "name": "format", "meta": { "added": [ "v0.5.3" ], "changes": [ { "version": "v8.4.0", "pr-url": "https://github.com/nodejs/node/pull/14558", "description": "The `%o` and `%O` specifiers are supported now." } ] }, "signatures": [ { "params": [ { "textRaw": "`format` {string} A `printf`-like format string. ", "name": "format", "type": "string", "desc": "A `printf`-like format string." }, { "name": "...args", "optional": true } ] }, { "params": [ { "name": "format" }, { "name": "...args", "optional": true } ] } ], "desc": "

The util.format() method returns a formatted string using the first argument\nas a printf-like format.

\n

The first argument is a string containing zero or more placeholder tokens.\nEach placeholder token is replaced with the converted value from the\ncorresponding argument. Supported placeholders are:

\n\n

If the placeholder does not have a corresponding argument, the placeholder is\nnot replaced.

\n
util.format('%s:%s', 'foo');\n// Returns: 'foo:%s'\n
\n

If there are more arguments passed to the util.format() method than the number\nof placeholders, the extra arguments are coerced into strings then concatenated\nto the returned string, each delimited by a space. Excessive arguments whose\ntypeof is 'object' or 'symbol' (except null) will be transformed by\nutil.inspect().

\n
util.format('%s:%s', 'foo', 'bar', 'baz'); // 'foo:bar baz'\n
\n

If the first argument is not a string then util.format() returns\na string that is the concatenation of all arguments separated by spaces.\nEach argument is converted to a string using util.inspect().

\n
util.format(1, 2, 3); // '1 2 3'\n
\n

If only one argument is passed to util.format(), it is returned as it is\nwithout any formatting.

\n
util.format('%% %s'); // '%% %s'\n
\n

Please note that util.format() is a synchronous method that is mainly\nintended as a debugging tool. Some input values can have a significant\nperformance overhead that can block the event loop. Use this function\nwith care and never in a hot code path.

\n" }, { "textRaw": "util.getSystemErrorName(err)", "type": "method", "name": "getSystemErrorName", "meta": { "added": [ "v9.7.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {string} ", "name": "return", "type": "string" }, "params": [ { "textRaw": "`err` {number} ", "name": "err", "type": "number" } ] }, { "params": [ { "name": "err" } ] } ], "desc": "

Returns the string name for a numeric error code that comes from a Node.js API.\nThe mapping between error codes and error names is platform-dependent.\nSee Common System Errors for the names of common errors.

\n
fs.access('file/that/does/not/exist', (err) => {\n  const name = util.getSystemErrorName(err.errno);\n  console.error(name);  // ENOENT\n});\n
\n" }, { "textRaw": "util.inherits(constructor, superConstructor)", "type": "method", "name": "inherits", "meta": { "added": [ "v0.3.0" ], "changes": [ { "version": "v5.0.0", "pr-url": "https://github.com/nodejs/node/pull/3455", "description": "The `constructor` parameter can refer to an ES6 class now." } ] }, "desc": "

Usage of util.inherits() is discouraged. Please use the ES6 class and\nextends keywords to get language level inheritance support. Also note\nthat the two styles are semantically incompatible.

\n\n

Inherit the prototype methods from one constructor into another. The\nprototype of constructor will be set to a new object created from\nsuperConstructor.

\n

As an additional convenience, superConstructor will be accessible\nthrough the constructor.super_ property.

\n
const util = require('util');\nconst EventEmitter = require('events');\n\nfunction MyStream() {\n  EventEmitter.call(this);\n}\n\nutil.inherits(MyStream, EventEmitter);\n\nMyStream.prototype.write = function(data) {\n  this.emit('data', data);\n};\n\nconst stream = new MyStream();\n\nconsole.log(stream instanceof EventEmitter); // true\nconsole.log(MyStream.super_ === EventEmitter); // true\n\nstream.on('data', (data) => {\n  console.log(`Received data: "${data}"`);\n});\nstream.write('It works!'); // Received data: "It works!"\n
\n

ES6 example using class and extends

\n
const EventEmitter = require('events');\n\nclass MyStream extends EventEmitter {\n  write(data) {\n    this.emit('data', data);\n  }\n}\n\nconst stream = new MyStream();\n\nstream.on('data', (data) => {\n  console.log(`Received data: "${data}"`);\n});\nstream.write('With ES6');\n
\n", "signatures": [ { "params": [ { "name": "constructor" }, { "name": "superConstructor" } ] } ] }, { "textRaw": "util.inspect(object[, options])", "type": "method", "name": "inspect", "meta": { "added": [ "v0.3.0" ], "changes": [ { "version": "v9.9.0", "pr-url": "https://github.com/nodejs/node/pull/17576", "description": "The `compact` option is supported now." }, { "version": "v6.6.0", "pr-url": "https://github.com/nodejs/node/pull/8174", "description": "Custom inspection functions can now return `this`." }, { "version": "v6.3.0", "pr-url": "https://github.com/nodejs/node/pull/7499", "description": "The `breakLength` option is supported now." }, { "version": "v6.1.0", "pr-url": "https://github.com/nodejs/node/pull/6334", "description": "The `maxArrayLength` option is supported now; in particular, long arrays are truncated by default." }, { "version": "v6.1.0", "pr-url": "https://github.com/nodejs/node/pull/6465", "description": "The `showProxy` option is supported now." } ] }, "signatures": [ { "params": [ { "textRaw": "`object` {any} Any JavaScript primitive or Object. ", "name": "object", "type": "any", "desc": "Any JavaScript primitive or Object." }, { "textRaw": "`options` {Object} ", "options": [ { "textRaw": "`showHidden` {boolean} If `true`, the `object`'s non-enumerable symbols and properties will be included in the formatted result. Defaults to `false`. ", "name": "showHidden", "type": "boolean", "desc": "If `true`, the `object`'s non-enumerable symbols and properties will be included in the formatted result. Defaults to `false`." }, { "textRaw": "`depth` {number} Specifies the number of times to recurse while formatting the `object`. This is useful for inspecting large complicated objects. Defaults to `2`. To make it recurse indefinitely pass `null`. ", "name": "depth", "type": "number", "desc": "Specifies the number of times to recurse while formatting the `object`. This is useful for inspecting large complicated objects. Defaults to `2`. To make it recurse indefinitely pass `null`." }, { "textRaw": "`colors` {boolean} If `true`, the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see [Customizing `util.inspect` colors][]. ", "name": "colors", "type": "boolean", "desc": "If `true`, the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see [Customizing `util.inspect` colors][]." }, { "textRaw": "`customInspect` {boolean} If `false`, then custom `inspect(depth, opts)` functions will not be called. Defaults to `true`. ", "name": "customInspect", "type": "boolean", "desc": "If `false`, then custom `inspect(depth, opts)` functions will not be called. Defaults to `true`." }, { "textRaw": "`showProxy` {boolean} If `true`, then objects and functions that are `Proxy` objects will be introspected to show their `target` and `handler` objects. Defaults to `false`. ", "name": "showProxy", "type": "boolean", "desc": "If `true`, then objects and functions that are `Proxy` objects will be introspected to show their `target` and `handler` objects. Defaults to `false`." }, { "textRaw": "`maxArrayLength` {number} Specifies the maximum number of array and `TypedArray` elements to include when formatting. Defaults to `100`. Set to `null` to show all array elements. Set to `0` or negative to show no array elements. ", "name": "maxArrayLength", "type": "number", "desc": "Specifies the maximum number of array and `TypedArray` elements to include when formatting. Defaults to `100`. Set to `null` to show all array elements. Set to `0` or negative to show no array elements." }, { "textRaw": "`breakLength` {number} The length at which an object's keys are split across multiple lines. Set to `Infinity` to format an object as a single line. Defaults to 60 for legacy compatibility. ", "name": "breakLength", "type": "number", "desc": "The length at which an object's keys are split across multiple lines. Set to `Infinity` to format an object as a single line. Defaults to 60 for legacy compatibility." }, { "textRaw": "`compact` {boolean} Setting this to `false` changes the default indentation to use a line break for each object key instead of lining up multiple properties in one line. It will also break text that is above the `breakLength` size into smaller and better readable chunks and indents objects the same as arrays. Note that no text will be reduced below 16 characters, no matter the `breakLength` size. For more information, see the example below. Defaults to `true`. ", "name": "compact", "type": "boolean", "desc": "Setting this to `false` changes the default indentation to use a line break for each object key instead of lining up multiple properties in one line. It will also break text that is above the `breakLength` size into smaller and better readable chunks and indents objects the same as arrays. Note that no text will be reduced below 16 characters, no matter the `breakLength` size. For more information, see the example below. Defaults to `true`." } ], "name": "options", "type": "Object", "optional": true } ] }, { "params": [ { "name": "object" }, { "name": "options", "optional": true } ] } ], "desc": "

The util.inspect() method returns a string representation of object that is\nprimarily useful for debugging. Additional options may be passed that alter\ncertain aspects of the formatted string.

\n

The following example inspects all properties of the util object:

\n
const util = require('util');\n\nconsole.log(util.inspect(util, { showHidden: true, depth: null }));\n
\n

Values may supply their own custom inspect(depth, opts) functions, when\ncalled these receive the current depth in the recursive inspection, as well as\nthe options object passed to util.inspect().

\n

The following example highlights the difference with the compact option:

\n
const util = require('util');\n\nconst o = {\n  a: [1, 2, [[\n    'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ' +\n      'eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n    'test',\n    'foo']], 4],\n  b: new Map([['za', 1], ['zb', 'test']])\n};\nconsole.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));\n\n// This will print\n\n// { a:\n//   [ 1,\n//     2,\n//     [ [ 'Lorem ipsum dolor sit amet, consectetur [...]', // A long line\n//           'test',\n//           'foo' ] ],\n//     4 ],\n//   b: Map { 'za' => 1, 'zb' => 'test' } }\n\n// Setting `compact` to false changes the output to be more reader friendly.\nconsole.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));\n\n// {\n//   a: [\n//     1,\n//     2,\n//     [\n//       [\n//         'Lorem ipsum dolor sit amet, consectetur ' +\n//           'adipiscing elit, sed do eiusmod tempor ' +\n//           'incididunt ut labore et dolore magna ' +\n//           'aliqua.,\n//         'test',\n//         'foo'\n//       ]\n//     ],\n//     4\n//   ],\n//   b: Map {\n//     'za' => 1,\n//     'zb' => 'test'\n//   }\n// }\n\n// Setting `breakLength` to e.g. 150 will print the "Lorem ipsum" text in a\n// single line.\n// Reducing the `breakLength` will split the "Lorem ipsum" text in smaller\n// chunks.\n
\n

Please note that util.inspect() is a synchronous method that is mainly\nintended as a debugging tool. Some input values can have a significant\nperformance overhead that can block the event loop. Use this function\nwith care and never in a hot code path.

\n", "miscs": [ { "textRaw": "Customizing `util.inspect` colors", "name": "Customizing `util.inspect` colors", "type": "misc", "desc": "

Color output (if enabled) of util.inspect is customizable globally\nvia the util.inspect.styles and util.inspect.colors properties.

\n

util.inspect.styles is a map associating a style name to a color from\nutil.inspect.colors.

\n

The default styles and associated colors are:

\n\n

The predefined color codes are: white, grey, black, blue, cyan,\ngreen, magenta, red and yellow. There are also bold, italic,\nunderline and inverse codes.

\n

Color styling uses ANSI control codes that may not be supported on all\nterminals.

\n" }, { "textRaw": "Custom inspection functions on Objects", "name": "Custom inspection functions on Objects", "type": "misc", "desc": "

Objects may also define their own [util.inspect.custom](depth, opts)\n(or the equivalent but deprecated inspect(depth, opts)) function that\nutil.inspect() will invoke and use the result of when inspecting the object:

\n
const util = require('util');\n\nclass Box {\n  constructor(value) {\n    this.value = value;\n  }\n\n  [util.inspect.custom](depth, options) {\n    if (depth < 0) {\n      return options.stylize('[Box]', 'special');\n    }\n\n    const newOptions = Object.assign({}, options, {\n      depth: options.depth === null ? null : options.depth - 1\n    });\n\n    // Five space padding because that's the size of "Box< ".\n    const padding = ' '.repeat(5);\n    const inner = util.inspect(this.value, newOptions)\n                      .replace(/\\n/g, `\\n${padding}`);\n    return `${options.stylize('Box', 'special')}< ${inner} >`;\n  }\n}\n\nconst box = new Box(true);\n\nutil.inspect(box);\n// Returns: "Box< true >"\n
\n

Custom [util.inspect.custom](depth, opts) functions typically return a string\nbut may return a value of any type that will be formatted accordingly by\nutil.inspect().

\n
const util = require('util');\n\nconst obj = { foo: 'this will not show up in the inspect() output' };\nobj[util.inspect.custom] = (depth) => {\n  return { bar: 'baz' };\n};\n\nutil.inspect(obj);\n// Returns: "{ bar: 'baz' }"\n
\n" } ], "modules": [ { "textRaw": "util.inspect.custom", "name": "util.inspect.custom", "meta": { "added": [ "v6.6.0" ], "changes": [] }, "desc": "

A Symbol that can be used to declare custom inspect functions, see\nCustom inspection functions on Objects.

\n", "type": "module", "displayName": "util.inspect.custom" }, { "textRaw": "util.inspect.defaultOptions", "name": "util.inspect.defaultoptions", "meta": { "added": [ "v6.4.0" ], "changes": [] }, "desc": "

The defaultOptions value allows customization of the default options used by\nutil.inspect. This is useful for functions like console.log or\nutil.format which implicitly call into util.inspect. It shall be set to an\nobject containing one or more valid util.inspect() options. Setting\noption properties directly is also supported.

\n
const util = require('util');\nconst arr = Array(101).fill(0);\n\nconsole.log(arr); // logs the truncated array\nutil.inspect.defaultOptions.maxArrayLength = null;\nconsole.log(arr); // logs the full array\n
\n", "type": "module", "displayName": "util.inspect.defaultOptions" } ] }, { "textRaw": "util.isDeepStrictEqual(val1, val2)", "type": "method", "name": "isDeepStrictEqual", "meta": { "added": [ "v9.0.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`val1` {any} ", "name": "val1", "type": "any" }, { "textRaw": "`val2` {any} ", "name": "val2", "type": "any" } ] }, { "params": [ { "name": "val1" }, { "name": "val2" } ] } ], "desc": "

Returns true if there is deep strict equality between val1 and val2.\nOtherwise, returns false.

\n

See assert.deepStrictEqual() for more information about deep strict\nequality.

\n" }, { "textRaw": "util.promisify(original)", "type": "method", "name": "promisify", "meta": { "added": [ "v8.0.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {Function} ", "name": "return", "type": "Function" }, "params": [ { "textRaw": "`original` {Function} ", "name": "original", "type": "Function" } ] }, { "params": [ { "name": "original" } ] } ], "desc": "

Takes a function following the common error-first callback style, i.e. taking\na (err, value) => ... callback as the last argument, and returns a version\nthat returns promises.

\n
const util = require('util');\nconst fs = require('fs');\n\nconst stat = util.promisify(fs.stat);\nstat('.').then((stats) => {\n  // Do something with `stats`\n}).catch((error) => {\n  // Handle the error.\n});\n
\n

Or, equivalently using async functions:

\n
const util = require('util');\nconst fs = require('fs');\n\nconst stat = util.promisify(fs.stat);\n\nasync function callStat() {\n  const stats = await stat('.');\n  console.log(`This directory is owned by ${stats.uid}`);\n}\n
\n

If there is an original[util.promisify.custom] property present, promisify\nwill return its value, see Custom promisified functions.

\n

promisify() assumes that original is a function taking a callback as its\nfinal argument in all cases. If original is not a function, promisify()\nwill throw an error. If original is a function but its last argument is not\nan error-first callback, it will still be passed an error-first\ncallback as its last argument.

\n", "modules": [ { "textRaw": "Custom promisified functions", "name": "custom_promisified_functions", "desc": "

Using the util.promisify.custom symbol one can override the return value of\nutil.promisify():

\n
const util = require('util');\n\nfunction doSomething(foo, callback) {\n  // ...\n}\n\ndoSomething[util.promisify.custom] = (foo) => {\n  return getPromiseSomehow();\n};\n\nconst promisified = util.promisify(doSomething);\nconsole.log(promisified === doSomething[util.promisify.custom]);\n// prints 'true'\n
\n

This can be useful for cases where the original function does not follow the\nstandard format of taking an error-first callback as the last argument.

\n

For example, with a function that takes in (foo, onSuccessCallback, \nonErrorCallback):

\n
doSomething[util.promisify.custom] = (foo) => {\n  return new Promise((resolve, reject) => {\n    doSomething(foo, resolve, reject);\n  });\n};\n
\n

If promisify.custom is defined but is not a function, promisify() will\nthrow an error.

\n", "type": "module", "displayName": "Custom promisified functions" }, { "textRaw": "util.promisify.custom", "name": "util.promisify.custom", "meta": { "added": [ "v8.0.0" ], "changes": [] }, "desc": "\n

A Symbol that can be used to declare custom promisified variants of functions,\nsee Custom promisified functions.

\n", "type": "module", "displayName": "util.promisify.custom" } ] } ], "classes": [ { "textRaw": "Class: util.TextDecoder", "type": "class", "name": "util.TextDecoder", "meta": { "added": [ "v8.3.0" ], "changes": [] }, "desc": "

An implementation of the WHATWG Encoding Standard TextDecoder API.

\n
const decoder = new TextDecoder('shift_jis');\nlet string = '';\nlet buffer;\nwhile (buffer = getNextChunkSomehow()) {\n  string += decoder.decode(buffer, { stream: true });\n}\nstring += decoder.decode(); // end-of-stream\n
\n", "modules": [ { "textRaw": "WHATWG Supported Encodings", "name": "whatwg_supported_encodings", "desc": "

Per the WHATWG Encoding Standard, the encodings supported by the\nTextDecoder API are outlined in the tables below. For each encoding,\none or more aliases may be used.

\n

Different Node.js build configurations support different sets of encodings.\nWhile a very basic set of encodings is supported even on Node.js builds without\nICU enabled, support for some encodings is provided only when Node.js is built\nwith ICU and using the full ICU data (see Internationalization).

\n", "modules": [ { "textRaw": "Encodings Supported Without ICU", "name": "encodings_supported_without_icu", "desc": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EncodingAliases
'utf-8''unicode-1-1-utf-8', 'utf8'
'utf-16le''utf-16'
\n", "type": "module", "displayName": "Encodings Supported Without ICU" }, { "textRaw": "Encodings Supported by Default (With ICU)", "name": "encodings_supported_by_default_(with_icu)", "desc": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EncodingAliases
'utf-8''unicode-1-1-utf-8', 'utf8'
'utf-16le''utf-16'
'utf-16be'
\n", "type": "module", "displayName": "Encodings Supported by Default (With ICU)" }, { "textRaw": "Encodings Requiring Full ICU Data", "name": "encodings_requiring_full_icu_data", "desc": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EncodingAliases
'ibm866''866', 'cp866', 'csibm866'
'iso-8859-2''csisolatin2', 'iso-ir-101', 'iso8859-2', 'iso88592', 'iso_8859-2', 'iso_8859-2:1987', 'l2', 'latin2'
'iso-8859-3''csisolatin3', 'iso-ir-109', 'iso8859-3', 'iso88593', 'iso_8859-3', 'iso_8859-3:1988', 'l3', 'latin3'
'iso-8859-4''csisolatin4', 'iso-ir-110', 'iso8859-4', 'iso88594', 'iso_8859-4', 'iso_8859-4:1988', 'l4', 'latin4'
'iso-8859-5''csisolatincyrillic', 'cyrillic', 'iso-ir-144', 'iso8859-5', 'iso88595', 'iso_8859-5', 'iso_8859-5:1988'
'iso-8859-6''arabic', 'asmo-708', 'csiso88596e', 'csiso88596i', 'csisolatinarabic', 'ecma-114', 'iso-8859-6-e', 'iso-8859-6-i', 'iso-ir-127', 'iso8859-6', 'iso88596', 'iso_8859-6', 'iso_8859-6:1987'
'iso-8859-7''csisolatingreek', 'ecma-118', 'elot_928', 'greek', 'greek8', 'iso-ir-126', 'iso8859-7', 'iso88597', 'iso_8859-7', 'iso_8859-7:1987', 'sun_eu_greek'
'iso-8859-8''csiso88598e', 'csisolatinhebrew', 'hebrew', 'iso-8859-8-e', 'iso-ir-138', 'iso8859-8', 'iso88598', 'iso_8859-8', 'iso_8859-8:1988', 'visual'
'iso-8859-8-i''csiso88598i', 'logical'
'iso-8859-10''csisolatin6', 'iso-ir-157', 'iso8859-10', 'iso885910', 'l6', 'latin6'
'iso-8859-13''iso8859-13', 'iso885913'
'iso-8859-14''iso8859-14', 'iso885914'
'iso-8859-15''csisolatin9', 'iso8859-15', 'iso885915', 'iso_8859-15', 'l9'
'koi8-r''cskoi8r', 'koi', 'koi8', 'koi8_r'
'koi8-u''koi8-ru'
'macintosh''csmacintosh', 'mac', 'x-mac-roman'
'windows-874''dos-874', 'iso-8859-11', 'iso8859-11', 'iso885911', 'tis-620'
'windows-1250''cp1250', 'x-cp1250'
'windows-1251''cp1251', 'x-cp1251'
'windows-1252''ansi_x3.4-1968', 'ascii', 'cp1252', 'cp819', 'csisolatin1', 'ibm819', 'iso-8859-1', 'iso-ir-100', 'iso8859-1', 'iso88591', 'iso_8859-1', 'iso_8859-1:1987', 'l1', 'latin1', 'us-ascii', 'x-cp1252'
'windows-1253''cp1253', 'x-cp1253'
'windows-1254''cp1254', 'csisolatin5', 'iso-8859-9', 'iso-ir-148', 'iso8859-9', 'iso88599', 'iso_8859-9', 'iso_8859-9:1989', 'l5', 'latin5', 'x-cp1254'
'windows-1255''cp1255', 'x-cp1255'
'windows-1256''cp1256', 'x-cp1256'
'windows-1257''cp1257', 'x-cp1257'
'windows-1258''cp1258', 'x-cp1258'
'x-mac-cyrillic''x-mac-ukrainian'
'gbk''chinese', 'csgb2312', 'csiso58gb231280', 'gb2312', 'gb_2312', 'gb_2312-80', 'iso-ir-58', 'x-gbk'
'gb18030'
'big5''big5-hkscs', 'cn-big5', 'csbig5', 'x-x-big5'
'euc-jp''cseucpkdfmtjapanese', 'x-euc-jp'
'iso-2022-jp''csiso2022jp'
'shift_jis''csshiftjis', 'ms932', 'ms_kanji', 'shift-jis', 'sjis', 'windows-31j', 'x-sjis'
'euc-kr''cseuckr', 'csksc56011987', 'iso-ir-149', 'korean', 'ks_c_5601-1987', 'ks_c_5601-1989', 'ksc5601', 'ksc_5601', 'windows-949'
\n

The 'iso-8859-16' encoding listed in the WHATWG Encoding Standard\nis not supported.

\n", "type": "module", "displayName": "Encodings Requiring Full ICU Data" } ], "type": "module", "displayName": "WHATWG Supported Encodings" } ], "methods": [ { "textRaw": "textDecoder.decode([input[, options]])", "type": "method", "name": "decode", "signatures": [ { "return": { "textRaw": "Returns: {string} ", "name": "return", "type": "string" }, "params": [ { "textRaw": "`input` {ArrayBuffer|DataView|TypedArray} An `ArrayBuffer`, `DataView` or Typed Array instance containing the encoded data. ", "name": "input", "type": "ArrayBuffer|DataView|TypedArray", "desc": "An `ArrayBuffer`, `DataView` or Typed Array instance containing the encoded data.", "optional": true }, { "textRaw": "`options` {Object} ", "options": [ { "textRaw": "`stream` {boolean} `true` if additional chunks of data are expected. Defaults to `false`. ", "name": "stream", "type": "boolean", "desc": "`true` if additional chunks of data are expected. Defaults to `false`." } ], "name": "options", "type": "Object", "optional": true } ] }, { "params": [ { "name": "input", "optional": true }, { "name": "options", "optional": true } ] } ], "desc": "

Decodes the input and returns a string. If options.stream is true, any\nincomplete byte sequences occurring at the end of the input are buffered\ninternally and emitted after the next call to textDecoder.decode().

\n

If textDecoder.fatal is true, decoding errors that occur will result in a\nTypeError being thrown.

\n" } ], "properties": [ { "textRaw": "`encoding` {string} ", "type": "string", "name": "encoding", "desc": "

The encoding supported by the TextDecoder instance.

\n" }, { "textRaw": "`fatal` {boolean} ", "type": "boolean", "name": "fatal", "desc": "

The value will be true if decoding errors result in a TypeError being\nthrown.

\n" }, { "textRaw": "`ignoreBOM` {boolean} ", "type": "boolean", "name": "ignoreBOM", "desc": "

The value will be true if the decoding result will include the byte order\nmark.

\n" } ], "signatures": [ { "params": [ { "textRaw": "`encoding` {string} Identifies the `encoding` that this `TextDecoder` instance supports. Defaults to `'utf-8'`. ", "name": "encoding", "type": "string", "desc": "Identifies the `encoding` that this `TextDecoder` instance supports. Defaults to `'utf-8'`.", "optional": true }, { "textRaw": "`options` {Object} ", "options": [ { "textRaw": "`fatal` {boolean} `true` if decoding failures are fatal. Defaults to `false`. This option is only supported when ICU is enabled (see [Internationalization][]). ", "name": "fatal", "type": "boolean", "desc": "`true` if decoding failures are fatal. Defaults to `false`. This option is only supported when ICU is enabled (see [Internationalization][])." }, { "textRaw": "`ignoreBOM` {boolean} When `true`, the `TextDecoder` will include the byte order mark in the decoded result. When `false`, the byte order mark will be removed from the output. This option is only used when `encoding` is `'utf-8'`, `'utf-16be'` or `'utf-16le'`. Defaults to `false`. ", "name": "ignoreBOM", "type": "boolean", "desc": "When `true`, the `TextDecoder` will include the byte order mark in the decoded result. When `false`, the byte order mark will be removed from the output. This option is only used when `encoding` is `'utf-8'`, `'utf-16be'` or `'utf-16le'`. Defaults to `false`." } ], "name": "options", "type": "Object", "optional": true } ], "desc": "

Creates an new TextDecoder instance. The encoding may specify one of the\nsupported encodings or an alias.

\n" }, { "params": [ { "name": "encoding", "optional": true }, { "name": "options", "optional": true } ], "desc": "

Creates an new TextDecoder instance. The encoding may specify one of the\nsupported encodings or an alias.

\n" } ] }, { "textRaw": "Class: util.TextEncoder", "type": "class", "name": "util.TextEncoder", "meta": { "added": [ "v8.3.0" ], "changes": [] }, "desc": "

An implementation of the WHATWG Encoding Standard TextEncoder API. All\ninstances of TextEncoder only support UTF-8 encoding.

\n
const encoder = new TextEncoder();\nconst uint8array = encoder.encode('this is some data');\n
\n", "methods": [ { "textRaw": "textEncoder.encode([input])", "type": "method", "name": "encode", "signatures": [ { "return": { "textRaw": "Returns: {Uint8Array} ", "name": "return", "type": "Uint8Array" }, "params": [ { "textRaw": "`input` {string} The text to encode. Defaults to an empty string. ", "name": "input", "type": "string", "desc": "The text to encode. Defaults to an empty string.", "optional": true } ] }, { "params": [ { "name": "input", "optional": true } ] } ], "desc": "

UTF-8 encodes the input string and returns a Uint8Array containing the\nencoded bytes.

\n" } ], "properties": [ { "textRaw": "`encoding` {string} ", "type": "string", "name": "encoding", "desc": "

The encoding supported by the TextEncoder instance. Always set to 'utf-8'.

\n" } ] } ], "modules": [ { "textRaw": "Deprecated APIs", "name": "deprecated_apis", "desc": "

The following APIs have been deprecated and should no longer be used. Existing\napplications and modules should be updated to find alternative approaches.

\n", "methods": [ { "textRaw": "util.\\_extend(target, source)", "type": "method", "name": "\\_extend", "meta": { "added": [ "v0.7.5" ], "deprecated": [ "v6.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated: Use [`Object.assign()`] instead.", "desc": "

The util._extend() method was never intended to be used outside of internal\nNode.js modules. The community found and used it anyway.

\n

It is deprecated and should not be used in new code. JavaScript comes with very\nsimilar built-in functionality through Object.assign().

\n", "signatures": [ { "params": [ { "name": "target" }, { "name": "source" } ] } ] }, { "textRaw": "util.debug(string)", "type": "method", "name": "debug", "meta": { "added": [ "v0.3.0" ], "deprecated": [ "v0.11.3" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated: Use [`console.error()`][] instead.", "signatures": [ { "params": [ { "textRaw": "`string` {string} The message to print to `stderr` ", "name": "string", "type": "string", "desc": "The message to print to `stderr`" } ] }, { "params": [ { "name": "string" } ] } ], "desc": "

Deprecated predecessor of console.error.

\n" }, { "textRaw": "util.error([...strings])", "type": "method", "name": "error", "meta": { "added": [ "v0.3.0" ], "deprecated": [ "v0.11.3" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated: Use [`console.error()`][] instead.", "signatures": [ { "params": [ { "textRaw": "`...strings` {string} The message to print to `stderr` ", "name": "...strings", "type": "string", "desc": "The message to print to `stderr`", "optional": true } ] }, { "params": [ { "name": "...strings", "optional": true } ] } ], "desc": "

Deprecated predecessor of console.error.

\n" }, { "textRaw": "util.isArray(object)", "type": "method", "name": "isArray", "meta": { "added": [ "v0.6.0" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Internal alias for Array.isArray.

\n

Returns true if the given object is an Array. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isArray([]);\n// Returns: true\nutil.isArray(new Array());\n// Returns: true\nutil.isArray({});\n// Returns: false\n
\n" }, { "textRaw": "util.isBoolean(object)", "type": "method", "name": "isBoolean", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a Boolean. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isBoolean(1);\n// Returns: false\nutil.isBoolean(0);\n// Returns: false\nutil.isBoolean(false);\n// Returns: true\n
\n" }, { "textRaw": "util.isBuffer(object)", "type": "method", "name": "isBuffer", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated: Use [`Buffer.isBuffer()`][] instead.", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a Buffer. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isBuffer({ length: 0 });\n// Returns: false\nutil.isBuffer([]);\n// Returns: false\nutil.isBuffer(Buffer.from('hello world'));\n// Returns: true\n
\n" }, { "textRaw": "util.isDate(object)", "type": "method", "name": "isDate", "meta": { "added": [ "v0.6.0" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a Date. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isDate(new Date());\n// Returns: true\nutil.isDate(Date());\n// false (without 'new' returns a String)\nutil.isDate({});\n// Returns: false\n
\n" }, { "textRaw": "util.isError(object)", "type": "method", "name": "isError", "meta": { "added": [ "v0.6.0" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is an Error. Otherwise, returns\nfalse.

\n
const util = require('util');\n\nutil.isError(new Error());\n// Returns: true\nutil.isError(new TypeError());\n// Returns: true\nutil.isError({ name: 'Error', message: 'an error occurred' });\n// Returns: false\n
\n

Note that this method relies on Object.prototype.toString() behavior. It is\npossible to obtain an incorrect result when the object argument manipulates\n@@toStringTag.

\n
const util = require('util');\nconst obj = { name: 'Error', message: 'an error occurred' };\n\nutil.isError(obj);\n// Returns: false\nobj[Symbol.toStringTag] = 'Error';\nutil.isError(obj);\n// Returns: true\n
\n" }, { "textRaw": "util.isFunction(object)", "type": "method", "name": "isFunction", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a Function. Otherwise, returns\nfalse.

\n
const util = require('util');\n\nfunction Foo() {}\nconst Bar = () => {};\n\nutil.isFunction({});\n// Returns: false\nutil.isFunction(Foo);\n// Returns: true\nutil.isFunction(Bar);\n// Returns: true\n
\n" }, { "textRaw": "util.isNull(object)", "type": "method", "name": "isNull", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is strictly null. Otherwise, returns\nfalse.

\n
const util = require('util');\n\nutil.isNull(0);\n// Returns: false\nutil.isNull(undefined);\n// Returns: false\nutil.isNull(null);\n// Returns: true\n
\n" }, { "textRaw": "util.isNullOrUndefined(object)", "type": "method", "name": "isNullOrUndefined", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is null or undefined. Otherwise,\nreturns false.

\n
const util = require('util');\n\nutil.isNullOrUndefined(0);\n// Returns: false\nutil.isNullOrUndefined(undefined);\n// Returns: true\nutil.isNullOrUndefined(null);\n// Returns: true\n
\n" }, { "textRaw": "util.isNumber(object)", "type": "method", "name": "isNumber", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a Number. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isNumber(false);\n// Returns: false\nutil.isNumber(Infinity);\n// Returns: true\nutil.isNumber(0);\n// Returns: true\nutil.isNumber(NaN);\n// Returns: true\n
\n" }, { "textRaw": "util.isObject(object)", "type": "method", "name": "isObject", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is strictly an Object and not a\nFunction. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isObject(5);\n// Returns: false\nutil.isObject(null);\n// Returns: false\nutil.isObject({});\n// Returns: true\nutil.isObject(() => {});\n// Returns: false\n
\n" }, { "textRaw": "util.isPrimitive(object)", "type": "method", "name": "isPrimitive", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a primitive type. Otherwise, returns\nfalse.

\n
const util = require('util');\n\nutil.isPrimitive(5);\n// Returns: true\nutil.isPrimitive('foo');\n// Returns: true\nutil.isPrimitive(false);\n// Returns: true\nutil.isPrimitive(null);\n// Returns: true\nutil.isPrimitive(undefined);\n// Returns: true\nutil.isPrimitive({});\n// Returns: false\nutil.isPrimitive(() => {});\n// Returns: false\nutil.isPrimitive(/^$/);\n// Returns: false\nutil.isPrimitive(new Date());\n// Returns: false\n
\n" }, { "textRaw": "util.isRegExp(object)", "type": "method", "name": "isRegExp", "meta": { "added": [ "v0.6.0" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a RegExp. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isRegExp(/some regexp/);\n// Returns: true\nutil.isRegExp(new RegExp('another regexp'));\n// Returns: true\nutil.isRegExp({});\n// Returns: false\n
\n" }, { "textRaw": "util.isString(object)", "type": "method", "name": "isString", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a string. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isString('');\n// Returns: true\nutil.isString('foo');\n// Returns: true\nutil.isString(String('foo'));\n// Returns: true\nutil.isString(5);\n// Returns: false\n
\n" }, { "textRaw": "util.isSymbol(object)", "type": "method", "name": "isSymbol", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is a Symbol. Otherwise, returns false.

\n
const util = require('util');\n\nutil.isSymbol(5);\n// Returns: false\nutil.isSymbol('foo');\n// Returns: false\nutil.isSymbol(Symbol('foo'));\n// Returns: true\n
\n" }, { "textRaw": "util.isUndefined(object)", "type": "method", "name": "isUndefined", "meta": { "added": [ "v0.11.5" ], "deprecated": [ "v4.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated", "signatures": [ { "return": { "textRaw": "Returns: {boolean} ", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`object` {any} ", "name": "object", "type": "any" } ] }, { "params": [ { "name": "object" } ] } ], "desc": "

Returns true if the given object is undefined. Otherwise, returns false.

\n
const util = require('util');\n\nconst foo = undefined;\nutil.isUndefined(5);\n// Returns: false\nutil.isUndefined(foo);\n// Returns: true\nutil.isUndefined(null);\n// Returns: false\n
\n" }, { "textRaw": "util.log(string)", "type": "method", "name": "log", "meta": { "added": [ "v0.3.0" ], "deprecated": [ "v6.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated: Use a third party module instead.", "signatures": [ { "params": [ { "textRaw": "`string` {string} ", "name": "string", "type": "string" } ] }, { "params": [ { "name": "string" } ] } ], "desc": "

The util.log() method prints the given string to stdout with an included\ntimestamp.

\n
const util = require('util');\n\nutil.log('Timestamped message.');\n
\n" }, { "textRaw": "util.print([...strings])", "type": "method", "name": "print", "meta": { "added": [ "v0.3.0" ], "deprecated": [ "v0.11.3" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated: Use [`console.log()`][] instead.", "desc": "

Deprecated predecessor of console.log.

\n", "signatures": [ { "params": [ { "name": "...strings", "optional": true } ] } ] }, { "textRaw": "util.puts([...strings])", "type": "method", "name": "puts", "meta": { "added": [ "v0.3.0" ], "deprecated": [ "v0.11.3" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated: Use [`console.log()`][] instead.", "desc": "

Deprecated predecessor of console.log.

\n", "signatures": [ { "params": [ { "name": "...strings", "optional": true } ] } ] } ], "type": "module", "displayName": "Deprecated APIs" } ], "type": "module", "displayName": "Util" } ] }