aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/storage.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2019-01-29 21:34:40 +1100
committerSam Potts <sam@potts.es>2019-01-29 21:34:40 +1100
commitb1da599b5d5891dc1dca44bd6aa9d8d03872fdcb (patch)
treec799fb2b444482f6d99dcdf3f16a957b290888c0 /src/js/storage.js
parentafc969bac322f9b17dc0554a65fa848eb998c8e6 (diff)
parentb798368ba68853558819d79a995aa0deec27f95e (diff)
downloadplyr-b1da599b5d5891dc1dca44bd6aa9d8d03872fdcb.tar.lz
plyr-b1da599b5d5891dc1dca44bd6aa9d8d03872fdcb.tar.xz
plyr-b1da599b5d5891dc1dca44bd6aa9d8d03872fdcb.zip
Merge branch 'develop' into beta
Diffstat (limited to 'src/js/storage.js')
-rw-r--r--src/js/storage.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/js/storage.js b/src/js/storage.js
index 5b914331..27fdad9f 100644
--- a/src/js/storage.js
+++ b/src/js/storage.js
@@ -2,7 +2,8 @@
// Plyr storage
// ==========================================================================
-import utils from './utils';
+import is from './utils/is';
+import { extend } from './utils/objects';
class Storage {
constructor(player) {
@@ -31,19 +32,19 @@ class Storage {
}
get(key) {
- if (!Storage.supported) {
+ if (!Storage.supported || !this.enabled) {
return null;
}
const store = window.localStorage.getItem(this.key);
- if (utils.is.empty(store)) {
+ if (is.empty(store)) {
return null;
}
const json = JSON.parse(store);
- return utils.is.string(key) && key.length ? json[key] : json;
+ return is.string(key) && key.length ? json[key] : json;
}
set(object) {
@@ -53,7 +54,7 @@ class Storage {
}
// Can only store objectst
- if (!utils.is.object(object)) {
+ if (!is.object(object)) {
return;
}
@@ -61,12 +62,12 @@ class Storage {
let storage = this.get();
// Default to empty object
- if (utils.is.empty(storage)) {
+ if (is.empty(storage)) {
storage = {};
}
// Update the working copy of the values
- utils.extend(storage, object);
+ extend(storage, object);
// Update storage
window.localStorage.setItem(this.key, JSON.stringify(storage));