Browse Source

repl: Private Buffer object in lib/* files

Fixes usage of global object 'Buffer' in lib/* files by ensuring that
each file does an explicit require('buffer').Buffer.  Previously, when
running a repl, due to usage of global 'Buffer', any redefinition of
Buffer would cause a crash eg var Buffer = {}.

Fixes: https://github.com/joyent/node/issues/8588
PR-URL: https://github.com/joyent/node/pull/8603
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
v0.10.34-release
Emmanuel Odeke 10 years ago
committed by Trevor Norris
parent
commit
523929c927
  1. 1
      lib/_stream_readable.js
  2. 1
      lib/_stream_writable.js
  3. 3
      lib/assert.js
  4. 1
      lib/dgram.js
  5. 1
      lib/fs.js
  6. 1
      lib/http.js
  7. 1
      lib/net.js
  8. 1
      lib/readline.js
  9. 1
      lib/tls.js
  10. 1
      lib/zlib.js

1
lib/_stream_readable.js

@ -24,6 +24,7 @@ Readable.ReadableState = ReadableState;
var EE = require('events').EventEmitter; var EE = require('events').EventEmitter;
var Stream = require('stream'); var Stream = require('stream');
var Buffer = require('buffer').Buffer;
var util = require('util'); var util = require('util');
var StringDecoder; var StringDecoder;

1
lib/_stream_writable.js

@ -28,6 +28,7 @@ Writable.WritableState = WritableState;
var util = require('util'); var util = require('util');
var Stream = require('stream'); var Stream = require('stream');
var Buffer = require('buffer').Buffer;
util.inherits(Writable, Stream); util.inherits(Writable, Stream);

3
lib/assert.js

@ -24,6 +24,7 @@
// UTILITY // UTILITY
var util = require('util'); var util = require('util');
var b = require('buffer');
var pSlice = Array.prototype.slice; var pSlice = Array.prototype.slice;
// 1. The assert module provides functions that throw // 1. The assert module provides functions that throw
@ -144,7 +145,7 @@ function _deepEqual(actual, expected) {
if (actual === expected) { if (actual === expected) {
return true; return true;
} else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { } else if (b.Buffer.isBuffer(actual) && b.Buffer.isBuffer(expected)) {
if (actual.length != expected.length) return false; if (actual.length != expected.length) return false;
for (var i = 0; i < actual.length; i++) { for (var i = 0; i < actual.length; i++) {

1
lib/dgram.js

@ -22,6 +22,7 @@
var assert = require('assert'); var assert = require('assert');
var util = require('util'); var util = require('util');
var events = require('events'); var events = require('events');
var Buffer = require('buffer').Buffer;
var UDP = process.binding('udp_wrap').UDP; var UDP = process.binding('udp_wrap').UDP;

1
lib/fs.js

@ -31,6 +31,7 @@ var pathModule = require('path');
var binding = process.binding('fs'); var binding = process.binding('fs');
var constants = process.binding('constants'); var constants = process.binding('constants');
var fs = exports; var fs = exports;
var Buffer = require('buffer').Buffer;
var Stream = require('stream').Stream; var Stream = require('stream').Stream;
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;

1
lib/http.js

@ -24,6 +24,7 @@ var net = require('net');
var Stream = require('stream'); var Stream = require('stream');
var timers = require('timers'); var timers = require('timers');
var url = require('url'); var url = require('url');
var Buffer = require('buffer').Buffer;
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;
var FreeList = require('freelist').FreeList; var FreeList = require('freelist').FreeList;
var HTTPParser = process.binding('http_parser').HTTPParser; var HTTPParser = process.binding('http_parser').HTTPParser;

1
lib/net.js

@ -25,6 +25,7 @@ var timers = require('timers');
var util = require('util'); var util = require('util');
var assert = require('assert'); var assert = require('assert');
var cares = process.binding('cares_wrap'); var cares = process.binding('cares_wrap');
var Buffer = require('buffer').Buffer;
var cluster; var cluster;
function noop() {} function noop() {}

1
lib/readline.js

@ -29,6 +29,7 @@ var kHistorySize = 30;
var kBufSize = 10 * 1024; var kBufSize = 10 * 1024;
var util = require('util'); var util = require('util');
var Buffer = require('buffer').Buffer;
var inherits = require('util').inherits; var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;

1
lib/tls.js

@ -26,6 +26,7 @@ var url = require('url');
var events = require('events'); var events = require('events');
var stream = require('stream'); var stream = require('stream');
var assert = require('assert').ok; var assert = require('assert').ok;
var Buffer = require('buffer').Buffer;
var constants = require('constants'); var constants = require('constants');
var Timer = process.binding('timer_wrap').Timer; var Timer = process.binding('timer_wrap').Timer;

1
lib/zlib.js

@ -23,6 +23,7 @@ var Transform = require('_stream_transform');
var binding = process.binding('zlib'); var binding = process.binding('zlib');
var util = require('util'); var util = require('util');
var Buffer = require('buffer').Buffer;
var assert = require('assert').ok; var assert = require('assert').ok;
// zlib doesn't provide these, so kludge them in following the same // zlib doesn't provide these, so kludge them in following the same

Loading…
Cancel
Save