Giter Club home page Giter Club logo

pulverized's Introduction

License Version Weekly Downloads Issues Open CircleCi Build Snyk Vulnerabilities

Pulverized

Utilize any compression algorithm with just a single module... The compression methods that are taken care of as of now are gzip, deflate and brotli.. if any new cool methods become mainstream, we will do our best to include them...

Notes

Any version below 1.3 works using the iltorb npm module which is ideal for any node version below 11... Versions 1.3 and above use node's native zlib brotli methods and are ideal with Node.js version 11 (and above)... There is a thrown error when you attempt to use the latest version but aren't in an ideal environment to do such...

Install

Like we need to tell you but run this...

npm install pulverized

And then you can start using the module by doing the below...

var Pulverized = require('pulverized');

Lastly, you can understand the methods and signatures of those methods if you read the below section...

Methods

This is the Pulverized singleton 'illustrated' as a tree...

Pulverized
|-- compress
|   |-- async
|   |   |-- br ( dataToCompress, callback, brotliSettingsObject )
|   |   |-- df ( dataToCompress, callback, deflateSettingsObject )
|   |   \-- gz ( dataToCompress, callback, gzipSettingsObject )
|   |
|   |-- stream
|   |   |-- br ( brotliSettingsObject )
|   |   |-- df ( deflateSettingsObject )
|   |   \-- gz ( gzipSettingsObject )
|   |
|   \-- sync
|       |-- br ( dataToCompress, brotliSettingsObject )
|       |-- df ( dataToCompress, deflateSettingsObject )
|       \-- gz ( dataToCompress, gzipSettingsObject )
|
\-- decompress
    |-- async
    |   |-- br ( dataToDecompress, callback )
    |   |-- df ( dataToDecompress, callback )
    |   \-- gz ( dataToDecompress, callback )
    |
    |-- stream
    |   |-- br ( )
    |   |-- df ( )
    |   \-- gz ( )
    |
    \-- sync
        |-- br ( dataToDecompress )
        |-- df ( dataToDecompress )
        \-- gz ( dataToDecompress )

Examples

Within all compression methods, the pulverizedSettingsObject uses the encoding parameters of the relevant algorithm deflate, gzip or brotli within the object.

The below pretty much points out what is in the examples folder... so I have each example from below in those files and more...

Compress Methods

Sync Examples

Pulverized["COMPRESS OR DECOMPRESS"]["ALGORITHM"].sync(
    buffer /* required */, 
    pulverizedSettingsObject /* optional */
)
fs.writeFileSync(
	"./examples/lorem-sync-l9.txt.gz",
	Pulverized.compress.gz.sync(
		fs.readFileSync(loremFilename,"utf8"), {
			level:9
		}
	)
);

Async Examples

Pulverized["COMPRESS OR DECOMPRESS"]["ALGORITHM"].async(
    buffer /* required */, 
    callback /* required */, 
    pulverizedSettingsObject /* optional */
)
Pulverized.compress.df.async(
	fs.readFileSync(loremFilename,"utf8"),
	function(err, output){
		fs.writeFileSync(
			"./examples/lorem-async-l5.txt.df",
			output
		);
		
		console.log(
			"df decompressed async setup",
			Pulverized.decompress.df.async(
				fs.readFileSync(
					"./examples/lorem-async-l5.txt.df"
				), function(err, output){
					console.log(
						"df decompressed output",
						err,
						output
					)
				}
			)
		);
	},{
		level:5
	}
)

Stream Examples

Pulverized["COMPRESS OR DECOMPRESS"]["ALGORITHM"].stream(
    pulverizedSettingsObject /* optional */
)
fs.createReadStream(loremFilename)
	.pipe(Pulverized.compress.br.stream({
		quality:1
	}))
	.pipe(fs.createWriteStream("./examples/lorem-stream-q1.txt.br"));

pulverized's People

Contributors

delmarc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.