You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the document, by calling util.deprecate(function, string),
it should run the function before printing the string on stderr.
However, I find that the function does NOT run when I call util.deprecate.
To reproduce it, use the sample code in the document
// test.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');
And the output is nothing:
$ node test.js
$
Another example is as follows:
const util = require('util');
console.log(util.deprecate);
var f = function() {
console.log("F");
};
util.deprecate(f, "DEPRECATED");
console.log("END");
And the output does not show F as expected:
$ node test.js
[Function: deprecate]
END
$
Do I have any misunderstanding or is there any tricky issue upon this function? Thanks a lot.
The text was updated successfully, but these errors were encountered:
According to the document, by calling
util.deprecate(function, string)
,it should run the function before printing the string on stderr.
However, I find that the function does NOT run when I call
util.deprecate
.To reproduce it, use the sample code in the document
And the output is nothing:
Another example is as follows:
And the output does not show
F
as expected:Do I have any misunderstanding or is there any tricky issue upon this function? Thanks a lot.
The text was updated successfully, but these errors were encountered: