alasql 4.3.3 → 4.4.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.
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.3.2 build: develop-6ecba2e1 | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.3.3 build: develop-b9447ae3 | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.3.2
4
+ @version 4.3.3
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.3.2 build: develop-6ecba2e1 | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.3.3 build: develop-b9447ae3 | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.3.2
4
+ @version 4.3.3
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.3.2';
145
- alasql.build = 'develop-6ecba2e1';
144
+ alasql.version = '4.3.3';
145
+ alasql.build = 'develop-b9447ae3';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -3781,7 +3781,7 @@ utils.autoExtFilename = function (filename, ext, config) {
3781
3781
  config = config || {};
3782
3782
  if (
3783
3783
  typeof filename !== 'string' ||
3784
- filename.match(/^[A-z]+:\/\/|\n|\..{2,4}$/) ||
3784
+ filename.match(/^[A-Z]+:\/\/|\n|\..{2,6}$/i) ||
3785
3785
  config.autoExt === 0 ||
3786
3786
  config.autoExt === false
3787
3787
  ) {
@@ -8469,27 +8469,52 @@ yy.Select.prototype.compileGroup = function (query) {
8469
8469
  let colexp1 = colExpIfFunIdExists(col.expression);
8470
8470
  return (
8471
8471
  pre +
8472
- `if(g['${colas}'] == null && ${colexp1} == null){g['${colas}'] = null}
8473
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'object' && typeof ${colexp1}!== 'number'){ g['${colas}'] = null }
8474
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1} == 'number'){ g['${colas}'] = ${colexp} }
8475
- else if(typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'){ g['${colas}'] = g['${colas}'] }
8476
- else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp1} == null || (typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'))){ g['${colas}'] = null }
8477
- else if(typeof g['${colas}'] == 'number' && typeof ${colexp1} ==null){ g['${colas}'] = g['${colas}'] }
8478
- else if(typeof g['${colas}'] == null && typeof ${colexp1} =='number'){ g['${colas}'] = ${colexp} }
8479
- else{g['${colas}'] += ${colexp}||0}` +
8472
+ `
8473
+ {
8474
+ const __g_colas = g['${colas}'];
8475
+ const __typeof_colexp1 = typeof ${colexp1};
8476
+
8477
+ if (__g_colas == null && ${colexp1} == null) {
8478
+ g['${colas}'] = null;
8479
+ } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 !== 'object' && __typeof_colexp1 !== 'number') ||
8480
+ (__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp1} == null || (__typeof_colexp1 !== 'number' && __typeof_colexp1 !== 'object'))) {
8481
+ g['${colas}'] = null;
8482
+ } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 == 'number') ||
8483
+ (__g_colas == null && __typeof_colexp1 == 'number')) {
8484
+ g['${colas}'] = ${colexp};
8485
+ } else if (typeof __g_colas == 'number' && ${colexp1} == null) {
8486
+ g['${colas}'] = __g_colas;
8487
+ } else {
8488
+ g['${colas}'] += ${colexp} || 0;
8489
+ }
8490
+ }
8491
+ ` +
8480
8492
  post
8481
8493
  );
8482
8494
  }
8483
8495
  return (
8484
8496
  pre +
8485
- `if(g['${colas}'] == null && ${colexp} == null){g['${colas}'] = null}
8486
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number'&& typeof ${colexp}!== 'object' && typeof ${colexp}!== 'number'){g['${colas}'] = null}
8487
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp} == 'number'){g['${colas}'] = ${colexp}}
8488
- else if(typeof g['${colas}']!== 'number' && typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'){g['${colas}'] = g['${colas}']}
8489
- else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp} == null || (typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'))){g['${colas}'] = null}
8490
- else if(typeof g['${colas}'] == 'number' && typeof ${colexp} ==null){g['${colas}'] = g['${colas}']}
8491
- else if(typeof g['${colas}'] == null && typeof ${colexp} =='number'){g['${colas}'] = ${colexp}}
8492
- else{g['${colas}'] += ${colexp}||0}` +
8497
+ `
8498
+ {
8499
+ const __g_colas = g['${colas}'];
8500
+ const __typeof_colexp = typeof ${colexp};
8501
+
8502
+ if (__g_colas == null && ${colexp} == null) {
8503
+ g['${colas}'] = null;
8504
+ } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp !== 'object' && __typeof_colexp !== 'number') ||
8505
+ (__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp} == null || (__typeof_colexp !== 'number' && __typeof_colexp !== 'object'))) {
8506
+ g['${colas}'] = null;
8507
+ } else if (typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp == 'number') {
8508
+ g['${colas}'] = ${colexp};
8509
+ } else if (typeof __g_colas == 'number' && ${colexp} == null) {
8510
+ g['${colas}'] = __g_colas;
8511
+ } else if (__g_colas == null && __typeof_colexp == 'number') {
8512
+ g['${colas}'] = ${colexp};
8513
+ } else {
8514
+ g['${colas}'] += ${colexp} || 0;
8515
+ }
8516
+ }
8517
+ ` +
8493
8518
  post
8494
8519
  );
8495
8520
  } else if (col.aggregatorid === 'TOTAL') {
@@ -8497,23 +8522,51 @@ yy.Select.prototype.compileGroup = function (query) {
8497
8522
  let colexp1 = colExpIfFunIdExists(col.expression);
8498
8523
  return (
8499
8524
  pre +
8500
- `if(typeof g['${colas}'] == 'string' && !isNaN(g['${colas}']) && typeof Number(g['${colas}']) == 'number' &&
8501
- typeof ${colexp1} == 'string' && !isNaN(${colexp1}) && typeof Number(${colexp1}) == 'number'){g['${colas}'] = Number(g['${colas}']) + Number(${colexp1})}
8502
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp1} == 'string'){g['${colas}'] = 0}
8503
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp1} == 'number'){g['${colas}'] = ${colexp1}}
8504
- else if(typeof ${colexp1} == 'string' && typeof g['${colas}'] == 'number'){g['${colas}'] = g['${colas}']}
8505
- else{g['${colas}'] += ${colexp1}||0}` +
8525
+ `{
8526
+ const __g_colas = g['${colas}'];
8527
+ const __colexp1 = ${colexp1};
8528
+ const __typeof_g_colas = typeof __g_colas;
8529
+ const __typeof_colexp1 = typeof __colexp1;
8530
+
8531
+ if (__typeof_g_colas == 'string' && !isNaN(__g_colas) && typeof Number(__g_colas) == 'number' &&
8532
+ __typeof_colexp1 == 'string' && !isNaN(__colexp1) && typeof Number(__colexp1) == 'number') {
8533
+ g['${colas}'] = Number(__g_colas) + Number(__colexp1);
8534
+ } else if (__typeof_g_colas == 'string' && __typeof_colexp1 == 'string') {
8535
+ g['${colas}'] = 0;
8536
+ } else if (__typeof_g_colas == 'string' && __typeof_colexp1 == 'number') {
8537
+ g['${colas}'] = __colexp1;
8538
+ } else if (__typeof_colexp1 == 'string' && __typeof_g_colas == 'number') {
8539
+ g['${colas}'] = __g_colas;
8540
+ } else {
8541
+ g['${colas}'] += __colexp1 || 0;
8542
+ }
8543
+ }` +
8506
8544
  post
8507
8545
  );
8508
8546
  }
8509
8547
  return (
8510
8548
  pre +
8511
- `if(typeof g['${colas}'] == 'string' && !isNaN(g['${colas}']) && typeof Number(g['${colas}']) == 'number' &&
8512
- typeof ${colexp} == 'string' && !isNaN(${colexp}) && typeof Number(${colexp}) == 'number'){g['${colas}'] = Number(g['${colas}']) + Number(${colexp})}
8513
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp} == 'string'){g['${colas}'] = 0}
8514
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp} == 'number'){g['${colas}'] = ${colexp}}
8515
- else if(typeof ${colexp} == 'string' && typeof g['${colas}'] == 'number'){g['${colas}'] = g['${colas}']}
8516
- else{g['${colas}'] += ${colexp}||0}` +
8549
+ `{
8550
+ const __g_colas = g['${colas}'];
8551
+ const __colexp = ${colexp};
8552
+ const __typeof_g_colas = typeof __g_colas;
8553
+ const __typeof_colexp = typeof __colexp;
8554
+
8555
+ if (__typeof_g_colas === 'string' && !isNaN(__g_colas) && typeof Number(__g_colas) === 'number' &&
8556
+ __typeof_colexp === 'string' && !isNaN(__colexp) && typeof Number(__colexp) === 'number') {
8557
+ g['${colas}'] = Number(__g_colas) + Number(__colexp);
8558
+ } else if (__typeof_g_colas === 'string' && __typeof_colexp === 'string') {
8559
+ g['${colas}'] = 0;
8560
+ } else if (__typeof_g_colas === 'string' && __typeof_colexp === 'number') {
8561
+ g['${colas}'] = __colexp;
8562
+ } else if (__typeof_colexp === 'string' && __typeof_g_colas === 'number') {
8563
+ g['${colas}'] = __g_colas;
8564
+ } else {
8565
+ g['${colas}'] += __colexp || 0;
8566
+ }
8567
+ }
8568
+
8569
+ ` +
8517
8570
  post
8518
8571
  );
8519
8572
  } else if (col.aggregatorid === 'COUNT') {
@@ -16258,10 +16311,47 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
16258
16311
  if (cb) {
16259
16312
  res = cb(res, idx, query);
16260
16313
  }
16261
- });
16314
+ }),
16315
+ err => {
16316
+ throw new Error(err);
16317
+ };
16262
16318
  return res;
