Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sqlite-async

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlite-async - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

2

package.json
{
"name": "sqlite-async",
"version": "1.0.8",
"version": "1.0.9",
"description": "ES6 Promise-based interface to the sqlite3 module.",

@@ -5,0 +5,0 @@ "main": "sqlite-async.js",

@@ -33,5 +33,5 @@ # sqlite-async

### Database#close()
### Database#close([promise])
Closes the database and returns a promise.
Closes the database and returns a promise. If the optional promise is specified, it is run before closing the database. The database is closed regardless whether the optional promise is resolved or rejected. If the optional promise is rejected, then the close method itself will return a rejected promise with the error from the optional promise.

@@ -38,0 +38,0 @@ ### Database#run(sql, [param, ...])

@@ -44,7 +44,18 @@ /**

close() {
close(promise) {
if (!this.db) {
return Promise.reject(new Error('Database.close: database is not open'))
}
if (promise) {
return promise(this).then(result => {
return this.close().then(_ => {
return result
})
}).catch(err => {
return this.close().then(_ => {
return Promise.reject(err)
})
})
}
return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.close: database is not open'))
}
this.db.close(err => {

@@ -51,0 +62,0 @@ if (err) {

@@ -184,2 +184,21 @@ const assert = require('assert')

})
describe('open', function () {
it('should open the database again', function () {
return Database.open('test.db').then(_db => {
db = _db
})
})
})
describe('close', function () {
it('should close database after executing the promise', function () {
return db.close(db => {
return Promise.resolve('success')
}).then(result => {
assert.strictEqual(result, 'success')
})
})
it('should no longer be able to use the database', function () {
assert(db.db === null)
})
})
})

@@ -186,0 +205,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc