Skip to content

Commit

Permalink
fix: export
Browse files Browse the repository at this point in the history
  • Loading branch information
qianxin.yy committed Apr 27, 2020
1 parent 74a4094 commit 9bb2d3a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 61 deletions.
4 changes: 1 addition & 3 deletions packages/asyncstorage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.3.0",
"description": "A universal AsyncStorage API.",
"main": "lib/index.js",
"module": "src/index.js",
"files": [
"dist",
"es",
Expand All @@ -12,8 +11,7 @@
"types"
],
"keywords": [
"Rax",
"rax-component"
"Rax"
],
"engines": {
"npm": ">=3.0.0"
Expand Down
119 changes: 61 additions & 58 deletions packages/asyncstorage/src/quickapp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9bb2d3a

Please sign in to comment.