mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
ES2015 first look / babeljs
This commit is contained in:
parent
5dcceaaca5
commit
445cd155e5
123 changed files with 3214 additions and 3680 deletions
31
dev/Storage/Client.jsx
Normal file
31
dev/Storage/Client.jsx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
import {_} from 'common';
|
||||
import {Cookie} from 'Common/ClientStorageDriver/Cookie';
|
||||
import {LocalStorage} from 'Common/ClientStorageDriver/LocalStorage';
|
||||
|
||||
class ClientStorage
|
||||
{
|
||||
constructor() {
|
||||
const SupportedStorageDriver = _.find([LocalStorage, Cookie], (StorageDriver) => StorageDriver && StorageDriver.supported());
|
||||
this.driver = SupportedStorageDriver ? new SupportedStorageDriver() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} key
|
||||
* @param {*} data
|
||||
* @return {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
return this.driver ? this.driver.set('p' + key, data) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} key
|
||||
* @return {*}
|
||||
*/
|
||||
get(key) {
|
||||
return this.driver ? this.driver.get('p' + key) : null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new ClientStorage();
|
||||
Loading…
Add table
Add a link
Reference in a new issue