标签:
var co = require(‘co‘);
var thunkify = require(‘thunkify‘);
var zlib = require(‘zlib‘);
var gzip = thunkify(zlib.gzip);//相当于给函数起别名
var unzip = thunkify(zlib.unzip);
co(function *(){
var structs = ‘123‘;
var _structs = yield gzip(structs);
_structs = _structs.toString(‘base64‘);
var str = yield unzip(new Buffer(_structs, ‘base64‘));
str = str.toString();
console.log(str); //打印123
})
标签:
原文地址:http://www.cnblogs.com/tudou1223/p/4930242.html