diff --git a/.jshintignore b/.jshintignore index 2935a60..ed1a17c 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,4 +1,4 @@ .git/ node_modules/ -lib/ -/benchmark/implementations +benchmark/implementations +lib/zlib diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js index bb8e82b..b17c9b1 100644 --- a/benchmark/benchmark.js +++ b/benchmark/benchmark.js @@ -38,30 +38,35 @@ fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) { content = new Uint8Array(fs.readFileSync(filepath)), title = util.format('%s (%d bytes)', sample, content.length); - function onStart() { - console.log('\nSample: %s', this.name); - } - - function onCycle(event) { - cursor.horizontalAbsolute(); - cursor.eraseLine(); - cursor.write(' > ' + event.target); - } - function onComplete() { cursor.write('\n'); } + var suite = new Benchmark.Suite(title, { - onStart: onStart, + + onStart: function onStart() { + console.log('\nSample: %s', sample); + }, + onComplete: onComplete + }); + IMPLS.forEach(function (impl) { suite.add(impl.name, { - onCycle: onCycle, + + onCycle: function onCycle(event) { + cursor.horizontalAbsolute(); + cursor.eraseLine(); + cursor.write(' > ' + event.target); + }, + onComplete: onComplete, + defer: !!impl.code.async, + fn: function (deferred) { if (!!impl.code.async) { impl.code.run(content, function() { @@ -76,6 +81,7 @@ fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) { }); }); + SAMPLES.push({ name: basename, title: title, @@ -117,7 +123,7 @@ function run(files) { console.log(' > %s', sample.name); }); } else { - console.log("There isn't any sample matches any of these patterns: %s", util.inspect(files)); + console.log('There isn\'t any sample matches any of these patterns: %s', util.inspect(files)); } selected.forEach(function (sample) { diff --git a/lib/deflate.js b/lib/deflate.js index 7ddb0b7..e1f38bf 100644 --- a/lib/deflate.js +++ b/lib/deflate.js @@ -1,4 +1,9 @@ +'use strict'; + + var zlib = require('zlib/deflate.js'); + + /** * Deflate * @@ -7,7 +12,8 @@ var zlib = require('zlib/deflate.js'); */ var Deflate = function(options) { -} +}; + /** * Compresses the input data and fills output buffer with compressed data. @@ -15,26 +21,28 @@ var Deflate = function(options) { */ Deflate.prototype.deflate = function(input) { -} +}; Deflate.prototype.flush = function() { -} +}; Deflate.prototype.finish = function() { -} +}; Deflate.prototype.onData = function(output) { -} +}; Deflate.prototype.onEnd = function(error) { -} +}; + exports.Deflate = Deflate; + /** * Compresses the input data * @param input @@ -43,8 +51,9 @@ exports.Deflate = Deflate; */ exports.deflate = function(input, options) { -} +}; + exports.deflateRaw = function(input, options) { -} \ No newline at end of file +}; \ No newline at end of file