node-liblzma 1.0.4-8 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +5 -0
- package/README.md +199 -0
- package/binding.gyp +671 -43
- package/package.json +37 -23
- package/prebuilds/linux-x64/node_lzma.node +0 -0
- package/prebuilds/mac-x64/node_lzma.node +0 -0
- package/prebuilds/win-x64/node_lzma.node +0 -0
- package/scripts/download_extract_deps.py +29 -0
- package/scripts/prebuildify.py +13 -0
- package/scripts/walk_sources.py +7 -0
- package/src/bindings/module.cpp +86 -86
- package/src/bindings/node-liblzma.cpp +292 -273
- package/src/bindings/node-liblzma.hpp +62 -90
- package/src/lzma.coffee +25 -18
- package/build.yml +0 -78
- package/lib/lzma.js +0 -377
package/History.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Node-liblzma
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
[](https://npmjs.org/package/node-liblzma)
|
|
5
|
+
[](https://npmjs.org/package/node-liblzma)
|
|
6
|
+
[](https://travis-ci.org/oorabona/node-liblzma)
|
|
7
|
+
[](https://david-dm.org/oorabona/node-liblzma)
|
|
8
|
+
[](https://david-dm.org/oorabona/node-liblzma#info=devDependencies)
|
|
9
|
+
|
|
10
|
+
# What is liblzma/XZ ?
|
|
11
|
+
|
|
12
|
+
[XZ](http://tukaani.org/xz/xz-file-format.txt) is a container for compressed archives. It is among the best compressors out there according to several benchmarks:
|
|
13
|
+
* [Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZO](http://pokecraft.first-world.info/wiki/Quick_Benchmark:_Gzip_vs_Bzip2_vs_LZMA_vs_XZ_vs_LZ4_vs_LZO)
|
|
14
|
+
* [Large Text Compression Benchmark](http://mattmahoney.net/dc/text.html#2118)
|
|
15
|
+
* [Linux Compression Comparison (GZIP vs BZIP2 vs LZMA vs ZIP vs Compress)](http://bashitout.com/2009/08/30/Linux-Compression-Comparison-GZIP-vs-BZIP2-vs-LZMA-vs-ZIP-vs-Compress.html)
|
|
16
|
+
|
|
17
|
+
It has a good balance between compression time/ratio and decompression time/memory.
|
|
18
|
+
|
|
19
|
+
# About this project
|
|
20
|
+
|
|
21
|
+
This project aims towards providing:
|
|
22
|
+
* A quick and easy way to play with XZ compression:
|
|
23
|
+
Quick and easy as it conforms to zlib API, so that switching from __zlib/deflate__ to __xz__ might be as easy as a string search/replace in your code editor :smile:
|
|
24
|
+
|
|
25
|
+
* Complete integration with XZ sources/binaries:
|
|
26
|
+
You can either use system packages or download a specific version and compile it!
|
|
27
|
+
See [installation](#installation) below.
|
|
28
|
+
|
|
29
|
+
> Only LZMA2 is supported for compression output.
|
|
30
|
+
But the library can open and read any LZMA1 or LZMA2 compressed file. And possibly others...
|
|
31
|
+
|
|
32
|
+
# What's new ?
|
|
33
|
+
|
|
34
|
+
Supports all NodeJS versions, thanks to [nan](https://github.com/nodejs/nan) !
|
|
35
|
+
It has been tested and works on:
|
|
36
|
+
- Linux x64 (Ubuntu)
|
|
37
|
+
- OSX (tested with Travis)
|
|
38
|
+
- Raspberry Pi 2 (armv7l 32-bits)
|
|
39
|
+
- Raspberry Pi 3 (armv8l but still a 32 bits Raspbian)
|
|
40
|
+
- Windows (ongoing tests)
|
|
41
|
+
|
|
42
|
+
# Related projects
|
|
43
|
+
|
|
44
|
+
Thanks to the community, there are several choices out there:
|
|
45
|
+
* [lzma-purejs](https://github.com/cscott/lzma-purejs)
|
|
46
|
+
A pure JavaScript implementation of the algorithm
|
|
47
|
+
* [node-xz](https://github.com/robey/node-xz)
|
|
48
|
+
Node binding of XZ library
|
|
49
|
+
* [lzma-native](https://github.com/addaleax/lzma-native)
|
|
50
|
+
A very complete implementation of XZ library bindings
|
|
51
|
+
* Others are also available but they fork "xz" process in the background.
|
|
52
|
+
|
|
53
|
+
# API comparison
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
var lzma = require('lzma');
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Zlib | XZlib | Arguments
|
|
60
|
+
----------------|-------------------------|---------------
|
|
61
|
+
createGzip | createXz | ([lzma_options, [options]])
|
|
62
|
+
createGunzip | createUnxz | ([lzma_options, [options]])
|
|
63
|
+
gzip | xz | (buf, [options], callback)
|
|
64
|
+
gunzip | unxz | (buf, [options], callback)
|
|
65
|
+
gzipSync | xzSync | (buf, [options])
|
|
66
|
+
gunzipSync | unxzSync | (buf, [options])
|
|
67
|
+
|
|
68
|
+
## Constants
|
|
69
|
+
|
|
70
|
+
`options` is an `Object` with the following possible attributes:
|
|
71
|
+
|
|
72
|
+
Attribute | Type | Available options
|
|
73
|
+
---------------------|----------|------------
|
|
74
|
+
check | Uint32 | NONE
|
|
75
|
+
| |CRC32
|
|
76
|
+
| |CRC64
|
|
77
|
+
| |SHA256
|
|
78
|
+
preset | Uint32 | DEFAULT
|
|
79
|
+
| |EXTREME
|
|
80
|
+
flag | Uint32 | TELL_NO_CHECK
|
|
81
|
+
| |TELL_UNSUPPORTED_CHECK
|
|
82
|
+
| |TELL_ANY_CHECK
|
|
83
|
+
| |CONCATENATED
|
|
84
|
+
mode | Uint32 | FAST
|
|
85
|
+
| |NORMAL
|
|
86
|
+
filters | Array | LZMA2 (added by default)
|
|
87
|
+
| |X86
|
|
88
|
+
| |POWERPC
|
|
89
|
+
| |IA64
|
|
90
|
+
| |ARM
|
|
91
|
+
| |ARMTHUMB
|
|
92
|
+
| |SPARC
|
|
93
|
+
|
|
94
|
+
For further information about each of these flags, you will find reference at [XZ SDK](http://7-zip.org/sdk.html).
|
|
95
|
+
|
|
96
|
+
# Installation
|
|
97
|
+
|
|
98
|
+
Well, as simple as this one-liner:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
$ npm i node-liblzma --save
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If you want to enable threading support in the module, then opt in with:
|
|
105
|
+
|
|
106
|
+
``` bash
|
|
107
|
+
$ ENABLE_MT=1 npm install node-liblzma --save
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
> This will of course work only if you have a binary version of liblzma with threading enabled.
|
|
111
|
+
If this is not the case, it will not fail (even at runtime). It justs won't work.
|
|
112
|
+
To check if this is enabled or not, run the [tests suite](#tests)
|
|
113
|
+
|
|
114
|
+
In both cases, it will try to download an existing pre-compiled module binary and if none exists it will build it.
|
|
115
|
+
|
|
116
|
+
To build the module, you have the following options:
|
|
117
|
+
1. Using system development libraries
|
|
118
|
+
2. Automatic download and compilation of `xz` libs, and statically link against node module
|
|
119
|
+
3. Compile `xz` yourself, outside `node-liblzma` and build node module with dynamically linked library
|
|
120
|
+
|
|
121
|
+
## Using system dev libraries to compile
|
|
122
|
+
|
|
123
|
+
You need to have the development package installed on your system. If you have Debian based distro:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
# apt-get install liblzma-dev
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Automatic download and compilation to statically link `xz`
|
|
130
|
+
|
|
131
|
+
If you do not plan on having a local install, you can ask for automatic download and build of whatever version of `xz` you want.
|
|
132
|
+
With the use of [UBS](https://github.com/oorabona/ubs), you do not need to download/configure/install `xz` yourself anymore.
|
|
133
|
+
|
|
134
|
+
Just do:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
$ COMPILE=1 npm install --save node-liblzma
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
When no option is given in the commandline arguments, it will build with default values.
|
|
141
|
+
|
|
142
|
+
If you want to build __experimental__ multi-threading feature, you can build `xz` with threads enabled just for this library by running:
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
$ ENABLE_MT=1 COMPILE=1 npm install --save node-liblzma
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Local install of `xz` sources (outside `node-liblzma`)
|
|
149
|
+
|
|
150
|
+
So you did install `xz` somewhere outside the module and want the module to use it.
|
|
151
|
+
|
|
152
|
+
For that, you need to set the include directory and library directory search paths as GCC [environment variables](https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html).
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
$ export CPATH=$HOME/path/to/headers
|
|
156
|
+
$ export LIBRARY_PATH=$HOME/path/to/lib
|
|
157
|
+
$ export LD_LIBRARY_PATH=$HOME/path/to/lib:$LD_LIBRARY_PATH
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The latest is needed for tests to be run right after.
|
|
161
|
+
|
|
162
|
+
Once done, this should suffice:
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
$ npm install
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
# Tests
|
|
169
|
+
|
|
170
|
+
You can run tests with:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
$ npm test
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
It will build and launch tests suite with [Mocha](https://github.com/visionmedia/mocha).
|
|
177
|
+
|
|
178
|
+
# Usage
|
|
179
|
+
|
|
180
|
+
As the API is very close to NodeJS Zlib, you will probably find a good reference
|
|
181
|
+
[there](http://www.nodejs.org/api/zlib.html).
|
|
182
|
+
|
|
183
|
+
Otherwise examples can be found as part of the test suite, so feel free to use them!
|
|
184
|
+
They are written in [CoffeeScript](http://www.coffeescript.org).
|
|
185
|
+
|
|
186
|
+
# Bugs
|
|
187
|
+
|
|
188
|
+
If you find one, feel free to contribute and post a new issue!
|
|
189
|
+
PR are accepted as well :)
|
|
190
|
+
|
|
191
|
+
Kudos goes to [addaleax](https://github.com/addaleax) for helping me out with C++ stuff !
|
|
192
|
+
|
|
193
|
+
If you compile with threads, you may see a bunch of warnings about `-Wmissing-field-initializers`.
|
|
194
|
+
This is _normal_ and does not prevent threading from being active and working.
|
|
195
|
+
I did not yet figure how to fix this except by masking the warning..
|
|
196
|
+
|
|
197
|
+
# License
|
|
198
|
+
|
|
199
|
+
This software is released under LGPL3.0+
|