Comments (8)
That's been created as part of this pull: #27
It causes node.js to always fail with idb, which is not quite right - Electron, Atom or anything else that provides a browser window could access idb in node, so that check needs to be expanded.
from idb.
let me know how i can help with this
it looks like on line https://github.com/jakearchibald/idb/pull/27/files#diff-0e57e9bd985a92cc0d6572193082ed61R4
and https://github.com/jakearchibald/idb/pull/27/files#diff-0e57e9bd985a92cc0d6572193082ed61R7
we can check if IDBIndex (not window) exists before throwing error
from idb.
Couldn't the check be something like what jQuery implements? For example here are the first few lines of jQuery...
"use strict";
if ( typeof module === "object" && typeof module.exports === "object" ) {
// For CommonJS and CommonJS-like environments where a proper `window`
// is present, execute the factory and get jQuery.
// For environments that do not have a `window` with a `document`
// (such as Node.js), expose a factory as module.exports.
// This accentuates the need for the creation of a real `window`.
// e.g. var jQuery = require("jquery")(window);
// See ticket #14549 for more info.
module.exports = global.document ?
factory( global, true ) :
function( w ) {
if ( !w.document ) {
throw new Error( "jQuery requires a window with a document" );
}
return factory( w );
};
} else {
factory( global );
}
// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
jQuery still throws errors in the node terminal, but in electron it doesn't.
from idb.
I think we can solve this by having the node version do a bit of feature detecting. Will have a think.
from idb.
@jakearchibald couldn't you check if there was an existing document?
from idb.
https://github.com/jakearchibald/idb/tree/electron-fix should solve the problem. Can someone check?
from idb.
It works in the project that I'm using it in!
from idb.
Merged, and published as 2.0.1! Thanks for the report & help fixing this. I'm delighted, as always, that people find my silly codes useful 😄
from idb.
Related Issues (20)
- egronomic way to provide schema via JSDoc
- ConstraintError: Key already exists in the object store. HOT 2
- Not able to import openDB from idb/with-async-ittr in Ver 8
- Comment confusing `unlisten`
- delete only takes key as string but autoincremented keys are numbers HOT 1
- When I try to use main.js in my app I get a referenc eerror-
- DeleteDB should call Close() HOT 5
- How order for getAllFromIndex
- TS declaration error: Type 'IndexNames<DBTypes, StoreName>' does not satisfy the constraint 'string' HOT 15
- Types exports are incorrect in package.json
- Add type exports for openDB callbacks
- TypeError: Invalid value used as weak map key. when my value is `NaN`
- Remove Add Event Listeners?
- Is the nativescript browser compatible with this library?
- "No overload matches this call" when passing the store name as a variable
- `done` promise semantics is confusing and may cause uncaught promise rejections HOT 2
- cursor.continue(key) can hang? HOT 1
- After using idb, the IDBRequest's onsuccess & onerror will not be called
- cannot unwrap db
- Incorrect type for tx.store.indexNames
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from idb.