alasql 4.1.8 → 4.1.10

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/build.sh ADDED
@@ -0,0 +1,207 @@
1
+ rm -fr dist/
2
+ mkdir dist/
3
+
4
+ if ! command -v "rexreplace" > /dev/null 2>&1; then
5
+ echo "\nSpeed up the process by having rexreplace installed globally"
6
+ echo "> npm install -g rexreplace"
7
+ fi
8
+
9
+ if ! command -v "esbuild" > /dev/null 2>&1; then
10
+ echo "\nSpeed up the process by having esbuild installed globally"
11
+ echo "> npm install -g esbuild"
12
+ fi
13
+
14
+
15
+ # Run comands via x to avoid npx overhead if the command is installed globally (3.27x slower)
16
+ x() {
17
+ local cmd="$1"
18
+ shift
19
+ if command -v "$cmd" > /dev/null 2>&1; then
20
+ "$cmd" "$@" # Run the command with all remaining arguments
21
+ else
22
+ npx "$cmd" "$@" # Use npx to run the command with all remaining arguments
23
+ fi
24
+ }
25
+
26
+ branch=$(git rev-parse --abbrev-ref HEAD | rexreplace '[^0-9a-z-]' '.' | rexreplace '^[^0-9a-z]+|[^0-9a-z]+$' '')
27
+ commit=$(git rev-parse --short HEAD)
28
+
29
+
30
+
31
+ echo '\nPrepare types'
32
+ cp 'types/alasql.d.ts' dist/
33
+
34
+
35
+ echo '\nPrepare echo plugin'
36
+ cp 'src/echo/alasql-echo.js' dist/
37
+
38
+
39
+
40
+ echo '\nPrepare prolog'
41
+ cp 'src/prolog/alasql-prolog.js' dist/
42
+
43
+
44
+
45
+
46
+
47
+
48
+ echo '\nBuild alasql.js files'
49
+ outfile_fs="dist/alasql.fs.js"
50
+ outfile="dist/alasql.js"
51
+ outfile_min="dist/alasql.min.js"
52
+
53
+ echo '# Concat all parts'
54
+ cat \
55
+ src/05copyright.js \
56
+ src/10start.js \
57
+ src/alasqlparser.js \
58
+ src/12pretty.js \
59
+ src/15utility.js \
60
+ src/16comments.js \
61
+ src/17alasql.js \
62
+ src/18promise.js \
63
+ src/20database.js \
64
+ src/21transaction.js \
65
+ src/23table.js \
66
+ src/24view.js \
67
+ src/25queryclass.js \
68
+ src/28yy.js \
69
+ src/30statements.js \
70
+ src/35search.js \
71
+ src/38query.js \
72
+ src/39dojoin.js \
73
+ src/40select.js \
74
+ src/41exists.js \
75
+ src/420from.js \
76
+ src/421join.js \
77
+ src/422where.js \
78
+ src/423groupby.js \
79
+ src/424select.js \
80
+ src/425having.js \
81
+ src/426orderby.js \
82
+ src/427pivot.js \
83
+ src/43rollup.js \
84
+ src/44defcols.js \
85
+ src/45union.js \
86
+ src/46apply.js \
87
+ src/47over.js \
88
+ src/50expression.js \
89
+ src/52linq.js \
90
+ src/55functions.js \
91
+ src/57case.js \
92
+ src/58json.js \
93
+ src/59convert.js \
94
+ src/60createtable.js \
95
+ src/61date.js \
96
+ src/62droptable.js \
97
+ src/63createvertex.js \
98
+ src/64altertable.js \
99
+ src/65createindex.js \
100
+ src/66dropindex.js \
101
+ src/67withselect.js \
102
+ src/68if.js \
103
+ src/69while.js \
104
+ src/70insert.js \
105
+ src/71trigger.js \
106
+ src/72delete.js \
107
+ src/74update.js \
108
+ src/75merge.js \
109
+ src/76usedatabase.js \
110
+ src/77declare.js \
111
+ src/78show.js \
112
+ src/79set.js \
113
+ src/80console.js \
114
+ src/81commit.js \
115
+ src/821tsql.js \
116
+ src/822mysql.js \
117
+ src/823postgres.js \
118
+ src/824oracle.js \
119
+ src/825sqlite.js \
120
+ src/830into.js \
121
+ src/831xls.js \
122
+ src/832xlsxml.js \
123
+ src/833xlsx.js \
124
+ src/84from.js \
125
+ src/843xml.js \
126
+ src/844gexf.js \
127
+ src/86print.js \
128
+ src/87source.js \
129
+ src/88require.js \
130
+ src/89assert.js \
131
+ src/91indexeddb.js \
132
+ src/92localstorage.js \
133
+ src/93sqljs.js \
134
+ src/94filestorage.js \
135
+ src/97saveas.js \
136
+ src/99worker.js \
137
+ src/FileSaver.js \
138
+ src/98finish.js \
139
+ > $outfile_fs
140
+
141
+ echo '# Remove multiline comments starting with "/*/*"'
142
+ x rexreplace '/\*/\*[\S\s]+?\*/' '' -q $outfile_fs
143
+
144
+ echo '# Remove single line comments where the // part is first thing'
145
+ x rexreplace '^//[ \t]{2,}.*' '' -q $outfile_fs
146
+
147
+ echo '# Remove single line comments "console.log(" is part of the line'
148
+ x rexreplace '//.*?console\.log\(.*' '' -q $outfile_fs
149
+
150
+ echo '# Collaps multilinebreak'
151
+ x rexreplace '\n[\s]+\n' '\n\n' -q $outfile_fs
152
+
153
+ echo '# Inject package version'
154
+ x rexreplace 'PACKAGE_VERSION' 'r("package").version' -j -q $outfile_fs
155
+
156
+ echo '# Inject build version'
157
+ x rexreplace 'BUILD_VERSION' "['$branch','$commit'].filter(Boolean).join('-')" -j -q $outfile_fs
158
+
159
+ echo '# Prepare browser version'
160
+ cp $outfile_fs $outfile
161
+
162
+ echo '# Remove things not for browser build'
163
+ x rexreplace '//*not-for-browser/*' '/*not-for-browser/*' -L -q $outfile
164
+
165
+ echo '# Reveal things only for browser build'
166
+ x rexreplace '/*only-for-browser/*' '//*only-for-browser/*' -L -q $outfile
167
+
168
+ echo '# Support "use strict in jison output" ' # https://github.com/zaach/jison/pull/373
169
+ x rexreplace 'function locateNearestErrorRecoveryRule(state) {' 'var locateNearestErrorRecoveryRule = function (state) {' -L -q $outfile
170
+
171
+ x esbuild --minify --outfile="$outfile_min" "$outfile" --allow-overwrite
172
+
173
+ #first_line=$(head -n 1 $outfile)
174
+ #x rexreplace '^' "c = 'first_line'; c.match(/^\/\//) ? c : ''" -j -M $outfile_min
175
+
176
+
177
+
178
+
179
+
180
+
181
+ echo '\nBuild worker files'
182
+ outfile="dist/alasql-worker.js"
183
+ outfile_min="dist/alasql-worker.js"
184
+
185
+ echo '# Concat all parts'
186
+ cat \
187
+ src/05copyright.js \
188
+ src/99worker-start.js \
189
+ src/99worker.js \
190
+ src/99worker-finish.js \
191
+ > $outfile
192
+
193
+ echo '# Inject package version'
194
+ x rexreplace 'PACKAGE_VERSION' 'r("package").version' -j -q $outfile
195
+
196
+ echo '# Inject build version'
197
+ x rexreplace 'BUILD_VERSION' "['$branch','$commit'].filter(Boolean).join('-')" -j -q $outfile
198
+
199
+ echo '# Prepare min version'
200
+ x esbuild --minify --outfile="$outfile_min" "$outfile" --allow-overwrite
201
+
202
+ #first_line=$(head -n 1 $outfile)
203
+ #x rexreplace '^' "c = 'first_line'; c.match(/^\/\//) ? c : ''" -j -M $outfile_min
204
+
205
+
206
+
207
+
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.1.7 build: develop-fcae8eb7 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.1.9 build: develop-a3395d54 | © 2014-2023 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.1.7
4
+ @version 4.1.9
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2023 Andrey Gershun & Mathias Wulff
@@ -28,218 +28,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
28
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
29
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
30
  SOFTWARE.