16263
16319
  };
16264
16320
 
16321
+ const jsonl = ext => {
16322
+ return function (filename, opts, cb, idx, query) {
16323
+ let out = [];
16324
+ filename = alasql.utils.autoExtFilename(filename, ext, opts);
16325
+ alasql.utils.loadFile(
16326
+ filename,
16327
+ !!cb,
16328
+ function (data) {
16329
+ data.split(/\r?\n/).forEach((line, ix) => {
16330
+ const trimmed = line.trim();
16331
+ if (trimmed !== '') {
16332
+ // skip empty lines, we do not use filter on an input, as we want to preserve line numbers
16333
+ try {
16334
+ out.push(JSON.parse(trimmed));
16335
+ } catch (e) {
16336
+ throw new Error(`Could not parse JSON at line ${ix}: ${e.toString()}`);
16337
+ }
16338
+ }
16339
+ });
16340
+ if (cb) {
16341
+ res = cb(out, idx, query);
16342
+ }
16343
+ },
16344
+ err => {
16345
+ throw new Error(err);
16346
+ }
16347
+ );
16348
+ return out;
16349
+ };
16350
+ };
16351
+
16352
+ alasql.from.JSONL = jsonl('jsonl');
16353
+ alasql.from.NDJSON = jsonl('ndjson');
16354
+
16265
16355
  alasql.from.TXT = function (filename, opts, cb, idx, query) {
16266
16356
  var res;
16267
16357
  filename = alasql.utils.autoExtFilename(filename, 'txt', opts);
package/dist/alasql.js CHANGED
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.3.2 build: develop-6ecba2e1 | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.3.3 build: develop-b9447ae3 | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.3.2
4
+ @version 4.3.3
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.3.2';
145
- alasql.build = 'develop-6ecba2e1';
144
+ alasql.version = '4.3.3';
145
+ alasql.build = 'develop-b9447ae3';
146
146
 
147
147
  /**
148
148
  Debug flag
@@ -3781,7 +3781,7 @@ utils.autoExtFilename = function (filename, ext, config) {
3781
3781
  config = config || {};
3782
3782
  if (
3783
3783
  typeof filename !== 'string' ||
3784
- filename.match(/^[A-z]+:\/\/|\n|\..{2,4}$/) ||
3784
+ filename.match(/^[A-Z]+:\/\/|\n|\..{2,6}$/i) ||
3785
3785
  config.autoExt === 0 ||
3786
3786
  config.autoExt === false
3787
3787
  ) {
@@ -8469,27 +8469,52 @@ yy.Select.prototype.compileGroup = function (query) {
8469
8469
  let colexp1 = colExpIfFunIdExists(col.expression);
8470
8470
  return (
8471
8471
  pre +
8472
- `if(g['${colas}'] == null && ${colexp1} == null){g['${colas}'] = null}
8473
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'object' && typeof ${colexp1}!== 'number'){ g['${colas}'] = null }
8474
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp1} == 'number'){ g['${colas}'] = ${colexp} }
8475
- else if(typeof g['${colas}']!== 'number' && typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'){ g['${colas}'] = g['${colas}'] }
8476
- else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp1} == null || (typeof ${colexp1}!== 'number' && typeof ${colexp1}!== 'object'))){ g['${colas}'] = null }
8477
- else if(typeof g['${colas}'] == 'number' && typeof ${colexp1} ==null){ g['${colas}'] = g['${colas}'] }
8478
- else if(typeof g['${colas}'] == null && typeof ${colexp1} =='number'){ g['${colas}'] = ${colexp} }
8479
- else{g['${colas}'] += ${colexp}||0}` +
8472
+ `
8473
+ {
8474
+ const __g_colas = g['${colas}'];
8475
+ const __typeof_colexp1 = typeof ${colexp1};
8476
+
8477
+ if (__g_colas == null && ${colexp1} == null) {
8478
+ g['${colas}'] = null;
8479
+ } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 !== 'object' && __typeof_colexp1 !== 'number') ||
8480
+ (__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp1} == null || (__typeof_colexp1 !== 'number' && __typeof_colexp1 !== 'object'))) {
8481
+ g['${colas}'] = null;
8482
+ } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp1 == 'number') ||
8483
+ (__g_colas == null && __typeof_colexp1 == 'number')) {
8484
+ g['${colas}'] = ${colexp};
8485
+ } else if (typeof __g_colas == 'number' && ${colexp1} == null) {
8486
+ g['${colas}'] = __g_colas;
8487
+ } else {
8488
+ g['${colas}'] += ${colexp} || 0;
8489
+ }
8490
+ }
8491
+ ` +
8480
8492
  post
8481
8493
  );
8482
8494
  }
8483
8495
  return (
8484
8496
  pre +
8485
- `if(g['${colas}'] == null && ${colexp} == null){g['${colas}'] = null}
8486
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number'&& typeof ${colexp}!== 'object' && typeof ${colexp}!== 'number'){g['${colas}'] = null}
8487
- else if(typeof g['${colas}']!== 'object' && typeof g['${colas}']!== 'number' && typeof ${colexp} == 'number'){g['${colas}'] = ${colexp}}
8488
- else if(typeof g['${colas}']!== 'number' && typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'){g['${colas}'] = g['${colas}']}
8489
- else if((g['${colas}'] == null || (typeof g['${colas}']!== 'number' && typeof g['${colas}']!== 'object')) && (${colexp} == null || (typeof ${colexp}!== 'number' && typeof ${colexp}!== 'object'))){g['${colas}'] = null}
8490
- else if(typeof g['${colas}'] == 'number' && typeof ${colexp} ==null){g['${colas}'] = g['${colas}']}
8491
- else if(typeof g['${colas}'] == null && typeof ${colexp} =='number'){g['${colas}'] = ${colexp}}
8492
- else{g['${colas}'] += ${colexp}||0}` +
8497
+ `
8498
+ {
8499
+ const __g_colas = g['${colas}'];
8500
+ const __typeof_colexp = typeof ${colexp};
8501
+
8502
+ if (__g_colas == null && ${colexp} == null) {
8503
+ g['${colas}'] = null;
8504
+ } else if ((typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp !== 'object' && __typeof_colexp !== 'number') ||
8505
+ (__g_colas == null || (typeof __g_colas !== 'number' && typeof __g_colas !== 'object')) && (${colexp} == null || (__typeof_colexp !== 'number' && __typeof_colexp !== 'object'))) {
8506
+ g['${colas}'] = null;
8507
+ } else if (typeof __g_colas !== 'object' && typeof __g_colas !== 'number' && __typeof_colexp == 'number') {
8508
+ g['${colas}'] = ${colexp};
8509
+ } else if (typeof __g_colas == 'number' && ${colexp} == null) {
8510
+ g['${colas}'] = __g_colas;
8511
+ } else if (__g_colas == null && __typeof_colexp == 'number') {
8512
+ g['${colas}'] = ${colexp};
8513
+ } else {
8514
+ g['${colas}'] += ${colexp} || 0;
8515
+ }
8516
+ }
8517
+ ` +
8493
8518
  post
8494
8519
  );
8495
8520
  } else if (col.aggregatorid === 'TOTAL') {
@@ -8497,23 +8522,51 @@ yy.Select.prototype.compileGroup = function (query) {
8497
8522
  let colexp1 = colExpIfFunIdExists(col.expression);
8498
8523
  return (
8499
8524
  pre +
8500
- `if(typeof g['${colas}'] == 'string' && !isNaN(g['${colas}']) && typeof Number(g['${colas}']) == 'number' &&
8501
- typeof ${colexp1} == 'string' && !isNaN(${colexp1}) && typeof Number(${colexp1}) == 'number'){g['${colas}'] = Number(g['${colas}']) + Number(${colexp1})}
8502
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp1} == 'string'){g['${colas}'] = 0}
8503
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp1} == 'number'){g['${colas}'] = ${colexp1}}
8504
- else if(typeof ${colexp1} == 'string' && typeof g['${colas}'] == 'number'){g['${colas}'] = g['${colas}']}
8505
- else{g['${colas}'] += ${colexp1}||0}` +
8525
+ `{
8526
+ const __g_colas = g['${colas}'];
8527
+ const __colexp1 = ${colexp1};
8528
+ const __typeof_g_colas = typeof __g_colas;
8529
+ const __typeof_colexp1 = typeof __colexp1;
8530
+
8531
+ if (__typeof_g_colas == 'string' && !isNaN(__g_colas) && typeof Number(__g_colas) == 'number' &&
8532
+ __typeof_colexp1 == 'string' && !isNaN(__colexp1) && typeof Number(__colexp1) == 'number') {
8533
+ g['${colas}'] = Number(__g_colas) + Number(__colexp1);
8534
+ } else if (__typeof_g_colas == 'string' && __typeof_colexp1 == 'string') {
8535
+ g['${colas}'] = 0;
8536
+ } else if (__typeof_g_colas == 'string' && __typeof_colexp1 == 'number') {
8537
+ g['${colas}'] = __colexp1;
8538
+ } else if (__typeof_colexp1 == 'string' && __typeof_g_colas == 'number') {
8539
+ g['${colas}'] = __g_colas;
8540
+ } else {
8541
+ g['${colas}'] += __colexp1 || 0;
8542
+ }
8543
+ }` +
8506
8544
  post
8507
8545
  );
8508
8546
  }
8509
8547
  return (
8510
8548
  pre +
8511
- `if(typeof g['${colas}'] == 'string' && !isNaN(g['${colas}']) && typeof Number(g['${colas}']) == 'number' &&
8512
- typeof ${colexp} == 'string' && !isNaN(${colexp}) && typeof Number(${colexp}) == 'number'){g['${colas}'] = Number(g['${colas}']) + Number(${colexp})}
8513
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp} == 'string'){g['${colas}'] = 0}
8514
- else if(typeof g['${colas}'] == 'string' && typeof ${colexp} == 'number'){g['${colas}'] = ${colexp}}
8515
- else if(typeof ${colexp} == 'string' && typeof g['${colas}'] == 'number'){g['${colas}'] = g['${colas}']}
8516
- else{g['${colas}'] += ${colexp}||0}` +
8549
+ `{
8550
+ const __g_colas = g['${colas}'];
8551
+ const __colexp = ${colexp};
8552
+ const __typeof_g_colas = typeof __g_colas;
8553
+ const __typeof_colexp = typeof __colexp;
8554
+
8555
+ if (__typeof_g_colas === 'string' && !isNaN(__g_colas) && typeof Number(__g_colas) === 'number' &&
8556
+ __typeof_colexp === 'string' && !isNaN(__colexp) && typeof Number(__colexp) === 'number') {
8557
+ g['${colas}'] = Number(__g_colas) + Number(__colexp);
8558
+ } else if (__typeof_g_colas === 'string' && __typeof_colexp === 'string') {
8559
+ g['${colas}'] = 0;
8560
+ } else if (__typeof_g_colas === 'string' && __typeof_colexp === 'number') {
8561
+ g['${colas}'] = __colexp;
8562
+ } else if (__typeof_colexp === 'string' && __typeof_g_colas === 'number') {
8563
+ g['${colas}'] = __g_colas;
8564
+ } else {
8565
+ g['${colas}'] += __colexp || 0;
8566
+ }
8567
+ }
8568
+
8569
+ ` +
8517
8570
  post
8518
8571
  );
8519
8572
  } else if (col.aggregatorid === 'COUNT') {
@@ -16258,10 +16311,47 @@ alasql.from.JSON = function (filename, opts, cb, idx, query) {
16258
16311
  if (cb) {
16259
16312
  res = cb(res, idx, query);
16260
16313
  }
16261
- });
16314
+ }),
16315
+ err => {
16316
+ throw new Error(err);
16317
+ };
16262
16318
  return res;
16263
16319
  };
16264
16320
 
16321
+ const jsonl = ext => {
16322
+ return function (filename, opts, cb, idx, query) {
16323
+ let out = [];
16324
+ filename = alasql.utils.autoExtFilename(filename, ext, opts);
16325
+ alasql.utils.loadFile(
16326
+ filename,
16327
+ !!cb,
16328
+ function (data) {
16329
+ data.split(/\r?\n/).forEach((line, ix) => {
16330
+ const trimmed = line.trim();
16331
+ if (trimmed !== '') {
16332
+ // skip empty lines, we do not use filter on an input, as we want to preserve line numbers
16333
+ try {
16334
+ out.push(JSON.parse(trimmed));
16335
+ } catch (e) {
16336
+ throw new Error(`Could not parse JSON at line ${ix}: ${e.toString()}`);
16337
+ }
16338
+ }
16339
+ });
16340
+ if (cb) {
16341
+ res = cb(out, idx, query);
16342
+ }
16343
+ },
16344
+ err => {
16345
+ throw new Error(err);
16346
+ }
16347
+ );
16348
+ return out;
16349
+ };
16350
+ };
16351
+
16352
+ alasql.from.JSONL = jsonl('jsonl');
16353
+ alasql.from.NDJSON = jsonl('ndjson');
16354
+
16265
16355
  alasql.from.TXT = function (filename, opts, cb, idx, query) {
16266
16356
  var res;
16267
16357
  filename = alasql.utils.autoExtFilename(filename, 'txt', opts);