diff --git a/doc/api/util.md b/doc/api/util.md index 3ba8cade5439e0..e100971af91eb7 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -107,13 +107,20 @@ environment variable set, then it will not print anything. Multiple comma-separated `section` names may be specified in the `NODE_DEBUG` environment variable. For example: `NODE_DEBUG=fs,net,tls`. -## util.deprecate(function, string) +## util.deprecate(fn, msg[, code]) -The `util.deprecate()` method wraps the given `function` or class in such a way that -it is marked as deprecated. +* `fn` {Function} The function that is being deprecated. +* `msg` {string} A warning message to display when the deprecated function is + invoked. +* `code` {string} A deprecation code. See the [list of deprecated APIs][] for a + list of codes. +* Returns: {Function} The deprecated function wrapped to emit a warning. + +The `util.deprecate()` method wraps `fn` (which may be a function or class) in +such a way that it is marked as deprecated. ```js @@ -127,10 +134,9 @@ exports.puts = util.deprecate(function() { ``` When called, `util.deprecate()` will return a function that will emit a -`DeprecationWarning` using the `process.on('warning')` event. By default, -this warning will be emitted and printed to `stderr` exactly once, the first -time it is called. After the warning is emitted, the wrapped `function` -is called. +`DeprecationWarning` using the `process.on('warning')` event. The warning will +be emitted and printed to `stderr` exactly once, the first time it is called. +After the warning is emitted, the wrapped function is called. If either the `--no-deprecation` or `--no-warnings` command line flags are used, or if the `process.noDeprecation` property is set to `true` *prior* to @@ -1213,4 +1219,5 @@ Deprecated predecessor of `console.log`. [Internationalization]: intl.html [WHATWG Encoding Standard]: https://encoding.spec.whatwg.org/ [constructor]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/constructor +[list of deprecated APIS]: deprecations.html#deprecations_list_of_deprecated_apis [semantically incompatible]: https://github.com/nodejs/node/issues/4179