mirror of
https://github.com/janishutz/fundamentals-of-webengineering.git
synced 2025-11-25 05:44:24 +00:00
25 lines
619 B
TypeScript
25 lines
619 B
TypeScript
import {
|
|
PersistanceConfig
|
|
} from './types';
|
|
|
|
// Using localStorage for persistance
|
|
const persistanceStore: PersistanceConfig = JSON.parse( localStorage.getItem( 'persistance' ) ?? '{}' );
|
|
|
|
export const store = (
|
|
filename: string,
|
|
size: number,
|
|
sorted: string,
|
|
active: string
|
|
) => {
|
|
persistanceStore[ `${ filename }-${ size }` ] = {
|
|
'active': active,
|
|
'sorted': sorted
|
|
};
|
|
localStorage.setItem( 'persistance', JSON.stringify( persistanceStore ) );
|
|
};
|
|
|
|
|
|
export const get = ( filename: string, size: number ) => {
|
|
return persistanceStore[ `${ filename }-${ size }` ];
|
|
};
|