src/839zip.js
function pack(items) {
		var data = arguments,
			idx = 0,
			buffer,
			bufferSize = 0;

		// Calculate buffer size
		items = items.split('');
		items.forEach(function(type) {
			if (type == 'v') {
				bufferSize += 2;
			} else if (type == 'V' || type == 'l') {
				bufferSize += 4;
			}
		});

		// Fill buffer
		buffer = new Buffer(bufferSize);
		items.forEach(function(type, index) {
			if (type == 'v') {
				buffer.writeUInt16LE(data[index + 1], idx);
				idx += 2;
			} else if (type == 'V') {
				buffer.writeUInt32LE(data[index + 1], idx);
				idx += 4;
			} else if (type == 'l') {
				buffer.writeInt32LE(data[index + 1], idx);
				idx += 4;
			}
		});

		return buffer;
	}
function pack(items) {
		var data = arguments,
			idx = 0,
			buffer,
			bufferSize = 0;

		// Calculate buffer size
		items = items.split('');
		items.forEach(function(type) {
			if (type == 'v') {
				bufferSize += 2;
			} else if (type == 'V' || type == 'l') {
				bufferSize += 4;
			}
		});

		// Fill buffer
		buffer = new Buffer(bufferSize);
		items.forEach(function(type, index) {
			if (type == 'v') {
				buffer.writeUInt16LE(data[index + 1], idx);
				idx += 2;
			} else if (type == 'V') {
				buffer.writeUInt32LE(data[index + 1], idx);
				idx += 4;
			} else if (type == 'l') {
				buffer.writeInt32LE(data[index + 1], idx);
				idx += 4;
			}
		});

		return buffer;
	}
function pack ( items ) { var data = arguments , idx = 0 , buffer , bufferSize = 0 ; // Calculate buffer size items = items . split ( '' ) ; items . forEach ( function ( type ) { if ( type == 'v' ) { bufferSize += 2 ; } else if ( type == 'V' || type == 'l' ) { bufferSize += 4 ; } } ) ; // Fill buffer buffer = new Buffer ( bufferSize ) ; items . forEach ( function ( type , index ) { if ( type == 'v' ) { buffer . writeUInt16LE ( data [ index + 1 ] , idx ) ; idx += 2 ; } else if ( type == 'V' ) { buffer . writeUInt32LE ( data [ index + 1 ] , idx ) ; idx += 4 ; } else if ( type == 'l' ) { buffer . writeInt32LE ( data [ index + 1 ] , idx ) ; idx += 4 ; } } ) ; return buffer ; }
Pack data in the buffer
@function
@param {array} items
@return {string}
Pack data in the buffer