import { encoder } from "../functions/encoder" ; export class Storage { private storage : any ; constructor ( name ) { this . storage = window [ name ] ; } save ( keyName , value , isEncryption = true ) { var local = { } ; local [ keyName ] = isEncryption ? encoder ( value , true ) : value ; value = JSON . stringify ( local ) ; this . storage . setItem ( keyName , value ) ; } get ( keyName , isEncrypted = true ) { var jsonData = this . storage . getItem ( keyName ) ; if ( jsonData ) { jsonData = JSON . parse ( jsonData ) ; return isEncrypted ? encoder ( jsonData [ keyName ] , false ) : jsonData [ keyName ] ; } return undefined ; } clearAll ( ) { this . storage . clear ( ) ; } remove ( keyName ) { this . storage . removeItem ( keyName ) ; } }