lib/constants.js

1.
/**
2.
 * This is the constants class. It contains multiple classes with constants for the compression 
3.
 * settings that are available in the settings class.
4.
 * @class compression.constants
5.
 */
6.
module.exports = class constants {
7.
	/**
8.
	 * This function returns the {@link compression.constants.flush.constructor} class. It contains the constants for the flush 
9.
	 * setting.
10.
	 * @summary Returns the {@link compression.constants.flush.constructor} class.
11.
	 * @return {Class} The {@link compression.constants.flush.constructor} class.
12.
	 * @function flush
13.
	 */
14.
	flush() {
15.
		if(this.flush === undefined) {
16.
			this.flush = new constants_flush();
17.
		}
18.

			
19.
		return this.flush;
20.
	}
21.

			
22.
	/**
23.
	 * This functions return the {@link compression.constants.codes.constructor} class. It contains codes, like errors, the 
24.
	 * compression class may return.
25.
	 * @summary Returns the {@link compression.constants.codes.constructor} class.
26.
	 * @return {Class} The {@link compression.constants.codes.constructor} class.
27.
	 * @function codes
28.
	 */
29.
	codes() {
30.
		if(this.codes === undefined) {
31.
			this.codes = new constants_codes();
32.
		}
33.

			
34.
		return this.codes;
35.
	}
36.

			
37.
	/**
38.
	 * This functions return the {@link compression.constants.level.constructor} class. It contains the constants for the 
39.
	 * compression level setting.
40.
	 * @summary Returns the {@link compression.constants.level.constructor} class.
41.
	 * @return {Class} The {@link compression.constants.level.constructor} class.
42.
	 * @function level
43.
	 */
44.
	level() {
45.
		if(this.level === undefined) {
46.
			this.level = new constants_level();
47.
		}
48.

			
49.
		return this.level;
50.
	}
51.

			
52.
	/**
53.
	 * This functions return the {@link compression.constants.strategy.constructor} class. It contains the constants for the 
54.
	 * compression strategy setting.
55.
	 * @summary Returns the {@link compression.constants.strategy.constructor} class.
56.
	 * @return {Class} The {@link compression.constants.strategy.constructor} class.
57.
	 * @function strategy
58.
	 */
59.
	strategy() {
60.
		if(this.strategy === undefined) {
61.
			this.strategy = new constants_strategy();
62.
		}
63.

			
64.
		return this.strategy;
65.
	}
66.

			
67.
	/**
68.
	 * This functions return the {@link compression.constants.windowbits.constructor} class. It contains the constants for the 
69.
	 * windowbits setting.
70.
	 * @summary Returns the {@link compression.constants.windowbits.constructor} class.
71.
	 * @return {Class} The {@link compression.constants.windowbits.constructor} class.
72.
	 * @function windowbits
73.
	 */
74.
	windowbits() {
75.
		if(this.windowbits === undefined) {
76.
			this.windowbits = new constants_windowbits();
77.
		}
78.

			
79.
		return this.windowbits;
80.
	}
81.

			
82.
	/**
83.
	 * This functions return the {@link compression.constants.memory.constructor} class. It contains the constants for the memory
84.
	 * level setting.
85.
	 * @summary Returns the {@link compression.constants.memory.constructor} class.
86.
	 * @return {Class} The {@link compression.constants.memory.constructor} class.
87.
	 * @function memory
88.
	 */
89.
	memory() {
90.
		if(this.memory === undefined) {
91.
			this.memory = new constants_memory();
92.
		}
93.

			
94.
		return this.memory;
95.
	}
96.

			
97.
	/**
98.
	 * This functions return the {@link compression.constants.chunk.constructor} class. It contains the constants for the chunk size
99.
	 * setting.
100.
	 * @summary Returns the {@link compression.constants.chunk.constructor} class.
101.
	 * @return {Class} The {@link compression.constants.chunk.constructor} class.
102.
	 * @function chunk
103.
	 */
104.
	chunk() {
105.
		if(this.chunk === undefined) {
106.
			this.chunk = new constants_chunk();
107.
		}
108.

			
109.
		return this.chunk;
110.
	}
111.
}
112.

			
113.
/**
114.
 * This is the flush contants class. It contains constants that can be used in the flush setting.
115.
 * @class compression.constants.flush
116.
 */
