SQLite Utilities
npm install @w0s/sqlite-utility

``JavaScript
import { jsToSQLiteComparison, jsToSQLiteAssignment, sqliteToJS, prepareSelect, prepareInsert, prepareUpdate, prepareDelete } from '@w0s/sqlite-utility';
jsToSQLiteComparison('text'); // 'text'
jsToSQLiteComparison(123); // 123
jsToSQLiteComparison(true); // 1
jsToSQLiteComparison(false); // 0
jsToSQLiteComparison(new Date('2000-01-01')); // 946684800
jsToSQLiteComparison(new URL('http://example.com/foo?bar#baz')); // 'http://example.com/foo?bar#baz'
jsToSQLiteAssignment('text'); // 'text'
...
jsToSQLiteAssignment(undefined); // null
sqliteToJS('text'); // 'text'
sqliteToJS(123); // 123
sqliteToJS(0, 'boolean'); // false
sqliteToJS(1, 'boolean'); // true
try {
sqliteToJS(2, 'boolean'); // Error
} catch {
}
sqliteToJS(946684800, 'date'); // Date objectURL
try {
sqliteToJS(1.2, 'date'); // Error
} catch {
}
sqliteToJS('http://example.com/foo?bar#baz', 'url'); // interface`
try {
sqliteToJS(123, 'url'); // Error
} catch {
}
sqliteToJS(null); // undefined
`TypeScript``
type JSType = string | number | boolean | Date | URL | undefined;
type SQLiteType = string | number | null;
const jsToSQLiteComparison = (value: Exclude<JSType, undefined>): Exclude<SQLiteType, null>WHERE / HAVING / ON / CASE clause)const jsToSQLiteAssignment = (value: JSType): SQLiteTypeSET / VALUES clause)function sqliteToJS(value: SQLiteType, type?: 'boolean' | 'date' | 'url'): JSType