Skip to content

Commit 86865e6

Browse files
author
Christopher J. Brody
committed
Merge branch 'master' of https://github.com/kripken/sql.js into custom-functions
2 parents 3eb8f81 + e810a2c commit 86865e6

7 files changed

+16
-17
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ The test files provide up to date example of the use of the api.
8686
<script src='/dist/sql-wasm.js'></script>
8787
<script>
8888
config = {
89-
locateFile: filename => `/dist/${filename}`
89+
locateFile: filename => `/dist/${filename}`
9090
}
9191
// The `initSqlJs` function is globally provided by all of the main dist files if loaded in the browser.
9292
// We must specify this locateFile function if we are loading a wasm file from anywhere other than the current html page's folder.
@@ -97,11 +97,11 @@ The test files provide up to date example of the use of the api.
9797
db.run("CREATE TABLE test (col1, col2);");
9898
// Insert two rows: (1,111) and (2,222)
9999
db.run("INSERT INTO test VALUES (?,?), (?,?)", [1,111,2,222]);
100-
100+
101101
// Prepare a statement
102102
var stmt = db.prepare("SELECT * FROM test WHERE col1 BETWEEN $start AND $end");
103103
stmt.getAsObject({$start:1, $end:1}); // {col1:1, col2:111}
104-
104+
105105
// Bind new values
106106
stmt.bind({$start:1, $end:2});
107107
while(stmt.step()) { //
@@ -161,7 +161,7 @@ Alternatively, you can simply download `sql-wasm.js` and `sql-wasm.wasm`, from t
161161
var fs = require('fs');
162162
var initSqlJs = require('sql-wasm.js');
163163
var filebuffer = fs.readFileSync('test.sqlite');
164-
164+
165165
initSqlJs().then(function(SQL){
166166
// Load the db
167167
var db = new SQL.Database(filebuffer);
@@ -196,7 +196,7 @@ Example:
196196
worker.onmessage = event => {
197197
console.log(event.data); // The result of the query
198198
};
199-
199+
200200
worker.postMessage({
201201
id: 2,
202202
action: 'exec',
@@ -221,7 +221,7 @@ This library includes both WebAssembly and asm.js versions of Sqlite. (WebAssemb
221221

222222
## Upgrading from 0.x to 1.x
223223

224-
Version 1.0 of sql.js must be loaded asynchronously, whereas asm.js was able to be loaded synchronously.
224+
Version 1.0 of sql.js must be loaded asynchronously, whereas asm.js was able to be loaded synchronously.
225225

226226
So in the past, you would:
227227
```html
@@ -260,7 +260,7 @@ initSqlJs().then(function(SQL){
260260
`NOTHING` is now a reserved word in SQLite, whereas previously it was not. This could cause errors like `Error: near "nothing": syntax error`
261261

262262
### Downloading/Using: ###
263-
Although asm.js files were distributed as a single Javascript file, WebAssembly libraries are most efficiently distributed as a pair of files, the `.js` loader and the `.wasm` file, like [dist/sql-wasm.js]([dist/sql-wasm.js]) and [dist/sql-wasm.wasm]([dist/sql-wasm.wasm]). The `.js` file is responsible for wrapping/loading the `.wasm` file.
263+
Although asm.js files were distributed as a single Javascript file, WebAssembly libraries are most efficiently distributed as a pair of files, the `.js` loader and the `.wasm` file, like [dist/sql-wasm.js]([dist/sql-wasm.js]) and [dist/sql-wasm.wasm]([dist/sql-wasm.wasm]). The `.js` file is responsible for wrapping/loading the `.wasm` file.
264264

265265

266266

examples/start_local_server.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env python
2+
23
import BaseHTTPServer, SimpleHTTPServer, os
3-
4+
45
# We need to host from the root because we are going to be requesting files inside of dist
56
os.chdir('../')
67
port=8081
78
print "Running on port %d" % port
8-
9+
910
SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map['.wasm'] = 'application/wasm'
1011

1112
httpd = BaseHTTPServer.HTTPServer(('localhost', port), SimpleHTTPServer.SimpleHTTPRequestHandler)
12-
13+
1314
print "Mapping \".wasm\" to \"%s\"" % SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map['.wasm']
14-
httpd.serve_forever()
15+
httpd.serve_forever()

src/api-data.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ SQLite.TEXT=3
4040
SQLite.BLOB=4
4141
SQLite.NULL=5
4242

43-
# Encodings, used for registering functions.
43+
# Encodings, used for registering functions.
4444
SQLite.UTF8=1

src/api.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class Database
319319
try
320320
# Store the SQL string in memory. The string will be consumed, one statement
321321
# at a time, by sqlite3_prepare_v2_sqlptr.
322-
# Note that if we want to allocate as much memory as could _possibly_ be used, we can
322+
# Note that if we want to allocate as much memory as could _possibly_ be used, we can
323323
# we allocate bytes equal to 4* the number of chars in the sql string.
324324
# It would be faster, but this is probably a premature optimization
325325
nextSqlPtr = allocateUTF8OnStack(sql)
@@ -490,7 +490,7 @@ class Database
490490
sqlite3_result_error(cx,error,-1)
491491
return
492492

493-
# Return the result of the user defined function to SQLite
493+
# Return the result of the user defined function to SQLite
494494
switch typeof(result)
495495
when 'boolean' then sqlite3_result_int(cx,if result then 1 else 0)
496496
when 'number' then sqlite3_result_double(cx, result)

src/exported_runtime_methods.json

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
"stackSave",
55
"stackRestore"
66
]
7-

src/shell-post.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ else if (typeof define === 'function' && define['amd']) {
2020
else if (typeof exports === 'object'){
2121
exports["Module"] = initSqlJs;
2222
}
23-

src/shell-pre.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ var initSqlJs = function (moduleConfig) {
6666
// of the options, and has the side effect of reducing emcc's efforts to modify the module if its output were to change in the future.
6767
// That's a nice side effect since we're handling the modularization efforts ourselves
6868
module = undefined;
69-
69+
7070
// The emcc-generated code and shell-post.js code goes below,
7171
// meaning that all of it runs inside of this promise. If anything throws an exception, our promise will abort

0 commit comments

Comments
 (0)