117.
class constants_flush {
118.
	/**
119.
	 * This is the NO_FLUSH constant. This means the compression class won't flush it's data when 
120.
	 * the flush setting is set to this.
121.
	 * @summary Returns the NO_FLUSH constant.
122.
	 * @returns {Constant} Z_NO_FLUSH
123.
	 * @function no
124.
	 */
125.
	no() {
126.
		return zlib.constants.Z_NO_FLUSH;
127.
	}
128.

			
129.
	/**
130.
	 * This is the PARTIAL_FLUSH constant. This means the compression class will only do a partial
131.
	 * flush when the flush setting is set to this.
132.
	 * @summary Returns the PARTIAL_FLUSH constant.
133.
	 * @returns {Constant} Z_PARTIAL_FLUSH
134.
	 * @function partial
135.
	 */
136.
	partial() {
137.
		return zlib.constants.Z_PARTIAL_FLUSH;
138.
	}
139.

			
140.
	/**
141.
	 * This is the SYNC_FLUSH constant. This means the compression class will only flush if it 
142.
	 * needs to sync up when the flush setting is set to this. This happens when new data is added 
143.
	 * to the compression stream.
144.
	 * @summary Returns the SYNC_FLUSH constant.
145.
	 * @returns {Constant} Z_SYNC_FLUSH
146.
	 * @function sync
147.
	 */
148.
	sync() {
149.
		return zlib.constants.Z_SYNC_FLUSH;
150.
	}
151.

			
152.
	/**
153.
	 * This is the FULL_FLUSH constant. THis means the compression class will fully flush the 
154.
	 * stream every time new data has been added.
155.
	 * @summary Returns the FULL_FLUSH constant.
156.
	 * @returns {Constant} Z_FULL_FLUSH
157.
	 * @function full
158.
	 */
159.
	full() {
160.
		return zlib.constants.Z_FULL_FLUSH;
161.
	}
162.

			
163.
	/**
164.
	 * This is the FINISH constant. This means the compression class will only do a flush when the 
165.
	 * compression has been ended. 
166.
	 * @summary Returns the FINISH constant.
167.
	 * @returns {Constant} Z_FINISH
168.
	 * @function finish
169.
	 */
170.
	finish() {
171.
		return zlib.constants.Z_FINISH;
172.
	}
173.

			
174.
	/**
175.
	 * This is the BLOCK constant. This means the compression class will flush every time a new 
176.
	 * block has been created. A block is a certain amount of data, which size depends on the 
177.
	 * machine you're using.
178.
	 * @summary Returns the BLOCK constant.
179.
	 * @returns {Constant} Z_BLOCK
180.
	 * @function block
181.
	 */
182.
	block() {
183.
		return zlib.constants.Z_BLOCK;
184.
	}
185.

			
186.
	/**
187.
	 * This is the TREES constant. This means the compression class will only flush the tree. This 
188.
	 * is a sort of dictionary that is used to compress the data.
189.
	 * @summary Returns the TREES constant.
190.
	 * @returns {Constant} Z_TREES_FLUSH
191.
	 * @function trees
192.
	 */
193.
	trees() {
194.
		return zlib.constants.Z_TREES;
195.
	}
196.
}
197.

			
198.
/**
199.
 * This is the codes contants class. It contains possible error or messages that can be returned by
200.
 * the compression class.
201.
 * @class compression.constants.codes
202.
 */
