Skip to content

Commit 2d7109f

Browse files
committed
changed code style
1 parent 9ac3b5a commit 2d7109f

36 files changed

+360
-349
lines changed

benchmark/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const clc = require('cli-color');
66
const getTrials = (searchTerms) => {
77
// Without any command-line arguments, we do a general-purpose benchmark.
88
if (!searchTerms.length) return require('./trials').default;
9-
9+
1010
// With command-line arguments, the user can run specific groups of trials.
1111
return require('./trials').searchable.filter(filterBySearchTerms(searchTerms));
1212
};

benchmark/seed.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ module.exports = () => {
3030
process.on('exit', () => fs.removeSync(tempDir));
3131
fs.removeSync(tempDir);
3232
fs.ensureDirSync(tempDir);
33-
33+
3434
const db = require('../.')(path.join(tempDir, 'benchmark.db'));
3535
db.pragma('journal_mode = OFF');
3636
db.pragma('synchronous = OFF');
37-
37+
3838
for (const [name, ctx] of tables.entries()) {
3939
db.exec(`CREATE TABLE ${name} ${ctx.schema}`);
4040
const columns = db.pragma(`table_info(${name})`).map(() => '?');
4141
const insert = db.prepare(`INSERT INTO ${name} VALUES (${columns.join(', ')})`).bind(ctx.data);
4242
for (let i = 0; i < ctx.count; ++i) insert.run();
4343
}
44-
44+
4545
db.close();
4646
return tables;
4747
};

deps/download.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# ===
44
# This script defines and generates the bundled SQLite3 unit (sqlite3.c).
5-
#
5+
#
66
# The following steps are taken:
77
# 1. populate the shell environment with the defined compile-time options.
88
# 2. download and extract the SQLite3 source code into a temporary directory.
99
# 3. run "sh configure" and "make sqlite3.c" within the source directory.
1010
# 4. bundle the generated amalgamation into a tar.gz file (sqlite3.tar.gz).
1111
# 5. export the defined compile-time options to a gyp file (defines.gypi).
1212
# 6. update the docs (../docs/compilation.md) with details of this distribution.
13-
#
13+
#
1414
# When a user builds better-sqlite3, the following steps are taken:
1515
# 1. node-gyp loads the previously exported compile-time options (defines.gypi).
1616
# 2. the extract.js script unpacks the bundled amalgamation (sqlite3.tar.gz).

docs/tips.md

-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ Foreign key clauses can be followed by `ON DELETE` and/or `ON UPDATE`, with the
3333
- `SET DEFAULT`: if the parent column is updated or deleted, the child column becomes its `DEFAULT` value.
3434
- *NOTE: This still causes a constraint violation if the child column's `DEFAULT` value does not correspond with an actual parent row*.
3535
- `CASCADE`: if the parent row is deleted, the child row is deleted; if the parent column is updated, the new value is propogated to the child column.
36-

lib/aggregate.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = (createAggregate) => {
66
if (typeof name !== 'string') throw new TypeError('Expected first argument to be a string');
77
if (typeof options !== 'object' || options === null) throw new TypeError('Expected second argument to be an options object');
88
if (!name) throw new TypeError('User-defined function name cannot be an empty string');
9-
9+
1010
const start = 'start' in options ? options.start : null;
1111
const step = getFunctionOption(options, 'step', true);
1212
const inverse = getFunctionOption(options, 'inverse', false);
@@ -15,13 +15,13 @@ module.exports = (createAggregate) => {
1515
const deterministic = getBooleanOption(options, 'deterministic');
1616
const varargs = getBooleanOption(options, 'varargs');
1717
let argCount = -1;
18-
18+
1919
if (!varargs) {
2020
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
2121
if (argCount > 0) argCount -= 1;
2222
if (argCount > 100) throw new RangeError('User-defined functions cannot have more than 100 arguments');
2323
}
24-
24+
2525
return createAggregate.call(this, start, step, inverse, result, name, argCount, safeIntegers, deterministic);
2626
};
2727
};

