alasql 4.10.0 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,46 +6,40 @@
6
6
  [![NPM downloads](http://img.shields.io/npm/dm/alasql.svg?style=flat&label=npm%20downloads)](https://npm-stat.com/charts.html?package=alasql)
7
7
  [![OPEN open source software](https://img.shields.io/badge/Open--OSS-%E2%9C%94-brightgreen.svg)](http://open-oss.com)
8
8
  [![Release](https://img.shields.io/github/release/alasql/alasql.svg?label=npm&a)](https://www.npmjs.com/package/alasql)
9
- [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/AlaSQL/alasql.svg)](http://isitmaintained.com/project/AlaSQL/alasql "Average time to resolve an issue")
10
- [![Coverage]( https://img.shields.io/codecov/c/github/alasql/alasql/develop.svg)](https://rawgit.com/alasql/alasql/develop/test/coverage/lcov-report/dist/alasql.fs.js.html)
9
+ [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/AlaSQL/alasql.svg)](http://isitmaintained.com/project/AlaSQL/alasql 'Average time to resolve an issue')
10
+ [![Coverage](https://img.shields.io/codecov/c/github/alasql/alasql/develop.svg)](https://rawgit.com/alasql/alasql/develop/test/coverage/lcov-report/dist/alasql.fs.js.html)
11
11
  [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/AlaSQL/alasql/badge)](https://securityscorecards.dev/viewer/?uri=github.com/AlaSQL/alasql)
12
12
  [![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/328/badge)](https://bestpractices.coreinfrastructure.org/projects/328)
13
13
  [![](https://data.jsdelivr.com/v1/package/npm/alasql/badge?style=rounded)](https://www.jsdelivr.com/package/npm/alasql)
14
14
  [![Stars](https://img.shields.io/github/stars/alasql/alasql.svg?label=Github%20%E2%98%85&a)](https://github.com/alasql/alasql)
15
15
 
16
-
17
-
18
-
19
16
  # AlaSQL
20
17
 
21
18
  <h2 align="center"><a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/19309516/94f8007e-9085-11e6-810f-62fd60b42185.png" alt="AlaSQL logo" styl="max-width:80%"/></a>
22
19
  </h2>
23
20
 
24
-
25
-
26
- AlaSQL - _( [à la](http://en.wiktionary.org/wiki/%C3%A0_la) [SQL](http://en.wikipedia.org/wiki/SQL) ) [ælæ ɛskju:ɛl]_ - is an open source SQL database for JavaScript with a strong focus on query speed and data source flexibility for both relational data and schemaless data. It works in the web browser, Node.js, and mobile apps.
21
+ AlaSQL - _( [à la](http://en.wiktionary.org/wiki/%C3%A0_la) [SQL](http://en.wikipedia.org/wiki/SQL) ) [ælæ ɛskju:ɛl]_ - is an open source SQL database for JavaScript with a strong focus on query speed and data source flexibility for both relational data and schemaless data. It works in the web browser, Node.js, and mobile apps.
27
22
 
28
23
  This library is perfect for:
29
24
 
30
- * Fast in-memory SQL data processing for BI and ERP applications on fat clients
31
- * Easy ETL and options for persistence by data import / manipulation / export of several formats
32
- * All major browsers, Node.js, and mobile applications
25
+ - Fast in-memory SQL data processing for BI and ERP applications on fat clients
26
+ - Easy ETL and options for persistence by data import / manipulation / export of several formats
27
+ - All major browsers, Node.js, and mobile applications
33
28
 
34
29
  We focus on [speed](https://github.com/alasql/alasql/wiki/Speed) by taking advantage of the dynamic nature of JavaScript when building up queries. Real-world solutions demand flexibility regarding where data comes from and where it is to be stored. We focus on flexibility by making sure you can [import/export](https://github.com/alasql/alasql/wiki/Import-export) and query directly on data stored in Excel (both `.xls` and `.xlsx`), CSV, JSON, TAB, IndexedDB, LocalStorage, and SQLite files.
35
30
 
36
31
  The library adds the comfort of a full database engine to your JavaScript app. No, really - it's working towards a full database engine complying with [most of the SQL-99 language](https://github.com/alasql/alasql/wiki/Supported-SQL-statements), spiced up with additional syntax for NoSQL (schema-less) data and graph networks.
37
32
 
38
-
39
33
  #### Traditional SQL Table
40
34
 
41
35
  ```js
42
36
  /* create SQL Table and add data */
43
- alasql("CREATE TABLE cities (city string, pop number)");
37
+ alasql('CREATE TABLE cities (city string, pop number)');
44
38
 
45
39
  alasql("INSERT INTO cities VALUES ('Paris',2249975),('Berlin',3517424),('Madrid',3041579)");
46
40
 
47
41
  /* execute query */
48
- var res = alasql("SELECT * FROM cities WHERE pop < 3500000 ORDER BY pop DESC");
42
+ var res = alasql('SELECT * FROM cities WHERE pop < 3500000 ORDER BY pop DESC');
49
43
 
50
44
  // res = [ { "city": "Madrid", "pop": 3041579 }, { "city": "Paris", "pop": 2249975 } ]
51
45
  ```
@@ -55,9 +49,13 @@ var res = alasql("SELECT * FROM cities WHERE pop < 3500000 ORDER BY pop DESC");
55
49
  #### Array of Objects
56
50
 
57
51
  ```js
58
- var data = [ {a: 1, b: 10}, {a: 2, b: 20}, {a: 1, b: 30} ];
52
+ var data = [
53
+ {a: 1, b: 10},
54
+ {a: 2, b: 20},
55
+ {a: 1, b: 30},
56
+ ];
59
57
 
60
- var res = alasql('SELECT a, SUM(b) AS b FROM ? GROUP BY a',[data]);
58
+ var res = alasql('SELECT a, SUM(b) AS b FROM ? GROUP BY a', [data]);
61
59
 
62
60
  // res = [ { "a": 1, "b": 40},{ "a": 2, "b": 20 } ]
63
61
  ```
@@ -68,45 +66,46 @@ var res = alasql('SELECT a, SUM(b) AS b FROM ? GROUP BY a',[data]);
68
66
 
69
67
  ```js
70
68
  // file is read asynchronously (Promise returned when SQL given as array)
71
- alasql(['SELECT * FROM XLS("./data/mydata") WHERE lastname LIKE "A%" and city = "London" GROUP BY name '])
72
- .then(function(res){
73
- console.log(res); // output depends on mydata.xls
74
- }).catch(function(err){
75
- console.log('Does the file exist? There was an error:', err);
76
- });
69
+ alasql([
70
+ 'SELECT * FROM XLS("./data/mydata") WHERE lastname LIKE "A%" and city = "London" GROUP BY name ',
71
+ ])
72
+ .then(function (res) {
73
+ console.log(res); // output depends on mydata.xls
74
+ })
75
+ .catch(function (err) {
76
+ console.log('Does the file exist? There was an error:', err);
77
+ });
77
78
  ```
78
79
 
79
-
80
80
  #### Bulk Data Load
81
81
 
82
82
  ```js
83
- alasql("CREATE TABLE example1 (a INT, b INT)");
83
+ alasql('CREATE TABLE example1 (a INT, b INT)');
84
84
 
85
85
  // alasql's data store for a table can be assigned directly
86
86
  alasql.tables.example1.data = [
87
- {a:2,b:6},
88
- {a:3,b:4}
87
+ {a: 2, b: 6},
88
+ {a: 3, b: 4},
89
89
  ];
90
90
 
91
91
  // ... or manipulated with normal SQL
92
- alasql("INSERT INTO example1 VALUES (1,5)");
92
+ alasql('INSERT INTO example1 VALUES (1,5)');
93
93
 
94
- var res = alasql("SELECT * FROM example1 ORDER BY b DESC");
94
+ var res = alasql('SELECT * FROM example1 ORDER BY b DESC');
95
95
 
96
96
  console.log(res); // [{a:2,b:6},{a:1,b:5},{a:3,b:4}]
97
97
  ```
98
98
 
99
- __If you are familiar with SQL, it should be no surprise that proper use of indexes on your tables is essential for good performance.__
99
+ **If you are familiar with SQL, it should be no surprise that proper use of indexes on your tables is essential for good performance.**
100
100
 
101
101
  #### Options
102
102
 
103
- AlaSQL has several [configuration options](https://github.com/AlaSQL/alasql/wiki/AlaSQL-Options) which change the behavior. It can be set via SQL statements or via the options object before using `alasql`.
103
+ AlaSQL has several [configuration options](https://github.com/AlaSQL/alasql/wiki/AlaSQL-Options) which change the behavior. It can be set via SQL statements or via the options object before using `alasql`.
104
104
 
105
- If you're using `NOW()` in queries often, setting `alasql.options.dateAsString` to `false` speed things up. It will just return a JS Date object instead of a string representation of a date.
105
+ If you're using `NOW()` in queries often, setting `alasql.options.dateAsString` to `false` speed things up. It will just return a JS Date object instead of a string representation of a date.
106
106
 
107
107
  ## Installation
108
108
 
109
-
110
109
  ```bash
111
110
  yarn add alasql # yarn
112
111
 
@@ -117,12 +116,10 @@ npm install -g alasql # global install of command line tool
117
116
 
118
117
  For the browsers: include [alasql.min.js](https://cdn.jsdelivr.net/npm/alasql)
119
118
 
120
-
121
119
  ```html
122
120
  <script src="https://cdn.jsdelivr.net/npm/alasql@4"></script>
123
121
  ```
124
122
 
125
-
126
123
  ## Getting started
127
124
 
128
125
  See the ["Getting started" section of the wiki](https://github.com/alasql/alasql/wiki/Getting%20started)
@@ -131,16 +128,15 @@ More advanced topics are covered in other wiki sections like ["Data manipulation
131
128
 
132
129
  Other links:
133
130
 
134
- * Documentation: [Github wiki](https://github.com/alasql/alasql/wiki)
135
-
136
- * Library CDN: [jsDelivr.com](http://www.jsdelivr.com/#!alasql)
131
+ - Documentation: [Github wiki](https://github.com/alasql/alasql/wiki)
137
132
 
138
- * Feedback: [Open an issue](https://github.com/alasql/alasql/issues/new)
133
+ - Library CDN: [jsDelivr.com](http://www.jsdelivr.com/#!alasql)
139
134
 
140
- * Try online: <a href="http://alasql.org/console?CREATE TABLE cities (city string, population number);INSERT INTO cities VALUES ('Rome',2863223), ('Paris',2249975),('Berlin',3517424), ('Madrid',3041579);SELECT * FROM cities WHERE population < 3500000 ORDER BY population DESC">Playground</a>
135
+ - Feedback: [Open an issue](https://github.com/alasql/alasql/issues/new)
141
136
 
142
- * Website: [alasql.org](http://AlaSQL.org)
137
+ - Try online: <a href="http://alasql.org/console?CREATE TABLE cities (city string, population number);INSERT INTO cities VALUES ('Rome',2863223), ('Paris',2249975),('Berlin',3517424), ('Madrid',3041579);SELECT * FROM cities WHERE population < 3500000 ORDER BY population DESC">Playground</a>
143
138
 
139
+ - Website: [alasql.org](http://AlaSQL.org)
144
140
 
145
141
  ## Please note
146
142
 
@@ -155,72 +151,85 @@ Please check out the [limitations of the library](https://github.com/alasql/alas
155
151
 
156
152
  AlaSQL is designed for speed and includes some of the classic SQL engine optimizations:
157
153
 
158
- * Queries are cached as compiled functions
159
- * Joined tables are pre-indexed
160
- * `WHERE` expressions are pre-filtered for joins
154
+ - Queries are cached as compiled functions
155
+ - Joined tables are pre-indexed
156
+ - `WHERE` expressions are pre-filtered for joins
161
157
 
162
158
  See more [performance-related info on the wiki](https://github.com/alasql/alasql/wiki/Speed)
163
159
 
164
160
  ## Features you might like
165
161
 
166
-
167
162
  ### Traditional SQL
168
163
 
169
164
  Use "good old" SQL on your data with multiple levels of: `JOIN`, `VIEW`, `GROUP BY`, `UNION`, `PRIMARY KEY`, `ANY`, `ALL`, `IN`, `ROLLUP()`, `CUBE()`, `GROUPING SETS()`, `CROSS APPLY`, `OUTER APPLY`, `WITH SELECT`, and subqueries. [The wiki lists supported SQL statements and keywords](https://github.com/alasql/alasql/wiki/SQL%20keywords).
170
165
 
171
-
172
-
173
166
  ### User-Defined Functions in your SQL
174
167
 
175
168
  You can use all benefits of SQL and JavaScript together by defining your own custom functions. Just add new functions to the alasql.fn object:
176
169
 
177
-
178
170
  ```js
179
- alasql.fn.myfn = function(a,b) {
180
- return a*b+1;
171
+ alasql.fn.myfn = function (a, b) {
172
+ return a * b + 1;
181
173
  };
182
174
  var res = alasql('SELECT myfn(a,b) FROM one');
183
175
  ```
184
176
 
185
177
  You can also define your own aggregator functions (like your own `SUM(...)`). See more [in the wiki](https://github.com/alasql/alasql/wiki/User-Defined-Functions)
186
178
 
187
-
188
179
  ### Compiled statements and functions
189
180
 
190
181
  ```js
191
182
  var ins = alasql.compile('INSERT INTO one VALUES (?,?)');
192
- ins(1,10);
193
- ins(2,20);
183
+ ins(1, 10);
184
+ ins(2, 20);
194
185
  ```
195
186
 
196
187
  See more [in the wiki](https://github.com/alasql/alasql/wiki/Compile)
197
188
 
198
-
199
189
  ### SELECT against your JavaScript data
200
190
 
201
191
  Group your JavaScript array of objects by field and count number of records in each group:
202
192
 
203
193
  ```js
204
- var data = [{a:1,b:1,c:1},{a:1,b:2,c:1},{a:1,b:3,c:1}, {a:2,b:1,c:1}];
205
- var res = alasql('SELECT a, COUNT(*) AS b FROM ? GROUP BY a', [data] );
194
+ var data = [
195
+ {a: 1, b: 1, c: 1},
196
+ {a: 1, b: 2, c: 1},
197
+ {a: 1, b: 3, c: 1},
198
+ {a: 2, b: 1, c: 1},
199
+ ];
200
+ var res = alasql('SELECT a, COUNT(*) AS b FROM ? GROUP BY a', [data]);
206
201
  ```
207
202
 
208
203
  See more ideas for creative data manipulation [in the wiki](https://github.com/alasql/alasql/wiki/Getting-started)
209
204
 
210
-
211
-
212
205
  ### JavaScript Sugar
213
206
 
214
207
  AlaSQL extends "good old" SQL to make it closer to JavaScript. The "sugar" includes:
215
208
 
216
- * Write Json objects - `{a:'1',b:@['1','2','3']}`
209
+ - Write Json objects - `{a:'1',b:@['1','2','3']}`
210
+
211
+ - Access object properties - `obj->property->subproperty`
212
+ - Access object and arrays elements - `obj->(a*1)`
213
+ - Access JavaScript functions - `obj->valueOf()`
214
+ - Format query output with `SELECT VALUE, ROW, COLUMN, MATRIX`
215
+ - Output nested objects with `INTO OBJECT()` - converts arrow notation columns back to nested structure
216
+ - ES5 multiline SQL with `var SQL = function(){/*SELECT 'MY MULTILINE SQL'*/}` and pass instead of SQL string (will not work if you compress your code)
217
+
218
+ #### Extracting Nested Properties with INTO OBJECT()
219
+
220
+ When selecting nested properties using arrow notation (`->`), results are normally flattened with the arrow path as the key. Use `INTO OBJECT()` to restore the nested structure:
221
+
222
+ ```js
223
+ var data = [{name: 'Oslo', info: {country: 'Norway', population: 700000}}];
217
224
 
218
- * Access object properties - `obj->property->subproperty`
219
- * Access object and arrays elements - `obj->(a*1)`
220
- * Access JavaScript functions - `obj->valueOf()`
221
- * Format query output with `SELECT VALUE, ROW, COLUMN, MATRIX`
222
- * ES5 multiline SQL with `var SQL = function(){/*SELECT 'MY MULTILINE SQL'*/}` and pass instead of SQL string (will not work if you compress your code)
225
+ // Standard output (flattened)
226
+ alasql('SELECT name, info->country FROM ?', [data]);
227
+ // [{ "name": "Oslo", "info->country": "Norway" }]
223
228
 
229
+ // With INTO OBJECT() (nested)
230
+ alasql('SELECT name, info->country INTO OBJECT() FROM ?', [data]);
231
+ // [{ "name": "Oslo", "info": { "country": "Norway" } }]
232
+ ```
224
233
 
225
234
  ### Read and write Excel and raw data files
226
235
 
@@ -229,17 +238,19 @@ You can import from and export to CSV, TAB, TXT, and JSON files. File extensions
229
238
  ```js
230
239
  var tabFile = 'mydata.tab';
231
240
 
232
- alasql.promise([
233
- "SELECT * FROM txt('MyFile.log') WHERE [0] LIKE 'M%'", // parameter-less query
234
- [ "SELECT * FROM tab(?) ORDER BY [1]", [tabFile] ], // [query, array of params]
235
- "SELECT [3] AS city,[4] AS population FROM csv('./data/cities')",
236
- "SELECT * FROM json('../config/myJsonfile')"
237
- ]).then(function(results){
238
- console.log(results);
239
- }).catch(console.error);
241
+ alasql
242
+ .promise([
243
+ "SELECT * FROM txt('MyFile.log') WHERE [0] LIKE 'M%'", // parameter-less query
244
+ ['SELECT * FROM tab(?) ORDER BY [1]', [tabFile]], // [query, array of params]
245
+ "SELECT [3] AS city,[4] AS population FROM csv('./data/cities')",
246
+ "SELECT * FROM json('../config/myJsonfile')",
247
+ ])
248
+ .then(function (results) {
249
+ console.log(results);
250
+ })
251
+ .catch(console.error);
240
252
  ```
241
253
 
242
-
243
254
  ### Read SQLite database files
244
255
 
245
256
  AlaSQL can read (but not write) SQLite data files using [SQL.js](https://github.com/sql-js/sql.js) library:
@@ -248,19 +259,18 @@ AlaSQL can read (but not write) SQLite data files using [SQL.js](https://github.
248
259
  <script src="alasql.js"></script>
249
260
  <script src="sql.js"></script>
250
261
  <script>
251
- alasql([
252
- 'ATTACH SQLITE DATABASE Chinook("Chinook_Sqlite.sqlite")',
253
- 'USE Chinook',
254
- 'SELECT * FROM Genre'
255
- ]).then(function(res){
256
- console.log("Genres:",res.pop());
257
- });
262
+ alasql([
263
+ 'ATTACH SQLITE DATABASE Chinook("Chinook_Sqlite.sqlite")',
264
+ 'USE Chinook',
265
+ 'SELECT * FROM Genre',
266
+ ]).then(function (res) {
267
+ console.log('Genres:', res.pop());
268
+ });
258
269
  </script>
259
270
  ```
260
271
 
261
272
  `sql.js` calls will always be asynchronous.
262
273
 
263
-
264
274
  ### AlaSQL works in the console - CLI
265
275
 
266
276
  The node module ships with an `alasql` command-line tool:
@@ -279,7 +289,6 @@ $ alasql "VALUE OF SELECT COUNT(*) AS abc FROM TXT('README.md') WHERE LENGTH([0]
279
289
 
280
290
  [More examples are included in the wiki](https://github.com/alasql/alasql/wiki/AlaSQL-CLI)
281
291
 
282
-
283
292
  ## Features you might love
284
293
 
285
294
  ### AlaSQL ♥ D3.js
@@ -307,34 +316,33 @@ Pinpointing data on a map should be easy. AlaSQL is great to prepare source data
307
316
  AlaSQL can query data directly from a Google spreadsheet. A good "partnership" for easy editing and powerful data manipulation. See more about [Google Spreadsheets and AlaSQL in the wiki](https://github.com/alasql/alasql/wiki/Google-Spreadsheets)
308
317
 
309
318
  ### Miss a feature?
319
+
310
320
  Take charge and [add your idea](http://feathub.com/alasql/alasql/features/new) or [vote for your favorite feature](http://feathub.com/alasql/alasql) to be implemented:
311
321
 
312
322
  [![Feature Requests](http://feathub.com/alasql/alasql?format=svg)](http://feathub.com/alasql/alasql)
313
323
 
314
-
315
324
  ## Limitations
316
325
 
317
326
  Please be aware that AlaSQL has [bugs](https://github.com/alasql/alasql/labels/Bug). Beside having some bugs, there are a number of limitations:
318
327
 
319
- 0. AlaSQL has a (long) list of keywords that must be escaped if used for column names. When selecting a field named `key` please write ``` SELECT `key` FROM ... ``` instead. This is also the case for words like ``` `value` ```, ``` `read` ```, ``` `count` ```, ``` `by` ```, ``` `top` ```, ``` `path` ```, ``` `deleted` ```, ``` `work` ``` and ``` `offset` ```. Please consult the [full list of keywords](https://github.com/alasql/alasql/wiki/AlaSQL-Keywords).
328
+ 0. AlaSQL has a (long) list of keywords that must be escaped if used for column names. When selecting a field named `key` please write ``SELECT `key` FROM ...`` instead. This is also the case for words like `` `value` ``, `` `read` ``, `` `count` ``, `` `by` ``, `` `top` ``, `` `path` ``, `` `deleted` ``, `` `work` `` and `` `offset` ``. Please consult the [full list of keywords](https://github.com/alasql/alasql/wiki/AlaSQL-Keywords).
320
329
 
321
- 0. It is OK to `SELECT` 1000000 records or to `JOIN` two tables with 10000 records in each (You can use streaming functions to work with longer datasources - see [test/test143.js](test/test143.js)) but be aware that the workload is multiplied so `SELECT`ing from more than 8 tables with just 100 rows in each will show bad performance. This is one of our top priorities to make better.
330
+ 1. It is OK to `SELECT` 1000000 records or to `JOIN` two tables with 10000 records in each (You can use streaming functions to work with longer datasources - see [test/test143.js](test/test143.js)) but be aware that the workload is multiplied so `SELECT`ing from more than 8 tables with just 100 rows in each will show bad performance. This is one of our top priorities to make better.
322
331
 
323
- 0. Limited functionality for transactions (supports only for localStorage) - Sorry, transactions are limited, because AlaSQL switched to more complex approach for handling `PRIMARY KEY`s / `FOREIGN KEY`s. Transactions will be fully turned on again in a future version.
332
+ 2. Limited functionality for transactions (supports only for localStorage) - Sorry, transactions are limited, because AlaSQL switched to more complex approach for handling `PRIMARY KEY`s / `FOREIGN KEY`s. Transactions will be fully turned on again in a future version.
324
333
 
325
- 0. A `(FULL) OUTER JOIN` and `RIGHT JOIN` of more than 2 tables will not produce expected results. `INNER JOIN` and `LEFT JOIN` are OK.
334
+ 3. A `(FULL) OUTER JOIN` and `RIGHT JOIN` of more than 2 tables will not produce expected results. `INNER JOIN` and `LEFT JOIN` are OK.
326
335
 
327
- 0. Please use aliases when you want fields with the same name from different tables (`SELECT a.id AS a_id, b.id AS b_id FROM ?`).
336
+ 4. Please use aliases when you want fields with the same name from different tables (`SELECT a.id AS a_id, b.id AS b_id FROM ?`).
328
337
 
329
- 0. At the moment AlaSQL does not work with JSZip 3.0.0 - please use version 2.x.
338
+ 5. At the moment AlaSQL does not work with JSZip 3.0.0 - please use version 2.x.
330
339
 
331
- 0. `JOIN`ing a sub-`SELECT` does not work. Please use a `with` structure ([Example here](https://github.com/alasql/alasql/issues/832#issuecomment-377574550)) or fetch the sub-`SELECT` to a variable and pass it as an argument ([Example here](https://github.com/alasql/alasql/issues/832#issuecomment-377559478)).
340
+ 6. `JOIN`ing a sub-`SELECT` does not work. Please use a `with` structure ([Example here](https://github.com/alasql/alasql/issues/832#issuecomment-377574550)) or fetch the sub-`SELECT` to a variable and pass it as an argument ([Example here](https://github.com/alasql/alasql/issues/832#issuecomment-377559478)).
332
341
 
333
- 0. AlaSQL uses the [FileSaver.js](https://github.com/eligrey/FileSaver.js/) library for saving files locally from the browser. Please be aware that it does not save files in Safari 8.0.
342
+ 7. AlaSQL uses the [FileSaver.js](https://github.com/eligrey/FileSaver.js/) library for saving files locally from the browser. Please be aware that it does not save files in Safari 8.0.
334
343
 
335
344
  There are probably many others. Please help us fix them by [submitting an issue](https://github.com/alasql/alasql/issues). Thank you!
336
345
 
337
-
338
346
  ## How To
339
347
 
340
348
  ### Use AlaSQL to convert data from CSV to Excel
@@ -343,11 +351,11 @@ ETL example:
343
351
 
344
352
  ```js
345
353
  alasql([
346
- 'CREATE TABLE IF NOT EXISTS geo.country',
347
- 'SELECT * INTO geo.country FROM CSV("country.csv",{headers:true})',
348
- 'SELECT * INTO XLSX("asia") FROM geo.country WHERE continent_name = "Asia"'
349
- ]).then(function(res){
350
- // results from the file asia.xlsx
354
+ 'CREATE TABLE IF NOT EXISTS geo.country',
355
+ 'SELECT * INTO geo.country FROM CSV("country.csv",{headers:true})',
356
+ 'SELECT * INTO XLSX("asia") FROM geo.country WHERE continent_name = "Asia"',
357
+ ]).then(function (res) {
358
+ // results from the file asia.xlsx
351
359
  });
352
360
  ```
353
361
 
@@ -360,11 +368,11 @@ From the browser thread, the browser build `alasql-worker.min.js` automagically
360
368
  ```html
361
369
  <script src="alasql-worker.min.js"></script>
362
370
  <script>
363
- var arr = [{a:1},{a:2},{a:1}];
371
+ var arr = [{a: 1}, {a: 2}, {a: 1}];
364
372
 
365
- alasql([['SELECT * FROM ?',[arr]]]).then(function(data){
366
- console.log(data);
367
- });
373
+ alasql([['SELECT * FROM ?', [arr]]]).then(function (data) {
374
+ console.log(data);
375
+ });
368
376
  </script>
369
377
  ```
370
378
 
@@ -375,10 +383,12 @@ The standard build `alasql.min.js` will use Web Workers if `alasql.worker()` is
375
383
  ```html
376
384
  <script src="alasql.min.js"></script>
377
385
  <script>
378
- alasql.worker();
379
- alasql(['SELECT VALUE 10']).then(function(res){
380
- console.log(res);
381
- }).catch(console.error);
386
+ alasql.worker();
387
+ alasql(['SELECT VALUE 10'])
388
+ .then(function (res) {
389
+ console.log(res);
390
+ })
391
+ .catch(console.error);
382
392
  </script>
383
393
  ```
384
394
 
@@ -396,25 +406,25 @@ When targeting the browser, several code bundlers like Webpack and Browserify wi
396
406
 
397
407
  Here's a list of modules that AlaSQL may require in certain environments or for certain features:
398
408
 
399
- * Node.js
400
- * fs
401
- * net
402
- * tls
403
- * request
404
- * path
405
- * React Native
406
- * react-native
407
- * react-native-fs
408
- * react-native-fetch-blob
409
- * Vertx
410
- * vertx
411
- * Agonostic
412
- * XLSX/XLS support
413
- * cptable
414
- * jszip
415
- * xlsx
416
- * cpexcel
417
- * es6-promise
409
+ - Node.js
410
+ - fs
411
+ - net
412
+ - tls
413
+ - request
414
+ - path
415
+ - React Native
416
+ - react-native
417
+ - react-native-fs
418
+ - react-native-fetch-blob
419
+ - Vertx
420
+ - vertx
421
+ - Agonostic
422
+ - XLSX/XLS support
423
+ - cptable
424
+ - jszip
425
+ - xlsx
426
+ - cpexcel
427
+ - es6-promise
418
428
 
419
429
  #### Webpack
420
430
 
@@ -445,14 +455,13 @@ As of AlaSQL 0.3.5, you can simply tell Webpack not to parse AlaSQL, which avoid
445
455
  {module:noParse:[/alasql/]}
446
456
  ```
447
457
 
448
-
449
458
  ##### script-loader
450
459
 
451
460
  If both of the solutions above fail to meet your requirements, you can load AlaSQL with [script-loader](https://github.com/webpack/script-loader).
452
461
 
453
462
  ```js
454
463
  //Load alasql in the global scope with script-loader
455
- import "script!alasql"
464
+ import 'script!alasql';
456
465
  ```
457
466
 
458
467
  This can cause issues if you have a CSP that doesn't allow `eval`.
@@ -508,15 +517,12 @@ alasql> SELECT VALUE {a:'1',b:(2*2)}->b
508
517
 
509
518
  ```
510
519
 
511
- Try AlaSQL JSON objects in Console [sample](http://alasql.org/console?drop table if exists one;create table one;insert into one values {a:@[1,2,3],c:{e:23}}, {a:@[{b:@[1,2,3]}]};select * from one)
512
-
520
+ Try AlaSQL JSON objects in Console [sample](http://alasql.org/console?drop table if exists one;create table one;insert into one values {a:@[1,2,3],c:{e:23}}, {a:@[{b:@[1,2,3]}]};select \* from one)
513
521
 
514
522
  ## Experimental
515
523
 
516
524
  _Useful stuff, but there might be dragons_
517
525
 
518
-
519
-
520
526
  ### Graphs
521
527
 
522
528
  AlaSQL is a multi-paradigm database with support for graphs that can be searched or manipulated.
@@ -524,7 +530,7 @@ AlaSQL is a multi-paradigm database with support for graphs that can be searched
524
530
  ```js
525
531
  // Who loves lovers of Alice?
526
532
  var res = alasql('SEARCH / ANY(>> >> #Alice) name');
527
- console.log(res) // ['Olga','Helen']
533
+ console.log(res); // ['Olga','Helen']
528
534
  ```
529
535
 
530
536
  See more [in the wiki](https://github.com/alasql/alasql/wiki/GRAPH)
@@ -537,10 +543,12 @@ You can use browser localStorage and [DOM-storage](https://github.com/node-brows
537
543
  alasql('CREATE localStorage DATABASE IF NOT EXISTS Atlas');
538
544
  alasql('ATTACH localStorage DATABASE Atlas AS MyAtlas');
539
545
  alasql('CREATE TABLE IF NOT EXISTS MyAtlas.City (city string, population number)');
540
- alasql('SELECT * INTO MyAtlas.City FROM ?',[ [
541
- {city:'Vienna', population:1731000},
542
- {city:'Budapest', population:1728000}
543
- ] ]);
546
+ alasql('SELECT * INTO MyAtlas.City FROM ?', [
547
+ [
548
+ {city: 'Vienna', population: 1731000},
549
+ {city: 'Budapest', population: 1728000},
550
+ ],
551
+ ]);
544
552
  var res = alasql('SELECT * FROM MyAtlas.City');
545
553
  ```
546
554
 
@@ -570,14 +578,11 @@ then open <http://127.0.0.1:1337/?SELECT%20VALUE%20(2*2)> in your browser
570
578
 
571
579
  Warning: Alaserver is not multi-threaded, not concurrent, and not secured.
572
580
 
573
-
574
-
575
-
576
581
  ## Tests
577
582
 
578
583
  ### Regression tests
579
584
 
580
- AlaSQL currently has over 1200 regression tests, but they only cover [![Coverage]( https://img.shields.io/codecov/c/github/alasql/alasql/develop.svg)](https://rawgit.com/alasql/alasql/develop/test/coverage/lcov-report/dist/alasql.fs.js.html)
585
+ AlaSQL currently has over 1200 regression tests, but they only cover [![Coverage](https://img.shields.io/codecov/c/github/alasql/alasql/develop.svg)](https://rawgit.com/alasql/alasql/develop/test/coverage/lcov-report/dist/alasql.fs.js.html)
581
586
  of the codebase.
582
587
 
583
588
  AlaSQL uses `mocha` for regression tests. Install `mocha` and run
@@ -604,16 +609,15 @@ AlaSQL uses `SQLLOGICTEST` to test its compatibility with SQL-99. The tests incl
604
609
 
605
610
  The testruns can be found in the [testlog](TESTLOG.md).
606
611
 
607
- ## Rebuilding the parser
612
+ ## Rebuilding the parser
608
613
 
609
614
  To rebuild the parser, follow these steps:
610
615
 
611
- * Make changes to alasqlparser.jison
612
- * `npm install -g jison`
613
- * `npm run jison`
614
- * `npm test` to validate the changes made
615
- * Commit changes to alasqlparser.jison and alasqlparser.js
616
-
616
+ - Make changes to alasqlparser.jison
617
+ - `npm install -g jison`
618
+ - `npm run jison`
619
+ - `npm test` to validate the changes made
620
+ - Commit changes to alasqlparser.jison and alasqlparser.js
617
621
 
618
622
  ## Contributing
619
623
 
@@ -627,8 +631,8 @@ Thanks to all the people who already contributed!
627
631
 
628
632
  **Main contributors**
629
633
 
630
- * [Andrey Gershun](https://github.com/alasql)
631
- * [Mathias Rangel Wulff](https://twitter.com/rangelwulff)
634
+ - [Andrey Gershun](https://github.com/alasql)
635
+ - [Mathias Rangel Wulff](https://twitter.com/rangelwulff)
632
636
 
633
637
  AlaSQL is an [OPEN Open Source Project](https://openopensource.github.io/). This means that:
634
638
 
@@ -636,13 +640,10 @@ AlaSQL is an [OPEN Open Source Project](https://openopensource.github.io/). This
636
640
 
637
641
  We appreciate any and all contributions we can get. If you feel like contributing, have a look at [CONTRIBUTING.md](https://github.com/alasql/alasql/blob/develop/CONTRIBUTING.md)
638
642
 
639
-
640
-
641
643
  ## Sponsors
642
644
 
643
645
  We extend our heartfelt thanks to each and every sponsor for generously supporting the AlaSQL open-source project by providing infrastructure at no cost. Their contributions enhance the development experience, and we highly recommend exploring their offerings.
644
646
 
645
-
646
647
  ### Faster GitHub Actions with Blacksmith
647
648
 
648
649
  [Blacksmith](https://www.blacksmith.sh/?source=alasql) significantly improves the speed of our GitHub Actions workflows by offering more powerful machines and enhanced caching mechanisms. Transitining was a one-line change and it has reduced our automated test times from 70-90 seconds to 15-17 seconds.
@@ -651,7 +652,7 @@ We extend our heartfelt thanks to each and every sponsor for generously supporti
651
652
  <img src="https://github.com/user-attachments/assets/a85a8a5f-65fd-48e1-aaad-b3f247248928" alt="Blacksmith Logo" width="300">
652
653
  </a>
653
654
 
654
- ----
655
+ ---
655
656
 
656
657
  ### Browser Testing on Physical Devices with BrowserStack
657
658
 
@@ -661,7 +662,7 @@ We extend our heartfelt thanks to each and every sponsor for generously supporti
661
662
  <img src="https://github.com/user-attachments/assets/9f74c25b-7dde-4a62-944e-8f23fc399ba9" alt="BrowserStack Logo" width="300">
662
663
  </a>
663
664
 
664
- ----
665
+ ---
665
666
 
666
667
  ### Development Practice Tracking with OpenSSF
667
668
 
@@ -673,36 +674,30 @@ The [Open Source Security Foundation (OpenSSF)](https://openssf.org) provides au
673
674
  </a>
674
675
  </div>
675
676
 
676
-
677
-
678
677
  ## License
679
678
 
680
679
  MIT - see [MIT licence information](LICENSE)
681
680
 
682
-
683
-
684
-
685
681
  ## Credits
686
682
 
687
683
  Many thanks to:
688
684
 
689
- * Zach Carter for [Jison parser-generator](https://github.com/zaach/jison)
690
- * Andrew Kent for [JS SQL Parser](https://github.com/forward/sql-parser)
691
- * Eli Grey for [FileSaver.js](https://github.com/eligrey/FileSaver.js)
692
- * [SheetJS](https://sheetjs.com) for [JS XLSX Library](https://github.com/SheetJS/js-xlsx)
685
+ - Zach Carter for [Jison parser-generator](https://github.com/zaach/jison)
686
+ - Andrew Kent for [JS SQL Parser](https://github.com/forward/sql-parser)
687
+ - Eli Grey for [FileSaver.js](https://github.com/eligrey/FileSaver.js)
688
+ - [SheetJS](https://sheetjs.com) for [JS XLSX Library](https://github.com/SheetJS/js-xlsx)
693
689
 
694
690
  and other people for useful tools, which make our work much easier.
695
691
 
696
692
  ### Related projects that have inspired us
697
693
 
698
- * [AlaX](http://github.com/alasql/alax) - Export to Excel with colors and formats
699
- * [AlaMDX](http://github.com/alasql/alamdx) - JavaScript MDX OLAP library (work in progress)
700
- * [Other similar projects](http://github.com/alasql/alasql/wiki/Similar-Projects.md) - list of databases on JavaScript
701
-
694
+ - [AlaX](http://github.com/alasql/alax) - Export to Excel with colors and formats
695
+ - [AlaMDX](http://github.com/alasql/alamdx) - JavaScript MDX OLAP library (work in progress)
696
+ - [Other similar projects](http://github.com/alasql/alasql/wiki/Similar-Projects.md) - list of databases on JavaScript
702
697
 
698
+ ---
703
699
 
704
- ----
705
700
  <a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/14003946/d6e5c076-f156-11e5-8238-e62d2a8d20dc.png" align="right" alt="AlaSQL logo"/></a>
706
701
  © 2014-2025, Andrey Gershun (agershun@gmail.com) & Mathias Rangel Wulff (m@rawu.dk)
707
702
 
708
- See [this article](https://console.substack.com/p/console-187) for a bit of information about the motivation and background.
703
+ See [this article](https://console.substack.com/p/console-187) for a bit of information about the motivation and background.