const binding = process.binding('buffer');
const smalloc = process.binding('smalloc');
const util = require('util');
+const internalUtil = require('internal/util');
const alloc = smalloc.alloc;
const truncate = smalloc.truncate;
const sliceOnto = smalloc.sliceOnto;
// XXX legacy write(string, encoding, offset, length) - remove in v0.13
} else {
- if (!writeWarned) {
- if (process.throwDeprecation)
- throw new Error(writeMsg);
- else if (process.traceDeprecation)
- console.trace(writeMsg);
- else
- console.error(writeMsg);
- writeWarned = true;
- }
-
+ writeWarned = internalUtil.printDeprecationMessage(writeMsg, writeWarned);
var swap = encoding;
encoding = offset;
offset = length >>> 0;
--- /dev/null
+'use strict';
+
+exports.printDeprecationMessage = function(msg, warned) {
+ if (process.noDeprecation)
+ return true;
+
+ if (warned)
+ return warned;
+
+ if (process.throwDeprecation)
+ throw new Error(msg);
+ else if (process.traceDeprecation)
+ console.trace(msg);
+ else
+ console.error(msg);
+
+ return true;
+};
'use strict';
-const util = require('util');
+const util = require('internal/util');
// the sys module was renamed to 'util'.
// this shim remains to keep old programs working.
// sys is deprecated and shouldn't be used
-const setExports = util.deprecate(function() {
- module.exports = util;
-}, 'sys is deprecated. Use util instead.');
-
-setExports();
+module.exports = require('util');
+util.printDeprecationMessage('sys is deprecated. Use util instead.');
const uv = process.binding('uv');
const Debug = require('vm').runInDebugContext('Debug');
+const internalUtil = require('internal/util');
const formatRegExp = /%[sdj%]/g;
exports.format = function(f) {
var warned = false;
function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
- } else {
- console.error(msg);
- }
- warned = true;
- }
+ warned = internalUtil.printDeprecationMessage(msg, warned);
return fn.apply(this, arguments);
}
'lib/internal/smalloc.js',
'lib/internal/socket_list.js',
'lib/internal/repl.js',
+ 'lib/internal/util.js',
],
},