peeeto / ng-lz-string

An Angular wrapper for lz-string. Supports Angular 4.0 and above.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ng-lz-string

An Angular wrapper for lz-string. Built and tested for Angular 4. Should work for > Angular 4.

Installation

To install this library, run:

$ npm install ng-lz-string --save

Usage

Here's how you can use this library in your Angular app:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { LZStringModule, LZStringService } from 'ng-lz-string';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify the LZ String Module as an import
    LZStringModule
  ],
  providers: [
	// Specify the service in the providers section
	LZStringService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once the library is imported in your module, you can use it in your Angular application:

import {LZStringService} from 'ng-lz-string';

export class AppComponent implements OnInit {
	constructor(private lz: LZStringService){
	
	}
	
	performCompressionAndDecompression(){
		const compressed = this.lz.compress('This is going to be compressed');
		
		console.log(compressed);
		
		const decompressed = this.lz.decompress(compressed);
		
		console.log(decompressed);
	}
}

About

An Angular wrapper for lz-string. Supports Angular 4.0 and above.

License:MIT License


Languages

Language:TypeScript 73.9%Language:JavaScript 21.3%Language:HTML 3.8%Language:CSS 1.0%