File tree Expand file tree Collapse file tree 3 files changed +32
-34
lines changed Expand file tree Collapse file tree 3 files changed +32
-34
lines changed Original file line number Diff line number Diff line change @@ -2013,9 +2013,8 @@ const BENCHMARKS = [
2013
2013
new WasmEMCCBenchmark ( {
2014
2014
name : "sqlite3-wasm" ,
2015
2015
files : [
2016
- "./sqlite3/polyfills.js" ,
2017
- "./sqlite3/build/jswasm/speedtest1.js" ,
2018
2016
"./sqlite3/benchmark.js" ,
2017
+ "./sqlite3/build/jswasm/speedtest1.js" ,
2019
2018
] ,
2020
2019
preload : {
2021
2020
wasmBinary : "./sqlite3/build/jswasm/speedtest1.wasm"
Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- // Since a small portion of the setup of code of SQLite is run immediately
6
- // when loading it, some polyfills are split out of this file and loaded first.
5
+ // First, some polyfills for missing browser APIs in JavaScript shells.
6
+ // Since the generated JavaScript code of SQLite immediately uses some of them,
7
+ // we need to load and run this code before the generated `speedtest1.js` in the
8
+ // JetStream driver.
9
+
10
+ // Empty `URLSearchParams` has just the same interface as a `Map`.
11
+ globalThis . URLSearchParams = Map ;
12
+
13
+ // `TextEncoder` and `TextDecoder`. These are called only a few times with short
14
+ // ASCII strings, so this is sufficient and not performance-critical.
15
+ class TextEncoder {
16
+ encode ( string ) {
17
+ return Uint8Array . from ( string , ( char ) => {
18
+ let byte = char . codePointAt ( 0 ) ;
19
+ if ( byte > 0x7f )
20
+ throw new Error ( "TextEncoder polyfill only supports ASCII" ) ;
21
+ return byte ;
22
+ } ) ;
23
+ }
24
+ }
25
+ class TextDecoder {
26
+ decode ( array ) {
27
+ for ( let byte of array ) {
28
+ if ( byte > 0x7f )
29
+ throw new Error ( "TextDecoder polyfill only supports ASCII" ) ;
30
+ }
31
+ return String . fromCharCode . apply ( null , array ) ;
32
+ }
33
+ }
34
+
35
+ // Now, some configuration options for when we initialize SQLite.
7
36
8
37
// Use JetStream functions instead of `console.log` and friends.
9
38
globalThis . sqlite3ApiConfig = {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments