ee-core 1.5.2-beta.2 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/config/config.default.js +8 -1
  2. package/core/lib/ee.js +1 -1
  3. package/core/lib/loader/ee_loader.js +7 -3
  4. package/core/lib/loader/mixin/controller.js +3 -2
  5. package/core/lib/utils/function.js +30 -0
  6. package/index.js +2 -2
  7. package/lib/appLoader.js +0 -5
  8. package/lib/application.js +7 -6
  9. package/lib/baseApp.js +9 -26
  10. package/lib/eeApp.js +18 -52
  11. package/{lib/constant.js → module/const/index.js} +3 -0
  12. package/{lib/httpclient.js → module/httpclient/index.js} +45 -11
  13. package/module/jobs/child/forkProcess.js +99 -0
  14. package/module/jobs/child/index.js +33 -0
  15. package/module/jobs/index.js +55 -0
  16. package/module/jobs/renderer/index.js +140 -0
  17. package/module/jobs/renderer/loadView.js +40 -0
  18. package/module/loader/index.js +78 -0
  19. package/module/log/index.js +53 -0
  20. package/module/log/logger.js +61 -0
  21. package/module/message/index.js +13 -0
  22. package/module/message/ipcMain.js +160 -0
  23. package/module/message/ipcRender.js +0 -0
  24. package/{lib → module}/socket/httpServer.js +0 -0
  25. package/{lib → module}/socket/io.js +0 -0
  26. package/{lib → module}/socket/ipcServer.js +6 -8
  27. package/{lib → module}/socket/socketClient.js +4 -3
  28. package/{lib → module}/socket/socketServer.js +4 -3
  29. package/module/socket/start.js +22 -0
  30. package/{lib → module}/storage/index.js +13 -12
  31. package/module/storage/jsondb/adapters/Base.js +14 -0
  32. package/module/storage/jsondb/adapters/FileSync.js +32 -0
  33. package/{lib/storage/lowdb → module/storage/jsondb}/main.js +6 -10
  34. package/{lib/storage/lowdbStorage.js → module/storage/jsondbStorage.js} +13 -14
  35. package/{lib → module}/storage/sqliteStorage.js +7 -11
  36. package/module/utils/copyto.js +161 -0
  37. package/module/utils/helper.js +117 -0
  38. package/module/utils/index.js +120 -0
  39. package/module/utils/json.js +72 -0
  40. package/module/utils/ps.js +175 -0
  41. package/{utils → module/utils}/wrap.js +0 -2
  42. package/package.json +3 -7
  43. package/tools/encrypt.js +2 -2
  44. package/utils/index.js +17 -135
  45. package/lib/logger.js +0 -47
  46. package/lib/socket/start.js +0 -22
  47. package/lib/storage/lowdb/adapters/Base.js +0 -15
  48. package/lib/storage/lowdb/adapters/FileAsync.js +0 -41
  49. package/lib/storage/lowdb/adapters/FileSync.js +0 -39
  50. package/lib/storage/lowdb/adapters/LocalStorage.js +0 -20
  51. package/lib/storage/lowdb/adapters/Memory.js +0 -8
  52. package/lib/storage/lowdb/adapters/_stringify.js +0 -4
  53. package/lib/storage/lowdb/common.js +0 -33
  54. package/lib/storage/lowdb/fp.js +0 -23
  55. package/lib/storage/lowdb/isPromise.js +0 -6
  56. package/lib/storage/lowdb/nano.js +0 -5
  57. package/utils/common.js +0 -91
