File tree 5 files changed +81
-2
lines changed
5 files changed +81
-2
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,10 @@ const headRegexp = /(^module.exports = \w+;?)/m
171
171
/ B u f f e r \. ( (?: a l l o c ) | (?: a l l o c U n s a f e ) | (?: f r o m ) ) / g,
172
172
`bufferShim.$1`
173
173
]
174
+ , internalDirectory = [
175
+ / r e q u i r e \( ' i n t e r n a l \/ s t r e a m s \/ B u f f e r L i s t ' \) / ,
176
+ 'require(\'./internal/streams/BufferList\')'
177
+ ]
174
178
175
179
module . exports [ '_stream_duplex.js' ] = [
176
180
requireReplacement
@@ -215,6 +219,7 @@ module.exports['_stream_readable.js'] = [
215
219
, eventEmittterListenerCountReplacement
216
220
, bufferShimFix
217
221
, bufferStaticMethods
222
+ , internalDirectory
218
223
]
219
224
220
225
module . exports [ '_stream_transform.js' ] = [
@@ -246,3 +251,7 @@ module.exports['_stream_writable.js'] = [
246
251
, bufferShimFix
247
252
, bufferStaticMethods
248
253
]
254
+ module . exports [ 'internal/streams/BufferList.js' ] = [
255
+ bufferShimFix
256
+ , bufferStaticMethods
257
+ ]
Original file line number Diff line number Diff line change @@ -264,3 +264,9 @@ module.exports['test-stream3-cork-uncork.js'] = module.exports['test-stream3-cor
264
264
'assert.deepEqual(seen, expected);'
265
265
]
266
266
]
267
+ module . exports [ 'test-stream2-readable-from-list.js' ] = [
268
+ [
269
+ / r e q u i r e \( ' i n t e r n a l \/ s t r e a m s \/ B u f f e r L i s t ' \) / ,
270
+ 'require(\'../../lib/internal/streams/BufferList\')'
271
+ ]
272
+ ]
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ if (debugUtil && debugUtil.debuglog) {
51
51
}
52
52
/*</replacement>*/
53
53
54
- var BufferList = require ( 'internal/streams/BufferList' ) ;
54
+ var BufferList = require ( './ internal/streams/BufferList' ) ;
55
55
var StringDecoder ;
56
56
57
57
util . inherits ( Readable , Stream ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var Buffer = require ( 'buffer' ) . Buffer ;
4
+ /*<replacement>*/
5
+ var bufferShim = require ( 'buffer-shims' ) ;
6
+ /*</replacement>*/
7
+
8
+ module . exports = BufferList ;
9
+
10
+ function BufferList ( ) {
11
+ this . head = null ;
12
+ this . tail = null ;
13
+ this . length = 0 ;
14
+ }
15
+
16
+ BufferList . prototype . push = function ( v ) {
17
+ var entry = { data : v , next : null } ;
18
+ if ( this . length > 0 ) this . tail . next = entry ; else this . head = entry ;
19
+ this . tail = entry ;
20
+ ++ this . length ;
21
+ } ;
22
+
23
+ BufferList . prototype . unshift = function ( v ) {
24
+ var entry = { data : v , next : this . head } ;
25
+ if ( this . length === 0 ) this . tail = entry ;
26
+ this . head = entry ;
27
+ ++ this . length ;
28
+ } ;
29
+
30
+ BufferList . prototype . shift = function ( ) {
31
+ if ( this . length === 0 ) return ;
32
+ var ret = this . head . data ;
33
+ if ( this . length === 1 ) this . head = this . tail = null ; else this . head = this . head . next ;
34
+ -- this . length ;
35
+ return ret ;
36
+ } ;
37
+
38
+ BufferList . prototype . clear = function ( ) {
39
+ this . head = this . tail = null ;
40
+ this . length = 0 ;
41
+ } ;
42
+
43
+ BufferList . prototype . join = function ( s ) {
44
+ if ( this . length === 0 ) return '' ;
45
+ var p = this . head ;
46
+ var ret = '' + p . data ;
47
+ while ( p = p . next ) {
48
+ ret += s + p . data ;
49
+ } return ret ;
50
+ } ;
51
+
52
+ BufferList . prototype . concat = function ( n ) {
53
+ if ( this . length === 0 ) return bufferShim . alloc ( 0 ) ;
54
+ if ( this . length === 1 ) return this . head . data ;
55
+ var ret = bufferShim . allocUnsafe ( n >>> 0 ) ;
56
+ var p = this . head ;
57
+ var i = 0 ;
58
+ while ( p ) {
59
+ p . data . copy ( ret , i ) ;
60
+ i += p . data . length ;
61
+ p = p . next ;
62
+ }
63
+ return ret ;
64
+ } ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ var bufferShim = require('buffer-shims');
5
5
require ( '../common' ) ;
6
6
var assert = require ( 'assert/' ) ;
7
7
var fromList = require ( '../../lib/_stream_readable' ) . _fromList ;
8
- var BufferList = require ( 'internal/streams/BufferList' ) ;
8
+ var BufferList = require ( '../../lib/ internal/streams/BufferList' ) ;
9
9
10
10
// tiny node-tap lookalike.
11
11
var tests = [ ] ;
You can’t perform that action at this time.
0 commit comments