Code Monkey home page Code Monkey logo

Comments (8)

KeithHenry avatar KeithHenry commented on May 19, 2024

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.

noahehall avatar noahehall commented on May 19, 2024

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.

andrewgremlich avatar andrewgremlich commented on May 19, 2024

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.

jakearchibald avatar jakearchibald commented on May 19, 2024

I think we can solve this by having the node version do a bit of feature detecting. Will have a think.

from idb.

andrewgremlich avatar andrewgremlich commented on May 19, 2024

@jakearchibald couldn't you check if there was an existing document?

from idb.

jakearchibald avatar jakearchibald commented on May 19, 2024

https://github.com/jakearchibald/idb/tree/electron-fix should solve the problem. Can someone check?

from idb.

andrewgremlich avatar andrewgremlich commented on May 19, 2024

It works in the project that I'm using it in!

from idb.

jakearchibald avatar jakearchibald commented on May 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.