@@ -0,0 +1,72 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const mkdirp = require('mkdirp');
4
+
5
+ exports.strictParse = function (str) {
6
+ const obj = JSON.parse(str);
7
+ if (!obj || typeof obj !== 'object') {
8
+ throw new Error('JSON string is not object');
9
+ }
10
+ return obj;
11
+ };
12
+
13
+ exports.readSync = function(filepath) {
14
+ if (!fs.existsSync(filepath)) {
15
+ throw new Error(filepath + ' is not found');
16
+ }
17
+ return JSON.parse(fs.readFileSync(filepath));
18
+ };
19
+
20
+ exports.writeSync = function(filepath, str, options) {
21
+ options = options || {};
22
+ if (!('space' in options)) {
23
+ options.space = 2;
24
+ }
25
+
26
+ mkdirp.sync(path.dirname(filepath));
27
+ if (typeof str === 'object') {
28
+ str = JSON.stringify(str, options.replacer, options.space) + '\n';
29
+ }
30
+
31
+ fs.writeFileSync(filepath, str);
32
+ };
33
+
34
+ exports.read = function(filepath) {
35
+ return fs.stat(filepath)
36
+ .then(function(stats) {
37
+ if (!stats.isFile()) {
38
+ throw new Error(filepath + ' is not found');
39
+ }
40
+ return fs.readFile(filepath);
41
+ })
42
+ .then(function(buf) {
43
+ return JSON.parse(buf);
44
+ });
45
+ };
46
+
47
+ exports.write = function(filepath, str, options) {
48
+ options = options || {};
49
+ if (!('space' in options)) {
50
+ options.space = 2;
51
+ }
52
+
53
+ if (typeof str === 'object') {
54
+ str = JSON.stringify(str, options.replacer, options.space) + '\n';
55
+ }
56
+
57
+ return mkdir(path.dirname(filepath))
58
+ .then(function() {
59
+ return fs.writeFile(filepath, str);
60
+ });
61
+ };
62
+
63
+ function mkdir(dir) {
64
+ return new Promise(function(resolve, reject) {
65
+ mkdirp(dir, function(err) {
66
+ if (err) {
67
+ return reject(err);
68
+ }
69
+ resolve();
70
+ });
71
+ });
72
+ }
@@ -0,0 +1,175 @@
1
+ const path = require('path');
2
+
3
+ /**
4
+ * 当前进程的所有env
5
+ */
6
+ exports.allEnv = function() {
7
+ return process.env;
8
+ }
9
+
10
+ /**
11
+ * 当前环境 - local | prod
12
+ */
13
+ exports.env = function() {
14
+ return process.env.EE_SERVER_ENV;
15
+ }
16
+
17
+ /**
18
+ * 获取 当前环境
19
+ */
20
+ exports.getEnv = this.env
21
+
22
+ /**
23
+ * 是否为开发环境
24
+ */
25
+ exports.isDev = function() {
26
+ if ( process.env.EE_SERVER_ENV === 'development' ||
27
+ process.env.EE_SERVER_ENV === 'dev' ||
28
+ process.env.EE_SERVER_ENV === 'local'
29
+ ) {
30
+ return true;
31
+ }
32
+
33
+ if ( process.env.NODE_ENV === 'development' ||
34
+ process.env.NODE_ENV === 'dev' ||
35
+ process.env.NODE_ENV === 'local'
36
+ ) {
37
+ return true;
38
+ }
39
+
40
+ return false;
41
+ };
42
+
43
+ /**
44
+ * 是否为渲染进程
45
+ */
46
+ exports.isRenderer = function() {
47
+ return (typeof process === 'undefined' ||
48
+ !process ||
49
+ process.type === 'renderer');
50
+ };
51
+
52
+ /**
53
+ * 是否为主进程
54
+ */
55
+ exports.isMain = function() {
56
+ return ( typeof process !== 'undefined' &&
57
+ process.type === 'browser');
58
+ };
59
+
60
+ /**
61
+ * 是否为node子进程
62
+ */
63
+ exports.isForkedChild = function() {
64
+ return (Number(process.env.ELECTRON_RUN_AS_NODE) === 1);
65
+ };
66
+
67
+ /**
68
+ * 当前进程类型
69
+ */
70
+ exports.processType = function() {
71
+ let type = '';
72
+ if (this.isMain()) {
73
+ type = 'browser';
74
+ } else if (this.isRenderer()) {
75
+ type = 'renderer';
76
+ } else if (this.isForkedChild()) {
77
+ type = 'child';
78
+ }
79
+
80
+ return type;
81
+ };
82
+
83
+ /**
84
+ * 获取数据存储路径
85
+ */
86
+ exports.getHomeDir = function () {
87
+ return process.env.EE_HOME;
88
+ }
89
+
90
+ /**
91
+ * 获取数据存储路径
92
+ */
93
+ exports.getStorageDir = function () {
94
+ const storageDir = path.join(this.getRootDir(), 'data');
95
+ return storageDir;
96
+ }
97
+
98
+ /**
99
+ * 获取日志存储路径
100
+ */
101
+ exports.getLogDir = function () {
102
+ const dir = path.join(this.getRootDir(), 'logs');
103
+ return dir;
104
+ }
105
+
106
+ /**
107
+ * 获取root目录 (dev-项目根目录,pro-app user data目录)
108
+ */
109
+ exports.getRootDir = function () {
110
+ const appDir = this.isDev() ? process.env.EE_HOME : process.env.EE_APP_USER_DATA;
111
+ return appDir;
112
+ }
113
+
114
+ /**
115
+ * 获取 base目录
116
+ */
117
+ exports.getBaseDir = function() {
118
+ return process.env.EE_BASE_DIR;
119
+ }
120
+
121
+ /**
122
+ * 获取 appUserData目录
123
+ */
124
+ exports.getAppUserDataDir = function() {
125
+ return process.env.EE_APP_USER_DATA;
126
+ }
127
+
128
+ /**
129
+ * 获取数据存储路径
130
+ */
131
+ exports.getHomeDir = function () {
132
+ return process.env.EE_HOME;
133
+ }
134
+
135
+ /**
136
+ * 获取 exec目录
137
+ */
138
+ exports.getExecDir = function() {
139
+ return process.env.EE_EXEC_DIR;
140
+ }
141
+
142
+ /**
143
+ * 获取操作系统用户目录
144
+ */
145
+ exports.getUserHomeDir = function () {
146
+ return process.env.EE_USER_HOME;
147
+ }
148
+
149
+ /**
150
+ * 获取主进程端口
151
+ */
152
+ exports.getMainPort = function () {
153
+ return process.env.EE_MAIN_PORT;
154
+ }
155
+
156
+ /**
157
+ * 获取内置socket端口
158
+ */
159
+ exports.getSocketPort = function () {
160
+ return process.env.EE_SOCKET_PORT;
161
+ }
162
+
163
+ /**
164
+ * 获取内置http端口
165
+ */
166
+ exports.getHttpPort = function () {
167
+ return process.env.EE_HTTP_PORT;
168
+ }
169
+
170
+ /**
171
+ * 是否打包
172
+ */
173
+ exports.isPackaged = function () {
174
+ return process.env.EE_IS_PACKAGED;
175
+ }
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  const assert = require('assert');
4
2
  const is = require('is-type-of');