203.
class constants_codes {
204.
	/**
205.
	 * This is the OK code. This code means that the compression was succesful and that there was 
206.
	 * no error while compressing.
207.
	 * @summary Returns the OK code.
208.
	 * @returns {Constant} Z_OK
209.
	 * @function ok
210.
	 */
211.
	ok() {
212.
		return zlib.constants.Z_OK;
213.
	}
214.

			
215.
	/**
216.
	 * This is the STREAM_END code. This code means that the stream has been enden but something is
217.
	 * still trying to add data to the stream.
218.
	 * @summary Returns the STREAM_END code.
219.
	 * @returns {Constant} Z_STREAM_END
220.
	 * @function streamend
221.
	 */
222.
	streamend() {
223.
		return zlib.constants.Z_STREAM_END;
224.
	}
225.

			
226.
	
227.
	/**
228.
	 * This is the NEED_DICT code. This code means that the compression stream was trying to 
229.
	 * decompress something but couldn't find a dictionary. This is list of quick translations
230.
	 * the decompression class uses to quickly decompress data.
231.
	 * @summary Returns the NEED_DICT code.
232.
	 * @returns {Constant} Z_NEED_DICT
233.
	 * @function needdict
234.
	 */
235.
	needdict() {
236.
		return zlib.constants.Z_NEED_DICT;
237.
	}
238.

			
239.
	/**
240.
	 * This is the ERRNO code. This code means that there was an error while flushing the data.
241.
	 * @summary Returns the ERRNO code.
242.
	 * @returns {Constant} Z_ERRNO
243.
	 * @function errno
244.
	 */
245.
	errno() {
246.
		return zlib.constants.Z_ERRNO;
247.
	}
248.

			
249.
	/**
250.
	 * This is the STREAM_ERROR code. This code means that there was an error while accessing a 
251.
	 * file that needs to be written to or read from.
252.
	 * @summary Returns the STREAM_ERROR code.
253.
	 * @returns {Constant} Z_STREAM_ERROR
254.
	 * @function streamerror
255.
	 */
256.
	streamerror() {
257.
		return zlib.constants.Z_STREAM_ERROR;
258.
	}
259.
	
260.
	/**
261.
	 * This is the DATA_ERROR code. This code means that there was something that stopped the 
262.
	 * stream while it was compressing or decompressing data.
263.
	 * @summary Returns the DATA_ERROR code.
264.
	 * @returns {Constant} Z_DATA_ERROR
265.
	 * @function dataerror
266.
	 */
267.
	dataerror() {
268.
		return zlib.constants.Z_DATA_ERROR;
269.
	}
270.

			
271.
	/**
272.
	 * This is the MEM_ERROR code. This code means that there was an error while allocating 
273.
	 * memory to the compression or decompression process.
274.
	 * @summary Returns the MEM_ERROR code.
275.
	 * @returns {Constant} Z_MEM_ERROR
276.
	 * @function memerror
277.
	 */
278.
	memerror() {
279.
		return zlib.constants.Z_MEM_ERROR;
280.
	}
281.

			
282.
	/**
283.
	 * This is the BUF_ERROR code. This code means that there was an error while trying to write
284.
	 * data to the buffer since it was full.
285.
	 * @summary Returns the BUF_ERROR code.
286.
	 * @returns {Constant} Z_BUF_ERROR
287.
	 * @function buferror
288.
	 */
289.
	buferror() {
290.
		return zlib.constants.Z_BUF_ERROR;
291.
	}
292.

			
293.
	/**
294.
	 * This is the VERSION_ERROR code. This code means that there was an error since the version 
295.
	 * for zlib the user is using doesn't support the requested compression or decompression type.
296.
	 * @summary Returns the VERSION_ERROR code.
297.
	 * @returns {Constant} Z_VERSION_ERROR
298.
	 * @function versionerror
299.
	 */
300.
	versionerror() {
301.
		return zlib.constants.Z_VERSION_ERROR;
302.
	}
303.
}
304.

			
305.
/**
306.
 * This is the compession level contants class. It contains constants that can be used in the level
307.
 * setting.
308.
 * @class compression.constants.level
309.
 */
