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.3 to 1.0.4

2

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

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

@@ -13,9 +13,2 @@ /**

constructor(db) {
if (!(db instanceof sqlite.Database)) {
throw new TypeError(`Database: 'db' is not a database instance`)
}
this.db = db
}
static get OPEN_READONLY() { return sqlite.OPEN_READONLY }

@@ -26,9 +19,22 @@ static get OPEN_READWRITE() { return sqlite.OPEN_READWRITE }

static open(filename, mode) {
mode = mode || (Database.OPEN_READWRITE | Database.OPEN_CREATE)
let db = new Database()
return db.open(filename, mode)
}
open(filename, mode) {
if (typeof mode === 'undefined') {
mode = Database.OPEN_READWRITE | Database.OPEN_CREATE
} else if (typeof mode !== 'number') {
throw new TypeError('Database.open: mode is not a number')
}
return new Promise((resolve, reject) => {
let db = new sqlite.Database(filename, mode, err => {
if (this.db) {
return reject(new Error('Database.open: database is already open'))
}
this.db = new sqlite.Database(filename, mode, err => {
if (err) {
reject(err)
} else {
resolve(new Database(db))
this.filename = filename
resolve(this)
}

@@ -39,6 +45,7 @@ })

get filename() { return this.db.filename }
close() {
return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.close: database is not open'))
}
this.db.close(err => {

@@ -48,3 +55,4 @@ if (err) {

} else {
resolve() // can't use it anymore
this.db = null
resolve(this)
}

@@ -57,2 +65,5 @@ })

return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.run: database is not open'))
}
// Need a real function because 'this' is used.

@@ -79,2 +90,5 @@ let callback = function (err) {

return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.get: database is not open'))
}
let callback = (err, row) => {

@@ -94,2 +108,5 @@ if (err) {

return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.all: database is not open'))
}
let callback = (err, rows) => {

@@ -112,2 +129,5 @@ if (err) {

return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.each: database is not open'))
}
let callback = (err, nrows) => {

@@ -127,2 +147,5 @@ if (err) {

return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.exec: database is not open'))
}
this.db.exec(sql, err => {

@@ -140,2 +163,5 @@ if (err) {

return new Promise((resolve, reject) => {
if (!this.db) {
return reject(new Error('Database.prepare: database is not open'))
}
let statement

@@ -184,8 +210,4 @@ let callback = err => {

return new Promise((resolve, reject) => {
this.statement.reset(err => {
if (err) {
reject(err)
} else {
resolve(this)
}
this.statement.reset(_ => {
resolve(this)
})

@@ -192,0 +214,0 @@ })

@@ -83,2 +83,8 @@ const Database = require('../sqlite-async')

.then(_ => {
return db.run()
})
.catch(err => {
expect(err.message, `"Database.run: database is not open"`)
})
.then(_ => {
console.log('All tests pass.')

@@ -85,0 +91,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