util.deprecate()

util.deprecate(function, string)

Marks that a method should not be used any more.

const util = require('util');

exports.puts = util.deprecate(() => {
  for (var i = 0, len = arguments.length; i < len; ++i) {
    process.stdout.write(arguments[i] + '\n');
  }
}, 'util.puts: Use console.log instead');

It returns a modified function which warns once by default.

If --no-deprecation is set then this function is a NO-OP. Configurable at run-time through the process.noDeprecation boolean (only effective when set before a module is loaded.)

If --trace-deprecation is set, a warning and a stack trace are logged to the console the first time the deprecated API is used. Configurable at run-time through the process.traceDeprecation boolean.

If --throw-deprecation is set then the application throws an exception when the deprecated API is used. Configurable at run-time through the process.throwDeprecation boolean.

process.throwDeprecation takes precedence over process.traceDeprecation.

doc_Nodejs
2016-04-30 04:43:01
Comments
Leave a Comment

Please login to continue.