310.
class constants_level {
311.
	/**
312.
	 * This is the NO_COMPRESSION constant. When it's used the compression class won't compress 
313.
	 * anything.
314.
	 * @summary Returns the NO_COMPRESSION constant.
315.
	 * @returns {Constant} Z_NO_COMPRESSION
316.
	 * @function no
317.
	 */
318.
	no() {
319.
		return zlib.constants.Z_NO_COMPRESSION;
320.
	}
321.

			
322.
	/**
323.
	 * This is the BEST_SPEED constant. When it's used the compression class will compress with as
324.
	 * fast as possible, meaning the compression won't be as good.
325.
	 * @summary Returns the BEST_SPEED constant.
326.
	 * @returns {Constant} Z_BEST_SPEED
327.
	 * @function speed
328.
	 */
329.
	speed() {
330.
		return zlib.constants.Z_BEST_SPEED;
331.
	}
332.

			
333.
	/**
334.
	 * This is the BEST_COMPRESSION constant. When it's used the compression class will compress 
335.
	 * the data as much as possible. This will take more time than the other options.
336.
	 * @summary Returns the BEST_COMPRESSION constant.
337.
	 * @returns {Constant} Z_BEST_COMPRESSION
338.
	 * @function compression
339.
	 */
340.
	compression() {
341.
		return zlib.constants.Z_BEST_COMPRESSION;
342.
	}
343.
	
344.
	/**
345.
	 * This is the DEFAULT_COMPRESSION constant. When it's used the compression class will combine 
346.
	 * speed with amount of compression to create the highest possible speed/compression ratio.
347.
	 * @summary Returns the DEFAULT_COMPRESSION constant.
348.
	 * @returns {Constant} Z_DEFAULT_COMPRESSION
349.
	 * @function default
350.
	 */
351.
	default() {
352.
		return zlib.constants.Z_DEFAULT_COMPRESSION;
353.
	}
354.
}
355.

			
356.
/**
357.
 * This is the compession strategy contants class. It contains constants that can be used in the 
358.
 * strategy setting.
359.
 * @class compression.constants.strategy
360.
 */
361.
class constants_strategy {
362.
	/**
363.
	 * This is the FILTERED constant. This strategy is optimized for data that is produced by a 
364.
	 * filter. Meaning it is one kind of data.
365.
	 * @summary Returns the FILTERED constant.
366.
	 * @returns {Constant} Z_FILTERED
367.
	 * @function filtered
368.
	 */
369.
	filtered() {
370.
		return zlib.constants.Z_FILTERED;
371.
	}
372.

			
373.
	/**
374.
	 * This is the HUFFMAN_ONLY constant. This strategy is optimized for data you don't 
375.
	 * think contain any similar data, since it won't do any string matching.
376.
	 * @summary Returns the HUFFMAN_ONLY constant.
377.
	 * @returns {Constant} Z_HUFFMAN_ONLY
378.
	 * @function huffman
379.
	 */
380.
	huffman() {
381.
		return zlib.constants.Z_HUFFMAN_ONLY;
382.
	}
383.

			
384.
	/**
385.
	 * This is the RLE constant. This strategy is optimized for PNG images and is designed
386.
	 * to be almost as fust as HUFFMAN_ONLY
387.
	 * @summary Returns the RLE constant.
388.
	 * @returns {Constant} Z_RLE
389.
	 * @function rle
390.
	 */
391.
	rle() {
392.
		return zlib.constants.Z_RLE;
393.
	}
394.

			
395.
	/**
396.
	 * This is the FIXED constant. This strategy is optimized for simpler applications and is 
397.
	 * optimized for shorter strings, as it doesn't use Huffman's dynamic codes.
398.
	 * @summary Returns the FIXED constant.
399.
	 * @returns {Constant} Z_FIXED
400.
	 * @function fixed
401.
	 */
402.
	fixed() {
403.
		return zlib.constants.Z_FIXED;
404.
	}
405.

			
406.
	/**
407.
	 * This is the DEFAULT_STRATEGY constant. This strategy is optimized for normal data. It 
408.
	 * combines Huffman's compression with the standard text compression. 
409.
	 * @summary Returns the DEFAULT_STRATEGY constant.
410.
	 * @returns {Constant} Z_DEFAULT_STRATEGY
411.
	 * @function default
412.
	 */
413.
	default() {
414.
		return zlib.constants.Z_DEFAULT_STRATEGY;
415.
	}
416.
}
417.

			
418.
/**
419.
 * This is the windowbits contants class. It contains constants that can be used in the windowbits
420.
 * setting.
421.
 * @class compression.constants.windowbits
422.
 */
