Skip to content

Commit a65e24c

Browse files
authored
Merge pull request #20 from mszabo-wikia/native-brotli-support
Use Node's native brotli support if available
2 parents 41583c9 + 7f27e31 commit a65e24c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
language: node_js
33
node_js:
44
- "8"
5-
6-
sudo: false
7-
dist: trusty
5+
- "12"
86

97
cache:
108
yarn: true

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
var RSVP = require('rsvp');
55
var fs = require('fs');
66
var path = require('path');
7+
var zlib = require('zlib');
78
var minimatch = require('minimatch');
89
var caniuse = require('caniuse-api');
910
var RSVP = require('rsvp')
@@ -134,6 +135,15 @@ module.exports = {
134135
},
135136

136137
brotliCompressor() {
138+
// Use native brotli support on Node >= 11
139+
if (zlib.createBrotliCompress) {
140+
var brotliOptions = {};
141+
142+
brotliOptions[zlib.constants.BROTLI_PARAM_QUALITY] = 11;
143+
144+
return zlib.createBrotliCompress({ params: brotliOptions });
145+
}
146+
137147
return require('iltorb').compressStream({ quality: 11 });
138148
},
139149

0 commit comments

Comments
 (0)