better-sqlite3
Advanced tools
Comparing version 7.1.4 to 7.1.5
@@ -12,3 +12,3 @@ 'use strict'; | ||
function Database(filenameGiven, options) { | ||
if (new.target !== Database) { | ||
if (new.target == null) { | ||
return new Database(filenameGiven, options); | ||
@@ -15,0 +15,0 @@ } |
{ | ||
"name": "better-sqlite3", | ||
"version": "7.1.4", | ||
"version": "7.1.5", | ||
"description": "The fastest and simplest library for SQLite3 in Node.js.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/JoshuaWise/better-sqlite3", |
@@ -52,3 +52,3 @@ 'use strict'; | ||
expect(existsSync(util.next())).to.be.false; | ||
const db = this.db = Database(util.current()); | ||
const db = this.db = new Database(util.current()); | ||
expect(db.name).to.equal(util.current()); | ||
@@ -135,2 +135,27 @@ expect(db.memory).to.be.false; | ||
}); | ||
it('should work properly when called as a function', function () { | ||
const db = this.db = Database(util.next()); | ||
expect(db).to.be.an.instanceof(Database); | ||
expect(db.constructor).to.equal(Database); | ||
expect(Database.prototype.close).to.equal(db.close); | ||
expect(Database.prototype).to.equal(Object.getPrototypeOf(db)); | ||
}); | ||
it('should work properly when subclassed', function () { | ||
class MyDatabase extends Database { | ||
foo() { | ||
return 999; | ||
} | ||
} | ||
const db = this.db = new MyDatabase(util.next()); | ||
expect(db).to.be.an.instanceof(Database); | ||
expect(db).to.be.an.instanceof(MyDatabase); | ||
expect(db.constructor).to.equal(MyDatabase); | ||
expect(Database.prototype.close).to.equal(db.close); | ||
expect(MyDatabase.prototype.close).to.equal(db.close); | ||
expect(Database.prototype.foo).to.be.undefined; | ||
expect(MyDatabase.prototype.foo).to.equal(db.foo); | ||
expect(Database.prototype).to.equal(Object.getPrototypeOf(MyDatabase.prototype)); | ||
expect(MyDatabase.prototype).to.equal(Object.getPrototypeOf(db)); | ||
expect(db.foo()).to.equal(999); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2747375
3940