diff --git a/packages/asyncstorage/package.json b/packages/asyncstorage/package.json index 199f2e86..f57b2981 100644 --- a/packages/asyncstorage/package.json +++ b/packages/asyncstorage/package.json @@ -3,7 +3,6 @@ "version": "1.3.0", "description": "A universal AsyncStorage API.", "main": "lib/index.js", - "module": "src/index.js", "files": [ "dist", "es", @@ -12,8 +11,7 @@ "types" ], "keywords": [ - "Rax", - "rax-component" + "Rax" ], "engines": { "npm": ">=3.0.0" diff --git a/packages/asyncstorage/src/quickapp/index.js b/packages/asyncstorage/src/quickapp/index.js index 20c78a69..28886599 100644 --- a/packages/asyncstorage/src/quickapp/index.js +++ b/packages/asyncstorage/src/quickapp/index.js @@ -3,74 +3,77 @@ import otherModule from '../index'; let exportModule; -const quickModule = { - setItem: function(key, value) { - return new Promise(function(resolve, reject) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const storage = require('@system.storage'); - storage.set({ - key, - value, - success: function(data) { - resolve(data); - }, - fail: function(data, code) { - reject(`handling fail, code = ${code}`); - } - }); +function setItem(key, value) { + return new Promise(function(resolve, reject) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const storage = require('@system.storage'); + storage.set({ + key, + value, + success: function(data) { + resolve(data); + }, + fail: function(data, code) { + reject(`handling fail, code = ${code}`); + } }); - }, + }); +} - getItem: function(key) { - return new Promise(function(resolve, reject) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const storage = require('@system.storage'); - storage.get({ - key, - success: function(data) { - resolve(data); - }, - fail: function(data, code) { - reject(`handling fail, code = ${code}`); - } - }); +function getItem(key) { + return new Promise(function(resolve, reject) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const storage = require('@system.storage'); + storage.get({ + key, + success: function(data) { + resolve(data); + }, + fail: function(data, code) { + reject(`handling fail, code = ${code}`); + } }); - }, + }); +} - removeItem: function(key) { - return new Promise(function(resolve, reject) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const storage = require('@system.storage'); - storage.delete({ - key, - success: function(data) { - resolve(data); - }, - fail: function(data, code) { - reject(`handling fail, code = ${code}`); - } - }); +function removeItem(key) { + return new Promise(function(resolve, reject) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const storage = require('@system.storage'); + storage.delete({ + key, + success: function(data) { + resolve(data); + }, + fail: function(data, code) { + reject(`handling fail, code = ${code}`); + } }); - }, + }); +} - clear: function() { - return new Promise(function(resolve, reject) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const storage = require('@system.storage'); - storage.clear({ - success: function(data) { - resolve(data); - }, - fail: function(data, code) { - reject(`handling fail, code = ${code}`); - } - }); +function clear() { + return new Promise(function(resolve, reject) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const storage = require('@system.storage'); + storage.clear({ + success: function(data) { + resolve(data); + }, + fail: function(data, code) { + reject(`handling fail, code = ${code}`); + } }); - } + }); } if (isQuickApp) { - exportModule = quickModule; + exportModule = { + setItem, + getItem, + removeItem, + clear + }; } else { exportModule = otherModule; }