423.
class constants_windowbits {
424.
	/**
425.
	 * This is the MIN_WINDOWBITS constant. It returns the minimal amount of windowbits that can be
426.
	 * used for the compression and decompression.
427.
	 * @summary Returns the MIN_WINDOWBITS constant.
428.
	 * @returns {Constant} Z_MIN_WINDOWBITS
429.
	 * @function min
430.
	 */
431.
	min() {
432.
		return zlib.constants.Z_MIN_WINDOWBITS;
433.
	}
434.

			
435.
	/**
436.
	 * This is the MAX_WINDOWBITS constant. It returns the maximum amount of windowbits that can 
437.
	 * be used for the compression and decompression.
438.
	 * @summary Returns the MAX_WINDOWBITS constant.
439.
	 * @returns {Constant} Z_MAX_WINDOWBITS
440.
	 * @function max
441.
	 */
442.
	max() {
443.
		return zlib.constants.Z_MAX_WINDOWBITS;
444.
	}
445.

			
446.
	/**
447.
	 * This is the DEFAULT_WINDOWBITS constant. It returns the default amount of windowbits that is 
448.
	 * used for the compression and decompression.
449.
	 * @summary Returns the DEFAULT_WINDOWBITS constant.
450.
	 * @returns {Constant} Z_DEFAULT_WINDOWBITS
451.
	 * @function default
452.
	 */
453.
	default() {
454.
		return zlib.constants.Z_DEFAULT_WINDOWBITS;
455.
	}
456.
}
457.

			
458.
/**
459.
 * This is the memory contants class. It contains constants that can be used in the memory level
460.
 * setting.
461.
 * @class compression.constants.memory
462.
 */
463.
class constants_memory {
464.
	/**
465.
	* This is the MIN_MEMLEVEL constant. It returns the minimal amount of memory that can be used
466.
	* for the compression and decompression.
467.
	 * @summary Returns the MIN_MEMLEVEL constant.
468.
	* @returns {Constant} Z_MIN_MEMLEVEL
469.
	* @function min
470.
	*/
471.
	min() {
472.
		return zlib.constants.Z_MIN_MEMLEVEL;
473.
	}
474.

			
475.
	/**
476.
	 * This is the MAX_MEMLEVEL constant. It returns the maximum amount of memory that can be used
477.
	 * for the compression and decompression.
478.
	 * @summary Returns the MAX_MEMLEVEL constant.
479.
	 * @returns {Constant} Z_MAX_MEMLEVEL
480.
	 * @function max
481.
	 */
482.
	max() {
483.
		return zlib.constants.Z_MAX_MEMLEVEL;
484.
	}
485.

			
486.
	/**
487.
	 * This is the DEFAULT_MEMLEVEL constant. It returns the default amount of memory that is used
488.
	 * for the compression and decompression.
489.
	 * @summary Returns the DEFAULT_MEMLEVEL constant.
490.
	 * @returns {Constant} Z_DEFAULT_MEMLEVEL
491.
	 * @function default
492.
	 */
493.
	default() {
494.
		return zlib.constants.Z_DEFAULT_MEMLEVEL;
495.
	}
496.
}
497.

			
498.
/**
499.
 * This is the chunk size contants class. It contains constants that can be used in the chunk size
500.
 * setting.
501.
 * @class compression.constants.chunk
502.
 */
503.
class constants_chunk {
504.
	/**
505.
	* This is the MIN_CHUNK constant. It returns the minimal chunk size that can be used for the
506.
	 compression and decompression.
507.
	 * @summary Returns the MIN_CHUNK constant.
508.
	* @returns {Constant} Z_MIN_CHUNK
509.
	* @function min
510.
	*/
511.
	min() {
512.
		return zlib.constants.Z_MIN_CHUNK;
513.
	}
514.

			
515.
	/**
516.
	 * This is the MAX_CHUNK constant. It returns the maximum chunk size that can be used for the
517.
	 * compression and decompression.
518.
	 * @summary Returns the MAX_CHUNK constant.
519.
	 * @returns {Constant} Z_MAX_CHUNK
520.
	 * @function max
521.
	 */
522.
	max() {
523.
		return zlib.constants.Z_MAX_CHUNK;
524.
	}
525.

			
526.
	/**
527.
	 * This is the DEFAULT_CHUNK constant. It returns the default chunk size that is used for the 
528.
	 * compression and decompression.
529.
	 * @summary Returns the DEFAULT_CHUNK constant.
530.
	 * @returns {Constant} Z_DEFAULT_CHUNK
531.
	 * @function default
532.
	 */
533.
	default() {
534.
		return zlib.constants.Z_DEFAULT_CHUNK;
535.
	}
536.
}