5
3
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "1.5.2-beta.2",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,7 +25,6 @@
25
25
  "fs-extra": "^10.0.0",
26
26
  "get-port": "^5.1.1",
27
27
  "globby": "^10.0.0",
28
- "graceful-fs": "^4.1.3",
29
28
  "humanize-ms": "^1.2.1",
30
29
  "is-type-of": "^1.2.1",
31
30
  "javascript-obfuscator": "^4.0.0",
@@ -35,14 +34,11 @@
35
34
  "koa-static": "^5.0.0",
36
35
  "koa2-cors": "^2.0.6",
37
36
  "lodash": "^4.17.21",
38
- "lowdb": "^1.0.0",
37
+ "mkdirp": "^2.1.3",
39
38
  "path-to-regexp": "^6.2.0",
40
- "pify": "^6.1.0",
41
39
  "socket.io": "^4.4.1",
42
40
  "socket.io-client": "^4.4.1",
43
- "steno": "^0.4.1",
44
- "urllib": "^2.38.0",
45
- "utility": "^1.17.0"
41
+ "urllib": "^2.38.0"
46
42
  },
47
43
  "devDependencies": {}
48
44
  }
package/tools/encrypt.js CHANGED
@@ -5,9 +5,9 @@ const fs = require('fs');
5
5
  const fsPro = require('fs-extra');
6
6
  const is = require('is-type-of');
7
7
  const bytenode = require('bytenode');
8
- const utility = require('utility');
9
8
  const crypto = require('crypto');
10
9
  const JavaScriptObfuscator = require('javascript-obfuscator');
10
+ const utilsJson = require('../module/utils/json');
11
11
 
