From 7e38821df2c856dee3e1894d940c11b79db101f6 Mon Sep 17 00:00:00 2001 From: Mithun Sasidharan Date: Wed, 6 Dec 2017 21:29:34 +0530 Subject: [PATCH] doc: use arrow functions in util.md sample code PR-URL: https://github.com/nodejs/node/pull/17459 Reviewed-By: Luigi Pinca Reviewed-By: Jon Moss Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- doc/api/util.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 10474b6f836f5c..510b8c92ac9e5f 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -119,11 +119,9 @@ it is marked as deprecated. ```js const util = require('util'); -exports.puts = util.deprecate(function() { - for (let i = 0, len = arguments.length; i < len; ++i) { - process.stdout.write(arguments[i] + '\n'); - } -}, 'util.puts: Use console.log instead'); +exports.obsoleteFunction = util.deprecate(() => { + // Do something here. +}, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.'); ``` When called, `util.deprecate()` will return a function that will emit a @@ -1023,7 +1021,7 @@ util.isObject(null); // Returns: false util.isObject({}); // Returns: true -util.isObject(function() {}); +util.isObject(() => {}); // Returns: false ``` @@ -1055,7 +1053,7 @@ util.isPrimitive(undefined); // Returns: true util.isPrimitive({}); // Returns: false -util.isPrimitive(function() {}); +util.isPrimitive(() => {}); // Returns: false util.isPrimitive(/^$/); // Returns: false