Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
CPP = emcc
CPPFLAGS = -O3 -s TOTAL_MEMORY=318767104 -s NO_FILESYSTEM=1 --closure 1
CPPFLAGS = -O3 -s TOTAL_MEMORY=318767104 -s NO_FILESYSTEM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s 'EXPORT_NAME="brotli"' -s "EXPORTED_RUNTIME_METHODS=['getValue']" --closure 1

COMMONDIR = vendor/brotli/c/common
ENCDIR = vendor/brotli/c/enc
ENCSRC = compress.c $(wildcard $(COMMONDIR)/*.c) $(wildcard $(ENCDIR)/*.c)
DECDIR = vendor/brotli/c/dec
ENCSRC = compress.c decompress.c $(wildcard $(COMMONDIR)/*.c) $(wildcard $(ENCDIR)/*.c) $(wildcard $(DECDIR)/*.c)
ENCOBJ = $(ENCSRC:.c=.o)

all: build/encode.js
all: build/brotli.js

.c.o .cc.o:
$(CPP) -I vendor/brotli/c/include/ -c $< -o $@

build/encode.js: $(ENCOBJ)
build/brotli.js: $(ENCOBJ)
mkdir -p build/
$(CPP) $(CPPFLAGS) -s EXPORTED_FUNCTIONS="['_malloc', '_free', '_encodeWithDictionary']" $(ENCOBJ) -o build/encode.js
$(CPP) $(CPPFLAGS) -s EXPORTED_FUNCTIONS="['_malloc', '_free', '_encodeWithDictionary', '_decompress']" $(ENCOBJ) -o build/brotli.js

clean:
rm -rf $(ENCOBJ) build/
5 changes: 3 additions & 2 deletions compress.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
var brotli = require('./build/encode');
import brotliPromise from './build/brotli.js';

/**
* Compresses the given buffer
* The second parameter is optional and specifies whether the buffer is
* text or binary data (the default is binary).
* Returns null on error
*/
module.exports = function(buffer, opts) {
export const compress = async function(buffer, opts) {
const brotli = await brotliPromise();
// default to binary data
var quality = 11;
var mode = 0;
Expand Down
124 changes: 0 additions & 124 deletions dec/bit_reader.js

This file was deleted.

Loading