Skip to content

Commit 68ee980

Browse files
fix: ask for runtime version once
1 parent 17e6933 commit 68ee980

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ var vary = require('vary')
2424
var zlib = require('zlib')
2525
var ServerResponse = require('http').ServerResponse
2626

27+
var isOldRuntime = /^v0\.8\./.test(process.version)
28+
2729
/**
2830
* Module exports.
2931
*/
@@ -122,7 +124,7 @@ function compression (options) {
122124

123125
if (chunk) {
124126
chunk = toBuffer(chunk, encoding)
125-
if (/^v0\.8\./.test(process.version) && stream) {
127+
if (isOldRuntime && stream) {
126128
encoding = callback
127129
}
128130
}
@@ -171,7 +173,7 @@ function compression (options) {
171173

172174
if (chunk) {
173175
chunk = toBuffer(chunk, encoding)
174-
if (/^v0\.8\./.test(process.version) && stream) {
176+
if (isOldRuntime && stream) {
175177
encoding = callback
176178
}
177179
}

0 commit comments

Comments
 (0)