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)
- Error when building Next.js HOT 1
- Force to close DB HOT 1
- Typescript Schema typing error HOT 3
- Remove Edge-specific code
- Support discriminated union type or similar in database schemas HOT 3
- KnownKeys on ts > 4.2 HOT 1
- How to delete an object store? HOT 4
- Aborting a Transaction HOT 4
- Can't do async data migrations in the sync upgrade function HOT 7
- need method to bulk insert HOT 3
- Incorrect type of cursor value HOT 9
- Firebase Warning: Original error: (0 , _idb.openDB) is not a function. (app/idb-get). HOT 1
- IDBPTransaction TxStores type checking support HOT 1
- Typescript: cannot compose schema from multiple files HOT 1
- cannot delete particular data in store using IDBKeyRange and cursor. HOT 4
- idb does not detect changes HOT 1
- index.count and db.countFromIndex doesnt work in safari HOT 5
- Open Is Still Successful If Upgrade Throws Exception
- How to use it in a REPL? HOT 1
- Consider adding TypeDoc?
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.