alasql 2.1.6 → 2.1.7

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/.editorconfig ADDED
@@ -0,0 +1,11 @@
1
+ ; EditorConfig file: https://EditorConfig.org
2
+ ; Install the "EditorConfig" plugin into your editor to use
3
+
4
+ root = true
5
+
6
+ [*]
7
+ charset = utf-8
8
+ end_of_line = lf
9
+ insert_final_newline = true
10
+ indent_style = tab
11
+ trim_trailing_whitespace = true
package/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ **/*.min.js
2
+ src/alasqlparser.js
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.1.5-develop-eec33e2f | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.1.6-develop-8399ae92 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.1.5-develop-eec33e2f
4
+ @version 2.1.6-develop-8399ae92
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -1,2 +1,2 @@
1
- //! AlaSQL v2.1.5-develop-eec33e2f | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.1.6-develop-8399ae92 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  !function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function i(r,e,o){"function"==typeof(e=e||[])&&(scope=o,o=e,e=[]),"object"!=typeof e&&(e=[e]);var t=i.lastid++;i.buffer[t]=o,i.webworker.postMessage({id:t,sql:r,params:e})}var a;if(i.options={},i.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},i.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise&&(a=function(r,e,n,s){return new Promise(function(o,t){i(r,e,function(r,e){e?t(e):(n&&s&&!1!==i.options.progress&&i.options.progress(n,s),o(r))})})},i.promise=function(r,e){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return a(r,e);if(!isArray(r)||r.length<1||void 0!==e)throw new Error("Error in .promise parameters");var o=r;if(!(o.length<1)){for(var t,n,s=[],i=0;i<o.length;i++){if("string"==typeof(n=o[i])&&(n=[n]),!isArray(n)||n.length<1||2<n.length)throw new Error("Error in .promise parameter");t=n[0],n=n[1]||void 0,s.push(a(t,n,i,o.length))}return Promise.all(s)}}),i=i||!1)return i.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(i.worker=function(r,e,o){if(void 0===(r=!0===r?void 0:r))for(var t=document.getElementsByTagName("script"),n=0;n<t.length;n++){if("alasql-worker.js"===t[n].src.substr(-16).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===t[n].src.substr(-20).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-20)+"alasql.min.js";break}if("alasql.js"===t[n].src.substr(-9).toLowerCase()){r=t[n].src;break}if("alasql.min.js"===t[n].src.substr(-13).toLowerCase()){r=t[n].src.substr(0,t[n].src.length-13)+"alasql.min.js";break}}if(void 0===r)throw new Error("Path to alasql.js is not specified");var s;!1!==r?(s=(s="importScripts('")+r+"');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}",s=new Blob([s],{type:"text/plain"}),i.webworker=new Worker(URL.createObjectURL(s)),i.webworker.onmessage=function(r){var e=r.data.id;i.buffer[e](r.data.data),delete i.buffer[e]},i.webworker.onerror=function(r){throw r},1<arguments.length&&i("REQUIRE "+e.map(function(r){return'"'+r+'"'}).join(","),[],o)):!1===r&&delete i.webworker}),i.lastid=0,i.buffer={},i.worker(),i;throw new Error("alasql was not found")});
package/dist/alasql.fs.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v2.1.5-develop-eec33e2f | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v2.1.6-develop-8399ae92 | © 2014-2022 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 2.1.5-develop-eec33e2f
4
+ @version 2.1.6-develop-8399ae92
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
142
142
  Current version of alasql
143
143
  @constant {string}
144
144
  */
145
- alasql.version = '2.1.5-develop-eec33e2f';
145
+ alasql.version = '2.1.6-develop-8399ae92';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -3484,13 +3484,19 @@ var loadFile = (utils.loadFile = function (path, asy, success, error) {
3484
3484
  });
