Skip to content

Commit

Permalink
repl: Private Buffer object in lib/* files
Browse files Browse the repository at this point in the history
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: nodejs#8588
PR-URL: nodejs#8603
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
Emmanuel Odeke authored and trevnorris committed Oct 25, 2014
1 parent ea69dd7 commit 523929c
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Readable.ReadableState = ReadableState;

var EE = require('events').EventEmitter;
var Stream = require('stream');
var Buffer = require('buffer').Buffer;
var util = require('util');
var StringDecoder;

Expand Down
1 change: 1 addition & 0 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Writable.WritableState = WritableState;

var util = require('util');
var Stream = require('stream');
var Buffer = require('buffer').Buffer;

util.inherits(Writable, Stream);

Expand Down
3 changes: 2 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

// UTILITY
var util = require('util');
var b = require('buffer');
var pSlice = Array.prototype.slice;

// 1. The assert module provides functions that throw
Expand Down Expand Up @@ -144,7 +145,7 @@ function _deepEqual(actual, expected) {
if (actual === expected) {
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;

for (var i = 0; i < actual.length; i++) {
Expand Down
1 change: 1 addition & 0 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
var assert = require('assert');
var util = require('util');
var events = require('events');
var Buffer = require('buffer').Buffer;

var UDP = process.binding('udp_wrap').UDP;

Expand Down
1 change: 1 addition & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var pathModule = require('path');
var binding = process.binding('fs');
var constants = process.binding('constants');
var fs = exports;
var Buffer = require('buffer').Buffer;
var Stream = require('stream').Stream;
var EventEmitter = require('events').EventEmitter;

Expand Down
1 change: 1 addition & 0 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var net = require('net');
var Stream = require('stream');
var timers = require('timers');
var url = require('url');
var Buffer = require('buffer').Buffer;
var EventEmitter = require('events').EventEmitter;
var FreeList = require('freelist').FreeList;
var HTTPParser = process.binding('http_parser').HTTPParser;
Expand Down
1 change: 1 addition & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var timers = require('timers');
var util = require('util');
var assert = require('assert');
var cares = process.binding('cares_wrap');
var Buffer = require('buffer').Buffer;
var cluster;

function noop() {}
Expand Down
1 change: 1 addition & 0 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var kHistorySize = 30;
var kBufSize = 10 * 1024;

var util = require('util');
var Buffer = require('buffer').Buffer;
var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;

Expand Down
1 change: 1 addition & 0 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var url = require('url');
var events = require('events');
var stream = require('stream');
var assert = require('assert').ok;
var Buffer = require('buffer').Buffer;
var constants = require('constants');

var Timer = process.binding('timer_wrap').Timer;
Expand Down
1 change: 1 addition & 0 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var Transform = require('_stream_transform');

var binding = process.binding('zlib');
var util = require('util');
var Buffer = require('buffer').Buffer;
var assert = require('assert').ok;

// zlib doesn't provide these, so kludge them in following the same
Expand Down

0 comments on commit 523929c

Please sign in to comment.