Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update encoder #10

Merged
merged 7 commits into from
Sep 11, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update readme
  • Loading branch information
devongovett committed Sep 11, 2016
commit 10fdb1e5ee73f0450e12b568e860c06c30763dd7
4 changes: 2 additions & 2 deletions compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ module.exports = function(buffer, opts) {
// default to binary data
var quality = 11;
var mode = 0;
var lgwin = 0;
var lgwin = 22;

if (typeof opts === 'boolean') {
mode = opts ? 0 : 1;
} else if (typeof opts === 'object') {
quality = opts.quality || 11;
mode = opts.mode || 0;
mode = opts.lgwin || 0;
mode = opts.lgwin || 22;
}

// allocate input buffer and copy data to it
Expand Down
12 changes: 7 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ brotli.decompress(fs.readFileSync('compressed.bin'));

### brotli.compress(buffer, isText = false)

Compresses the given buffer. Pass `true` as the second argument if the input
buffer is text data. Pass `false` or nothing if it is binary. This function
is known to be quite slow.
Compresses the given buffer. Pass optional parameters as the second argument.

```javascript
// encode a buffer of binary data
brotli.compress(fs.readFileSync('myfile.bin'));

// encode some text data
brotli.compress(fs.readFileSync('myfile.bin'), true);
// encode some data with options (default options shown)
brotli.compress(fs.readFileSync('myfile.bin'), {
mode: 0, // 0 = generic, 1 = text, 2 = font (WOFF2)
quality: 11, // 0 - 11
lgwin: 22 // window size
});
```

## License
Expand Down