lib/database.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ function Database(filenameGiven, options) {
88
if (options == null) options = {};
99
if (typeof filenameGiven !== 'string') throw new TypeError('Expected first argument to be a string');
1010
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
11-
11+
1212
let filename = filenameGiven.trim();
1313
if (!filename) throw new TypeError('Database filename cannot be an empty string');
1414
if (filename.toLowerCase().startsWith('file:')) throw new TypeError('URI filenames are reserved for internal use only');
1515
if ('readOnly' in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
16-
16+
1717
const anonymous = filename === ':memory:';
1818
const memory = util.getBooleanOption(options, 'memory');
1919
const readonly = util.getBooleanOption(options, 'readonly');
2020
const fileMustExist = util.getBooleanOption(options, 'fileMustExist');
2121
const timeout = 'timeout' in options ? options.timeout : 5000;
22-
22+
2323
if (readonly && (memory || anonymous)) throw new TypeError('In-memory databases cannot be readonly');
2424
if (anonymous && !memory && 'memory' in options) throw new TypeError('Option "memory" conflicts with :memory: filename');
2525
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
2626
if (timeout > 0x7fffffff) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
27-
27+
2828
if (!memory && !anonymous && !fs.existsSync(path.dirname(filename))) {
2929
throw new TypeError('Cannot open database because the directory does not exist');
3030
}
31-
31+
3232
if (memory && !anonymous) {
3333
if (process.platform === 'win32') {
3434
filename = filename.replace(/\\/g, '/').replace(/^[a-z]:\//i, '/$&');

lib/function.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ module.exports = (createFunction) => {
99
if (typeof fn !== 'function') throw new TypeError('Expected last argument to be a function');
1010
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
1111
if (!name) throw new TypeError('User-defined function name cannot be an empty string');
12-
12+
1313
const safeIntegers = 'safeIntegers' in options ? +getBooleanOption(options, 'safeIntegers') : 2;
1414
const deterministic = getBooleanOption(options, 'deterministic');
1515
const varargs = getBooleanOption(options, 'varargs');
1616
let argCount = -1;
17-
17+
1818
if (!varargs) {
1919
argCount = fn.length;
2020
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError('Expected function.length to be a positive integer');
2121
if (argCount > 100) throw new RangeError('User-defined functions cannot have more than 100 arguments');
2222
}
23-
23+
2424
return createFunction.call(this, fn, name, argCount, safeIntegers, deterministic);
2525
};
2626
};

lib/pragma.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = (setPragmaMode) => {
77
if (typeof source !== 'string') throw new TypeError('Expected first argument to be a string');
88
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
99
const simple = getBooleanOption(options, 'simple');
10-
10+
1111
setPragmaMode.call(this, true);
1212
try {
1313
return simple

lib/transaction.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ module.exports = function transaction(fn) {
55
if (typeof fn !== 'function') throw new TypeError('Expected first argument to be a function');
66
const controller = getController(this);
77
const { apply } = Function.prototype;
8-
8+
99
const properties = {
1010
default: { value: wrapTransaction(apply, fn, this, controller.default) },
1111
deferred: { value: wrapTransaction(apply, fn, this, controller.deferred) },
1212
immediate: { value: wrapTransaction(apply, fn, this, controller.immediate) },
1313
exclusive: { value: wrapTransaction(apply, fn, this, controller.exclusive) },
1414
database: { value: this, enumerable: true },
1515
};
16-
16+
1717
Object.defineProperties(properties.default.value, properties);
1818
Object.defineProperties(properties.deferred.value, properties);
1919
Object.defineProperties(properties.immediate.value, properties);
2020
Object.defineProperties(properties.exclusive.value, properties);
21-
21+
2222
return properties.default.value;
2323
};
2424

0 commit comments

Comments
 (0)