Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
94280da45c | |||
9902414f5a | |||
65fe260519 | |||
6f425906e5 | |||
257b995ca0 | |||
2500ba4cd4 | |||
20a81e8209 | |||
18145a27e2 |
10671
package-lock.json
generated
10671
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/webstore",
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.8",
|
||||
"private": false,
|
||||
"description": "high performance storage in the browser using indexed db",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -13,20 +13,22 @@
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tstest": "^1.0.71",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^17.0.36"
|
||||
"@gitzone/tsbuild": "^2.1.65",
|
||||
"@gitzone/tsrun": "^1.2.39",
|
||||
"@gitzone/tstest": "^1.0.74",
|
||||
"@pushrocks/smartntml": "^2.0.3",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.16.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
||||
"@pushrocks/lik": "^6.0.0",
|
||||
"@pushrocks/smartenv": "^5.0.1",
|
||||
"@pushrocks/smartjson": "^4.0.6",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smartrx": "^2.0.25",
|
||||
"fake-indexeddb": "^3.1.7",
|
||||
"idb": "^7.0.2"
|
||||
"@apiglobal/typedrequest-interfaces": "^2.0.1",
|
||||
"@pushrocks/lik": "^6.0.2",
|
||||
"@pushrocks/smartenv": "^5.0.5",
|
||||
"@pushrocks/smartjson": "^5.0.5",
|
||||
"@pushrocks/smartpromise": "^4.0.2",
|
||||
"@pushrocks/smartrx": "^3.0.0",
|
||||
"fake-indexeddb": "^4.0.1",
|
||||
"idb": "^7.1.1"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
|
4649
pnpm-lock.yaml
generated
Normal file
4649
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
44
test/skip.coexistence.smartntml.ts
Normal file
44
test/skip.coexistence.smartntml.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smartntml from '@pushrocks/smartntml';
|
||||
const smartntmlInstance = new smartntml.Smartntml();
|
||||
|
||||
import * as webstore from '../ts/index.js';
|
||||
|
||||
let testWebstore: webstore.WebStore;
|
||||
|
||||
tap.test('first test', async () => {
|
||||
testWebstore = new webstore.WebStore({
|
||||
dbName: 'mytest-db',
|
||||
storeName: 'mytest-store',
|
||||
});
|
||||
expect(testWebstore).toBeInstanceOf(webstore.WebStore);
|
||||
});
|
||||
|
||||
tap.test('should allow storing a string', async () => {
|
||||
await testWebstore.set('mystring', 'heythere');
|
||||
expect(await testWebstore.get('mystring')).toEqual('heythere');
|
||||
});
|
||||
|
||||
tap.test('should allow storing an object', async () => {
|
||||
await testWebstore.set('testProp1', {
|
||||
wow: 'wowVal',
|
||||
});
|
||||
console.log(JSON.stringify(await testWebstore.get('testProp1')));
|
||||
});
|
||||
|
||||
tap.test('should overwrite a value', async () => {
|
||||
await testWebstore.set('testProp1', {
|
||||
wow: 'wowVal2',
|
||||
});
|
||||
console.log(JSON.stringify(await testWebstore.get('testProp1')));
|
||||
});
|
||||
|
||||
tap.test('should correctly check the existence of keys', async () => {
|
||||
const resultNotThere = await testWebstore.check('notThere');
|
||||
const resultThere = await testWebstore.check('testProp1');
|
||||
expect(resultNotThere).toBeFalse();
|
||||
expect(resultThere).toBeTrue();
|
||||
});
|
||||
|
||||
tap.start();
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/webstore',
|
||||
version: '2.0.4',
|
||||
version: '2.0.8',
|
||||
description: 'high performance storage in the browser using indexed db'
|
||||
}
|
||||
|
@ -24,8 +24,14 @@ export class WebStore<T = any> {
|
||||
this.initCalled = true;
|
||||
|
||||
const smartenv = new plugins.smartenv.Smartenv();
|
||||
if (!smartenv.isBrowser) {
|
||||
await smartenv.getSafeNodeModule('fake-indexeddb/auto.js');
|
||||
if (!smartenv.isBrowser && !globalThis.indexedDB) {
|
||||
console.log('hey');
|
||||
console.log(globalThis.indexedDB);
|
||||
await smartenv.getSafeNodeModule('fake-indexeddb/auto');
|
||||
if (!globalThis.indexedDB) {
|
||||
const mod = await smartenv.getSafeNodeModule('fake-indexeddb');
|
||||
globalThis.indexedDB = new mod.IDBFactory();
|
||||
}
|
||||
}
|
||||
|
||||
this.db = await plugins.idb.openDB(this.options.dbName, 1, {
|
||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user