31
- */
32
-
33
- /*
34
- //
35
- // AlaSQL Workker
36
- // Date: 13.04.2014
37
- // (c) 2014-2015, Andrey Gershun
38
- //
39
- */
40
- (function (root, factory) {
41
- if (typeof define === 'function' && define.amd) {
42
- define([], factory);
43
- } else if (typeof exports === 'object') {
44
- module.exports = factory();
45
- } else {
46
- root.alasql = factory();
47
- }
48
- }(this, function () {
49
-
50
- /**
51
- Main procedure for worker
52
- @function
53
- @param {string} sql SQL statement
54
- @param {object} params List of parameters (can be omitted)
55
- @param {callback} cb Callback function
56
- @return {object} Query result
57
- */
58
- function alasql(sql,params,cb){
59
-
60
- params = params||[];
61
-
62
- // Avoid setting params if not needed even with callback
63
- if(typeof params === 'function'){
64
- scope = cb;
65
- cb = params;
66
- params = [];
67
- }
68
-
69
- if(typeof params !== 'object'){
70
- params = [params];
71
- }
72
-
73
- // Increase last request id
74
- var id = alasql.lastid++;
75
- // Save callback
76
- alasql.buffer[id] = cb;
77
- // Send a message to worker
78
- alasql.webworker.postMessage({id:id,sql:sql,params:params});
79
- }
80
-
81
-
82
- alasql.options = {};
83
- alasql.options.progress = function(){};
84
-
85
- isArray = function(obj){
86
- return "[object Array]"===Object.prototype.toString.call(obj);
87
- }
88
-
89
- alasql.promise = function() {
90
- throw new Error('Please include a Promise/A+ library');
91
- }
92
-
93
- // From src/18promise.js
94
- if(typeof Promise !== "undefined"){
95
- var promiseExec = function(sql, params, counterStep, counterTotal){
96
- return new Promise(function(resolve, reject){
97
- alasql(sql, params, function(data,err) {
98
- if(err) {
99
- reject(err);
100
- } else {
101
- if (counterStep && counterTotal && alasql.options.progress !== false) {
102
- alasql.options.progress(counterStep, counterTotal);
103
- }
104
- resolve(data);
105
- }
106
- });
107
- });
108
- }
109
-
110
- var promiseAll = function(sqlParamsArray){
111
- if(sqlParamsArray.length<1){
112
- return ;
113
- }
114
-
115
- var active, sql, params;
116
-
117
- var execArray = [];
118
-
119
- for (var i = 0; i < sqlParamsArray.length; i++) {
120
- active = sqlParamsArray[i];
121
-
122
- if(typeof active === 'string'){
123
- active = [active];
124
- }
125
-
126
- if(!isArray(active) || active.length<1 || 2<active.length){
127
- throw new Error('Error in .promise parameter');
128
- }
129
-
130
- sql = active[0];
131
- params = active[1]||undefined;
132
-
133
- execArray.push(promiseExec(sql, params, i, sqlParamsArray.length));
134
- }
135
-
136
- return Promise.all(execArray);
137
- }
138
-
139
- alasql.promise = function(sql, params) {
140
- if(typeof Promise === "undefined"){
141
- throw new Error('Please include a Promise/A+ library');
142
- }
143
-
144
- if(typeof sql === 'string'){
145
- return promiseExec(sql, params);
146
- }
147
-
148
- if(!isArray(sql) || sql.length<1 || typeof params !== "undefined"){
149
- throw new Error('Error in .promise parameters');
150
- }
151
- return promiseAll(sql);
152
- };
153
-
154
- }
155
-
156
-
157
- alasql = alasql || false;
158
-
159
- if (!alasql) {
160
- throw new Error('alasql was not found');
161
- }
162
-
163
- alasql.worker = function () {
164
- throw new Error('Can find webworker in this enviroment');
165
- };
166
-
167
- if (typeof Worker !== 'undefined') {
168
- alasql.worker = function (path, paths, cb) {
169
- // var path;
170
- if (path === true) {
171
- path = undefined;
172
- }
173
-
174
- if (typeof path === 'undefined') {
175
- var sc = document.getElementsByTagName('script');
176
- for (var i = 0; i < sc.length; i++) {
177
- if (sc[i].src.substr(-16).toLowerCase() === 'alasql-worker.js') {
178
- path = sc[i].src.substr(0, sc[i].src.length - 16) + 'alasql.js';
179
- break;
180
- } else if (sc[i].src.substr(-20).toLowerCase() === 'alasql-worker.min.js') {
181
- path = sc[i].src.substr(0, sc[i].src.length - 20) + 'alasql.min.js';
182
- break;
183
- } else if (sc[i].src.substr(-9).toLowerCase() === 'alasql.js') {
184
- path = sc[i].src;
185
- break;
186
- } else if (sc[i].src.substr(-13).toLowerCase() === 'alasql.min.js') {
187
- path = sc[i].src.substr(0, sc[i].src.length - 13) + 'alasql.min.js';
188
- break;
189
- }
190
- }
191
- }
192
-
193
- if (typeof path === 'undefined') {
194
- throw new Error('Path to alasql.js is not specified');
195
- } else if (path !== false) {
196
- var js = "importScripts('";
197
- js += path;
198
- js +=
199
- "');self.onmessage = function(event) {" +
200
- 'alasql(event.data.sql,event.data.params, function(data){' +
201
- 'postMessage({id:event.data.id, data:data});});}';
202
-
203
- var blob = new Blob([js], {type: 'text/plain'});
204
- alasql.webworker = new Worker(URL.createObjectURL(blob));
205
-
206
- alasql.webworker.onmessage = function (event) {
207
- var id = event.data.id;
208
-
209
- alasql.buffer[id](event.data.data);
210
- delete alasql.buffer[id];
211
- };
212
-
213
- alasql.webworker.onerror = function (e) {
214
- throw e;
215
- };
216
-
217
- if (arguments.length > 1) {
218
- var sql =
219
- 'REQUIRE ' +
220
- paths
221
- .map(function (p) {
222
- return '"' + p + '"';
223
- })
224
- .join(',');
225
- alasql(sql, [], cb);
226
- }
227
- } else if (path === false) {
228
- delete alasql.webworker;
229
- return;
230
- }
231
- };
232
- }
233
-
234
-
235
- /* WebWorker */
236
- /** @type {number} */
237
- alasql.lastid = 0;
238
-
239
- /** @type {object} */
240
- alasql.buffer = {};
241
-
242
- alasql.worker();
243
-
244
- return alasql;
245
- }));
31
+ */(function(e,f){typeof define=="function"&&define.amd?define([],f):typeof exports=="object"?module.exports=f():e.alasql=f()})(this,function(){function e(r,n,i){n=n||[],typeof n=="function"&&(scope=i,i=n,n=[]),typeof n!="object"&&(n=[n]);var o=e.lastid++;e.buffer[o]=i,e.webworker.postMessage({id:o,sql:r,params:n})}if(e.options={},e.options.progress=function(){},isArray=function(r){return Object.prototype.toString.call(r)==="[object Array]"},e.promise=function(){throw new Error("Please include a Promise/A+ library")},typeof Promise<"u"){var f=function(r,n,i,o){return new Promise(function(t,s){e(r,n,function(u,l){l?s(l):(i&&o&&e.options.progress!==!1&&e.options.progress(i,o),t(u))})})},w=function(r){if(!(r.length<1)){for(var n,i,o,t=[],s=0;s<r.length;s++){if(n=r[s],typeof n=="string"&&(n=[n]),!isArray(n)||n.length<1||2<n.length)throw new Error("Error in .promise parameter");i=n[0],o=n[1]||void 0,t.push(f(i,o,s,r.length))}return Promise.all(t)}};e.promise=function(r,n){if(typeof Promise>"u")throw new Error("Please include a Promise/A+ library");if(typeof r=="string")return f(r,n);if(!isArray(r)||r.length<1||typeof n<"u")throw new Error("Error in .promise parameters");return w(r)}}if(e=e||!1,!e)throw new Error("alasql was not found");return e.worker=function(){throw new Error("Can find webworker in this enviroment")},typeof Worker<"u"&&(e.worker=function(r,n,i){if(r===!0&&(r=void 0),typeof r>"u"){for(var o=document.getElementsByTagName("script"),t=0;t<o.length;t++)if(o[t].src.substr(-16).toLowerCase()==="alasql-worker.js"){r=o[t].src.substr(0,o[t].src.length-16)+"alasql.js";break}else if(o[t].src.substr(-20).toLowerCase()==="alasql-worker.min.js"){r=o[t].src.substr(0,o[t].src.length-20)+"alasql.min.js";break}else if(o[t].src.substr(-9).toLowerCase()==="alasql.js"){r=o[t].src;break}else if(o[t].src.substr(-13).toLowerCase()==="alasql.min.js"){r=o[t].src.substr(0,o[t].src.length-13)+"alasql.min.js";break}}if(typeof r>"u")throw new Error("Path to alasql.js is not specified");if(r!==!1){var s="importScripts('";s+=r,s+="');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}";var u=new Blob([s],{type:"text/plain"});if(e.webworker=new Worker(URL.createObjectURL(u)),e.webworker.onmessage=function(a){var d=a.data.id;e.buffer[d](a.data.data),delete e.buffer[d]},e.webworker.onerror=function(a){throw a},arguments.length>1){var l="REQUIRE "+n.map(function(a){return'"'+a+'"'}).join(",");e(l,[],i)}}else if(r===!1){delete e.webworker;return}}),e.lastid=0,e.buffer={},e.worker(),e});