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