Skip to content

Commit a4f2f9e

Browse files
yorkietrevnorris
authored andcommitted
doc: add spec for util.deprecate()
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
1 parent f10fd1d commit a4f2f9e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/api/util.markdown

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,21 @@ through the `constructor.super_` property.
257257
stream.write("It works!"); // Received data: "It works!"
258258

259259

260+
## util.deprecate(function, string)
261+
262+
Marks that a method should not be used any more.
263+
264+
exports.puts = exports.deprecate(function() {
265+
for (var i = 0, len = arguments.length; i < len; ++i) {
266+
process.stdout.write(arguments[i] + '\n');
267+
}
268+
}, 'util.puts: Use console.log instead')
269+
270+
It returns a modified function which warns once by default. If
271+
`--no-deprecation` is set then this function is a NO-OP. If
272+
`--throw-deprecation` is set then the application will throw an exception
273+
if the deprecated API is used.
274+
260275
## util.debug(string)
261276

262277
Stability: 0 - Deprecated: use console.error() instead.

0 commit comments

Comments
 (0)