fix(core): update

This commit is contained in:
Philipp Kunz 2020-09-18 10:12:02 +00:00
parent 068199b5e9
commit 6bd3bd4f37
6 changed files with 1206 additions and 1020 deletions

2190
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,19 +9,18 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web)", "build": "(tsbuild --web)"
"format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.39", "@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.0.20", "@types/node": "^14.11.1",
"tslint": "^6.1.2", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"idb": "^5.0.4" "idb": "^5.0.6"
}, },
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"

View File

@ -6,7 +6,7 @@ let testWebstore: webstore.WebStore;
tap.test('first test', async () => { tap.test('first test', async () => {
testWebstore = new webstore.WebStore({ testWebstore = new webstore.WebStore({
dbName: 'mytest-db', dbName: 'mytest-db',
storeName: 'mytest-store' storeName: 'mytest-store',
}); });
expect(testWebstore).to.be.instanceOf(webstore.WebStore); expect(testWebstore).to.be.instanceOf(webstore.WebStore);
}); });
@ -20,24 +20,22 @@ tap.test('should allow storing a string', async () => {
expect(await testWebstore.get('mystring')).to.equal('heythere'); expect(await testWebstore.get('mystring')).to.equal('heythere');
}); });
tap.test('should allow storing an object', async () => { tap.test('should allow storing an object', async () => {
await testWebstore.set('testProp1', { await testWebstore.set('testProp1', {
wow: 'wowVal' wow: 'wowVal',
}); });
console.log(JSON.stringify(await testWebstore.get('testProp1'))); console.log(JSON.stringify(await testWebstore.get('testProp1')));
}); });
tap.test('should overwrite a value', async () => { tap.test('should overwrite a value', async () => {
await testWebstore.set('testProp1', { await testWebstore.set('testProp1', {
wow: 'wowVal2' wow: 'wowVal2',
}); });
console.log(JSON.stringify(await testWebstore.get('testProp1'))); console.log(JSON.stringify(await testWebstore.get('testProp1')));
}); });
tap.test('should correctly check the existence of keys', async () => { tap.test('should correctly check the existence of keys', async () => {
const resultNotThere = await testWebstore.check('notThere'); const resultNotThere = await testWebstore.check('notThere');
const resultThere = await testWebstore.check('testProp1'); const resultThere = await testWebstore.check('testProp1');
expect(resultNotThere).to.be.false; expect(resultNotThere).to.be.false;
expect(resultThere).to.be.true; expect(resultThere).to.be.true;

View File

@ -1 +1 @@
export * from './webstiore.classes.webstore'; export * from './webstore.classes.webstore';

View File

@ -10,12 +10,11 @@ export class WebStore<T = any> {
public objectStore: plugins.idb.IDBPObjectStore; public objectStore: plugins.idb.IDBPObjectStore;
public options: IWebStoreOptions; public options: IWebStoreOptions;
constructor(optionsArg: IWebStoreOptions) { constructor(optionsArg: IWebStoreOptions) {
this.options = optionsArg; this.options = optionsArg;
} }
public async init () { public async init() {
this.db = await plugins.idb.openDB(this.options.dbName, 1, { this.db = await plugins.idb.openDB(this.options.dbName, 1, {
upgrade: (db) => { upgrade: (db) => {
db.createObjectStore(this.options.storeName); db.createObjectStore(this.options.storeName);

View File

@ -1,5 +1,3 @@
import * as idb from 'idb'; import * as idb from 'idb';
export { export { idb };
idb
}