File tree 3 files changed +14
-4
lines changed
3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 1
- var inherits = require ( 'util' ) . inherits ;
2
1
var Readable = require ( 'stream' ) . Readable ;
3
2
var util = require ( './util' ) ;
4
3
@@ -10,7 +9,7 @@ function OpStream() {
10
9
}
11
10
module . exports = OpStream ;
12
11
13
- inherits ( OpStream , Readable ) ;
12
+ util . inherits ( OpStream , Readable ) ;
14
13
15
14
// This function is for notifying us that the stream is empty and needs data.
16
15
// For now, we'll just ignore the signal and assume the reader reads as fast
Original file line number Diff line number Diff line change 1
1
var Duplex = require ( 'stream' ) . Duplex ;
2
- var inherits = require ( 'util' ) . inherits ;
3
2
var logger = require ( './logger' ) ;
4
3
var util = require ( './util' ) ;
5
4
@@ -47,7 +46,7 @@ function ServerStream(socket) {
47
46
socket . close ( 'stopped' ) ;
48
47
} ) ;
49
48
}
50
- inherits ( ServerStream , Duplex ) ;
49
+ util . inherits ( ServerStream , Duplex ) ;
51
50
52
51
ServerStream . prototype . isServer = true ;
53
52
Original file line number Diff line number Diff line change @@ -113,3 +113,15 @@ Object.getOwnPropertyNames(Object.prototype).forEach(function(prop) {
113
113
exports . isDangerousProperty = function ( propName ) {
114
114
return propName === '__proto__' || objectProtoPropNames [ propName ] ;
115
115
} ;
116
+
117
+ try {
118
+ var util = require ( 'util' ) ;
119
+ if ( typeof util . inherits !== 'function' ) throw new Error ( 'Could not find util.inherits()' ) ;
120
+ exports . inherits = util . inherits ;
121
+ } catch ( e ) {
122
+ try {
123
+ exports . inherits = require ( 'inherits' ) ;
124
+ } catch ( e ) {
125
+ throw new Error ( 'If running sharedb in a browser, please install the "inherits" or "util" package' ) ;
126
+ }
127
+ }
You can’t perform that action at this time.
0 commit comments