Skip to content

dionoid/koa-zlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-zlib

Very simple wrapper to node's built-in zlib library for use in koa.
By using these 'thunkified' wrappers to zlib's convenience methods, they can be 'yielded' inside koa generator functions.

To install simply run:

npm install koa-zlib

Require koa first and will only work on node v0.11.7 or newer.

You must run node with --harmony flag (--harmony-generators works as well)

node --harmony example.js

Simple example using koa-zlib in koa:

var koa = require('koa');
var zlib = require('koa-zlib');
 
var app = koa();

app.use(function *() {

	var buffer = yield zlib.deflate('dionoid was here'); //Yay, zipping with no callbacks!
	this.body = 'Zipped text: ' + buffer.toString('base64');

	buffer = new Buffer('eJxLyczPy89MUShPLFbISC1KBQA0pwYW', 'base64');
	this.body += '\nUnzipped text: ' + (yield zlib.unzip(buffer)).toString();
});

app.listen(process.env.PORT || 8080);

About

wrapper for zlib library for use in koa

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published