alasql 4.6.6 → 4.8.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 +3 -3
- package/dist/alasql-worker.js +2 -2
- package/dist/alasql.fs.js +82 -50
- package/dist/alasql.js +82 -50
- package/dist/alasql.min.js +146 -139
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
- _AlaSQL is an unfunded open source project installed
|
|
1
|
+
- _AlaSQL is an unfunded open source project installed 650k+ times each month. [Please donate your time](https://github.com/AlaSQL/alasql/issues?q=is%3Aopen+label%3A%22Help+wanted%22+sort%3Aupdated-desc). We appreciate any and all contributions we can get._
|
|
2
2
|
|
|
3
|
-
- _Have a question? [Ask
|
|
3
|
+
- _Have a question? [Ask The AlaSQL Bot](https://chatgpt.com/g/g-XcBL24WTe-alasql-bot) or post on [Stack Overflow](http://stackoverflow.com/questions/ask?tags=AlaSQL)._
|
|
4
4
|
|
|
5
5
|
[](https://github.com/alasql/alasql/actions)
|
|
6
6
|
[](https://npm-stat.com/charts.html?package=alasql)
|
|
@@ -626,7 +626,7 @@ Thanks to all the people who already contributed!
|
|
|
626
626
|
* [Andrey Gershun](https://github.com/alasql)
|
|
627
627
|
* [Mathias Rangel Wulff](https://twitter.com/rangelwulff)
|
|
628
628
|
|
|
629
|
-
AlaSQL is an [OPEN Open Source Project](
|
|
629
|
+
AlaSQL is an [OPEN Open Source Project](https://openopensource.github.io/). This means that:
|
|
630
630
|
|
|
631
631
|
> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
|
|
632
632
|
|
package/dist/alasql-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v4.
|
|
1
|
+
//! AlaSQL v4.7.0 build: develop-916ff64e | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 4.
|
|
4
|
+
@version 4.7.0
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2024 Andrey Gershun & Mathias Wulff
|
package/dist/alasql.fs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v4.
|
|
1
|
+
//! AlaSQL v4.7.0 build: develop-916ff64e | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 4.
|
|
4
|
+
@version 4.7.0
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2024 Andrey Gershun & Mathias Wulff
|
|
@@ -141,8 +141,8 @@ SOFTWARE.
|
|
|
141
141
|
Current version of alasql
|
|
142
142
|
@constant {string}
|
|
143
143
|
*/
|
|
144
|
-
alasql.version = '4.
|
|
145
|
-
alasql.build = 'develop-
|
|
144
|
+
alasql.version = '4.7.0';
|
|
145
|
+
alasql.build = 'develop-916ff64e';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -244,7 +244,7 @@ case 1:
|
|
|
244
244
|
|
|
245
245
|
break;
|
|
246
246
|
case 2:
|
|
247
|
-
this.$ = doubleq($$[$0].substr(1,$$[$0].length-2));
|
|
247
|
+
this.$ = doubleq($$[$0].substr(1,$$[$0].length-2));
|
|
248
248
|
break;
|
|
249
249
|
case 3:
|
|
250
250
|
this.$ = $$[$0].toLowerCase()
|
|
@@ -3619,6 +3619,19 @@ async function fetchData(path, success, error, async) {
|
|
|
3619
3619
|
}
|
|
3620
3620
|
|
|
3621
3621
|
function getData(path, success, error) {
|
|
3622
|
+
return _fetch(path)
|
|
3623
|
+
.then(response => response.text())
|
|
3624
|
+
.then(txt => {
|
|
3625
|
+
success(txt);
|
|
3626
|
+
})
|
|
3627
|
+
.catch(e => {
|
|
3628
|
+
if (error) return error(e);
|
|
3629
|
+
console.error(e);
|
|
3630
|
+
throw e;
|
|
3631
|
+
});
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
function getBinaryData(path, success, error) {
|
|
3622
3635
|
return _fetch(path)
|
|
3623
3636
|
.then(response => response.arrayBuffer())
|
|
3624
3637
|
.then(buf => {
|
|
@@ -3658,7 +3671,7 @@ var loadBinaryFile = (utils.loadBinaryFile = function (
|
|
|
3658
3671
|
fs = require('fs');
|
|
3659
3672
|
|
|
3660
3673
|
if (/^[a-z]+:\/\//i.test(path)) {
|
|
3661
|
-
|
|
3674
|
+
return getBinaryData(path, success, error);
|
|
3662
3675
|
} else {
|
|
3663
3676
|
if (runAsync) {
|
|
3664
3677
|
fs.readFile(path, function (err, data) {
|
|
@@ -8430,9 +8443,9 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8430
8443
|
if (col.aggregatorid === 'SUM') {
|
|
8431
8444
|
if ('funcid' in col.expression) {
|
|
8432
8445
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
8433
|
-
return `'${colas}':(${
|
|
8446
|
+
return `'${colas}':(__alasql_tmp = ${colexp}, (__alasql_tmp instanceof Date) ? undefined : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : undefined)),`;
|
|
8434
8447
|
}
|
|
8435
|
-
return `'${colas}':(${colexp})|| typeof
|
|
8448
|
+
return `'${colas}':(__alasql_tmp = ${colexp}, (__alasql_tmp instanceof Date) ? undefined : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : undefined)),`;
|
|
8436
8449
|
} else if (col.aggregatorid === 'TOTAL') {
|
|
8437
8450
|
if ('funcid' in col.expression) {
|
|
8438
8451
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
@@ -8449,19 +8462,16 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8449
8462
|
if ('funcid' in col.expression) {
|
|
8450
8463
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
8451
8464
|
|
|
8452
|
-
return `'${colas}': (
|
|
8453
|
-
typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp} : null : null),`;
|
|
8465
|
+
return `'${colas}': (__alasql_tmp = ${colexp}, typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined),`;
|
|
8454
8466
|
}
|
|
8455
|
-
return `'${colas}': (
|
|
8456
|
-
typeof Number(${colexp}) == 'number' && ${colexp}!== null? ${colexp} : null : null),`;
|
|
8467
|
+
return `'${colas}': (__alasql_tmp = ${colexp}, typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined),`;
|
|
8457
8468
|
} else if (col.aggregatorid === 'MAX') {
|
|
8458
8469
|
if ('funcid' in col.expression) {
|
|
8459
8470
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
8460
|
-
return `'${colas}'
|
|
8461
|
-
typeof Number(${colexp1}) == 'number' ? ${colexp} : null : null),`;
|
|
8471
|
+
return `'${colas}': (__alasql_tmp = ${colexp}, typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined),`;
|
|
8462
8472
|
}
|
|
8463
8473
|
return `'${colas}' : (typeof ${colexp} == 'number' || typeof ${colexp} == 'bigint' ? ${colexp} : typeof ${colexp} == 'object' ?
|
|
8464
|
-
typeof Number(${colexp}) == 'number' ? ${colexp} :
|
|
8474
|
+
typeof Number(${colexp}) == 'number' ? ${colexp} : undefined : undefined),`;
|
|
8465
8475
|
} else if (col.aggregatorid === 'ARRAY') {
|
|
8466
8476
|
return `'${colas}':[${colexp}],`;
|
|
8467
8477
|
} else if (col.aggregatorid === 'COUNT') {
|
|
@@ -8474,7 +8484,7 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8474
8484
|
query.removeKeys.push(`_SUM_${colas}`);
|
|
8475
8485
|
query.removeKeys.push(`_COUNT_${colas}`);
|
|
8476
8486
|
|
|
8477
|
-
return `'${colas}'
|
|
8487
|
+
return `'${colas}':(function() { var t = ${colexp}; return (t instanceof Date) ? undefined : t; })(),'_SUM_${colas}':(function() { var t = ${colexp}; return (t instanceof Date) ? undefined : (t || 0); })(),'_COUNT_${colas}':(typeof ${colexp} == "undefined" || ${colexp} === null) ? 0 : 1,`;
|
|
8478
8488
|
} else if (col.aggregatorid === 'AGGR') {
|
|
8479
8489
|
aft += `,g['${colas}']=${col.expression.toJS('g', -1)}`;
|
|
8480
8490
|
return '';
|
|
@@ -8518,17 +8528,20 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8518
8528
|
const __colexp1 = ${colexp1};
|
|
8519
8529
|
|
|
8520
8530
|
if (__g_colas == null && ${colexp1} == null) {
|
|
8521
|
-
g['${colas}'] =
|
|
8531
|
+
g['${colas}'] = undefined;
|
|
8522
8532
|
} else if (typeof __g_colas === 'bigint' || typeof __colexp1 === 'bigint') {
|
|
8523
8533
|
g['${colas}'] = BigInt(__g_colas) + BigInt(__colexp);
|
|
8524
8534
|
} else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 !== 'object' && __typeof_colexp1 !== 'number') ||
|
|
8525
|
-
|
|
8526
|
-
g['${colas}'] =
|
|
8535
|
+
(__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp1} == null || (__typeof_colexp1 !== 'number' && __typeof_colexp1 !== 'object'))) {
|
|
8536
|
+
g['${colas}'] = undefined;
|
|
8527
8537
|
} else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 == 'number') ||
|
|
8528
8538
|
(__g_colas == null && __typeof_colexp1 == 'number')) {
|
|
8529
8539
|
g['${colas}'] = ${colexp};
|
|
8530
8540
|
} else if (typeof __g_colas == 'number' && ${colexp1} == null) {
|
|
8531
8541
|
g['${colas}'] = __g_colas;
|
|
8542
|
+
} else if (__g_colas instanceof Date || __colexp1 instanceof Date) {
|
|
8543
|
+
// Date objects cause string concatenation with +=, return undefined instead
|
|
8544
|
+
g['${colas}'] = undefined;
|
|
8532
8545
|
} else {
|
|
8533
8546
|
g['${colas}'] += ${colexp} || 0;
|
|
8534
8547
|
}
|
|
@@ -8546,23 +8559,26 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8546
8559
|
const __colexp = ${colexp};
|
|
8547
8560
|
|
|
8548
8561
|
if (__g_colas == null && ${colexp} == null) {
|
|
8549
|
-
g['${colas}'] =
|
|
8562
|
+
g['${colas}'] = undefined;
|
|
8550
8563
|
} else if (typeof __g_colas === 'bigint' || typeof __colexp === 'bigint') {
|
|
8551
8564
|
g['${colas}'] = BigInt(__g_colas) + BigInt(__colexp);
|
|
8552
8565
|
} else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp !== 'object' && __typeof_colexp !== 'number') ||
|
|
8553
8566
|
(__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp} == null || (__typeof_colexp !== 'number' && __typeof_colexp !== 'object'))) {
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
}
|
|
8567
|
+
g['${colas}'] = undefined;
|
|
8568
|
+
} else if (typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp == 'number') {
|
|
8569
|
+
g['${colas}'] = ${colexp};
|
|
8570
|
+
} else if (typeof __g_colas == 'number' && ${colexp} == null) {
|
|
8571
|
+
g['${colas}'] = __g_colas;
|
|
8572
|
+
} else if (__g_colas == null && __typeof_colexp == 'number') {
|
|
8573
|
+
g['${colas}'] = ${colexp};
|
|
8574
|
+
} else if (__g_colas instanceof Date || __colexp instanceof Date) {
|
|
8575
|
+
// Date objects cause string concatenation with +=, return undefined instead
|
|
8576
|
+
g['${colas}'] = undefined;
|
|
8577
|
+
} else {
|
|
8578
|
+
g['${colas}'] += ${colexp} || 0;
|
|
8564
8579
|
}
|
|
8565
|
-
|
|
8580
|
+
}
|
|
8581
|
+
` +
|
|
8566
8582
|
post
|
|
8567
8583
|
);
|
|
8568
8584
|
} else if (col.aggregatorid === 'TOTAL') {
|
|
@@ -8701,19 +8717,19 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8701
8717
|
}
|
|
8702
8718
|
return (
|
|
8703
8719
|
pre +
|
|
8704
|
-
`if((g['${colas}'] == null && ${colexp}!== null) ? y = ${colexp} :
|
|
8705
|
-
(g['${colas}']!== null && ${colexp} == null) ? y = g['${colas}'] :
|
|
8706
|
-
((y
|
|
8707
|
-
if(typeof y == 'number' || typeof y == 'bigint') {
|
|
8708
|
-
|
|
8709
|
-
} else if(typeof y == 'object' && y instanceof Date) {
|
|
8710
|
-
|
|
8711
|
-
} else if(typeof y == 'object' && typeof Number(y) == 'number') {
|
|
8712
|
-
|
|
8720
|
+
`if ((g['${colas}'] == null && ${colexp} !== null) ? y = ${colexp} :
|
|
8721
|
+
(g['${colas}'] !== null && ${colexp} == null) ? y = g['${colas}'] :
|
|
8722
|
+
((y = ${colexp}) > g['${colas}'])) {
|
|
8723
|
+
if (typeof y == 'number' || typeof y == 'bigint') {
|
|
8724
|
+
g['${colas}'] = y;
|
|
8725
|
+
} else if (typeof y == 'object' && y instanceof Date) {
|
|
8726
|
+
g['${colas}'] = y;
|
|
8727
|
+
} else if (typeof y == 'object' && typeof Number(y) == 'number') {
|
|
8728
|
+
g['${colas}'] = Number(y);
|
|
8713
8729
|
}
|
|
8714
|
-
} else if(g['${colas}']!== null && typeof g['${colas}'] == 'object' && y instanceof Date) {
|
|
8730
|
+
} else if (g['${colas}'] !== null && typeof g['${colas}'] == 'object' && y instanceof Date) {
|
|
8715
8731
|
g['${colas}'] = g['${colas}'];
|
|
8716
|
-
} else if(g['${colas}']!== null && typeof g['${colas}'] == 'object') {
|
|
8732
|
+
} else if (g['${colas}'] !== null && typeof g['${colas}'] == 'object') {
|
|
8717
8733
|
g['${colas}'] = Number(g['${colas}']);
|
|
8718
8734
|
}` +
|
|
8719
8735
|
post
|
|
@@ -8726,7 +8742,11 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8726
8742
|
return `${pre}
|
|
8727
8743
|
y= (${colexp});
|
|
8728
8744
|
g['_COUNT_${colas}'] += (typeof y == "undefined" || y === null) ? 0 : 1;
|
|
8729
|
-
if (
|
|
8745
|
+
if (y instanceof Date || (g['_SUM_${colas}'] && g['_SUM_${colas}'] instanceof Date)) {
|
|
8746
|
+
// AVG on Date objects doesn't make semantic sense - return undefined
|
|
8747
|
+
g['_SUM_${colas}'] = undefined;
|
|
8748
|
+
g['${colas}'] = undefined;
|
|
8749
|
+
} else if (typeof g['_SUM_${colas}'] === 'bigint' || typeof y === 'bigint') {
|
|
8730
8750
|
g['_SUM_${colas}'] = BigInt(g['_SUM_${colas}']);
|
|
8731
8751
|
g['_SUM_${colas}'] += BigInt(y || 0);
|
|
8732
8752
|
g['${colas}'] = BigInt(g['_SUM_${colas}']) / BigInt(g['_COUNT_${colas}']);
|
|
@@ -11257,9 +11277,21 @@ stdlib.RANDOM = function (r) {
|
|
|
11257
11277
|
};
|
|
11258
11278
|
stdlib.ROUND = function (s, d) {
|
|
11259
11279
|
if (arguments.length == 2) {
|
|
11260
|
-
return
|
|
11280
|
+
return (
|
|
11281
|
+
'(__alasql_tmp = (' +
|
|
11282
|
+
s +
|
|
11283
|
+
'), (__alasql_tmp == null || (typeof __alasql_tmp === "string" && __alasql_tmp.trim() === "")) ? undefined : ((__alasql_tmp = Number(__alasql_tmp)), isNaN(__alasql_tmp) ? undefined : Math.round(__alasql_tmp*Math.pow(10,(' +
|
|
11284
|
+
d +
|
|
11285
|
+
')))/Math.pow(10,(' +
|
|
11286
|
+
d +
|
|
11287
|
+
'))))'
|
|
11288
|
+
);
|
|
11261
11289
|
} else {
|
|
11262
|
-
return
|
|
11290
|
+
return (
|
|
11291
|
+
'(__alasql_tmp = (' +
|
|
11292
|
+
s +
|
|
11293
|
+
'), (__alasql_tmp == null || (typeof __alasql_tmp === "string" && __alasql_tmp.trim() === "")) ? undefined : ((__alasql_tmp = Number(__alasql_tmp)), isNaN(__alasql_tmp) ? undefined : Math.round(__alasql_tmp)))'
|
|
11294
|
+
);
|
|
11263
11295
|
}
|
|
11264
11296
|
};
|
|
11265
11297
|
stdlib.CEIL = stdlib.CEILING = function (s) {
|
|
@@ -16536,7 +16568,7 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
|
|
|
16536
16568
|
var res;
|
|
16537
16569
|
|
|
16538
16570
|
filename = alasql.utils.autoExtFilename(filename, 'json', opts);
|
|
16539
|
-
alasql.utils.loadFile(filename, !!cb, function (data) {
|
|
16571
|
+
(alasql.utils.loadFile(filename, !!cb, function (data) {
|
|
16540
16572
|
|
|
16541
16573
|
// res = [{a:1}];
|
|
16542
16574
|
res = JSON.parse(data);
|
|
@@ -16546,12 +16578,12 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
|
|
|
16546
16578
|
}),
|
|
16547
16579
|
err => {
|
|
16548
16580
|
const error = err instanceof Error ? err : new Error(err);
|
|
16549
|
-
if(query && query.cb) {
|
|
16581
|
+
if (query && query.cb) {
|
|
16550
16582
|
query.cb(null, error);
|
|
16551
16583
|
return;
|
|
16552
16584
|
}
|
|
16553
16585
|
throw error;
|
|
16554
|
-
};
|
|
16586
|
+
});
|
|
16555
16587
|
return res;
|
|
16556
16588
|
};
|
|
16557
16589
|
|
|
@@ -16580,7 +16612,7 @@ const jsonl = ext => {
|
|
|
16580
16612
|
},
|
|
16581
16613
|
err => {
|
|
16582
16614
|
const error = err instanceof Error ? err : new Error(err);
|
|
16583
|
-
if(query && query.cb) {
|
|
16615
|
+
if (query && query.cb) {
|
|
16584
16616
|
query.cb(null, error);
|
|
16585
16617
|
return;
|
|
16586
16618
|
}
|
|
@@ -16656,7 +16688,7 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
|
|
|
16656
16688
|
return EOF;
|
|
16657
16689
|
}
|
|
16658
16690
|
if (eol) {
|
|
16659
|
-
return (eol = false), EOL;
|
|
16691
|
+
return ((eol = false), EOL);
|
|
16660
16692
|
}
|
|
16661
16693
|
var j = I;
|
|
16662
16694
|
if (text.charCodeAt(j) === quoteCode) {
|
package/dist/alasql.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! AlaSQL v4.
|
|
1
|
+
//! AlaSQL v4.7.0 build: develop-916ff64e | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
|
|
2
2
|
/*
|
|
3
3
|
@module alasql
|
|
4
|
-
@version 4.
|
|
4
|
+
@version 4.7.0
|
|
5
5
|
|
|
6
6
|
AlaSQL - JavaScript SQL database
|
|
7
7
|
© 2014-2024 Andrey Gershun & Mathias Wulff
|
|
@@ -141,8 +141,8 @@ SOFTWARE.
|
|
|
141
141
|
Current version of alasql
|
|
142
142
|
@constant {string}
|
|
143
143
|
*/
|
|
144
|
-
alasql.version = '4.
|
|
145
|
-
alasql.build = 'develop-
|
|
144
|
+
alasql.version = '4.7.0';
|
|
145
|
+
alasql.build = 'develop-916ff64e';
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
Debug flag
|
|
@@ -244,7 +244,7 @@ case 1:
|
|
|
244
244
|
|
|
245
245
|
break;
|
|
246
246
|
case 2:
|
|
247
|
-
this.$ = doubleq($$[$0].substr(1,$$[$0].length-2));
|
|
247
|
+
this.$ = doubleq($$[$0].substr(1,$$[$0].length-2));
|
|
248
248
|
break;
|
|
249
249
|
case 3:
|
|
250
250
|
this.$ = $$[$0].toLowerCase()
|
|
@@ -3619,6 +3619,19 @@ async function fetchData(path, success, error, async) {
|
|
|
3619
3619
|
}
|
|
3620
3620
|
|
|
3621
3621
|
function getData(path, success, error) {
|
|
3622
|
+
return _fetch(path)
|
|
3623
|
+
.then(response => response.text())
|
|
3624
|
+
.then(txt => {
|
|
3625
|
+
success(txt);
|
|
3626
|
+
})
|
|
3627
|
+
.catch(e => {
|
|
3628
|
+
if (error) return error(e);
|
|
3629
|
+
console.error(e);
|
|
3630
|
+
throw e;
|
|
3631
|
+
});
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
function getBinaryData(path, success, error) {
|
|
3622
3635
|
return _fetch(path)
|
|
3623
3636
|
.then(response => response.arrayBuffer())
|
|
3624
3637
|
.then(buf => {
|
|
@@ -3658,7 +3671,7 @@ var loadBinaryFile = (utils.loadBinaryFile = function (
|
|
|
3658
3671
|
fs = require('fs');
|
|
3659
3672
|
|
|
3660
3673
|
if (/^[a-z]+:\/\//i.test(path)) {
|
|
3661
|
-
|
|
3674
|
+
return getBinaryData(path, success, error);
|
|
3662
3675
|
} else {
|
|
3663
3676
|
if (runAsync) {
|
|
3664
3677
|
fs.readFile(path, function (err, data) {
|
|
@@ -8430,9 +8443,9 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8430
8443
|
if (col.aggregatorid === 'SUM') {
|
|
8431
8444
|
if ('funcid' in col.expression) {
|
|
8432
8445
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
8433
|
-
return `'${colas}':(${
|
|
8446
|
+
return `'${colas}':(__alasql_tmp = ${colexp}, (__alasql_tmp instanceof Date) ? undefined : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : undefined)),`;
|
|
8434
8447
|
}
|
|
8435
|
-
return `'${colas}':(${colexp})|| typeof
|
|
8448
|
+
return `'${colas}':(__alasql_tmp = ${colexp}, (__alasql_tmp instanceof Date) ? undefined : ((__alasql_tmp || typeof __alasql_tmp == 'number') ? __alasql_tmp : undefined)),`;
|
|
8436
8449
|
} else if (col.aggregatorid === 'TOTAL') {
|
|
8437
8450
|
if ('funcid' in col.expression) {
|
|
8438
8451
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
@@ -8449,19 +8462,16 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8449
8462
|
if ('funcid' in col.expression) {
|
|
8450
8463
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
8451
8464
|
|
|
8452
|
-
return `'${colas}': (
|
|
8453
|
-
typeof Number(${colexp1}) == 'number' && ${colexp1}!== null? ${colexp} : null : null),`;
|
|
8465
|
+
return `'${colas}': (__alasql_tmp = ${colexp}, typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined),`;
|
|
8454
8466
|
}
|
|
8455
|
-
return `'${colas}': (
|
|
8456
|
-
typeof Number(${colexp}) == 'number' && ${colexp}!== null? ${colexp} : null : null),`;
|
|
8467
|
+
return `'${colas}': (__alasql_tmp = ${colexp}, typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined),`;
|
|
8457
8468
|
} else if (col.aggregatorid === 'MAX') {
|
|
8458
8469
|
if ('funcid' in col.expression) {
|
|
8459
8470
|
let colexp1 = colExpIfFunIdExists(col.expression);
|
|
8460
|
-
return `'${colas}'
|
|
8461
|
-
typeof Number(${colexp1}) == 'number' ? ${colexp} : null : null),`;
|
|
8471
|
+
return `'${colas}': (__alasql_tmp = ${colexp}, typeof __alasql_tmp == 'number' || typeof __alasql_tmp == 'bigint' || (typeof __alasql_tmp == 'object' && (typeof Number(__alasql_tmp) == 'number' || __alasql_tmp instanceof Date)) ? __alasql_tmp : undefined),`;
|
|
8462
8472
|
}
|
|
8463
8473
|
return `'${colas}' : (typeof ${colexp} == 'number' || typeof ${colexp} == 'bigint' ? ${colexp} : typeof ${colexp} == 'object' ?
|
|
8464
|
-
typeof Number(${colexp}) == 'number' ? ${colexp} :
|
|
8474
|
+
typeof Number(${colexp}) == 'number' ? ${colexp} : undefined : undefined),`;
|
|
8465
8475
|
} else if (col.aggregatorid === 'ARRAY') {
|
|
8466
8476
|
return `'${colas}':[${colexp}],`;
|
|
8467
8477
|
} else if (col.aggregatorid === 'COUNT') {
|
|
@@ -8474,7 +8484,7 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8474
8484
|
query.removeKeys.push(`_SUM_${colas}`);
|
|
8475
8485
|
query.removeKeys.push(`_COUNT_${colas}`);
|
|
8476
8486
|
|
|
8477
|
-
return `'${colas}'
|
|
8487
|
+
return `'${colas}':(function() { var t = ${colexp}; return (t instanceof Date) ? undefined : t; })(),'_SUM_${colas}':(function() { var t = ${colexp}; return (t instanceof Date) ? undefined : (t || 0); })(),'_COUNT_${colas}':(typeof ${colexp} == "undefined" || ${colexp} === null) ? 0 : 1,`;
|
|
8478
8488
|
} else if (col.aggregatorid === 'AGGR') {
|
|
8479
8489
|
aft += `,g['${colas}']=${col.expression.toJS('g', -1)}`;
|
|
8480
8490
|
return '';
|
|
@@ -8518,17 +8528,20 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8518
8528
|
const __colexp1 = ${colexp1};
|
|
8519
8529
|
|
|
8520
8530
|
if (__g_colas == null && ${colexp1} == null) {
|
|
8521
|
-
g['${colas}'] =
|
|
8531
|
+
g['${colas}'] = undefined;
|
|
8522
8532
|
} else if (typeof __g_colas === 'bigint' || typeof __colexp1 === 'bigint') {
|
|
8523
8533
|
g['${colas}'] = BigInt(__g_colas) + BigInt(__colexp);
|
|
8524
8534
|
} else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 !== 'object' && __typeof_colexp1 !== 'number') ||
|
|
8525
|
-
|
|
8526
|
-
g['${colas}'] =
|
|
8535
|
+
(__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp1} == null || (__typeof_colexp1 !== 'number' && __typeof_colexp1 !== 'object'))) {
|
|
8536
|
+
g['${colas}'] = undefined;
|
|
8527
8537
|
} else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 == 'number') ||
|
|
8528
8538
|
(__g_colas == null && __typeof_colexp1 == 'number')) {
|
|
8529
8539
|
g['${colas}'] = ${colexp};
|
|
8530
8540
|
} else if (typeof __g_colas == 'number' && ${colexp1} == null) {
|
|
8531
8541
|
g['${colas}'] = __g_colas;
|
|
8542
|
+
} else if (__g_colas instanceof Date || __colexp1 instanceof Date) {
|
|
8543
|
+
// Date objects cause string concatenation with +=, return undefined instead
|
|
8544
|
+
g['${colas}'] = undefined;
|
|
8532
8545
|
} else {
|
|
8533
8546
|
g['${colas}'] += ${colexp} || 0;
|
|
8534
8547
|
}
|
|
@@ -8546,23 +8559,26 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8546
8559
|
const __colexp = ${colexp};
|
|
8547
8560
|
|
|
8548
8561
|
if (__g_colas == null && ${colexp} == null) {
|
|
8549
|
-
g['${colas}'] =
|
|
8562
|
+
g['${colas}'] = undefined;
|
|
8550
8563
|
} else if (typeof __g_colas === 'bigint' || typeof __colexp === 'bigint') {
|
|
8551
8564
|
g['${colas}'] = BigInt(__g_colas) + BigInt(__colexp);
|
|
8552
8565
|
} else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp !== 'object' && __typeof_colexp !== 'number') ||
|
|
8553
8566
|
(__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp} == null || (__typeof_colexp !== 'number' && __typeof_colexp !== 'object'))) {
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
}
|
|
8567
|
+
g['${colas}'] = undefined;
|
|
8568
|
+
} else if (typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp == 'number') {
|
|
8569
|
+
g['${colas}'] = ${colexp};
|
|
8570
|
+
} else if (typeof __g_colas == 'number' && ${colexp} == null) {
|
|
8571
|
+
g['${colas}'] = __g_colas;
|
|
8572
|
+
} else if (__g_colas == null && __typeof_colexp == 'number') {
|
|
8573
|
+
g['${colas}'] = ${colexp};
|
|
8574
|
+
} else if (__g_colas instanceof Date || __colexp instanceof Date) {
|
|
8575
|
+
// Date objects cause string concatenation with +=, return undefined instead
|
|
8576
|
+
g['${colas}'] = undefined;
|
|
8577
|
+
} else {
|
|
8578
|
+
g['${colas}'] += ${colexp} || 0;
|
|
8564
8579
|
}
|
|
8565
|
-
|
|
8580
|
+
}
|
|
8581
|
+
` +
|
|
8566
8582
|
post
|
|
8567
8583
|
);
|
|
8568
8584
|
} else if (col.aggregatorid === 'TOTAL') {
|
|
@@ -8701,19 +8717,19 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8701
8717
|
}
|
|
8702
8718
|
return (
|
|
8703
8719
|
pre +
|
|
8704
|
-
`if((g['${colas}'] == null && ${colexp}!== null) ? y = ${colexp} :
|
|
8705
|
-
(g['${colas}']!== null && ${colexp} == null) ? y = g['${colas}'] :
|
|
8706
|
-
((y
|
|
8707
|
-
if(typeof y == 'number' || typeof y == 'bigint') {
|
|
8708
|
-
|
|
8709
|
-
} else if(typeof y == 'object' && y instanceof Date) {
|
|
8710
|
-
|
|
8711
|
-
} else if(typeof y == 'object' && typeof Number(y) == 'number') {
|
|
8712
|
-
|
|
8720
|
+
`if ((g['${colas}'] == null && ${colexp} !== null) ? y = ${colexp} :
|
|
8721
|
+
(g['${colas}'] !== null && ${colexp} == null) ? y = g['${colas}'] :
|
|
8722
|
+
((y = ${colexp}) > g['${colas}'])) {
|
|
8723
|
+
if (typeof y == 'number' || typeof y == 'bigint') {
|
|
8724
|
+
g['${colas}'] = y;
|
|
8725
|
+
} else if (typeof y == 'object' && y instanceof Date) {
|
|
8726
|
+
g['${colas}'] = y;
|
|
8727
|
+
} else if (typeof y == 'object' && typeof Number(y) == 'number') {
|
|
8728
|
+
g['${colas}'] = Number(y);
|
|
8713
8729
|
}
|
|
8714
|
-
} else if(g['${colas}']!== null && typeof g['${colas}'] == 'object' && y instanceof Date) {
|
|
8730
|
+
} else if (g['${colas}'] !== null && typeof g['${colas}'] == 'object' && y instanceof Date) {
|
|
8715
8731
|
g['${colas}'] = g['${colas}'];
|
|
8716
|
-
} else if(g['${colas}']!== null && typeof g['${colas}'] == 'object') {
|
|
8732
|
+
} else if (g['${colas}'] !== null && typeof g['${colas}'] == 'object') {
|
|
8717
8733
|
g['${colas}'] = Number(g['${colas}']);
|
|
8718
8734
|
}` +
|
|
8719
8735
|
post
|
|
@@ -8726,7 +8742,11 @@ yy.Select.prototype.compileGroup = function (query) {
|
|
|
8726
8742
|
return `${pre}
|
|
8727
8743
|
y= (${colexp});
|
|
8728
8744
|
g['_COUNT_${colas}'] += (typeof y == "undefined" || y === null) ? 0 : 1;
|
|
8729
|
-
if (
|
|
8745
|
+
if (y instanceof Date || (g['_SUM_${colas}'] && g['_SUM_${colas}'] instanceof Date)) {
|
|
8746
|
+
// AVG on Date objects doesn't make semantic sense - return undefined
|
|
8747
|
+
g['_SUM_${colas}'] = undefined;
|
|
8748
|
+
g['${colas}'] = undefined;
|
|
8749
|
+
} else if (typeof g['_SUM_${colas}'] === 'bigint' || typeof y === 'bigint') {
|
|
8730
8750
|
g['_SUM_${colas}'] = BigInt(g['_SUM_${colas}']);
|
|
8731
8751
|
g['_SUM_${colas}'] += BigInt(y || 0);
|
|
8732
8752
|
g['${colas}'] = BigInt(g['_SUM_${colas}']) / BigInt(g['_COUNT_${colas}']);
|
|
@@ -11257,9 +11277,21 @@ stdlib.RANDOM = function (r) {
|
|
|
11257
11277
|
};
|
|
11258
11278
|
stdlib.ROUND = function (s, d) {
|
|
11259
11279
|
if (arguments.length == 2) {
|
|
11260
|
-
return
|
|
11280
|
+
return (
|
|
11281
|
+
'(__alasql_tmp = (' +
|
|
11282
|
+
s +
|
|
11283
|
+
'), (__alasql_tmp == null || (typeof __alasql_tmp === "string" && __alasql_tmp.trim() === "")) ? undefined : ((__alasql_tmp = Number(__alasql_tmp)), isNaN(__alasql_tmp) ? undefined : Math.round(__alasql_tmp*Math.pow(10,(' +
|
|
11284
|
+
d +
|
|
11285
|
+
')))/Math.pow(10,(' +
|
|
11286
|
+
d +
|
|
11287
|
+
'))))'
|
|
11288
|
+
);
|
|
11261
11289
|
} else {
|
|
11262
|
-
return
|
|
11290
|
+
return (
|
|
11291
|
+
'(__alasql_tmp = (' +
|
|
11292
|
+
s +
|
|
11293
|
+
'), (__alasql_tmp == null || (typeof __alasql_tmp === "string" && __alasql_tmp.trim() === "")) ? undefined : ((__alasql_tmp = Number(__alasql_tmp)), isNaN(__alasql_tmp) ? undefined : Math.round(__alasql_tmp)))'
|
|
11294
|
+
);
|
|
11263
11295
|
}
|
|
11264
11296
|
};
|
|
11265
11297
|
stdlib.CEIL = stdlib.CEILING = function (s) {
|
|
@@ -16536,7 +16568,7 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
|
|
|
16536
16568
|
var res;
|
|
16537
16569
|
|
|
16538
16570
|
filename = alasql.utils.autoExtFilename(filename, 'json', opts);
|
|
16539
|
-
alasql.utils.loadFile(filename, !!cb, function (data) {
|
|
16571
|
+
(alasql.utils.loadFile(filename, !!cb, function (data) {
|
|
16540
16572
|
|
|
16541
16573
|
// res = [{a:1}];
|
|
16542
16574
|
res = JSON.parse(data);
|
|
@@ -16546,12 +16578,12 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
|
|
|
16546
16578
|
}),
|
|
16547
16579
|
err => {
|
|
16548
16580
|
const error = err instanceof Error ? err : new Error(err);
|
|
16549
|
-
if(query && query.cb) {
|
|
16581
|
+
if (query && query.cb) {
|
|
16550
16582
|
query.cb(null, error);
|
|
16551
16583
|
return;
|
|
16552
16584
|
}
|
|
16553
16585
|
throw error;
|
|
16554
|
-
};
|
|
16586
|
+
});
|
|
16555
16587
|
return res;
|
|
16556
16588
|
};
|
|
16557
16589
|
|
|
@@ -16580,7 +16612,7 @@ const jsonl = ext => {
|
|
|
16580
16612
|
},
|
|
16581
16613
|
err => {
|
|
16582
16614
|
const error = err instanceof Error ? err : new Error(err);
|
|
16583
|
-
if(query && query.cb) {
|
|
16615
|
+
if (query && query.cb) {
|
|
16584
16616
|
query.cb(null, error);
|
|
16585
16617
|
return;
|
|
16586
16618
|
}
|
|
@@ -16656,7 +16688,7 @@ alasql.from.CSV = function (contents, opts, cb, idx, query) {
|
|
|
16656
16688
|
return EOF;
|
|
16657
16689
|
}
|
|
16658
16690
|
if (eol) {
|
|
16659
|
-
return (eol = false), EOL;
|
|
16691
|
+
return ((eol = false), EOL);
|
|
16660
16692
|
}
|
|
16661
16693
|
var j = I;
|
|
16662
16694
|
if (text.charCodeAt(j) === quoteCode) {
|