Skip to content

Commit

Permalink
Use the built-in zlib module instead of iltorb
Browse files Browse the repository at this point in the history
As the latter has been deprecated:
nstepien/iltorb#119 (comment)
  • Loading branch information
boris-petrov authored and valpackett committed May 31, 2021
1 parent 88f28ff commit 54bc38b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
13 changes: 3 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var RSVP = require('rsvp'),
helpers = require('broccoli-kitchen-sink-helpers'),
Filter = require('broccoli-filter'),
Buffer = require('buffer').Buffer,
brotli = require('iltorb');
zlib = require('zlib');


BrotliFilter.prototype = Object.create(Filter.prototype);
Expand All @@ -21,14 +21,7 @@ function BrotliFilter(inputNode, options) {
if (!(this instanceof BrotliFilter))
return new BrotliFilter(inputNode, options);

options = options || {};

this.brotliOptions = {
mode: options.mode || 0,
quality: options.quality || 11,
lgwin: options.lgwin || 22,
lgblock: options.lgblock || 0
};
this.brotliOptions = options || {};
this.keepUncompressed = options.keepUncompressed;
this.appendSuffix = (options.hasOwnProperty('appendSuffix') ?
options.appendSuffix :
Expand All @@ -55,7 +48,7 @@ BrotliFilter.prototype.processFile = function(srcDir, destDir, relativePath) {
};

BrotliFilter.prototype.processString = function(str) {
return RSVP.denodeify(brotli.compress)(Buffer.from(str), this.brotliOptions);
return RSVP.denodeify(zlib.brotliCompress)(Buffer.from(str), this.brotliOptions);
};

BrotliFilter.prototype.getDestFilePath = function() {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"dependencies": {
"broccoli-filter": "^1.2.4",
"broccoli-kitchen-sink-helpers": "^0.3.1",
"iltorb": "^2.0.2",
"rsvp": "^4.7.0"
}
}
8 changes: 4 additions & 4 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var brotli = require('../index');

var RSVP = require('rsvp');
var iltorb = require('iltorb');
var zlib = require('zlib');
var expect = require('expect.js');

var fs = require('fs');
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('broccoli-brotli', function(){
return RSVP.hash({
dir: builder.outputPath,
actualCsv: fs.readFileSync(sourcePath + '/test.csv'),
actualText: RSVP.denodeify(iltorb.decompress)(brotledText)
actualText: RSVP.denodeify(zlib.brotliDecompress)(brotledText)
});
}).then(function(result) {
expect(result.actualText).to.eql(textContent);
Expand All @@ -54,7 +54,7 @@ describe('broccoli-brotli', function(){
return RSVP.hash({
dir: builder.outputPath,
actualCsv: fs.readFileSync(builder.outputPath + '/test.csv'),
actualText: RSVP.denodeify(iltorb.decompress)(brotledText)
actualText: RSVP.denodeify(zlib.brotliDecompress)(brotledText)
});
}).then(function(result) {
expect(result.actualText).to.eql(textContent);
Expand All @@ -75,7 +75,7 @@ describe('broccoli-brotli', function(){
var brotledText = fs.readFileSync(builder.outputPath + '/test.txt');
return RSVP.hash({
dir: builder.outputPath,
actualText: RSVP.denodeify(iltorb.decompress)(brotledText)
actualText: RSVP.denodeify(zlib.brotliDecompress)(brotledText)
});
}).then(function(result) {
expect(result.actualText).to.eql(textContent);
Expand Down

0 comments on commit 54bc38b

Please sign in to comment.