package/.gitignore000644 000765 000024 00000000023 11620023733 015204 0ustar00kkaeferstaff000000 000000 build .lock-wscriptpackage/configure000755 000765 000024 00000000034 11620023733 015125 0ustar00kkaeferstaff000000 000000 #!/bin/sh node-waf configurepackage/index.js000644 000765 000024 00000000050 11620023733 014661 0ustar00kkaeferstaff000000 000000 module.exports = require('./lib/zlib'); package/LICENSE000644 000765 000024 00000002752 11620023733 014234 0ustar00kkaeferstaff000000 000000 Copyright (c) 2011, Konstantin Käfer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of node-zlib nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Konstantin Käfer BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package/Makefile000644 000765 000024 00000000301 11620023733 014653 0ustar00kkaeferstaff000000 000000 build: node-waf build clean: node-waf clean ifndef only test: build @expresso -I lib test/*.test.js else test: build @expresso -I lib test/${only}.test.js endif .PHONY: build clean test package/package.json000644 000765 000024 00000000715 11620023733 015512 0ustar00kkaeferstaff000000 000000 { "name": "zlib", "description": "Simple, synchronous deflate/inflate for buffers", "version": "1.0.5", "homepage": "https://github.com/kkaefer/node-zlib", "author": "Konstantin Käfer ", "repository": { "type": "git", "url": "git://github.com/kkaefer/node-zlib.git" }, "engines": { "node": ">=0.2.0" }, "licenses": [ { "type": "BSD" } ], "main": "./lib/zlib" } package/README.md000644 000765 000024 00000002135 11620023733 014501 0ustar00kkaeferstaff000000 000000 # NAME node-zlib - Simple, synchronous deflate/inflate for node.js buffers. # USAGE Install with `npm install zlib`. var Buffer = require('buffer').Buffer; var zlib = require('zlib'); var input = new Buffer('lorem ipsum dolor sit amet'); var compressed = zlib.deflate(input); var output = zlib.inflate(compressed); Note that `node-zlib` is only intended for small (< 128 KB) data that you already have buffered. It is not meant for input/output streams. # BUILDING Make sure you have `zlib` installed. Mac OS X ships with it by default. To obtain and build the bindings: git clone git://github.com/kkaefer/node-zlib.git cd node-zlib ./configure make You can also use [`npm`](https://github.com/isaacs/npm) to download and install them: npm install zlib # TESTS [expresso](https://github.com/visionmedia/expresso) is required to run unit tests. npm install expresso make test # CONTRIBUTORS * [Konstantin Käfer](https://github.com/kkaefer) # LICENSE `node-zlib` is [BSD licensed](https://github.com/kkaefer/node-zlib/raw/master/LICENSE). package/wscript000644 000765 000024 00000002001 11620023733 014630 0ustar00kkaeferstaff000000 000000 import os import Options from os.path import exists from shutil import copy2 as copy TARGET = 'zlib_bindings' TARGET_FILE = '%s.node' % TARGET built = 'build/default/%s' % TARGET_FILE dest = 'lib/%s' % TARGET_FILE def set_options(opt): opt.tool_options("compiler_cxx") def configure(conf): conf.check_tool("compiler_cxx") conf.check_tool("node_addon") if not conf.check(lib="z", libpath=['/usr/local/lib'], uselib_store="ZLIB"): conf.fatal('Missing zlib'); linkflags = [] if os.environ.has_key('LINKFLAGS'): linkflags.extend(os.environ['LINKFLAGS'].split(' ')) conf.env.append_value("LINKFLAGS", linkflags) def build(bld): obj = bld.new_task_gen("cxx", "shlib", "node_addon") obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"] obj.target = TARGET obj.source = "src/node-zlib.cc" obj.uselib = "ZLIB" def shutdown(): if Options.commands['clean']: if exists(TARGET_FILE): unlink(TARGET_FILE) else: if exists(built): copy(built, dest)package/lib/zlib.js000644 000765 000024 00000000055 11620023733 015265 0ustar00kkaeferstaff000000 000000 module.exports = require('./zlib_bindings'); package/src/node-zlib.cc000644 000765 000024 00000010746 11620023733 016212 0ustar00kkaeferstaff000000 000000 #include #include #include #include #include #include #include using namespace v8; using namespace node; // node v0.2.x compatibility #if NODE_VERSION_AT_LEAST(0,3,0) #define Buffer_Data Buffer::Data #define Buffer_Length Buffer::Length #define Buffer_New Buffer::New #else inline char* Buffer_Data(Handle obj) { return (ObjectWrap::Unwrap(obj))->data(); } inline size_t Buffer_Length(Handle obj) { return (ObjectWrap::Unwrap(obj))->length(); } inline Buffer* Buffer_New(char* data, size_t length) { Buffer* buffer = Buffer::New(length); memcpy(buffer->data(), data, length); return buffer; } #endif z_stream deflate_s; z_stream inflate_s; inline Handle ZLib_error(const char* msg = NULL) { return ThrowException(Exception::Error( String::New(msg ? msg : "Unknown Error"))); } #define ZLib_Xflate(x, factor) \ Handle ZLib_##x##flate(const Arguments& args) { \ HandleScope scope; \ \ if (args.Length() < 1 || !Buffer::HasInstance(args[0])) { \ return ZLib_error("Expected Buffer as first argument"); \ } \ \ if ((x##flateReset(&x##flate_s)) != Z_OK) { \ assert((false, "ZLib stream is beyond repair")); \ } \ \ Local input = args[0]->ToObject(); \ x##flate_s.next_in = (Bytef*)Buffer_Data(input); \ int length = x##flate_s.avail_in = Buffer_Length(input); \ \ int ret; \ char* result = NULL; \ \ int compressed = 0; \ do { \ result = (char*)realloc(result, compressed + factor * length); \ if (!result) return ZLib_error("Could not allocate memory"); \ \ x##flate_s.avail_out = factor * length; \ x##flate_s.next_out = (Bytef*)result + compressed; \ \ ret = x##flate(&x##flate_s, Z_FINISH); \ if (ret != Z_STREAM_END && ret != Z_OK && ret != Z_BUF_ERROR) { \ free(result); \ return ZLib_error(x##flate_s.msg); \ } \ \ compressed += (factor * length - x##flate_s.avail_out); \ } while (x##flate_s.avail_out == 0); \ \ Buffer* output = Buffer_New(result, compressed); \ free(result); \ return scope.Close(Local::New(output->handle_)); \ } ZLib_Xflate(de, 1); ZLib_Xflate(in, 2); extern "C" void init (Handle target) { deflate_s.zalloc = inflate_s.zalloc = Z_NULL; deflate_s.zfree = inflate_s.zfree = Z_NULL; deflate_s.opaque = inflate_s.opaque = Z_NULL; deflateInit(&deflate_s, Z_DEFAULT_COMPRESSION); inflateInit(&inflate_s); NODE_SET_METHOD(target, "deflate", ZLib_deflate); NODE_SET_METHOD(target, "inflate", ZLib_inflate); } package/test/deflate.test.js000644 000765 000024 00000055056 11620023733 017133 0ustar00kkaeferstaff000000 000000 var assert = require('assert'); var Buffer = require('buffer').Buffer; var zlib = require('../lib/zlib'); exports['test deflate/inflate buffer'] = function(beforeExit) { var input = new Buffer('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'); var compressed = zlib.deflate(input); var output = zlib.inflate(compressed); assert.deepEqual(input, output); }; exports['test deflate/inflate with high compression ratio'] = function(beforeExit) { var input = new Buffer('[" !!!!!!!########################$$$$$$$$$$$$$$$$%%%%%%%%%% %%%%%%%%%%%%%%%% % %"," !!!!!!########################$$$$$$$$$$$$$$$$$%%%%%%%%%%% %%%%%%%%%%%%% %%%% %%"," !!!!!########################$$$$$$$$$$$$$$$$$%%%%%%%%%%%%% %%%%%%% %%%%%% %%"," !!!!!###########################$$$$$$$$$$$$$$$$$%%%%%%%%%%%%% %%% %%%%%%%%%%"," !!!!###########################$$$$$$$$$$$$$$$$$%%%%%%%%%%%%% %%%%%%%%%%%%"," !!!!!!###################### ###$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%"," ! !!!!!###################### $$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%"," !!!!!!!##################### $$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%%"," !!!!!!!#################### $$$$$$$$$$$$%%%%%%%%%%%%% %%%%%%%%%%%%%%"," !!!!!##################### $$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%"," ! !!!!!##################### $$$$$$$$$$$$%%%%%%%%%%%%%% % %%% %%%%%%%%%%%%%"," ! !!!!!!!##################### $$$$$$$$$$$$$%%%%%%%%%%%%%%% %%%% %%%%%%%%%%%%%"," !!!!!!##################### $$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%% % %%%%%%%%%%%%"," !!!!!!###################### $$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%% %%%%%%%%%%%%%"," ! !!!!!!!!##################### $$$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!#################### $$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!################### $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%"," !!! !!!!####################### $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%"," !!!! !!!######################## $$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%"," ! !! !!!!####################### $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!! ! !!!###################### $$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ! ! !!!!!!!!#################### $$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!#################### $ $$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!################## $$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!! !!!!!!!!!!################## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!! !!!!!!!!!!################# $$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!! !!!!!!!!!!!!!################# $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!!############# $$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!!!############ $$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!!!############ $$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ! ! !!!!!!!!!!!!!!!!!!############ $$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!############## $$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!!############## $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!!################ $ $$$$$$$$$$$$$ $$$% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!! !!!!!!!!!!!!!!!!################ $ $$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!!!!!!!!!################# & & $ $$$$$$ $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ! !!!!!!!!!!!!!!!!!!################## & $ $$$$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ! !!!!!!!!!!!!!!!!!##################### $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!!! !!!#################### %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!! !!!!!!!!!!! !!!############## ##### \'\'\' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ! !!!!!!!!!!!! !!!################### \'\'\'\'\'\'\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!! !!!################### \'\'\'\'\'\'\'\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!!! #!################## \'\'\'\'\'\'\'\'\'\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!!! ################## \'\' \'\'\'\'\'\'\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!!!! ################ \'\'\'\'\'\'\'\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!!!! ################ \'\'\'\' \'\'\'\'\'\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!!!! ############### \'\' \'\'\'\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," !!!! ############## \' \'\'(\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ############# # ((((\'\'\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ) ############## # ( (((((\'\'\'\'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ) ############## ## ((( (((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )) ############ ## (((( ((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )))) ############ # (((((( (((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ) ))) ########### # # ((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )) ))) ########### ((((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )))))) ########### ((((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )))))))) ######### # (((****((((*(((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ))))))) ########## (************((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ))))))) )) #### **************(((((+++%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ))))) ) ))) #### ***************((+++++++%++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )))) ) )))) #### ***************++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )))) )) )))) # ***************++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ))) )) ) ) %**************+++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," )))) ) ) %%%%**********++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ,,,, ))) -- %%%%%%%%*********++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ,,, ) , ----- %%%%%%%*********+++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ,,,,,, ,,,, ------- ----%%%%%%-*******+++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ,,,,,, ,,,,,, -----------------------*****+*++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," , ,,,,, ,,,,,,,, -------------------------***+++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",". ,,,,,,,,,,,,,,, --------------------------+++++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"," ,,,,,,,,,,,,,,,,,,,,---------------------------+++++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",". /// ,,,,,,,,,,,,,,,,,,,,---------------------------+++++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",". /////,,,,,,,,,,,,,,,,,,,,---------------------------++++++++++++++++++++++%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",". .. /////,,,,,,,,,,,,,,,,,,,,----------------------------+++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%","..... ///////,,,,,,,,,,,,,,,,,,,,,---------------------------+++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%","..... //////,,,,,,,,,,,,,,,,,,,,,,-------------------------+++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%","..... ////////,,,,,,,,,,,,,,,,,,,,,------------------------+++++++++++++++++++++++++%%0000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%","..... ////////,,,,,,,,,,,,,,,,,,,,,,--------------------------++++++++++++++++++++000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",".... //////,,,,,,,,,,,,,,,,,,,,,,,,--------------------------++000000++++++++++++0000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%","... //////,,,,,,,,,,,,,,,,,,,,,,,,-------------------------+0000000000+++++0+++00000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",".. ///11///,,,,,,,,,,,,,,,,,,,,,,,,,-------------------------0000000000000000000+0000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%","..... 111111111/,,,,,,,,,,,,,,,,,,,,,,,,,-------------------------0000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%","... 22111111111/,,,,,,,,,,,,,,,,,,,,,,,3,3-------------------------00000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%"," 2222211111111,,,,,,,,,,,,,,,,,,,,,,33333------------------------00000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%"," 2222221111111,,,,,,,,,,,,,,,,,,,,333333333----------------------00000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%"," 2222222111111,,,,,,,,,,,,,,,,,,33333333333--3------------------000000000000000000000000000000000000%00%%%%%%%%%%%%%%%%%%%%%"," 22222222111114,,,,,,,,,,,,,,,,,3333333333333333----------------00000000000000000000000000000000000000000%0%%%%%%%%%%%%%%%%%%"," 22222222222211144,,,,,,,,,,,,,,,,,33333333333333333-------------000000000000000000000000000000000000000000000%%%%%%%%%%%%%%%%%"," 222222222222222144,,,,,,,,,,,,,,,,,333333333333333333-----------000000000000000000000000000000000000000000000000%0%%%%%%%%%%%%%"," 222222222222222222,,,,,,,,,,,,,,,,,,33333333333333335555-55555--00000000000000000000000000000000000000000000000000%%%%%%%%%%%%%","2222222222222222222222,,,,,,,,,,,,,,,,33333333333333555555555555-0000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%","222222222222222222222222,,,,,,,,,,,,,,,333366333333555555555555500000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%","22222222222222222222222,,,,,,,,,,,,,,,,,3366666665555555555555550000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%%","22222222222222222222222,,,,,,,,,,,,,,,,666666666555555555557775500000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%","2222222222222222222222,,,,,,,,,,,,,,,66666666666655555557577777770000000000089990000000000000000000000000000000000%%%%%%%%%%%%%%","2222222222222222222222,,,,,,,,,,,,,,,66666666666675555777777777777880000000888999990000000000000000000000000000000%%%%%%%%%%%%%%","2222222222222222222222,,,,,,,,,,,,,,,66666666666677757777777777788888880888888999999000000000000000000000000000%%%%%%%%%%%%%%%%%","2222222222222222222222::::::6,66,6666,66666666667777777777777778888888888888888999900000000000000000000000000%%%%%%%%%%%%%%%%%%%","22222222222222222222::::::::6,6666666666666666677777777777777778888888888888888999999000000000000000000000000%%%%%%%%%%%%%%%%%%%","22222222222222222222::::::::6666666666666666666777777777777777888888888888888888999990000000000000000000000 %%%%%%%%%%%%%%%%","2222222222222222222:::::::::::;6;;;;6666666666<7777777777777778888888888888888888999990000000000000000000 %%%%%%%%%%%%%%%%%%","222222222222222222:::::::::::;;;;;;;;;;6666<<<<77777777777777888888888888888888889999900 0000000000 %%%%%%%%%%%%%%%%%%%%","22222222222222222222::::;::;;;;;;;;;;;;<<<<<<<===777777777777888888888888888888889900000 000000000 %%%%%%%%%%%%%%%%%%%","22222222222222222222:::;;;;;;;;;;;;;;;;<<<<<<=====777777>>88888888888888888888889990000 00 00 %%%%%%%%%%%%%%%%%%%","22222222222222222222;;;;;;;;;;;;;;;;;;;<<<<<<======77=>>>>>888888888888888888888890000 000 %%%%%%%%%%%%%%%%%%%%","22222222222222222222;;;;;;;;;;;;;;;;; <<<<==========>>>>>>8888888888888888888899000 000000 %%%%%%%%%%%%%%%%%%%%%","222222222222222222222;;;;;;;;;;;;;; ================>>>>>8888888888888888888880088 000000 000% %%%%%%%%%%%%%%%%%%%%","2222222222222222222;;;;;;;;;;;;;;;;; == ==?=????=?==>>>>>>>88888888888888888888888 00000 00 %%%%%%%%%%%%%%%%%%%%%%%","22222222222222222222;;;;;;;;;;;;;;; = ==???????????>>>>>888888888888888888888888 0000 %%%%%%%%%%%%%%%%%%%%%","22222222222222222222;;;;;;;;;;;;;;; = ===?????????>>>>>>>>8>88888888888888888 000 %%%%%%%%%%%%%%%%%%%","22222222222222222222;;;;; ;;;;;;;;; ====????????>>>>>>>>>>88888888888888888 %%%%%%%%%%%%%%%%%%","2222222222222222222222;; ;;;;;;;; ===?????????>>>>>>>>>@88888888888@8888 %%%%%%%%%%%%%%%%","2222222222222222222222; ;;;;;;;; ===????????>>>>>>>>@@88888888@@@@@@88 %%%%%%%%%%%%%%%","222222222222222222222 ;;;;;;;;; ===???????>>>>>>>>@@@@@@@@@@@@@@@@@@ %%%%%%%%%%%%%%","22222222222 222 ;;;;;;;;;; = =?????A>>>>>>>>>@@@@@@@@@@@@@@@ BBB%%%%%%%%%%","222222222 ;;;;;;;;;; = =???AAA>>>>>>>>>@@@@@@@@@@@@@@ BBBBBB%%%%%","22C222222 ;;;;;;;;; ??AAAAA>>>>>>@@@@@@@@@@@@@@@@ BBBBBBBB%%%","CCCCC2222 222 ;;;;;;;;; =AAADD>>>>>>@@@@@@@@@@@@@@@ BBBBBBBBB","CCCCCCCCCC 222 ;;;;;;;; AADDD>>>>E@@@@@@@@@@@@@@@ BBBBBBBBB","CCCCCCCCCC 22 ;;;;;;;;; ADDD>EEEEE@@@@@@@@@@@@F@@ BBBBBBBBB","CCCCCCCCC 22 ;;;;;;;;;;;; DDDEEEEEEE@@@@@@@@@FFFFF FFFFFFFF BBBBBBBBB","CCCCCCC 2 ;;;;;;;;;; DDDEEEEEEE@@@G@@@@@GFFFFF FFFFFFFFFFFF BBBFBBBBB","CCCCCC ;;;;;;; DDDEEEEEEGGGGGGGGGGFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFBBBBB"]'); var compressed = zlib.deflate(input); var output = zlib.inflate(compressed); assert.deepEqual(input, output); }; exports['test inflate #2'] = function(beforeExit) { var compressed = new Buffer('\x78\x9c\xab\x56\x4a\x2f\xca\x4c\x51\xb2\x8a\x56\x52\xa0\x10\x28\xe9\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\x04\x12\x50\x04\x02\x2a\x18\x01\x01\x64\x1b\x81\x64\x06\xdc\x10\xd2\x8c\x50\x44\x36\x02\x66\x06\x05\xae\x80\x99\x41\x72\x8c\x60\x9a\x41\x46\xa4\x0e\x0e\x23\x80\x81\xaa\x40\xa9\x11\x0a\x28\x46\x28\x52\xe6\x0a\x45\x0a\x8c\x40\x0e\x10\xf2\xb3\x19\x15\x8c\x80\x1b\x42\x69\x66\x57\x54\x54\xa6\xbc\xbc\xa0\x82\x11\x43\xb3\xe0\x1b\x42\x46\xa8\x50\xc1\x15\x2a\xa4\x1a\x42\xb9\x47\x54\x95\x62\x75\x94\xb2\x53\x2b\x8b\x41\x03\x19\x40\xe3\x7c\x23\x80\x84\x7b\x08\x90\xf0\x0e\x02\x12\xae\xce\x4a\xb1\xb5\x00\x83\x32\x27\xf3', 'binary'); var output = zlib.inflate(compressed); assert.equal(output.toString(), '{"grid":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," !!!! "," !!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!! "," !!!!!!! !"," ! !!!!!!!! !"," ! !!!!!!!!!!!"," !!!!!!!!!"," !!!!!!!"," !!#"," #"," "," "," "," "," "," "," $ "," $$ "," %"],"keys":["","MX","GT","KR","EC"]}'); }; package/test/inflate.test.js000644 000765 000024 00000047467 11620023733 017160 0ustar00kkaeferstaff000000 000000 var assert = require('assert'); var Buffer = require('buffer').Buffer; var zlib = require('../lib/zlib'); exports['test header inflate fail'] = function(beforeExit) { var compressed = new Buffer('\x78\x80\x9c\xab\x56\x4a\x93\xaf\x46\x00\x1b\xa9\x02\x77\x92\x0f', 'binary'); assert.throws(function() { var output = zlib.inflate(compressed); }, "incorrect header check"); var compressed = new Buffer('\x78\x9c\xab\x56\x4a\x2f\xca\x4c\x51\xb2\x8a\x56\x52\xa0\x10\x28\xe9\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\x04\x12\x50\x04\x02\x2a\x18\x01\x01\x64\x1b\x81\x64\x06\xdc\x10\xd2\x8c\x50\x44\x36\x02\x66\x06\x05\xae\x80\x99\x41\x72\x8c\x60\x9a\x41\x46\xa4\x0e\x0e\x23\x80\x81\xaa\x40\xa9\x11\x0a\x28\x46\x28\x52\xe6\x0a\x45\x0a\x8c\x40\x0e\x10\xf2\xb3\x19\x15\x8c\x80\x1b\x42\x69\x66\x57\x54\x54\xa6\xbc\xbc\xa0\x82\x11\x43\xb3\xe0\x1b\x42\x46\xa8\x50\xc1\x15\x2a\xa4\x1a\x42\xb9\x47\x54\x95\x62\x75\x94\xb2\x53\x2b\x8b\x41\x03\x19\x40\xe3\x7c\x23\x80\x84\x7b\x08\x90\xf0\x0e\x02\x12\xae\xce\x4a\xb1\xb5\x00\x83\x32\x27\xf3', 'binary'); var output = zlib.inflate(compressed); assert.equal(output.toString(), '{"grid":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," !!!! "," !!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!! "," !!!!!!! !"," ! !!!!!!!! !"," ! !!!!!!!!!!!"," !!!!!!!!!"," !!!!!!!"," !!#"," #"," "," "," "," "," "," "," $ "," $$ "," %"],"keys":["","MX","GT","KR","EC"]}'); }; exports['test truncated inflate fail'] = function(beforeExit) { var compressed = new Buffer('\x78\x9c\xab\x56\x4a\x2f\xca\x4c\x51\xb2\x8a\x56\x52\xa0\x10\x28\xe9\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\x04\x12\x50\x04\x02\x2a\x18\x01\x01\x64\x1b\x81\x64\x06\xdc\x10\xd2\x8c\x50\x44\x36\x02\x66\x06\x05\xae\x80\x99\x41\x72\x8c\x60\x9a\x41\x46\xa4\x0e\x0e\x23\x80\x81\xaa\x40\xa9\x11\x0a\x28\x46\x28\x52\xe6\x0a\x45\x0a\x8c\x40\x0e\x10\xf2\xb3\x19\x15\x8c\x80\x1b\x42\x69\x66\x57\x54\x54\xa6', 'binary'); var output = zlib.inflate(compressed); assert.equal(output.toString(), '{"grid":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," !!!! "," !!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!! "," !!!!!!! !"," ! !!!!!!!! !"," ! !!!!!!!!!!!"," !!!!!!!!!"," !!!!!!!"," !!#'); var compressed = new Buffer('\x78\x9c\xab\x56\x4a\x2f\xca\x4c\x51\xb2\x8a\x56\x52\xa0\x10\x28\xe9\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\x04\x12\x50\x04\x02\x2a\x18\x01\x01\x64\x1b\x81\x64\x06\xdc\x10\xd2\x8c\x50\x44\x36\x02\x66\x06\x05\xae\x80\x99\x41\x72\x8c\x60\x9a\x41\x46\xa4\x0e\x0e\x23\x80\x81\xaa\x40\xa9\x11\x0a\x28\x46\x28\x52\xe6\x0a\x45\x0a\x8c\x40\x0e\x10\xf2\xb3\x19\x15\x8c\x80\x1b\x42\x69\x66\x57\x54\x54\xa6\xbc\xbc\xa0\x82\x11\x43\xb3\xe0\x1b\x42\x46\xa8\x50\xc1\x15\x2a\xa4\x1a\x42\xb9\x47\x54\x95\x62\x75\x94\xb2\x53\x2b\x8b\x41\x03\x19\x40\xe3\x7c\x23\x80\x84\x7b\x08\x90\xf0\x0e\x02\x12\xae\xce\x4a\xb1\xb5\x00\x83\x32\x27\xf3', 'binary'); var output = zlib.inflate(compressed); assert.equal(output.toString(), '{"grid":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," !!!! "," !!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!! "," !!!!!!! !"," ! !!!!!!!! !"," ! !!!!!!!!!!!"," !!!!!!!!!"," !!!!!!!"," !!#"," #"," "," "," "," "," "," "," $ "," $$ "," %"],"keys":["","MX","GT","KR","EC"]}'); }; exports['test bogus inflate fail'] = function(beforeExit) { var compressed = new Buffer('bahbahfoobar', 'binary'); assert.throws(function() { var output = zlib.inflate(compressed); }, "incorrect header check"); var compressed = new Buffer('\x78\x9c\xab\x56\x4a\x2f\xca\x4c\x51\xb2\x8a\x56\x52\xa0\x10\x28\xe9\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\xc4\xa8\x11\xa3\x46\x8c\x1a\x31\x6a\x04\x12\x50\x04\x02\x2a\x18\x01\x01\x64\x1b\x81\x64\x06\xdc\x10\xd2\x8c\x50\x44\x36\x02\x66\x06\x05\xae\x80\x99\x41\x72\x8c\x60\x9a\x41\x46\xa4\x0e\x0e\x23\x80\x81\xaa\x40\xa9\x11\x0a\x28\x46\x28\x52\xe6\x0a\x45\x0a\x8c\x40\x0e\x10\xf2\xb3\x19\x15\x8c\x80\x1b\x42\x69\x66\x57\x54\x54\xa6\xbc\xbc\xa0\x82\x11\x43\xb3\xe0\x1b\x42\x46\xa8\x50\xc1\x15\x2a\xa4\x1a\x42\xb9\x47\x54\x95\x62\x75\x94\xb2\x53\x2b\x8b\x41\x03\x19\x40\xe3\x7c\x23\x80\x84\x7b\x08\x90\xf0\x0e\x02\x12\xae\xce\x4a\xb1\xb5\x00\x83\x32\x27\xf3', 'binary'); var output = zlib.inflate(compressed); assert.equal(output.toString(), '{"grid":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," !!!! "," !!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!!!! "," !!!!!!!!!!! "," !!!!!!!!!!! "," ! !!!!!!! "," !!!!!!! !"," ! !!!!!!!! !"," ! !!!!!!!!!!!"," !!!!!!!!!"," !!!!!!!"," !!#"," #"," "," "," "," "," "," "," $ "," $$ "," %"],"keys":["","MX","GT","KR","EC"]}'); };