12
12
  class Encrypt {
13
13
  constructor() {
@@ -86,7 +86,7 @@ class Encrypt {
86
86
  const content = {
87
87
  nameMap: {}
88
88
  };
89
- utility.writeJSONSync(this.tmpFile, content);
89
+ utilsJson.writeSync(this.tmpFile, content);
90
90
  }
91
91
  }
92
92
 
package/utils/index.js CHANGED
@@ -1,35 +1,28 @@
1
- 'use strict';
1
+ /**
2
+ * 该模块不在增加新功能,请使用 /module/utils/index 模块
3
+ */
2
4
 
3
5
  const path = require('path');
4
- const constant = require('../lib/constant');
5
- const convert = require('koa-convert');
6
- const is = require('is-type-of');
7
- const co = require('co');
8
- const utility = require('utility');
9
6
  const eis = require('electron-is');
10
- const utilsCommon = require('./common');
7
+ const UtilsJson = require('../module/utils/json');
8
+ const UtilsPs = require('../module/utils/ps');
9
+ const UtilsHelper = require('../module/utils/helper');
10
+ const Copy = require('../module/utils/copyto');
11
+ const Storage = require('../module/storage');
12
+ const Constants = require('../module/const');
11
13
 
12
14
  /**
13
- * 创建文件夹
15
+ * other module
14
16
  */
15
- exports.mkdir = function (dirpath, dirname) {
16
- return utilsCommon.mkdir(dirpath, dirname);
17
- }
18
-
19
- /**
20
- * 修改文件权限
21
- */
22
- exports.chmodPath = function (path, mode) {
23
- return utilsCommon.chmodPath(path, mode);
24
- }
17
+ Copy(UtilsPs)
18
+ .and(UtilsHelper)
19
+ .to(exports);
25
20
 
26
21
  /**
27
22
  * 获取项目根目录package.json
28
23
  */
29
24
  exports.getPackage = function() {
30
- const cdb = this.getCoreDB();
31
- const config = cdb.getItem('config');
32
- const json = utility.readJSONSync(path.join(config.homeDir, 'package.json'));
25
+ const json = UtilsJson.readSync(path.join(this.getHomeDir(), 'package.json'));
33
26
 
34
27
  return json;
35
28
  };
@@ -38,20 +31,10 @@ exports.getPackage = function() {
38
31
  * 获取 coredb
39
32
  */
40
33
  exports.getCoreDB = function() {
41
- const coreDB = require('../lib/storage/index').JsonDB.connection('system');
34
+ const coreDB = Storage.connection('system');
42
35
  return coreDB;
43
36
  }
44
37
 
45
- /**
46
- * 获取 当前环境
47
- */
48
- exports.getEnv = function() {
49
- const cdb = this.getCoreDB();
50
- const env = cdb.getItem('config').env;
51
-
52
- return env;
53
- }
54
-
55
38
  /**
56
39
  * 获取 ee配置
57
40
  */
@@ -62,75 +45,6 @@ exports.getEeConfig = function() {
62
45
  return config;
63
46
  }
64
47
 
65
- /**
66
- * 获取 数据库存储路径
67
- */
68
- exports.getStorageDir = function() {
69
- const cdb = this.getCoreDB();
70
- const env = cdb.getItem('config').env;
71
-
72
- const appDir = env === 'local' || env === 'unittest' ? this.getHomeDir() : this.getAppUserDataDir();
73
- const storageDir = path.join(appDir, 'data');
74
-
75
- return storageDir;
76
- }
77
-
78
- /**
79
- * 获取 应用程序数据目录 (开发环境时,为项目根目录)
80
- */
81
- exports.getAppUserDataDir = function() {
82
- const cdb = this.getCoreDB();
83
- const config = cdb.getItem('config');
84
- const env = config.env;
85
- const dir = env === 'local' || env === 'unittest' ? config.homeDir : config.appUserDataDir;
86
- return dir;
87
- }
88
-
89
- /**
90
- * 获取 日志目录
91
- */
92
- exports.getLogDir = function() {
93
- const cdb = this.getCoreDB();
94
- const logPath = cdb.getItem('config').logger.dir;
95
- return logPath;
96
- }
97
-
98
- /**
99
- * 获取 home目录
100
- */
101
- exports.getHomeDir = function() {
102
- const cdb = this.getCoreDB();
103
- const homePath = cdb.getItem('config').homeDir;
104
- return homePath;
105
- }
106
-
107
- /**
108
- * 获取 base目录
109
- */
110
- exports.getBaseDir = function() {
111
- const cdb = this.getCoreDB();
112
- const basePath = cdb.getItem('config').baseDir;
113
- return basePath;
114
- }
115
-
116
- /**
117
- * 获取 root目录
118
- */
119
- exports.getRootDir = function() {
120
- const cdb = this.getCoreDB();
121
- const rootPath = cdb.getItem('config').root;
122
- return rootPath;
123
- }
124
-
125
- /**
126
- * 获取 appUserData目录
127
- */
128
- exports.getAppUserDataDir = function() {
129
- const cdb = this.getCoreDB();
130
- const dataPath = cdb.getItem('config').appUserDataDir;
131
- return dataPath;
132
- }
133
-
134
48
  /**
135
49
  * 获取 app version
136
50
  */
@@ -140,15 +54,6 @@ exports.getAppVersion = function() {
140
54
  return v;
141
55
  }
142
56
 
143
- /**
144
- * 获取 exec目录
145
- */
146
- exports.getExecDir = function() {
147
- const cdb = this.getCoreDB();
148
- const execPath = cdb.getItem('config').execDir;
149
- return execPath;
150
- }
151
-
152
57
  /**
153
58
  * 获取 插件配置
154
59
  */
@@ -198,16 +103,14 @@ exports.getSocketPort = function() {
198
103
  * 获取 socket channel
199
104
  */
200
105
  exports.getSocketChannel = function() {
201
- return constant.socketIo.channel;
106
+ return Constants.socketIo.channel;
202
107
  }
203
108
 
204
109
  /**
205
110
  * 获取 额外资源目录
206
111
  */
207
112
  exports.getExtraResourcesDir = function() {
208
- const cdb = this.getCoreDB();
209
- const config = cdb.getItem('config');
210
- const execDir = config.execDir;
113
+ const execDir = this.getExecDir();
211
114
 
212
115
  // 资源路径不同
213
116
  let dir = '';
@@ -223,25 +126,4 @@ exports.getExtraResourcesDir = function() {
223
126
  dir = path.join(execDir, "build", "extraResources");
224
127
  }
225
128
  return dir;
226
- }
227
-
228
- /**
229
- * 执行一个函数
230
- */
231
- exports.callFn = async function (fn, args, ctx) {
232
- args = args || [];
233
- if (!is.function(fn)) return;
234
- if (is.generatorFunction(fn)) fn = co.wrap(fn);
235
- return ctx ? fn.call(ctx, ...args) : fn(...args);
236
- }
237
-
238
- exports.middleware = function (fn) {
239
- return is.generatorFunction(fn) ? convert(fn) : fn;
240
- }
241
-
242
- /**
243
- * 版本号比较
244
- */
245
- exports.compareVersion = function (v1, v2) {
246
- return utilsCommon.compareVersion(v1, v2);
247
129
  }
package/lib/logger.js DELETED
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- const debug = require('debug')('ee-core:logger');
4
- const Loggers = require('egg-logger').EggLoggers;
5
- const assert = require('assert');
6
-
7
- class Logger {
8
- constructor (config) {
9
- debug('Loaded logger');
10
- assert(Object.keys(config).length != 0, `logger config is null`);
11
- this.eggLogger = this.init(config);
12
- }
13
-
14
- /**
15
- * 单例
16
- */
17
- static getInstance (config = {}) {
18
- if (typeof this.instance === 'object') {
19
- return this.instance.eggLogger;
20
- }
21
-
22
- this.instance = new Logger(config);
23
-
24
- // 返回egg-logger实例
25
- return this.instance.eggLogger;
26
- }
27
-
28
- /**
29
- * 初始化模块
30
- */
31
- init(config) {
32
- const loggerConfig = config.logger;
33
- loggerConfig.type = 'application'; // application、agent
34
-
35
- if (config.env === 'prod' && loggerConfig.level === 'DEBUG' && !loggerConfig.allowDebugAtProd) {
36
- loggerConfig.level = 'INFO';
37
- }
38
-
39
- const loggers = new Loggers(config);
40
-
41
- loggers.coreLogger.info('[ee-core:logger] init all loggers with options: %j', loggerConfig);
42
-
43
- return loggers;
44
- };
45
- }
46
-
47
- module.exports = Logger;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const socketServer = require('./socketServer');
4
- const ipcServer = require('./ipcServer');
5
- const httpServer = require('./httpServer');
6
-
7
- /**
8
- * server
9
- */
10
- module.exports = (app) => {
11
-
12
- // 启动 socket server
13
- new socketServer(app);
14
-
15
- // 启动 http server
16
- new httpServer(app);
17
-
18
- // 启动 electron ipc server
19
- new ipcServer(app);
20
-
21
- }
22
-
@@ -1,15 +0,0 @@
1
- const stringify = require('./_stringify')
2
-
3
- class Base {
4
- constructor(
5
- source,
6
- { defaultValue = {}, serialize = stringify, deserialize = JSON.parse } = {}
7
- ) {
8
- this.source = source
9
- this.defaultValue = defaultValue
10
- this.serialize = serialize
11
- this.deserialize = deserialize
12
- }
13
- }
14
-
15
- module.exports = Base
@@ -1,41 +0,0 @@
1
- // Not using async/await on purpose to avoid adding regenerator-runtime
2
- // to lowdb dependencies
3
- const fs = require('graceful-fs')
4
- const pify = require('pify')
5
- const steno = require('steno')
6
- const Base = require('./Base')
7
-
8
- const readFile = pify(fs.readFile)
9
- const writeFile = pify(steno.writeFile)
10
-
11
- class FileAsync extends Base {
12
- read() {
13
- // fs.exists is deprecated but not fs.existsSync
14
- if (fs.existsSync(this.source)) {
15
- // Read database
16
- return readFile(this.source, 'utf-8')
17
- .then(data => {
18
- // Handle blank file
19
- const trimmed = data.trim()
20
- return trimmed ? this.deserialize(trimmed) : this.defaultValue
21
- })
22
- .catch(e => {
23
- if (e instanceof SyntaxError) {
24
- e.message = `Malformed JSON in file: ${this.source}\n${e.message}`
25
- }
26
- throw e
27
- })
28
- } else {
29
- // Initialize
30
- return writeFile(this.source, this.serialize(this.defaultValue)).then(
31
- () => this.defaultValue
32
- )
33
- }
34
- }
35
-
36
- write(data) {
37
- return writeFile(this.source, this.serialize(data))
38
- }
39
- }
40
-
41
- module.exports = FileAsync
@@ -1,39 +0,0 @@
1
- const fs = require('graceful-fs')
2
- const Base = require('./Base')
3
- const fileSystem = require('fs')
4
-
5
- //const readFile = fs.readFileSync
6
- const writeFile = fs.writeFileSync
7
-
8
- // Same code as in FileAsync, minus `await`
9
- class FileSync extends Base {
10
- read() {
11
- // fs.exists is deprecated but not fs.existsSync
12
- if (fs.existsSync(this.source)) {
13
- // Read database
14
- try {
15
- // 使用 fileSystem的readFileSync
16
- //const data = readFile(this.source, 'utf-8').trim()
17
- const data = fileSystem.readFileSync(this.source, {encoding: 'utf-8'})
18
-
19
- // Handle blank file
20
- return data ? this.deserialize(data) : this.defaultValue
21
- } catch (e) {
22
- if (e instanceof SyntaxError) {
23
- e.message = `Malformed JSON in file: ${this.source}\n${e.message}`
24
- }
25
- throw e
26
- }
27
- } else {
28
- // Initialize
29
- writeFile(this.source, this.serialize(this.defaultValue))
30
- return this.defaultValue
31
- }
32
- }
33
-
34
- write(data) {
35
- return writeFile(this.source, this.serialize(data))
36
- }
37
- }
38
-
39
- module.exports = FileSync
@@ -1,20 +0,0 @@
1
- /* global localStorage */
2
- const Base = require('./Base')
3
-
4
- class LocalStorage extends Base {
5
- read() {
6
- const data = localStorage.getItem(this.source)
7
- if (data) {
8
- return this.deserialize(data)
9
- } else {
10
- localStorage.setItem(this.source, this.serialize(this.defaultValue))
11
- return this.defaultValue
12
- }
13
- }
14
-
15
- write(data) {
16
- localStorage.setItem(this.source, this.serialize(data))
17
- }
18
- }
19
-
20
- module.exports = LocalStorage