sqlite-tag-spawned
Advanced tools
Comparing version 0.5.6 to 0.6.0
@@ -17,3 +17,6 @@ 'use strict'; | ||
const {from} = Array; | ||
const quote = /'/g; | ||
const hex = x => x.toString(16).padStart(2, '0'); | ||
const x = typed => `x'${from(typed, hex).join('')}'`; | ||
const asValue = value => { | ||
@@ -30,6 +33,14 @@ switch (typeof value) { | ||
case 'undefined': | ||
if (!value) | ||
return 'NULL'; | ||
else if (value instanceof Date) | ||
return "'" + value.toISOString() + "'"; | ||
switch (true) { | ||
case !value: | ||
return 'NULL'; | ||
case value instanceof Date: | ||
return "'" + value.toISOString() + "'"; | ||
case value instanceof Buffer: | ||
case value instanceof ArrayBuffer: | ||
value = new Uint8Array(value); | ||
case value instanceof Uint8Array: | ||
case value instanceof Uint8ClampedArray: | ||
return x(value); | ||
} | ||
} | ||
@@ -36,0 +47,0 @@ }; |
@@ -14,3 +14,6 @@ import plain from 'plain-tag'; | ||
const {from} = Array; | ||
const quote = /'/g; | ||
const hex = x => x.toString(16).padStart(2, '0'); | ||
const x = typed => `x'${from(typed, hex).join('')}'`; | ||
export const asValue = value => { | ||
@@ -27,6 +30,14 @@ switch (typeof value) { | ||
case 'undefined': | ||
if (!value) | ||
return 'NULL'; | ||
else if (value instanceof Date) | ||
return "'" + value.toISOString() + "'"; | ||
switch (true) { | ||
case !value: | ||
return 'NULL'; | ||
case value instanceof Date: | ||
return "'" + value.toISOString() + "'"; | ||
case value instanceof Buffer: | ||
case value instanceof ArrayBuffer: | ||
value = new Uint8Array(value); | ||
case value instanceof Uint8Array: | ||
case value instanceof Uint8ClampedArray: | ||
return x(value); | ||
} | ||
} | ||
@@ -33,0 +44,0 @@ }; |
{ | ||
"name": "sqlite-tag-spawned", | ||
"version": "0.5.6", | ||
"version": "0.6.0", | ||
"description": "Same as sqlite-tag but without the native sqlite3 module dependency", | ||
@@ -23,6 +23,7 @@ "main": "./cjs/index.js", | ||
"ascjs": "^5.0.1", | ||
"better-sqlite3": "^7.5.0", | ||
"c8": "^7.11.0", | ||
"sqlite-tag": "^1.3.1", | ||
"sqlite3": "^4.2.0" | ||
"better-sqlite3": "^7.5.1", | ||
"c8": "^7.11.2", | ||
"mitata": "^0.0.14", | ||
"sqlite-tag": "^1.3.2", | ||
"sqlite3": "^5.0.8" | ||
}, | ||
@@ -29,0 +30,0 @@ "module": "./esm/index.js", |
23363
531
6