3485
3485
  } else {
3486
3486
  if (/^[a-z]+:\/\//i.test(path)) {
3487
- var request = require('request');
3488
- request(path, function (err, response, body) {
3489
- if (err) {
3490
- return error(err, null);
3491
- }
3492
- success(cutbom(body.toString()));
3493
- });
3487
+ var fetch = require('node-fetch');
3488
+ fetch(path)
3489
+ .then((response) => response.arrayBuffer())
3490
+ .then((buf) => {
3491
+ var a = new Uint8Array(buf);
3492
+ var b = [...a].map((e) => String.fromCharCode(e)).join('');
3493
+ success(cutbom(b));
3494
+ })
3495
+ .catch((e) => {
3496
+ if (error) return error(e);
3497
+ console.error(e);
3498
+ throw e;
3499
+ });
3494
3500
  } else {
3495
3501
  //If async callthen call async
3496
3502
  if (asy) {
@@ -3620,17 +3626,19 @@ var loadBinaryFile = (utils.loadBinaryFile = function (
3620
3626
  fs = require('fs');
3621
3627
 
3622
3628
  if (/^[a-z]+:\/\//i.test(path)) {
3623
- var request = require('request');
3624
- request({url: path, encoding: null}, function (err, response, data) {
3625
- if (err) {
3626
- return error(err);
3627
- }
3628
- var arr = [];
3629
- for (var i = 0; i < data.length; ++i) {
3630
- arr[i] = String.fromCharCode(data[i]);
3631
- }
3632
- success(arr.join(''));
3633
- });
3629
+ var fetch = require('node-fetch');
3630
+ fetch(path)
3631
+ .then((response) => response.arrayBuffer())
3632
+ .then((buf) => {
3633
+ var a = new Uint8Array(buf);
3634
+ var b = [...a].map((e) => String.fromCharCode(e)).join('');
3635
+ success(b);
3636
+ })
3637
+ .catch((e) => {
3638
+ if (error) return error(e);
3639
+ console.error(e);
3640
+ throw e;
3641
+ });
3634
3642
  } else {
3635
3643
  if (runAsync) {
3636
3644
  fs.readFile(path, function (err, data) {
@@ -4848,422 +4856,7 @@ alasql.compile = function (sql, databaseid) {
4848
4856
  //
4849
4857
 
4850
4858
  if (!utils.global.Promise) {
4851
- if (utils.isNode) {
4852
- //*not-for-browser/*
4853
- utils.global.Promise = require('es6-promise').Promise;
4854
- //*/
4855
- } else {
4856
- /*!
4857
- * @overview es6-promise - a tiny implementation of Promises/A+.
4858
- * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
4859
- * @license Licensed under MIT license
4860
- * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
4861
- * @version 3.2.1
4862
- */
4863
- (function () {
4864
- 'use strict';
4865
- function t(t) {
4866
- return 'function' == typeof t || ('object' == typeof t && null !== t);
4867
- }
4868
- function e(t) {
4869
- return 'function' == typeof t;
4870
- }
4871
- function n(t) {
4872
- G = t;
4873
- }
4874
- function r(t) {
4875
- Q = t;
4876
- }
4877
- function o() {
4878
- return function () {
4879
- process.nextTick(a);
4880
- };
4881
- }
4882
- function i() {
4883
- return function () {
4884
- B(a);
4885
- };
4886
- }
4887
- function s() {
4888
- var t = 0,
4889
- e = new X(a),
4890
- n = document.createTextNode('');
4891
- return (
4892
- e.observe(n, {characterData: !0}),
4893
- function () {
4894
- n.data = t = ++t % 2;
4895
- }
4896
- );
4897
- }
4898
- function u() {
4899
- var t = new MessageChannel();
4900
- return (
4901
- (t.port1.onmessage = a),
4902
- function () {
4903
- t.port2.postMessage(0);
4904
- }
4905
- );
4906
- }
4907
- function c() {
4908
- return function () {
4909
- setTimeout(a, 1);
4910
- };
4911
- }
4912
- function a() {
4913
- for (var t = 0; J > t; t += 2) {
4914
- var e = tt[t],
4915
- n = tt[t + 1];
4916
- e(n), (tt[t] = void 0), (tt[t + 1] = void 0);
4917
- }
4918
- J = 0;
4919
- }
4920
- function f() {
4921
- try {
4922
- var t = require,
4923
- e = t('vertx');
4924
- return (B = e.runOnLoop || e.runOnContext), i();
4925
- } catch (n) {
4926
- return c();
4927
- }
4928
- }
4929
- function l(t, e) {
4930
- var n = this,
4931
- r = new this.constructor(p);
4932
- void 0 === r[rt] && k(r);
4933
- var o = n._state;
4934
- if (o) {
4935
- var i = arguments[o - 1];
4936
- Q(function () {
4937
- x(o, r, i, n._result);
4938
- });
4939
- } else E(n, r, t, e);
4940
- return r;
4941
- }
4942
- function h(t) {
4943
- var e = this;
4944
- if (t && 'object' == typeof t && t.constructor === e) return t;
4945
- var n = new e(p);
4946
- return g(n, t), n;
4947
- }
4948
- function p() {}
4949
- function _() {
4950
- return new TypeError('You cannot resolve a promise with itself');
4951
- }
4952
- function d() {
4953
- return new TypeError('A promises callback cannot return that same promise.');
4954
- }
4955
- function v(t) {
4956
- try {
4957
- return t.then;
4958
- } catch (e) {
4959
- return (ut.error = e), ut;
4960
- }
4961
- }
4962
- function y(t, e, n, r) {
4963
- try {
4964
- t.call(e, n, r);
4965
- } catch (o) {
4966
- return o;
4967
- }
4968
- }
4969
- function m(t, e, n) {
4970
- Q(function (t) {
4971
- var r = !1,
4972
- o = y(
4973
- n,
4974
- e,
4975
- function (n) {
4976
- r || ((r = !0), e !== n ? g(t, n) : S(t, n));
4977
- },
4978
- function (e) {
4979
- r || ((r = !0), j(t, e));
4980
- },
4981
- 'Settle: ' + (t._label || ' unknown promise')
4982
- );
4983
- !r && o && ((r = !0), j(t, o));
4984
- }, t);
4985
- }
4986
- function b(t, e) {
4987
- e._state === it
4988
- ? S(t, e._result)
4989
- : e._state === st
4990
- ? j(t, e._result)
4991
- : E(
4992
- e,
4993
- void 0,
4994
- function (e) {
4995
- g(t, e);
4996
- },
4997
- function (e) {
4998
- j(t, e);
4999
- }
5000
- );
5001
- }
5002
- function w(t, n, r) {
5003
- n.constructor === t.constructor && r === et && constructor.resolve === nt
5004
- ? b(t, n)
5005
- : r === ut
5006
- ? j(t, ut.error)
5007
- : void 0 === r
5008
- ? S(t, n)
5009
- : e(r)
5010
- ? m(t, n, r)
5011
- : S(t, n);
5012
- }
5013
- function g(e, n) {
5014
- e === n ? j(e, _()) : t(n) ? w(e, n, v(n)) : S(e, n);
5015
- }
5016
- function A(t) {
5017
- t._onerror && t._onerror(t._result), T(t);
5018
- }
5019
- function S(t, e) {
5020
- t._state === ot &&
5021
- ((t._result = e), (t._state = it), 0 !== t._subscribers.length && Q(T, t));
5022
- }
5023
- function j(t, e) {
5024
- t._state === ot && ((t._state = st), (t._result = e), Q(A, t));
5025
- }
5026
- function E(t, e, n, r) {
5027
- var o = t._subscribers,
5028
- i = o.length;
5029
- (t._onerror = null),
5030
- (o[i] = e),
5031
- (o[i + it] = n),
5032
- (o[i + st] = r),
5033
- 0 === i && t._state && Q(T, t);
5034
- }
5035
- function T(t) {
5036
- var e = t._subscribers,
5037
- n = t._state;
5038
- if (0 !== e.length) {
5039
- for (var r, o, i = t._result, s = 0; s < e.length; s += 3)
5040
- (r = e[s]), (o = e[s + n]), r ? x(n, r, o, i) : o(i);
5041
- t._subscribers.length = 0;
5042
- }
5043
- }
5044
- function M() {
5045
- this.error = null;
5046
- }
5047
- function P(t, e) {
5048
- try {
5049
- return t(e);
5050
- } catch (n) {
5051
- return (ct.error = n), ct;
5052
- }
5053
- }
5054
- function x(t, n, r, o) {
5055
- var i,
5056
- s,
5057
- u,
5058
- c,
5059
- a = e(r);
5060
- if (a) {
5061
- if (((i = P(r, o)), i === ct ? ((c = !0), (s = i.error), (i = null)) : (u = !0), n === i))
5062
- return void j(n, d());
5063
- } else (i = o), (u = !0);
5064
- n._state !== ot ||
5065
- (a && u ? g(n, i) : c ? j(n, s) : t === it ? S(n, i) : t === st && j(n, i));
5066
- }
5067
- function C(t, e) {
5068
- try {
5069
- e(
5070
- function (e) {
5071
- g(t, e);
5072
- },
5073
- function (e) {
5074
- j(t, e);
5075
- }
5076
- );
5077
- } catch (n) {
5078
- j(t, n);
5079
- }
5080
- }
5081
- function O() {
5082
- return at++;
5083
- }
5084
- function k(t) {
5085
- (t[rt] = at++), (t._state = void 0), (t._result = void 0), (t._subscribers = []);
5086
- }
5087
- function Y(t) {
5088
- return new _t(this, t).promise;
5089
- }
5090
- function q(t) {
5091
- var e = this;
5092
- return new e(
5093
- I(t)
5094
- ? function (n, r) {
5095
- for (var o = t.length, i = 0; o > i; i++) e.resolve(t[i]).then(n, r);
5096
- }
5097
- : function (t, e) {
5098
- e(new TypeError('You must pass an array to race.'));
5099
- }
5100
- );
5101
- }
5102
- function F(t) {
5103
- var e = this,
5104
- n = new e(p);
5105
- return j(n, t), n;
5106
- }
5107
- function D() {
5108
- throw new TypeError(
5109
- 'You must pass a resolver function as the first argument to the promise constructor'
5110
- );
5111
- }
5112
- function K() {
5113
- throw new TypeError(
5114
- "Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."
5115
- );
5116
- }
5117
- function L(t) {
5118
- (this[rt] = O()),
5119
- (this._result = this._state = void 0),
5120
- (this._subscribers = []),
5121
- p !== t && ('function' != typeof t && D(), this instanceof L ? C(this, t) : K());
5122
- }
5123
- function N(t, e) {
5124
- (this._instanceConstructor = t),
5125
- (this.promise = new t(p)),
5126
- this.promise[rt] || k(this.promise),
5127
- Array.isArray(e)
5128
- ? ((this._input = e),
5129
- (this.length = e.length),
5130
- (this._remaining = e.length),
5131
- (this._result = new Array(this.length)),
5132
- 0 === this.length
5133
- ? S(this.promise, this._result)
5134
- : ((this.length = this.length || 0),
5135
- this._enumerate(),
5136
- 0 === this._remaining && S(this.promise, this._result)))
5137
- : j(this.promise, U());
5138
- }
5139
- function U() {
5140
- return new Error('Array Methods must be provided an Array');
5141
- }
5142
- function W() {
5143
- var t;
5144
- if ('undefined' != typeof global) t = global;
5145
- else if ('undefined' != typeof self) t = self;
5146
- else
5147
- try {
5148
- t = Function('return this')();
5149
- } catch (e) {
5150
- throw new Error(
5151
- 'polyfill failed because global object is unavailable in this environment'
5152
- );
5153
- }
5154
- var n = t.Promise;
5155
- (!n || '[object Promise]' !== Object.prototype.toString.call(n.resolve()) || n.cast) &&
5156
- (t.Promise = pt);
5157
- }
5158
- var z;
5159
- z = Array.isArray
5160
- ? Array.isArray
5161
- : function (t) {
5162
- return '[object Array]' === Object.prototype.toString.call(t);
5163
- };
5164
- var B,
5165
- G,
5166
- H,
5167
- I = z,
5168
- J = 0,
5169
- Q = function (t, e) {
5170
- (tt[J] = t), (tt[J + 1] = e), (J += 2), 2 === J && (G ? G(a) : H());
5171
- },
5172
- R = 'undefined' != typeof window ? window : void 0,
5173
- V = R || {},
5174
- X = V.MutationObserver || V.WebKitMutationObserver,
5175
- Z =
5176
- 'undefined' == typeof self &&
5177
- 'undefined' != typeof process &&
5178
- '[object process]' === {}.toString.call(process),
5179
- $ =
5180
- 'undefined' != typeof Uint8ClampedArray &&
5181
- 'undefined' != typeof importScripts &&
5182
- 'undefined' != typeof MessageChannel,
5183
- tt = new Array(1e3);
5184
- H = Z ? o() : X ? s() : $ ? u() : void 0 === R && 'function' == typeof require ? f() : c();
5185
- var et = l,
5186
- nt = h,
5187
- rt = Math.random().toString(36).substring(16),
5188
- ot = void 0,
5189
- it = 1,
5190
- st = 2,
5191
- ut = new M(),
5192
- ct = new M(),
5193
- at = 0,
5194
- ft = Y,
5195
- lt = q,
5196
- ht = F,
5197
- pt = L;
5198
- (L.all = ft),
5199
- (L.race = lt),
5200
- (L.resolve = nt),
5201
- (L.reject = ht),
5202
- (L._setScheduler = n),
5203
- (L._setAsap = r),
5204
- (L._asap = Q),
5205
- (L.prototype = {
5206
- constructor: L,
5207
- then: et,
5208
- catch: function (t) {
5209
- return this.then(null, t);
5210
- },
5211
- });
5212
- var _t = N;
5213
- (N.prototype._enumerate = function () {
5214
- for (var t = this.length, e = this._input, n = 0; this._state === ot && t > n; n++)
5215
- this._eachEntry(e[n], n);
5216
- }),
5217
- (N.prototype._eachEntry = function (t, e) {
5218
- var n = this._instanceConstructor,
5219
- r = n.resolve;
5220
- if (r === nt) {
5221
- var o = v(t);
5222
- if (o === et && t._state !== ot) this._settledAt(t._state, e, t._result);
5223
- else if ('function' != typeof o) this._remaining--, (this._result[e] = t);
5224
- else if (n === pt) {
5225
- var i = new n(p);
5226
- w(i, t, o), this._willSettleAt(i, e);
5227
- } else
5228
- this._willSettleAt(
5229
- new n(function (e) {
5230
- e(t);
5231
- }),
5232
- e
5233
- );
5234
- } else this._willSettleAt(r(t), e);
5235
- }),
5236
- (N.prototype._settledAt = function (t, e, n) {
5237
- var r = this.promise;
5238
- r._state === ot && (this._remaining--, t === st ? j(r, n) : (this._result[e] = n)),
5239
- 0 === this._remaining && S(r, this._result);
5240
- }),
5241
- (N.prototype._willSettleAt = function (t, e) {
5242
- var n = this;
5243
- E(
5244
- t,
5245
- void 0,
5246
- function (t) {
5247
- n._settledAt(it, e, t);
5248
- },
5249
- function (t) {
5250
- n._settledAt(st, e, t);
5251
- }
5252
- );
5253
- });
5254
- var dt = W,
5255
- vt = {Promise: pt, polyfill: dt};
5256
- 'function' == typeof define && define.amd
5257
- ? define(function () {
5258
- return vt;
5259
- })
5260
- : 'undefined' != typeof module && module.exports
5261
- ? (module.exports = vt)
5262
- : 'undefined' != typeof this && (this.ES6Promise = vt),
5263
- dt();
5264
- }.call(this));
5265
-
5266
- }
4859
+ utils.global.Promise = Promise;
5267
4860
  }
5268
4861
 
5269
4862
  var promiseExec = function (sql, params, counterStep, counterTotal) {
@@ -15714,10 +15307,6 @@ yy.SetVariable.prototype.execute = function (databaseid, params, cb) {
15714
15307
  return res;
15715
15308
  };
15716
15309
 
15717
- // Console functions
15718
-
15719
- /* global alasql, yy */
15720
-
15721
15310
  alasql.test = function (name, times, fn) {
15722
15311
  if (arguments.length === 0) {
15723
15312
  alasql.log(alasql.con.results);
@@ -19743,7 +19332,7 @@ if (typeof module !== 'undefined' && module.exports) {
19743
19332
 
19744
19333
  /*only-for-browser/*
19745
19334
  if(utils.isCordova || utils.isMeteorServer || utils.isNode ){
19746
- console.warn('It looks like you are using the browser version of AlaSQL. Please use the alasql.fs.js file instead.')
19335
+ console.log('It looks like you are using the browser version of AlaSQL. Please use the alasql.fs.js file instead.')
19747
19336
  }
19748
19337
  //*/
19749
19338