Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import Memory from './memory';
import Storage from './storage';

const store = typeof window !== 'undefined' && 'localStorage' in window
? window.localStorage
: Memory;
let store;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

['localStorage', 'sessionStorage'].forEach( v => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

if (store) return;
try {
store = typeof window !== 'undefined' && v in window ? window[v] : undefined;
} catch (e) { console.log(v + ' error: ' + e) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

if (!store) store = Memory;
const ls = new Storage(store);

const VueLocalStorage = {
Expand Down